Browse Source

reports fix

master
venkataakhil 1 year ago
parent
commit
835752e094
  1. 27
      smart_service/add_ons/report/model_download_report/model_download_report.py
  2. 18
      smart_service/add_ons/report/model_hit_report/model_hit_report.py
  3. 8
      smart_service/apis/addon_api.py
  4. 24
      smart_service/transactions/report/procedure_report/procedure_report.js

27
smart_service/add_ons/report/model_download_report/model_download_report.py

@ -21,21 +21,20 @@ def get_data(filters):
from_date=filters['from_date'] from_date=filters['from_date']
to_date=filters['to_date'] to_date=filters['to_date']
modelfilter=filters['model'] modelfilter=filters['model']
# try:
# vId=frappe.db.sql("""SELECT myid FROM _d6463952657fa86c.tabVehicle where vehicle='{0}';""".format(modelfilter), as_dict=1) data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, app_version, download_vehicle_id, download_vehicle_version,
# vId=vId[-1] download_vehicle_date, download_vehicle_language_id, download_vehicle_current_version, user_id
# vId=vId['myid'] FROM {0}.`tabModel Hit` WHERE download_vehicle_id='{1}' and (date(date) between '{2}' and '{3}') order by download_vehicle_id;""".format(current_db_name,
# except: modelfilter, from_date, to_date), as_dict=1)
# frappe.msgprint('Vehicle ID Mismatching.')
data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, app_version, download_vehicle_id, download_vehicle_version, download_vehicle_date, download_vehicle_language_id, download_vehicle_current_version, user_id
FROM {0}.`tabModel Hit` WHERE download_vehicle_id='{1}' and (date(date) between '{2}' and '{3}');""".format(current_db_name, modelfilter, from_date, to_date), as_dict=1)
for d in data: for d in data:
d['download_vehicle_id']=modelfilter d['download_vehicle_id']=modelfilter
if d['user_id']: if d['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']
@ -53,16 +52,16 @@ def get_data(filters):
def get_columns(): def get_columns():
columns = [ columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 100}, {"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 100},
{"label": _("<b>Downloaded Vehicle</b>"), "fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 170},
{"label": _("<b>Downloaded Version</b>"), "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 150},
{"label": _("<b>Downloaded Language</b>"), "fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>App Version</b>"), "fieldname": "app_version", "fieldtype": "Data", "width": 150},
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 100}, {"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 100},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150}, {"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150}, {"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150}, {"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 100}, {"label": _("<b>Device</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 100},
{"label": _("<b>Device Type</b>"), "fieldname": "device_type", "fieldtype": "Data", "width": 130}, {"label": _("<b>Device Type</b>"), "fieldname": "device_type", "fieldtype": "Data", "width": 130}
{"label": _("<b>Downloaded Vehicle</b>"), "fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 170},
{"label": _("<b>Downloaded Version</b>"), "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 150},
{"label": _("<b>Downloaded Language</b>"), "fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>App Version</b>"), "fieldname": "app_version", "fieldtype": "Data", "width": 150}
] ]
return columns return columns

18
smart_service/add_ons/report/model_hit_report/model_hit_report.py

@ -119,22 +119,22 @@ def get_data(filters):
def get_columns(): def get_columns():
columns = [ columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 150}, {"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 150},
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 150},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device Type</b>"), "fieldname": "device_type", "fieldtype": "Data", "width": 150},
{"label": _("<b>Module</b>"), "fieldname": "module_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Module</b>"), "fieldname": "module_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Model</b>"), "fieldname": "vehicle_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Model</b>"), "fieldname": "vehicle_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Variant Mapping</b>"), "fieldname": "variant_mapping_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Variant Mapping</b>"), "fieldname": "variant_mapping_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Variant</b>"), "fieldname": "variant_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Variant</b>"), "fieldname": "variant_id", "fieldtype": "Data", "width": 80},
{"label": _("<b>System</b>"), "fieldname": "system_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>System</b>"), "fieldname": "system_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Sub System</b>"), "fieldname": "sub_system_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Sub System</b>"), "fieldname": "sub_system_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Procedure</b>"), "fieldname": "procedure_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Procedure</b>"), "fieldname": "procedure_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Steps</b>"), "fieldname": "steps_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Steps</b>"), "fieldname": "steps_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Language</b>"), "fieldname": "language", "fieldtype": "Data", "width": 150}, {"label": _("<b>Language</b>"), "fieldname": "language", "fieldtype": "Data", "width": 80},
{"label": _("<b>Count</b>"), "fieldname": "count", "fieldtype": "Data", "width": 150} {"label": _("<b>Count</b>"), "fieldname": "count", "fieldtype": "Data", "width": 80},
{"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 150},
{"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},
{"label": _("<b>Dealer Name</b>"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device</b>"), "fieldname": "device_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Device Type</b>"), "fieldname": "device_type", "fieldtype": "Data", "width": 150}
] ]
return columns return columns

8
smart_service/apis/addon_api.py

@ -257,12 +257,8 @@ def model_hit(args=None, request=None):
val = input_validation(args=args, request=request) val = input_validation(args=args, request=request)
if val != '': if val != '':
return {"status": 0, "error": "Input parameter Missing: " + val} return {"status": 0, "error": "Input parameter Missing: " + val}
# if args == None and request == None:
# return {"status": 0, "error": "Parameter's missing: args & request"}
# if args == None:
# return {"status": 0, "error": "Parameter missing: args"}
# if request == None:
# return {"status": 0, "error": "Parameter missing: request"}
if args and request: if args and request:
if args == "model_hit": if args == "model_hit":
try: try:

24
smart_service/transactions/report/procedure_report/procedure_report.js

@ -126,21 +126,21 @@ frappe.query_reports["Procedure Report"] = {
} }
if(data && String(column.fieldname).slice(3)=='workflow_state'){ if (data && String(column.fieldname).slice(3) == 'workflow_state') {
if (value !== undefined){ if (value !== undefined) {
value = `<span> value = `<span>
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 0 24 24" width="18px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M17 7h-4v2h4c1.65 0 3 1.35 3 3s-1.35 3-3 3h-4v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5zm-6 8H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-2zm-3-4h8v2H8z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 0 24 24" width="18px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M17 7h-4v2h4c1.65 0 3 1.35 3 3s-1.35 3-3 3h-4v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5zm-6 8H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-2zm-3-4h8v2H8z"/></svg>
&nbsp&nbsp ${value} </span>` &nbsp&nbsp ${value} </span>`
var langCode = String(column.fieldname).slice(0,2) var langCode = String(column.fieldname).slice(0, 2)
var proc = String(data.procedure).slice(0,-2) var proc = String(data.procedure).slice(0, -2)
column.link_onclick = "frappe.query_reports['_Procedure Report'].set_route(" + JSON.stringify(proc+langCode) + ")" column.link_onclick = "frappe.query_reports['_Procedure Report'].set_route(" + JSON.stringify(proc + langCode) + ")"
} }
} }
if(data && String(column.fieldname).slice(2) == '_active_status'){ if (data && String(column.fieldname).slice(2) == '_active_status') {
switch(data.indent){ switch (data.indent) {
case 2: case 2:
if(value !== undefined){ if (value !== undefined) {
newValue = "" newValue = ""
val = String(value).split(' / '); val = String(value).split(' / ');
switch (val[0]) { switch (val[0]) {
@ -151,12 +151,12 @@ frappe.query_reports["Procedure Report"] = {
newValue = `<span class="filterable indicator-pill red ellipsis"> ${val[0]} </span>` newValue = `<span class="filterable indicator-pill red ellipsis"> ${val[0]} </span>`
break; break;
} }
value = newValue +" / "+ `<span class="filterable indicator-pill red ellipsis"> ${val[1]} </span>` value = newValue + " / " + `<span class="filterable indicator-pill red ellipsis"> ${val[1]} </span>`
} }
break; break;
case 3: case 3:
column.align= 'center' column.align = 'center'
if (value !==undefined){ if (value !== undefined) {
value = `<span class="filterable indicator-pill orange ellipsis"> ${value}</span>` value = `<span class="filterable indicator-pill orange ellipsis"> ${value}</span>`
} }
break; break;

Loading…
Cancel
Save