data=frappe.db.sql("""select dealer.zone,au.user_id,concat_ws('',au.first_name,au.last_name) as user_name,dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version,
data=frappe.db.sql("""select dealer.zone,au.user_id,concat_ws('',au.first_name,au.last_name) as user_name,dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version,
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name,d['user_id']),as_dict=1)
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(
current_db_name,d['user_id']),as_dict=1)
dealer_info=dealer_info[-1]['dealer']
dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(current_db_name,dealer_info),as_dict=1)
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(
current_db_name,dealer_info),as_dict=1)
dealer_details=dealer_details[-1]
dealer_details=dealer_details[-1]
d['dealer_code']=dealer_details['dealer_code']
d['dealer_code']=dealer_details['dealer_code']
d['dealer_name']=dealer_details['dealer_name']
d['dealer_name']=dealer_details['dealer_name']
@ -67,9 +68,11 @@ def get_data(filters):
fordindata:
fordindata:
ifd['user_id']:
ifd['user_id']:
try:
try:
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name,d['user_id']),as_dict=1)
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(
current_db_name,d['user_id']),as_dict=1)
dealer_info=dealer_info[-1]['dealer']
dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(current_db_name,dealer_info),as_dict=1)
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(
current_db_name,dealer_info),as_dict=1)
dealer_details=dealer_details[-1]
dealer_details=dealer_details[-1]
d['dealer_code']=dealer_details['dealer_code']
d['dealer_code']=dealer_details['dealer_code']
d['dealer_name']=dealer_details['dealer_name']
d['dealer_name']=dealer_details['dealer_name']
@ -83,7 +86,6 @@ def get_data(filters):
else:
else:
frappe.msgprint('No Data for Selected Filters.')
frappe.msgprint('No Data for Selected Filters.')
eliffilters.get('variant'):
eliffilters.get('variant'):
from_date=filters['from_date']
from_date=filters['from_date']
to_date=filters['to_date']
to_date=filters['to_date']
@ -102,7 +104,8 @@ def get_data(filters):
fordindata:
fordindata:
ifd['user_id']:
ifd['user_id']:
try:
try:
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name,d['user_id']),as_dict=1)
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(
current_db_name,d['user_id']),as_dict=1)
dealer_info=dealer_info[-1]['dealer']
dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer`
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer`