diff --git a/smart_service/__pycache__/hooks.cpython-38.pyc b/smart_service/__pycache__/hooks.cpython-38.pyc index 4728d9b..00905c8 100644 Binary files a/smart_service/__pycache__/hooks.cpython-38.pyc and b/smart_service/__pycache__/hooks.cpython-38.pyc differ diff --git a/smart_service/add_ons/doctype/app_device/app_device.json b/smart_service/add_ons/doctype/app_device/app_device.json index 4360a2a..bb85a6b 100644 --- a/smart_service/add_ons/doctype/app_device/app_device.json +++ b/smart_service/add_ons/doctype/app_device/app_device.json @@ -1,6 +1,6 @@ { "actions": [], - "autoname": "I-.####", + "autoname": "AppDev-.####", "creation": "2021-11-08 17:49:56.262550", "doctype": "DocType", "editable_grid": 1, @@ -70,7 +70,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2022-01-28 12:56:52.746692", + "modified": "2022-02-03 13:10:00.963263", "modified_by": "Administrator", "module": "Add Ons", "name": "App Device", diff --git a/smart_service/add_ons/doctype/circular/circular.json b/smart_service/add_ons/doctype/circular/circular.json index 847733e..6c84461 100644 --- a/smart_service/add_ons/doctype/circular/circular.json +++ b/smart_service/add_ons/doctype/circular/circular.json @@ -11,6 +11,7 @@ "status", "valid_till", "section_break_4", + "circular_image", "description", "amended_from" ], @@ -24,7 +25,7 @@ }, { "fieldname": "description", - "fieldtype": "Text Editor", + "fieldtype": "Small Text", "in_list_view": 1, "label": "Description", "reqd": 1 @@ -58,12 +59,17 @@ "fieldname": "valid_till", "fieldtype": "Date", "label": "Valid Till" + }, + { + "fieldname": "circular_image", + "fieldtype": "Attach", + "label": "Circular Image" } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2022-01-28 12:44:24.971752", + "modified": "2022-02-04 10:27:12.813102", "modified_by": "Administrator", "module": "Add Ons", "name": "Circular", diff --git a/smart_service/add_ons/doctype/model_hit/model_hit.json b/smart_service/add_ons/doctype/model_hit/model_hit.json index 2241dc2..16280e1 100644 --- a/smart_service/add_ons/doctype/model_hit/model_hit.json +++ b/smart_service/add_ons/doctype/model_hit/model_hit.json @@ -14,7 +14,8 @@ "download_vehicle_version", "download_vehicle_date", "download_vehicle_language_id", - "download_vehicle_current_version" + "download_vehicle_current_version", + "device_type" ], "fields": [ { @@ -61,11 +62,16 @@ "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "label": "Download Vehicle Current Version" + }, + { + "fieldname": "device_type", + "fieldtype": "Data", + "label": "Device Type" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2022-01-28 12:58:06.556118", + "modified": "2022-02-01 13:00:12.216340", "modified_by": "Administrator", "module": "Add Ons", "name": "Model Hit", diff --git a/smart_service/add_ons/doctype/model_usage/model_usage.json b/smart_service/add_ons/doctype/model_usage/model_usage.json index 9b34892..63c0ab1 100644 --- a/smart_service/add_ons/doctype/model_usage/model_usage.json +++ b/smart_service/add_ons/doctype/model_usage/model_usage.json @@ -19,7 +19,8 @@ "procedure_id", "steps_id", "menu_id", - "language" + "language", + "device_type" ], "fields": [ { @@ -91,11 +92,16 @@ "fieldname": "language", "fieldtype": "Data", "label": "Language" + }, + { + "fieldname": "device_type", + "fieldtype": "Data", + "label": "Device Type" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2022-01-28 12:58:08.631540", + "modified": "2022-02-01 12:59:57.225198", "modified_by": "Administrator", "module": "Add Ons", "name": "Model Usage", diff --git a/smart_service/add_ons/doctype/teknet_module/teknet_module.json b/smart_service/add_ons/doctype/teknet_module/teknet_module.json index f648d5d..66c5b30 100644 --- a/smart_service/add_ons/doctype/teknet_module/teknet_module.json +++ b/smart_service/add_ons/doctype/teknet_module/teknet_module.json @@ -7,7 +7,8 @@ "engine": "InnoDB", "field_order": [ "teknet_module_name", - "active_status" + "active_status", + "flvl_id" ], "fields": [ { @@ -20,11 +21,16 @@ "fieldtype": "Select", "label": "Active Status", "options": "Active\nInactive" + }, + { + "fieldname": "flvl_id", + "fieldtype": "Int", + "label": "Flvl ID" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2022-01-28 12:56:14.758742", + "modified": "2022-02-02 11:27:22.812375", "modified_by": "Administrator", "module": "Add Ons", "name": "Teknet Module", diff --git a/smart_service/add_ons/report/feedback_report/__pycache__/feedback_report.cpython-38.pyc b/smart_service/add_ons/report/feedback_report/__pycache__/feedback_report.cpython-38.pyc index 1bae9cb..93471cc 100644 Binary files a/smart_service/add_ons/report/feedback_report/__pycache__/feedback_report.cpython-38.pyc and b/smart_service/add_ons/report/feedback_report/__pycache__/feedback_report.cpython-38.pyc differ diff --git a/smart_service/add_ons/report/feedback_report/feedback_report.py b/smart_service/add_ons/report/feedback_report/feedback_report.py index 715c360..256b482 100644 --- a/smart_service/add_ons/report/feedback_report/feedback_report.py +++ b/smart_service/add_ons/report/feedback_report/feedback_report.py @@ -13,12 +13,12 @@ def execute(filters=None): return columns, data def get_data(filters): + current_db_name = frappe.conf.get("db_name") data = frappe.db.sql("""select uf.name,uf.date,uf.subject,uf.user_name,uf.status,uf.attachments,uf.closure_date,uf.closed_by, uf.description,uf.feedback_type,dealer.dealer_code,dealer.zone,dealer.dealer_name,uf.closure_date,uf.closed_by, - dealer.area,au.user_id,au.first_name from `tabUser Feedback` uf,`tabApp Dealer` dealer,`tabApp Users` au + dealer.area,au.user_id,au.first_name from {0}.`tabUser Feedback` uf,{0}.`tabApp Dealer` dealer,{0}.`tabApp Users` au where uf.user_name = au.name and - (uf.modified between %s and %s) group by uf.name""",(filters.get('from_date'), filters.get('to_date')), as_dict=1) - #frappe.throw("DATA" + str(data)) + (date(uf.modified) between '{1}' and '{2}') group by uf.name""".format(current_db_name,filters.get('from_date'), filters.get('to_date')), as_dict=1) if data: return data else: diff --git a/smart_service/add_ons/report/model_download_report/__pycache__/model_download_report.cpython-38.pyc b/smart_service/add_ons/report/model_download_report/__pycache__/model_download_report.cpython-38.pyc index 89f8191..1dbcbb5 100644 Binary files a/smart_service/add_ons/report/model_download_report/__pycache__/model_download_report.cpython-38.pyc and b/smart_service/add_ons/report/model_download_report/__pycache__/model_download_report.cpython-38.pyc differ diff --git a/smart_service/add_ons/report/model_download_report/model_download_report.py b/smart_service/add_ons/report/model_download_report/model_download_report.py index 69984cb..68b5f17 100644 --- a/smart_service/add_ons/report/model_download_report/model_download_report.py +++ b/smart_service/add_ons/report/model_download_report/model_download_report.py @@ -21,14 +21,14 @@ def get_data(filters): from_date=filters['from_date'] to_date=filters['to_date'] modelfilter=filters['model'] - try: - vId=frappe.db.sql("""SELECT myid FROM _d6463952657fa86c.tabVehicle where vehicle='{0}';""".format(modelfilter), as_dict=1) - vId=vId[-1] - vId=vId['myid'] - except: - frappe.msgprint('Vehicle ID Mismatching.') - data = frappe.db.sql("""SELECT date(date) as date, device_id, 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, vId, from_date, to_date), as_dict=1) + # try: + # vId=frappe.db.sql("""SELECT myid FROM _d6463952657fa86c.tabVehicle where vehicle='{0}';""".format(modelfilter), as_dict=1) + # vId=vId[-1] + # vId=vId['myid'] + # except: + # 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: d['download_vehicle_id']=modelfilter if d['user_id']: @@ -52,16 +52,17 @@ def get_data(filters): def get_columns(): columns = [ - {"label": _("Date"), "fieldname": "date", "fieldtype": "Date", "width": 100}, - {"label": _("Zone"), "fieldname": "zone", "fieldtype": "Data", "width": 100}, - {"label": _("Dealer Location"), "fieldname": "area", "fieldtype": "Data", "width": 150}, - {"label": _("Dealer Code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150}, - {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150}, - {"label": _("Device"), "fieldname": "device_id", "fieldtype": "Data", "width": 100}, - {"label": _("Downloaded Vehicle"), "fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 170}, - {"label": _("Downloaded Version"), "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 250}, - {"label": _("Downloaded Language"), "fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 250}, - {"label": _("App Version"), "fieldname": "app_version", "fieldtype": "Data", "width": 150} + {"label": _("Date"), "fieldname": "date", "fieldtype": "Date", "width": 100}, + {"label": _("Zone"), "fieldname": "zone", "fieldtype": "Data", "width": 100}, + {"label": _("Dealer Location"), "fieldname": "area", "fieldtype": "Data", "width": 150}, + {"label": _("Dealer Code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150}, + {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150}, + {"label": _("Device"), "fieldname": "device_id", "fieldtype": "Data", "width": 100}, + {"label": _("Device Type"), "fieldname": "device_type", "fieldtype": "Data", "width": 130}, + {"label": _("Downloaded Vehicle"), "fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 170}, + {"label": _("Downloaded Version"), "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 250}, + {"label": _("Downloaded Language"), "fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 250}, + {"label": _("App Version"), "fieldname": "app_version", "fieldtype": "Data", "width": 150} ] return columns \ No newline at end of file diff --git a/smart_service/add_ons/report/model_hit_report/__pycache__/model_hit_report.cpython-38.pyc b/smart_service/add_ons/report/model_hit_report/__pycache__/model_hit_report.cpython-38.pyc index 0a7787a..7c1b9c7 100644 Binary files a/smart_service/add_ons/report/model_hit_report/__pycache__/model_hit_report.cpython-38.pyc and b/smart_service/add_ons/report/model_hit_report/__pycache__/model_hit_report.cpython-38.pyc differ diff --git a/smart_service/add_ons/report/model_hit_report/model_hit_report.js b/smart_service/add_ons/report/model_hit_report/model_hit_report.js index 9e8c13c..f24e839 100644 --- a/smart_service/add_ons/report/model_hit_report/model_hit_report.js +++ b/smart_service/add_ons/report/model_hit_report/model_hit_report.js @@ -43,5 +43,18 @@ frappe.query_reports["Model Hit Report"] = { } } - ] + ], + "formatter": function (value, row, column, data, default_formatter) { + + + if (value === undefined || value === 0 || value === '' || value===null || value==='0' || value==='null' || value==='None'){ + + value = "-" + } + if (data && column.fieldname !== undefined){ + column.align = 'center'; + } + value = default_formatter(value, row, column, data); + return value; + } }; diff --git a/smart_service/add_ons/report/model_hit_report/model_hit_report.py b/smart_service/add_ons/report/model_hit_report/model_hit_report.py index 7034469..cf2ef66 100644 --- a/smart_service/add_ons/report/model_hit_report/model_hit_report.py +++ b/smart_service/add_ons/report/model_hit_report/model_hit_report.py @@ -27,9 +27,9 @@ def get_data(filters): variantfilter=filters['variant'] variantfilter=variantfilter.split(".") - data = frappe.db.sql("""SELECT date as date, device_id, module_id, vehicle_id, variant_id, system_id, sub_system_id, procedure_id, steps_id, count(*) as count, user_id, language + data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id, system_id, sub_system_id, procedure_id, steps_id, count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and variant_id='{2}' and (date(date) between '{3}' and '{4}') - GROUP BY date, user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id, language;""".format(current_db_name, modelfilter, variantfilter[1], from_date, to_date), as_dict=1) + GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id, language;""".format(current_db_name, modelfilter, variantfilter[1], from_date, to_date), as_dict=1) for d in data: if d['user_id']: @@ -55,9 +55,9 @@ def get_data(filters): to_date=filters['to_date'] modelfilter=filters['model'] - data = frappe.db.sql("""SELECT date as date, device_id, module_id, vehicle_id, variant_id, system_id, sub_system_id, procedure_id, steps_id, count(*) as count, user_id, language + data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id, system_id, sub_system_id, procedure_id, steps_id, count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and (date(date) between '{2}' and '{3}') - GROUP BY date, user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id, language;""".format(current_db_name, modelfilter, from_date, to_date), as_dict=1) + GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id, language;""".format(current_db_name, modelfilter, from_date, to_date), as_dict=1) for d in data: if d['user_id']: @@ -84,9 +84,9 @@ def get_data(filters): to_date=filters['to_date'] variantfilter=filters['variant'] variantfilter=variantfilter.split(".") - data = frappe.db.sql("""SELECT date as date, device_id, module_id, vehicle_id, variant_id, system_id, sub_system_id, procedure_id, steps_id, count(*) as count, user_id, language + data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id, system_id, sub_system_id, procedure_id, steps_id, count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and variant_id='{2}' and (date(date) between '{3}' and '{4}') - GROUP BY date, user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id, language;""".format(current_db_name, variantfilter[0], variantfilter[1], from_date, to_date), as_dict=1) + GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id, language;""".format(current_db_name, variantfilter[0], variantfilter[1], from_date, to_date), as_dict=1) for d in data: if d['user_id']: @@ -110,21 +110,22 @@ def get_data(filters): def get_columns(): columns = [ - {"label": _("Date"), "fieldname": "date", "fieldtype": "Date", "width": 100}, - {"label": _("Zone"), "fieldname": "zone", "fieldtype": "Data", "width": 100}, - {"label": _("Dealer Location"), "fieldname": "area", "fieldtype": "Data", "width": 100}, - {"label": _("Dealer Code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 100}, - {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 100}, - {"label": _("Device"), "fieldname": "device_id", "fieldtype": "Data", "width": 100}, - {"label": _("Module"), "fieldname": "module_id", "fieldtype": "Data", "width": 150}, - {"label": _("Model"), "fieldname": "vehicle_id", "fieldtype": "Data", "width": 100}, - {"label": _("Variant"), "fieldname": "variant_id", "fieldtype": "Data", "width": 100}, - {"label": _("System"), "fieldname": "system_id", "fieldtype": "Data", "width": 100}, - {"label": _("Sub System"), "fieldname": "sub_system_id", "fieldtype": "Data", "width": 100}, - {"label": _("Procedure"), "fieldname": "procedure_id", "fieldtype": "Data", "width": 100}, - {"label": _("Steps"), "fieldname": "steps_id", "fieldtype": "Data", "width": 100}, - {"label": _("Language"), "fieldname": "language", "fieldtype": "Data", "width": 100}, - {"label": _("Count"), "fieldname": "count", "fieldtype": "Data", "width": 100} + {"label": _("Date"), "fieldname": "date", "fieldtype": "Date", "width": 150}, + {"label": _("Zone"), "fieldname": "zone", "fieldtype": "Data", "width": 150}, + {"label": _("Dealer Location"), "fieldname": "area", "fieldtype": "Data", "width": 150}, + {"label": _("Dealer Code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150}, + {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype": "Data", "width": 150}, + {"label": _("Device"), "fieldname": "device_id", "fieldtype": "Data", "width": 150}, + {"label": _("Device Type"), "fieldname": "device_type", "fieldtype": "Data", "width": 150}, + {"label": _("Module"), "fieldname": "module_id", "fieldtype": "Data", "width": 150}, + {"label": _("Model"), "fieldname": "vehicle_id", "fieldtype": "Data", "width": 150}, + {"label": _("Variant"), "fieldname": "variant_id", "fieldtype": "Data", "width": 150}, + {"label": _("System"), "fieldname": "system_id", "fieldtype": "Data", "width": 150}, + {"label": _("Sub System"), "fieldname": "sub_system_id", "fieldtype": "Data", "width": 150}, + {"label": _("Procedure"), "fieldname": "procedure_id", "fieldtype": "Data", "width": 150}, + {"label": _("Steps"), "fieldname": "steps_id", "fieldtype": "Data", "width": 150}, + {"label": _("Language"), "fieldname": "language", "fieldtype": "Data", "width": 150}, + {"label": _("Count"), "fieldname": "count", "fieldtype": "Data", "width": 150} ] return columns diff --git a/smart_service/apis/__pycache__/addon_api.cpython-38.pyc b/smart_service/apis/__pycache__/addon_api.cpython-38.pyc index 1b72664..3535bea 100644 Binary files a/smart_service/apis/__pycache__/addon_api.cpython-38.pyc and b/smart_service/apis/__pycache__/addon_api.cpython-38.pyc differ diff --git a/smart_service/apis/__pycache__/app_user_login.cpython-38.pyc b/smart_service/apis/__pycache__/app_user_login.cpython-38.pyc index 6448e57..ee0e18b 100644 Binary files a/smart_service/apis/__pycache__/app_user_login.cpython-38.pyc and b/smart_service/apis/__pycache__/app_user_login.cpython-38.pyc differ diff --git a/smart_service/apis/__pycache__/publish_api.cpython-38.pyc b/smart_service/apis/__pycache__/publish_api.cpython-38.pyc index 603fd08..1f333a8 100644 Binary files a/smart_service/apis/__pycache__/publish_api.cpython-38.pyc and b/smart_service/apis/__pycache__/publish_api.cpython-38.pyc differ diff --git a/smart_service/apis/__pycache__/transaction_api.cpython-38.pyc b/smart_service/apis/__pycache__/transaction_api.cpython-38.pyc index 833fa13..e7b8524 100644 Binary files a/smart_service/apis/__pycache__/transaction_api.cpython-38.pyc and b/smart_service/apis/__pycache__/transaction_api.cpython-38.pyc differ diff --git a/smart_service/apis/__pycache__/update_validation.cpython-38.pyc b/smart_service/apis/__pycache__/update_validation.cpython-38.pyc index 8ca869c..f4f43ad 100644 Binary files a/smart_service/apis/__pycache__/update_validation.cpython-38.pyc and b/smart_service/apis/__pycache__/update_validation.cpython-38.pyc differ diff --git a/smart_service/apis/addon_api.py b/smart_service/apis/addon_api.py index 9cd9c34..1164db6 100644 --- a/smart_service/apis/addon_api.py +++ b/smart_service/apis/addon_api.py @@ -9,8 +9,8 @@ current_db_name = frappe.conf.get("db_name") def addon(args): if args == "circular": api = frappe.db.get_list( - "Circular", fields=["name", "title", "status", "description", "valid_till"] - ) + "Circular", fields=["name", "title", "status", "description","circular_image", "valid_till"]) + for i in api: if i["status"] == "Active": i["status"] = True @@ -27,11 +27,7 @@ def addon(args): i["status"] = False elif args == "teknet_group": - api = frappe.db.get_list( - "Teknet Group", - fields=["name", "teknet_group_code", - "teknet_group_description", "active_status"], - ) + api = frappe.db.sql('''SELECT name,teknet_group_code,teknet_group_description,active_status FROM {}.`tabTeknet Group` order by teknet_group_description asc;'''.format(current_db_name),as_dict = True) for i in api: if i["active_status"] == "Active": i["active_status"] = True @@ -146,18 +142,20 @@ def model_hit(args, request): UserID = request["UserID"] AppVersion = request["AppVersion"] DeviceID = request["DeviceID"] + DeviceType = request["DeviceType"] for i in request['VehicleDownloadhits']: model_hit = frappe.new_doc('Model Hit') model_hit.user_id = UserID model_hit.app_version = AppVersion model_hit.device_id = DeviceID + model_hit.device_type = DeviceType model_hit.date = i['Date'] model_hit.download_vehicle_id = i['DownloadVehicleID'] model_hit.download_vehicle_version = i['DownloadVehicleVersion'] model_hit.download_vehicle_date = i['DownloadVehicleDate'] model_hit.download_vehicle_language_id = i['DownloadVehicleLanguageID'] model_hit.download_vehicle_current_version = i['DownloadVehicleCurrentVersion'] - model_hit.save() + model_hit.insert(ignore_if_duplicate=True, ignore_mandatory=True) return {"isSuccessful": True} except: return {"isSuccessful": False} @@ -171,11 +169,13 @@ def model_usage(args, request): UserID = request["UserID"] AppVersion = request["AppVersion"] DeviceID = request["DeviceID"] + DeviceType = request["DeviceType"] for i in request['ModuleUsagehits']: model_usage = frappe.new_doc('Model Usage') model_usage.user_id = UserID model_usage.app_version = AppVersion model_usage.device_id = DeviceID + model_usage.device_type = DeviceType model_usage.date = i['Date'] model_usage.module_id = i['ModuleID'] model_usage.vehicle_id = i['VehicleID'] diff --git a/smart_service/apis/app_user_login.py b/smart_service/apis/app_user_login.py index 92d339b..9f9fa1f 100644 --- a/smart_service/apis/app_user_login.py +++ b/smart_service/apis/app_user_login.py @@ -35,6 +35,7 @@ def app_user_validation(usr, pwd): else: message_to_send={'status':0,'error':'Invalid Credentials'} return message_to_send + elif technician_login==0 and mahindra_login==1: response1 = requests.post("http://www.mahindramile.com/WindowAuth/Service.asmx/ValidateCredential", data=data, headers=headers) decoded1 = response1.content.decode('utf-8') @@ -97,19 +98,19 @@ def app_user_validation(usr, pwd): "FirstName": usr, "LastName": "", "IsActive": "True", - "UserType": "Mahindra User", + "UserType": "", "SkillID": "", "SkillName": "", - "UserTypeDesc": "", + "UserTypeDesc": "Mahindra User", "PasswordChanged": "", "AreaName": "Mahindra", - "Zone": "MAhindra", + "Zone": "Mahindra", "LocationName": "Mahindra", "ChannelNo": "", "ServerDate": "", "ServerTime": "", "DealerName": "Mahindra", - "EmailId": "{}@mahindraemail.com".format(usr), + "EmailId": "{}@mahindra.com".format(usr), "isLDAPAuthenticated": ""} success_msg = None @@ -223,7 +224,7 @@ def grant_user_access(userdata,iid): app_device.os_version = os_version app_device.app_current_version = app_current_version app_device.last_login = now() - app_device.insert(ignore_if_duplicate=True) + app_device.insert() if frappe.db.exists({'doctype':'App Device','device_id' : device_id}): app_user1=frappe.get_last_doc('App Users', filters={"email_id": email}) @@ -251,7 +252,6 @@ def grant_user_access(userdata,iid): else : - frappe.db.sql('''UPDATE {4}.`tabApp Device` set last_logged_in= '{0}', user_name = '{2}', device_type = '{3}' where name = "{1}";'''.format(now(),iid,email,user_type_desc,current_db_name)) frappe.db.commit() app_user2=frappe.get_last_doc('App Users', filters={"email_id": email}) @@ -270,11 +270,12 @@ def grant_user_access(userdata,iid): docu = frappe.get_doc("Fish", None) token = docu.apple user_details['token'] = token - lst= frappe.db.sql('''SELECT name FROM {}.`tabApp Device` where device_id = "{}";'''.format(current_db_name,device_id), as_list=True) - lst1= frappe.db.sql('''SELECT name FROM {}.`tabApp Users` where email_id = "{}";'''.format(current_db_name,email), as_list=True) + lst= frappe.db.sql('''SELECT name FROM {}.`tabApp Device` where device_id = "{}" order by name desc limit 1;'''.format(current_db_name,device_id), as_list=True) + lst1= frappe.db.sql('''SELECT name FROM {}.`tabApp Users` where email_id = "{}" order by name desc limit 1;'''.format(current_db_name,email), as_list=True) + try: - user_details['Installation ID'] = lst[-1][0] - user_details['User ID'] = lst1[-1][0] + user_details['Installation ID'] = lst[0][0] + user_details['User ID'] = lst1[0][0] return user_details except: return "Login Failure" @@ -291,8 +292,8 @@ def grant_user_access(userdata,iid): docu = frappe.get_doc("Fish", None) token = docu.apple user_details['token'] = token - lst= frappe.db.sql('''SELECT name FROM {}.`tabApp Device` where device_id = "{}";'''.format(current_db_name,device_id), as_list=True) - lst1= frappe.db.sql('''SELECT name FROM {}.`tabApp Users` where email_id = "{}";'''.format(current_db_name,email), as_list=True) + lst= frappe.db.sql('''SELECT name FROM {}.`tabApp Device` where device_id = "{}" order by creation asc;'''.format(current_db_name,device_id), as_list=True) + lst1= frappe.db.sql('''SELECT name FROM {}.`tabApp Users` where email_id = "{}" order by creation asc;'''.format(current_db_name,email), as_list=True) try: user_details['Installation ID'] = lst[-1][0] user_details['User ID'] = lst1[-1][0] diff --git a/smart_service/apis/transaction_api.py b/smart_service/apis/transaction_api.py index ba1986b..d026ec9 100644 --- a/smart_service/apis/transaction_api.py +++ b/smart_service/apis/transaction_api.py @@ -12,13 +12,20 @@ base_url = os.path.expanduser("~") + "/frappe-bench/sites/"+site_name+"/public" @frappe.whitelist() def get_technical_manual(args): - manual_out=frappe.db.sql('''SELECT parent as variant, language, attach_file as file, active_status FROM {1}.`tabVariant Mapping_Assets` where parent='{0}' and category='Technical Manual' and parentfield = 'assets';'''.format(args,current_db_name), as_dict=True) - - for i in manual_out: - file_size = os.path.getsize(base_url+i['file']) - i['file_size']=file_size - if i["active_status"] == "Active": - i["active_status"] = True - else: - i["active_status"] = False - return manual_out \ No newline at end of file + try: + manual_out=frappe.db.sql('''SELECT parent as variant, language, attach_file as file, active_status FROM {1}.`tabVariant Mapping_Assets` where parent='{0}' and category='Technical Manual' + and parentfield = 'assets';'''.format(args,current_db_name), as_dict=True) + + for i in manual_out: + try: + file_size = os.path.getsize(base_url+i['file']) + i['file_size']=file_size + except: + i['file_size']=0 + if i["active_status"] == "Active": + i["active_status"] = True + else: + i["active_status"] = False + return manual_out + except: + return {"error":"File Not Found"} \ No newline at end of file diff --git a/smart_service/apis/update_validation.py b/smart_service/apis/update_validation.py index 1dbacd9..5d0ee42 100644 --- a/smart_service/apis/update_validation.py +++ b/smart_service/apis/update_validation.py @@ -93,10 +93,10 @@ def check_vehicle_update(vehicle_list): l_id = v['LanguageID'] current_version = v['CurrentVersion'] if publish_type == 'Internal': - publish_data = frappe.db.sql('''select name,CAST(version AS DECIMAL(10,2)) as version from {}.tabPublish where vehicle= '{}' and language='{}' and publish_type= '{}' and version > {} and vehicle_status = 'Active'; + publish_data = frappe.db.sql('''select name,CAST(version AS DECIMAL(10,2)) as version from {}.tabPublish where vehicle= '{}' and language='{}' and publish_type= '{}' and version > {} and vehicle_status = 'Active' and variant_mapping_status= 'Active'; '''.format(current_db_name, vehicle, l_id, publish_type, current_version), as_dict=True) else: - publish_data = frappe.db.sql('''select name,version from {}.tabPublish where vehicle= '{}' and language='{}' and publish_type= '{}' and version > {} and vehicle_status = 'Active'; + publish_data = frappe.db.sql('''select name,version from {}.tabPublish where vehicle= '{}' and language='{}' and publish_type= '{}' and version > {} and vehicle_status = 'Active' and variant_mapping_status= 'Active' ; '''.format(current_db_name, vehicle, l_id, publish_type, current_version), as_dict=True) @@ -201,7 +201,7 @@ def check_vehicle_update(vehicle_list): subsys = frappe.db.sql('''select `tabSystem Mapping_Sub System`.idx as subSystemdisplayorder, systems,sub_systems, symptom, component, estimated_time, rts, mat, cover_image, `tabSub Systems`.myid, `tabSystem Mapping_Sub System`.active_status,`tabSystem Mapping_Sub System`.cover_image from {4}.`tabSystem Mapping_Sub System` inner join {4}.`tabSub Systems` on `tabSystem Mapping_Sub System`.sub_systems = `tabSub Systems`.name - where `tabSystem Mapping_Sub System`.parent like '{0}-{3}%' and systems='{1}' and sub_systems='{2}';'''.format( + where `tabSystem Mapping_Sub System`.parent like '{0}-{3}%' and systems='{1}' and sub_systems='{2}' and `tabSystem Mapping_Sub System`.active_status = 'Active';'''.format( d, i, j, l_id, current_db_name), as_dict=True) if len(subsys) > 0: @@ -215,6 +215,13 @@ def check_vehicle_update(vehicle_list): '''SELECT kilometer as kilometer_name, idx as kilometer_IDX, applicable as kilometers_applicable FROM %s.`tabKilometer Mapping_Items` where sub_systems='%s' order by kilometer_IDX;''' % ( current_db_name, j), as_dict=True) + # kms = frappe.db.sql( + # '''SELECT kilometer as kilometer_name, idx as kilometer_IDX, applicable as kilometers_applicable,mat FROM {}.`tabKilometer Mapping_Items` where sub_systems='{}' + # and substring(parent,-5,2) = '{}' order by kilometer_IDX;'''.format(current_db_name, j,l_id), as_dict=True) + + # % ( + # current_db_name, j,l_id), as_dict=True) + subsys['Config Kilometer'] = kms for k in appendDict[d][i][j]: @@ -283,4 +290,18 @@ def update_completed(FileName): os.remove(base_url+ FileName) return {'isSuccessful':True} except: - return {'isSuccessful':True} \ No newline at end of file + return {'isSuccessful':True} + +@frappe.whitelist() +def delete_complete(doc=None,method=None): + site_name = cstr(frappe.local.site) + base_url = os.path.expanduser("~") + "/frappe-bench/sites/"+site_name+"/public" + path = base_url+'/files/json_files/temp1/' + path_file = os.listdir(path) + if path_file: + for file in path_file: + os.remove(str(path) + str(file)) + + + + \ No newline at end of file diff --git a/smart_service/hooks.py b/smart_service/hooks.py index 5eef174..d816c30 100644 --- a/smart_service/hooks.py +++ b/smart_service/hooks.py @@ -94,24 +94,21 @@ website_context = { # --------------- # Override standard doctype classes -override_doctype_class = { +#override_doctype_class = { # "ToDo": "custom_app.overrides.CustomToDo" - } + #} # Document Events # --------------- # Hook on document methods and events -doc_events = { - "User":{ -# "onload":"smart_service.masters.doctype.vehicle.vehicle.test" - } +#doc_events = { # "*": { # "on_update": "method", # "on_cancel": "method", # "on_trash": "method" # } -} +#} # Scheduled Tasks # --------------- @@ -120,18 +117,18 @@ scheduler_events = { # "all": [ # "smart_service.tasks.all" # ], -# "daily": [ + "daily": [ + "smart_service.apis.app_user_login.login_generate_token" # "smart_service.tasks.daily" -# ], - "hourly": [ + ], +# "hourly": [ #"smart_service.tasks.hourly" - "smart_service.masters.doctype.vehicle.vehicle.test" - #"smart_service.apis.app_user_login.login_generate_token" - #"frappe.website.doctype.web_page.web_page.login" - ] -# "weekly": [ + # "smart_service.apis.app_user_login.login_generate_token", + # ], + "weekly": [ # "smart_service.tasks.weekly" -# ] + "smart_service.apis.update_validation.delete_complete" + ] # "monthly": [ # "smart_service.tasks.monthly" # ] diff --git a/smart_service/mahindra_smart_service/doctype/release/__pycache__/release.cpython-38.pyc b/smart_service/mahindra_smart_service/doctype/release/__pycache__/release.cpython-38.pyc index b73891e..b4d0d4e 100644 Binary files a/smart_service/mahindra_smart_service/doctype/release/__pycache__/release.cpython-38.pyc and b/smart_service/mahindra_smart_service/doctype/release/__pycache__/release.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/doctype/release_docs/__pycache__/release_docs.cpython-38.pyc b/smart_service/mahindra_smart_service/doctype/release_docs/__pycache__/release_docs.cpython-38.pyc index c45082e..723ebc1 100644 Binary files a/smart_service/mahindra_smart_service/doctype/release_docs/__pycache__/release_docs.cpython-38.pyc and b/smart_service/mahindra_smart_service/doctype/release_docs/__pycache__/release_docs.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_applog_translation/__pycache__/_applog_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_applog_translation/__pycache__/_applog_translation.cpython-38.pyc index b027a7e..429796f 100644 Binary files a/smart_service/mahindra_smart_service/report/_applog_translation/__pycache__/_applog_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_applog_translation/__pycache__/_applog_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_applog_translation/_applog_translation.py b/smart_service/mahindra_smart_service/report/_applog_translation/_applog_translation.py index c641f0b..34699f8 100644 --- a/smart_service/mahindra_smart_service/report/_applog_translation/_applog_translation.py +++ b/smart_service/mahindra_smart_service/report/_applog_translation/_applog_translation.py @@ -15,7 +15,7 @@ def execute(filters=None): return columns, data def get_data(filters): - data = frappe.db.sql("""select dealer.zone,au.user_id,au.first_name,dealer.dealer_code,dealer.dealer_name,ad.os,ad.os_version, + data = frappe.db.sql("""select dealer.zone,au.user_id,au.first_name,dealer.dealer_code,dealer.area,dealer.dealer_name,ad.os,ad.os_version, al.device,ad.device_id,ad.app_current_version,al.type,al.date_time_stamp,al.creation from `tabApp Log` al,`tabApp Device` ad,`tabApp Users` au,`tabApp Dealer` dealer where @@ -26,18 +26,19 @@ def get_data(filters): def get_columns(): columns = [ - {"label": _("Zone"), "fieldname": "zone", "fieldtype": "Data", "width": 100}, - {"label": _("User ID"), "fieldname": "user_id", "fieldtype": "Data", "width": 100}, - {"label": _("User Name"), "fieldname": "first_name", "fieldtype": "Data", "width": 100}, - {"label": _("Dealer code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 100}, - {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype":"Data","width": 100}, - {"label": _("Device OS"), "fieldname": "os", "fieldtype": "Data", "width": 100}, - {"label": _("OS Version"), "fieldname": "os_version", "fieldtype": "Data", "width": 100}, - {"label": _("Activity Type"), "fieldname": "type", "fieldtype": "Data","width": 100}, - {"label": _("Device ID"), "fieldname": "device_id", "fieldtype": "Data", "width": 100}, - {"label": _("Activity Date"), "fieldname": "date_time_stamp", "fieldtype": "DateTime","width": 100}, - {"label": _("App Version No"), "fieldname": "app_current_version", "fieldtype": "Data", "width": 100}, - {"label": _("Installation"), "fieldname": "device", "fieldtype": "Data", "width": 100}, + {"label": _("Zone"), "fieldname": "zone", "fieldtype": "Data", "width": 150}, + {"label": _("Dealer Location"), "fieldname": "area", "fieldtype":"Data","width": 150}, + {"label": _("Dealer code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150}, + {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype":"Data","width": 300}, + {"label": _("User ID"), "fieldname": "user_id", "fieldtype": "Data", "width": 150}, + {"label": _("User Name"), "fieldname": "first_name", "fieldtype": "Data", "width": 150}, + {"label": _("Device ID"), "fieldname": "device_id", "fieldtype": "Data", "width": 150}, + {"label": _("Device OS"), "fieldname": "os", "fieldtype": "Data", "width": 150}, + {"label": _("OS Version"), "fieldname": "os_version", "fieldtype": "Data", "width": 150}, + {"label": _("Activity Type"), "fieldname": "type", "fieldtype": "Data","width": 150}, + {"label": _("Activity Date"), "fieldname": "date_time_stamp", "fieldtype": "DateTime","width": 150}, + {"label": _("App Version No"), "fieldname": "app_current_version", "fieldtype": "Data", "width": 150}, + {"label": _("Installation"), "fieldname": "device", "fieldtype": "Data", "width": 150}, ] return columns diff --git a/smart_service/mahindra_smart_service/report/_drive_translation/__pycache__/_drive_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_drive_translation/__pycache__/_drive_translation.cpython-38.pyc index 6c1ccb7..de57466 100644 Binary files a/smart_service/mahindra_smart_service/report/_drive_translation/__pycache__/_drive_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_drive_translation/__pycache__/_drive_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_drive_translation/_drive_translation.py b/smart_service/mahindra_smart_service/report/_drive_translation/_drive_translation.py index 2408c11..a6ee3e5 100644 --- a/smart_service/mahindra_smart_service/report/_drive_translation/_drive_translation.py +++ b/smart_service/mahindra_smart_service/report/_drive_translation/_drive_translation.py @@ -56,11 +56,11 @@ def get_data(): def get_columns(): columns = [] columns += [ - _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Drive") + ":Data/:220", + _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Drive") + ":Data/:220", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::220") + lang.append(""+cstr(d["lang_name"])+""+ "::220") columns += lang return columns,lang diff --git a/smart_service/mahindra_smart_service/report/_file_structure/_file_structure.js b/smart_service/mahindra_smart_service/report/_file_structure/_file_structure.js index f398b3c..cf1f7d0 100644 --- a/smart_service/mahindra_smart_service/report/_file_structure/_file_structure.js +++ b/smart_service/mahindra_smart_service/report/_file_structure/_file_structure.js @@ -5,8 +5,8 @@ const pictures = ['jpg','jpeg','png','tif','tiff','ico','bmp','gif','eps','raw'] const videos = ['avi','mp4','mov','wmv','webm','mkv','3gp']; const pdfs = ['pdf']; const documents =['doc','docx','txt','odt','ppt','pptx']; -const spreadsheets=['ods','xls','xlsx']; - +const spreadsheets=['ods','xls','xlsx','csv']; +const zip=['zip','zipx','rar'] frappe.query_reports["_File Structure"] = { "filters": [ @@ -17,72 +17,83 @@ frappe.query_reports["_File Structure"] = { if(data && column.fieldname=="filename" && data.folder==0){ if(data.private==1){ if(pictures.includes(data.fileformat)){ - value = `

- - - - - + value = `

+ + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(pdfs.includes(data.fileformat)){ - value = `

- - - - + value = `

+ + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(spreadsheets.includes(data.fileformat)){ - value = `

- - - - - - - + value = `

+ + + + + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(documents.includes(data.fileformat)){ - value = `

- - - - - - - - - - + value = `

+ + + + + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(videos.includes(data.fileformat)){ - value = `

- - - - - - - + value = `

+ + + + + +       ${value}

` + column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" + }else if(zip.includes(data.fileformat)){ + value = `

+ + + + + + + + + + + + + + + + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else{ - value = `

- - - - - - - + value = `

+ + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" @@ -90,72 +101,83 @@ frappe.query_reports["_File Structure"] = { } else if(data.private==0){ if(pictures.includes(data.fileformat)){ - value = `

- - - - - + value = `

+ + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(pdfs.includes(data.fileformat)){ - value = `

- - - - + value = `

+ + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(spreadsheets.includes(data.fileformat)){ - value = `

- - - - - - - + value = `

+ + + + + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(documents.includes(data.fileformat)){ - value = `

- - - - - - - - - - + value = `

+ + + + + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else if(videos.includes(data.fileformat)){ - value = `

- - - - - - - + value = `

+ + + + + +       ${value}

` + column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" + }else if(zip.includes(data.fileformat)){ + value = `

+ + + + + + + + + + + + + + + + + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" }else{ - value = `

- - - - - - - + value = `

+ + +       ${value}

` column.link_onclick = "frappe.query_reports['_File Structure'].set_route_to_file(" + JSON.stringify(data.filename) + ")" @@ -217,5 +239,5 @@ frappe.query_reports["_File Structure"] = { "tree": true, "name_field": "filename", "parent_field": "", - "initial_depth": 0 + "initial_depth": 4 }; diff --git a/smart_service/mahindra_smart_service/report/_fuel_translation/__pycache__/_fuel_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_fuel_translation/__pycache__/_fuel_translation.cpython-38.pyc index 0602c88..bb48ca6 100644 Binary files a/smart_service/mahindra_smart_service/report/_fuel_translation/__pycache__/_fuel_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_fuel_translation/__pycache__/_fuel_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.js b/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.js index 3cbf984..176bcf4 100644 --- a/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.js +++ b/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.js @@ -5,13 +5,5 @@ frappe.query_reports["_Fuel Translation"] = { "filters": [ - ], - "formatter": function (value, row, column, data, default_formatter) { - if(value==null){ - value=' ' - column.align='left'; - } - value = default_formatter(value, row, column, data); - return value; - } + ] }; diff --git a/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.py b/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.py index 8da4168..b042321 100644 --- a/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.py +++ b/smart_service/mahindra_smart_service/report/_fuel_translation/_fuel_translation.py @@ -59,11 +59,11 @@ def get_columns(): columns = [] columns += [ - _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Fuel") + ":Data/:220", + _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Fuel") + ":Data/:220", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM {}.`tabCustom Languages` where lang_code <> "en" order by lang_name """.format(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::220") + lang.append(""+cstr(d["lang_name"])+""+ "::220") columns += lang return columns,lang diff --git a/smart_service/mahindra_smart_service/report/_sub_systems_translation/__pycache__/_sub_systems_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_sub_systems_translation/__pycache__/_sub_systems_translation.cpython-38.pyc index 61f911e..0d1cd1c 100644 Binary files a/smart_service/mahindra_smart_service/report/_sub_systems_translation/__pycache__/_sub_systems_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_sub_systems_translation/__pycache__/_sub_systems_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_sub_systems_translation/_sub_systems_translation.py b/smart_service/mahindra_smart_service/report/_sub_systems_translation/_sub_systems_translation.py index e8c1bfa..130d217 100644 --- a/smart_service/mahindra_smart_service/report/_sub_systems_translation/_sub_systems_translation.py +++ b/smart_service/mahindra_smart_service/report/_sub_systems_translation/_sub_systems_translation.py @@ -60,11 +60,11 @@ def get_columns(): columns = [] columns += [ - _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Sub Systems") + ":Data/:300", + _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Sub Systems") + ":Data/:300", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM {0}.`tabCustom Languages` where lang_code <> "en" order by lang_name""".format(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::300") + lang.append(""+cstr(d["lang_name"])+""+ "::300") columns += lang return columns,lang diff --git a/smart_service/mahindra_smart_service/report/_systems_translation/__pycache__/_systems_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_systems_translation/__pycache__/_systems_translation.cpython-38.pyc index ccda7dd..0c3a230 100644 Binary files a/smart_service/mahindra_smart_service/report/_systems_translation/__pycache__/_systems_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_systems_translation/__pycache__/_systems_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_systems_translation/_systems_translation.py b/smart_service/mahindra_smart_service/report/_systems_translation/_systems_translation.py index c2d3e3e..bddcb85 100644 --- a/smart_service/mahindra_smart_service/report/_systems_translation/_systems_translation.py +++ b/smart_service/mahindra_smart_service/report/_systems_translation/_systems_translation.py @@ -57,11 +57,11 @@ def get_columns(): columns = [] columns += [ - _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Systems") + ":Data/:300", + _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Systems") + ":Data/:300", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::300") + lang.append(""+cstr(d["lang_name"])+""+ "::300") columns += lang return columns,lang \ No newline at end of file diff --git a/smart_service/mahindra_smart_service/report/_transmission_translation/__pycache__/_transmission_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_transmission_translation/__pycache__/_transmission_translation.cpython-38.pyc index b3931db..378d240 100644 Binary files a/smart_service/mahindra_smart_service/report/_transmission_translation/__pycache__/_transmission_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_transmission_translation/__pycache__/_transmission_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_transmission_translation/_transmission_translation.py b/smart_service/mahindra_smart_service/report/_transmission_translation/_transmission_translation.py index eaae867..5e35a23 100644 --- a/smart_service/mahindra_smart_service/report/_transmission_translation/_transmission_translation.py +++ b/smart_service/mahindra_smart_service/report/_transmission_translation/_transmission_translation.py @@ -55,11 +55,11 @@ def get_columns(): columns = [] columns += [ - _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Transmission") + ":Data/:220", + _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Transmission") + ":Data/:220", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::220") + lang.append(""+cstr(d["lang_name"])+""+ "::220") columns += lang return columns,lang diff --git a/smart_service/mahindra_smart_service/report/_variant_translation/__pycache__/_variant_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_variant_translation/__pycache__/_variant_translation.cpython-38.pyc index e9384df..25ee3ea 100644 Binary files a/smart_service/mahindra_smart_service/report/_variant_translation/__pycache__/_variant_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_variant_translation/__pycache__/_variant_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_variant_translation/_variant_translation.py b/smart_service/mahindra_smart_service/report/_variant_translation/_variant_translation.py index 550ef9a..c64438f 100644 --- a/smart_service/mahindra_smart_service/report/_variant_translation/_variant_translation.py +++ b/smart_service/mahindra_smart_service/report/_variant_translation/_variant_translation.py @@ -57,11 +57,11 @@ def get_columns(): columns = [] columns += [ - _("Modified On") + ":Data/:240", _("Status") + ":Data/:100", _("Vehicle") + ":Data/:200",_("Variant") + ":Data/:220", + _("Modified On") + ":Data/:240", _("Status") + ":Data/:100", _("Vehicle") + ":Data/:200",_("Variant") + ":Data/:220", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::220") + lang.append(""+cstr(d["lang_name"])+""+ "::220") columns += lang return columns,lang diff --git a/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/__pycache__/_vehicle_segment_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/__pycache__/_vehicle_segment_translation.cpython-38.pyc index b6e0da6..92bccf8 100644 Binary files a/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/__pycache__/_vehicle_segment_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/__pycache__/_vehicle_segment_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/_vehicle_segment_translation.py b/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/_vehicle_segment_translation.py index 6a0dae9..4e5f1cb 100644 --- a/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/_vehicle_segment_translation.py +++ b/smart_service/mahindra_smart_service/report/_vehicle_segment_translation/_vehicle_segment_translation.py @@ -61,11 +61,11 @@ def get_columns(): columns = [] columns += [ - _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Vehicle Segment") + ":Data/:220", + _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Vehicle Segment") + ":Data/:220", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::220") + lang.append(""+cstr(d["lang_name"])+""+ "::220") columns += lang return columns,lang diff --git a/smart_service/mahindra_smart_service/report/_vehicle_translation/__pycache__/_vehicle_translation.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_vehicle_translation/__pycache__/_vehicle_translation.cpython-38.pyc index 13beb39..87dab28 100644 Binary files a/smart_service/mahindra_smart_service/report/_vehicle_translation/__pycache__/_vehicle_translation.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_vehicle_translation/__pycache__/_vehicle_translation.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/_vehicle_translation/_vehicle_translation.py b/smart_service/mahindra_smart_service/report/_vehicle_translation/_vehicle_translation.py index d47a5d9..58abc0f 100644 --- a/smart_service/mahindra_smart_service/report/_vehicle_translation/_vehicle_translation.py +++ b/smart_service/mahindra_smart_service/report/_vehicle_translation/_vehicle_translation.py @@ -55,11 +55,11 @@ def get_columns(): columns = [] columns += [ - _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Vehicle") + ":Data/:220", + _("Modified On") + ":Datetime/:200", _("Status") + ":Data/:100",_("Vehicle") + ":Data/:220", ] lang = [] custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1) for d in custom_lang: - lang.append(cstr(d["lang_name"])+ "::220") + lang.append(""+cstr(d["lang_name"])+""+ "::220") columns += lang return columns,lang diff --git a/smart_service/mahindra_smart_service/report/installation_report/__pycache__/installation_report.cpython-38.pyc b/smart_service/mahindra_smart_service/report/installation_report/__pycache__/installation_report.cpython-38.pyc index bdb23da..e6e0181 100644 Binary files a/smart_service/mahindra_smart_service/report/installation_report/__pycache__/installation_report.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/installation_report/__pycache__/installation_report.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/installation_report/installation_report.py b/smart_service/mahindra_smart_service/report/installation_report/installation_report.py index c872244..becf35f 100644 --- a/smart_service/mahindra_smart_service/report/installation_report/installation_report.py +++ b/smart_service/mahindra_smart_service/report/installation_report/installation_report.py @@ -15,12 +15,13 @@ def execute(filters=None): return columns, data def get_data(filters): + current_db_name = frappe.conf.get("db_name") data = frappe.db.sql("""select dealer.zone,au.user_id,au.first_name,dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version, - al.device,ad.device_id,ad.app_current_version,al.type,al.date_time_stamp,al.creation,al.date_time_stamp as date,al.date_time_stamp as time,time(al.date_time_stamp) as last_time - from `tabApp Log` al,`tabApp Device` ad,`tabApp Users` au,`tabApp Dealer` dealer + al.device,ad.device_id,ad.app_current_version,al.type as type,ad.device_type,al.date_time_stamp,al.creation,al.date_time_stamp as date,al.date_time_stamp as time,time(al.date_time_stamp) as last_time + from {0}.`tabApp Log` al, {0}.`tabApp Device` ad, {0}.`tabApp Users` au, {0}.`tabApp Dealer` dealer where - al.device = ad.name and al.user = au.name and au.dealer = dealer.name and al.type = 'Installed' and - (al.modified between %s and %s)""",(filters.get('from_date'), filters.get('to_date')), as_dict=1) + al.device = ad.name and al.user = au.name and au.dealer = dealer.name and (al.type = 'Installed' or al.type = 'Reinstalled') and + (date(al.modified) between '{1}' and '{2}')""".format(current_db_name,filters.get('from_date'), filters.get('to_date')), as_dict=1) if data: return data @@ -34,12 +35,13 @@ def get_columns(): {"label": _("Dealer Location"), "fieldname": "area", "fieldtype":"Data","width": 150}, {"label": _("Dealer code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 100}, {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype":"Data","width": 150}, - {"label": _("Device Type"), "fieldname": "type", "fieldtype": "Data","width": 100}, + {"label": _("Device"), "fieldname": "device_type", "fieldtype": "Data","width": 100}, {"label": _("Device ID"), "fieldname": "device_id", "fieldtype": "Data", "width": 100}, {"label": _("Device OS"), "fieldname": "os", "fieldtype": "Data", "width": 100}, {"label": _("OS Version"), "fieldname": "os_version", "fieldtype": "Data", "width": 100}, {"label": _("User ID"), "fieldname": "user_id", "fieldtype": "Data", "width": 100}, {"label": _("User Name"), "fieldname": "first_name", "fieldtype": "Data", "width": 100}, + {"label": _("Activity Type"), "fieldname": "type", "fieldtype": "Data","width": 100}, {"label": _("App Installation Date"), "fieldname": "date_time_stamp", "fieldtype": "DateTime","width": 200}, {"label": _("App Last Accessed Date"), "fieldname": "date", "fieldtype": "DateTime","width": 200}, {"label": _("App Version No"), "fieldname": "app_current_version", "fieldtype": "Data", "width": 150}, diff --git a/smart_service/mahindra_smart_service/report/login_report/__pycache__/login_report.cpython-38.pyc b/smart_service/mahindra_smart_service/report/login_report/__pycache__/login_report.cpython-38.pyc index bbc25ca..fa2ecbc 100644 Binary files a/smart_service/mahindra_smart_service/report/login_report/__pycache__/login_report.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/login_report/__pycache__/login_report.cpython-38.pyc differ diff --git a/smart_service/mahindra_smart_service/report/login_report/login_report.py b/smart_service/mahindra_smart_service/report/login_report/login_report.py index ed13515..f7136a9 100644 --- a/smart_service/mahindra_smart_service/report/login_report/login_report.py +++ b/smart_service/mahindra_smart_service/report/login_report/login_report.py @@ -5,6 +5,10 @@ from __future__ import unicode_literals import frappe from frappe.utils import cstr, cint, getdate from frappe import msgprint, _ +from frappe.utils import cstr, flt, cint,TIME_FORMAT,DATE_FORMAT,DATETIME_FORMAT, now_datetime +from datetime import date, time, datetime, timedelta +from frappe.utils import now +import datetime def execute(filters=None): columns, data = [], [] @@ -13,13 +17,16 @@ def execute(filters=None): return columns, data def get_data(filters): + current_db_name = frappe.conf.get("db_name") + from_date = filters.get('from_date') + to_date = filters.get('to_date') data = frappe.db.sql("""select count(al.name) as count,dealer.zone,au.user_id,au.first_name,dealer.dealer_code,dealer.dealer_name,dealer.area,ad.os,ad.os_version, ad.device_type,ad.device_id,ad.app_current_version,al.type,al.latitude,al.longitude,al.date_time_stamp,al.creation, date(al.date_time_stamp) as date,time(al.date_time_stamp) as time - from `tabApp Log` al,`tabApp Device` ad,`tabApp Users` au,`tabApp Dealer` dealer + from {0}.`tabApp Log` al,{0}.`tabApp Device` ad,{0}.`tabApp Users` au,{0}.`tabApp Dealer` dealer where al.device = ad.name and al.user = au.name and au.dealer = dealer.name and al.type = 'Logged in' and - (al.modified between %s and %s) group by al.user,ad.device_id,date(al.date_time_stamp)""",(filters.get('from_date'), filters.get('to_date')), as_dict=1) + (date(al.modified) between '{1}' and '{2}') group by al.user,ad.device_id,date(al.date_time_stamp)""".format(current_db_name,from_date,to_date), as_dict=1) if data: return data else: @@ -34,8 +41,8 @@ def get_columns(): {"label": _("Dealer Location"), "fieldname": "area", "fieldtype": "Data", "width": 100}, {"label": _("Dealer code"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150}, {"label": _("Dealer Name"), "fieldname": "dealer_name", "fieldtype":"Data","width": 150}, - {"label": _("Device ID"), "fieldname": "device_id", "fieldtype": "Data", "width": 150}, {"label": _("Device"), "fieldname": "device_type", "fieldtype": "Data", "width": 100}, + {"label": _("Device ID"), "fieldname": "device_id", "fieldtype": "Data", "width": 150}, {"label": _("User ID"), "fieldname": "user_id", "fieldtype": "Data", "width": 150}, {"label": _("User Name"), "fieldname": "first_name", "fieldtype": "Data", "width": 100}, {"label": _("Latitude"), "fieldname": "latitude", "fieldtype": "Data", "width": 100}, diff --git a/smart_service/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc b/smart_service/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc index 371f928..9393353 100644 Binary files a/smart_service/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc and b/smart_service/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc differ diff --git a/smart_service/masters/doctype/vehicle/vehicle.py b/smart_service/masters/doctype/vehicle/vehicle.py index 4246657..9aa6e70 100644 --- a/smart_service/masters/doctype/vehicle/vehicle.py +++ b/smart_service/masters/doctype/vehicle/vehicle.py @@ -45,6 +45,11 @@ def login_user(login,pwd): num.id = login num.pwd = pwd num.save() -@frappe.whitelist() -def test(doc=None,method=None): - frappe.msgprint("called") \ No newline at end of file +###This method called from templates/includes/login/_login.js +@frappe.whitelist(allow_guest=True) +def login_user(login): + user = frappe.db.sql("""select username from `tabUser` where username=%s or email=%s or mobile_no=%s""",(login,login,login),as_list=True) + if user: + return user + else: + return 'None' \ No newline at end of file diff --git a/smart_service/public/css/smart_service.css b/smart_service/public/css/smart_service.css index 1a2060b..5c72dcb 100644 --- a/smart_service/public/css/smart_service.css +++ b/smart_service/public/css/smart_service.css @@ -1,86 +1,86 @@ -.btn.btn-primary { - background-color: #E31A37; - border-color: #E31A37; - outline: 0!important; - box-shadow: none!important; - - - color: var(--white); - white-space: nowrap; - --icon-stroke: #E31A37!important; - --icon-fill-bg: #E31A37!important; -} -.btn.btn-primary:active{ - background-color: #c50000!important; - border-color: #E31A37!important; - outline: 0!important; - box-shadow: 0 0 2px 2px #E31A37!important; - /* h-offset v-offset blur spread colour */ -} - - -.app-logo { - width: 100px !important; -} -.navbar{ - box-shadow: 7px -2px 11px #E31A37; -} - - -.a.nav-link.btn-login-area.active,.navbar-light .navbar-nav .nav-link.active, .navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover { - color: #E31A37!important; -} - - -.btn-primary-light.active { -background-color: #E31A37; -border-color: #E31A37; -outline: 0!important; -box-shadow: 0 0 2px 2px #E31A37!important; - -} -.login-captcha-refresh{ - right: 9px; - top: 9px; - position: absolute; - z-index: 2; - cursor: pointer; - font-size: 12px; -} -.txt-input-captcha{ - margin-left: 60px; - width: 81%; -} -.captcha-txt{ - font-size: 15px; - color: #E31A37; - font-weight: bold; -} -.loadingBlock{ top: 65%; - left: 48%;position: absolute;z-index:9999; } -.gear{width: 80px; height: 80px; border-radius:10%; margin:80px auto; border:5px solid #E31A37 ; position:relative; -} - -.gear:after{content:"";width: 100px; height: 100px;border-radius:100%; display:block; border:5px dashed #E31A37 ;position:absolute; top:-24px; left: -24px; box-shadow: inset 0px 0 0 20px #E31A37; transform:scale(.5) rotate(0deg); - animation:gear 8s linear infinite;} - -.gear:before{content:"";width: 58px; height: 58px;border-radius:100%; - display:block; border:5px dashed #E31A37 ; position:absolute; top:26px; right: -14px; box-shadow: inset 0px 0 0 10px #E31A37; transform:scale(.5) rotate(0deg); - animation:gear2 3s linear infinite;} - -@keyframes gear { - 0%{transform:scale(.5) rotate(0deg);} - 100%{transform:scale(.5) rotate(360deg);} -} -@-webkit-keyframes gear { - 0%{transform:scale(.5) rotate(0deg);} - 100%{transform:scale(.5) rotate(360deg);} -} - -@keyframes gear2 { - 0%{transform:scale(.5) rotate(0deg);} - 100%{transform:scale(.5) rotate(-360deg);} -} - - - +.btn.btn-primary { + background-color: #E31A37; + border-color: #E31A37; + outline: 0!important; + box-shadow: none!important; + + + color: var(--white); + white-space: nowrap; + --icon-stroke: #FFFFFF!important; + --icon-fill-bg: #FFFFFF!important; +} +.btn.btn-primary:active{ + background-color: #c50000!important; + border-color: #E31A37!important; + outline: 0!important; + box-shadow: 0 0 2px 2px #E31A37!important; + /* h-offset v-offset blur spread colour */ +} + + +.app-logo { + width: 100px !important; +} +.navbar{ + box-shadow: 7px -2px 11px #E31A37; +} + + +.a.nav-link.btn-login-area.active,.navbar-light .navbar-nav .nav-link.active, .navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover { + color: #E31A37!important; +} + + +.btn-primary-light.active { +background-color: #E31A37; +border-color: #E31A37; +outline: 0!important; +box-shadow: 0 0 2px 2px #E31A37!important; + +} +.login-captcha-refresh{ + right: 9px; + top: 9px; + position: absolute; + z-index: 2; + cursor: pointer; + font-size: 12px; +} +.txt-input-captcha{ + margin-left: 60px; + width: 81%; +} +.captcha-txt{ + font-size: 15px; + color: #E31A37; + font-weight: bold; +} +.loadingBlock{ top: 65%; + left: 48%;position: absolute;z-index:9999; } +.gear{width: 80px; height: 80px; border-radius:10%; margin:80px auto; border:5px solid #E31A37 ; position:relative; +} + +.gear:after{content:"";width: 100px; height: 100px;border-radius:100%; display:block; border:5px dashed #E31A37 ;position:absolute; top:-24px; left: -24px; box-shadow: inset 0px 0 0 20px #E31A37; transform:scale(.5) rotate(0deg); + animation:gear 8s linear infinite;} + +.gear:before{content:"";width: 58px; height: 58px;border-radius:100%; + display:block; border:5px dashed #E31A37 ; position:absolute; top:26px; right: -14px; box-shadow: inset 0px 0 0 10px #E31A37; transform:scale(.5) rotate(0deg); + animation:gear2 3s linear infinite;} + +@keyframes gear { + 0%{transform:scale(.5) rotate(0deg);} + 100%{transform:scale(.5) rotate(360deg);} +} +@-webkit-keyframes gear { + 0%{transform:scale(.5) rotate(0deg);} + 100%{transform:scale(.5) rotate(360deg);} +} + +@keyframes gear2 { + 0%{transform:scale(.5) rotate(0deg);} + 100%{transform:scale(.5) rotate(-360deg);} +} + + + diff --git a/smart_service/templates/includes/login/_login.js b/smart_service/templates/includes/login/_login.js index da0474a..5778931 100644 --- a/smart_service/templates/includes/login/_login.js +++ b/smart_service/templates/includes/login/_login.js @@ -345,7 +345,7 @@ login.login_handlers = (function () { var usr = ($("#login_email").val() || "").trim(); if (usr){ frappe.call({ - method: "smart_service.masters.doctype.vehi.vehi.login_user", + method: "smart_service.masters.doctype.vehicle.vehicle.login_user", args: {'login':usr, }, callback: function(r){ diff --git a/smart_service/transactions/doctype/procedure_details/procedure_details.json b/smart_service/transactions/doctype/procedure_details/procedure_details.json index 773a34f..4ccb902 100644 --- a/smart_service/transactions/doctype/procedure_details/procedure_details.json +++ b/smart_service/transactions/doctype/procedure_details/procedure_details.json @@ -9,6 +9,7 @@ "step_name", "content_type", "content", + "content1", "file" ], "fields": [ @@ -52,12 +53,19 @@ "fieldtype": "Attach", "in_list_view": 1, "label": "File" + }, + { + "fieldname": "content1", + "fieldtype": "Data", + "label": "Content1", + "options": "URL", + "read_only": 1 } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-12-23 13:42:47.545081", + "modified": "2022-02-04 11:18:15.633049", "modified_by": "Administrator", "module": "Transactions", "name": "Procedure_Details", diff --git a/smart_service/transactions/report/audit_report/__pycache__/audit_report.cpython-38.pyc b/smart_service/transactions/report/audit_report/__pycache__/audit_report.cpython-38.pyc index 68e184d..7034e3c 100644 Binary files a/smart_service/transactions/report/audit_report/__pycache__/audit_report.cpython-38.pyc and b/smart_service/transactions/report/audit_report/__pycache__/audit_report.cpython-38.pyc differ diff --git a/smart_service/transactions/report/audit_report/audit_report.js b/smart_service/transactions/report/audit_report/audit_report.js index 25d9999..61a8d56 100644 --- a/smart_service/transactions/report/audit_report/audit_report.js +++ b/smart_service/transactions/report/audit_report/audit_report.js @@ -13,99 +13,99 @@ frappe.query_reports["Audit Report"] = { ], "formatter": function (value, row, column, data, default_formatter) { - if (data && column.fieldname == "procedure_name") { - switch (data.indent) { - case 3: - value = `

- - - - - - - - - - -    ${value}

` - break; - case 2: - value = `

- - - - - - - -   ${value}

` - break; - case 1: - value = `

- - - - - - - - - - - - - - - - - - - - + if(value !== undefined){ + if (data && column.fieldname == "procedure_name") { + switch (data.indent){ + case 3: + value = `

+ + + + + + + + + + +    ${value}

` + break; + case 2: + value = `

+ + + + + + + +   ${value}

` + break; + case 1: + value = `

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + - - - - - - + - - -   ${value}

` - break; - case 0: - value = `

  ${value}

` - break; - default: - value = `

   - - - - - - - -    ${value}

` - break; +   ${value}

` + break; + case 0: + value = `

  ${value}

` + break; + default: + value = `

   + + + + + + + +    ${value}

` + break; + } } - } - - if(data && String(column.fieldname).slice(2) == '_active_status'){ - switch(data.indent){ - case 2: - if(value !== undefined){ + + if(data && String(column.fieldname).slice(2) == '_active_status'){ + switch(data.indent){ + case 2: newValue = "" val = String(value).split(' / '); switch (val[0]) { @@ -117,22 +117,21 @@ frappe.query_reports["Audit Report"] = { break; } value = newValue +" / "+ ` ${val[1]} ` - } - break; - case 3: - column.align= 'center' - if (value !==undefined){ - value = ` ${value}` - } - break; + break; + + case 3: + column.align= 'center' + if (value !==undefined){ + value = ` ${value}` + } + break; + } } - } - if (data && column.fieldname == "active_status") { - column.align = 'center'; - switch(data.indent){ - case 2: - if(value !== undefined){ + if (data && column.fieldname == "active_status") { + column.align = 'center'; + switch(data.indent){ + case 2: newValue = "" val = String(value).split(' / '); switch (val[0]) { @@ -148,32 +147,33 @@ frappe.query_reports["Audit Report"] = { }else{ value = newValue +" / "+ ` ${val[1]} Procedures ` } - } - break; + break; - case 3: - switch (value) { - case 1: - value = ` ${value} Step` - break; - default: - value = ` ${value} Steps` - break; - } - break; + case 3: + switch (value) { + case 1: + value = ` ${value} Step` + break; + default: + value = ` ${value} Steps` + break; + } + break; - case 1: - if(value == 1){ - value = ` ${value} Sub System`} - else{ - value = ` ${value} Sub Systems`} - break; - } - } - + case 1: + if(value == 1){ + value = ` ${value} Sub System`} + else{ + value = ` ${value} Sub Systems`} + break; + case 0: + value = ` ${value} ` + break; + } + } - if(data && String(column.fieldname).slice(2) === '_workflow_state'){ - if (value !== undefined){ + if(data && String(column.fieldname).slice(2) === '_workflow_state'){ + column.align = 'center'; value = `    ${value} ` @@ -181,11 +181,22 @@ frappe.query_reports["Audit Report"] = { var proc = String(data.procedure).slice(0,-2) column.link_onclick = "frappe.query_reports['Audit Report'].set_route(" + JSON.stringify(proc+langCode) + ")" } + + if(data && column.fieldname === 'modified' || String(column.fieldname).slice(2) === '_modified'){ + column.align = 'center'; + var options = { year: 'numeric', month: 'short', day: 'numeric',day: "numeric", hour: "2-digit", minute: "2-digit",second:'2-digit'}; + var date = new Date(value); + value = date.toLocaleDateString("en-US", options); + } + } + + if(data && String(column.fieldname).slice(2) == '_active_status'){ + column.align = 'center'; + if(value === undefined && data.indent === 2){ + value = "-" + } } - // if(data && column.fieldname === 'modified'){ - // value = new Date(value); - // } value = default_formatter(value, row, column, data); return value; }, diff --git a/smart_service/transactions/report/audit_report/audit_report.py b/smart_service/transactions/report/audit_report/audit_report.py index 4371235..8033ac7 100644 --- a/smart_service/transactions/report/audit_report/audit_report.py +++ b/smart_service/transactions/report/audit_report/audit_report.py @@ -4,24 +4,19 @@ from __future__ import unicode_literals import functools import frappe from frappe import _ +from datetime import datetime current_db_name = frappe.conf.get("db_name") custom_lang = frappe.db.sql('''SELECT lang_code,lang_name FROM {}.`tabCustom Languages` where lang_code <> 'en'; '''.format( current_db_name), as_dict=True) - def execute(filters=None): - validate_filters(filters) - data = get_data(filters) - columns = get_columns() + data = getData(filters) + columns = getColumns() return columns, data -def validate_filters(filters): - return - - -def get_data(filters): +def getData(filters): fil = None if filters.variant_mapping != None: fil = filters.variant_mapping + "%" @@ -52,9 +47,16 @@ def modifyData(dataInput, filterParent): list1 = [] inputData = modifyChildData(dataInput, indent=4, header=0) parentAppend = addParent(filterParent, indent=0, header=1) - list1.insert(0, parentAppend[0]) - sMap, sSize = getParentMap(inputData, 'systems') + systemSize="" + if len(sSize)==1: + systemSize = str(len(sMap)) + " System" + else: + systemSize = str(len(sMap)) + " Systems" + + parentAppend[0]['active_status'] = systemSize + list1.insert(0, parentAppend[0]) + for i in sMap: sMap1, sSize1 = getParentMap(sMap[i], 'systems') @@ -83,7 +85,6 @@ def modifyData(dataInput, filterParent): appendData = addDuplicateData(list1) appendData = removeDuplicateAndHeader(appendData) - return appendData @@ -100,7 +101,6 @@ def appendToDic1(mapData, indent, header): 'indent': indent, 'header': header, 'Type' : 'System' - } mapDataAppend.append(keyDict) return mapDataAppend @@ -154,17 +154,22 @@ def appendToDic3(mapData, procSize, j, indent, header, procedure): i = 0 dic1 = {} list1 = [] - for c in custom_lang: list2 = [] procedure = procedure[:-2]+c['lang_code'] + colmodified = c['lang_code'] + '_modified' other_step_count = frappe.db.sql( - '''select count(distinct(step_name)) as count from _d6463952657fa86c.tabProcedure_Details where parent= '{}' group by(procedure_name) order by idx;'''.format(procedure), as_list=True) + '''select count(distinct(step_name)) as count, modified as {} from _d6463952657fa86c.tabProcedure_Details where parent= '{}' group by(procedure_name) order by idx;'''.format(colmodified,procedure), as_list=True) + for l in other_step_count: - list2.append(l[0]) + list2.append(l) list1.append(list2) - - for u in mapData: + + for u in mapData: + dateList = [] + for k in mapData[u]: + dateList.append(str(k['modified'])) + dateList.sort(key=lambda date: datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")) procDict = { 'systems': mapData[u][0]['systems'], 'sub_systems': mapData[u][0]['sub_systems'], @@ -173,19 +178,23 @@ def appendToDic3(mapData, procSize, j, indent, header, procedure): 'indent': indent, 'header': header, 'active_status': procSize[i], - 'Type' : 'Procedure' + 'Type' : 'Procedure', + 'modified': dateList[-1] } - + dic2 = {} for cus in range(len(custom_lang)): if len(list1[cus]) > 0: - if list1[cus][i] == 1: + if list1[cus][i][0] == 1: dic1['{}_active_status'.format(custom_lang[cus]['lang_code'])] = str( - list1[cus][i]) + " Step" + list1[cus][i][0]) + " Step" else: dic1['{}_active_status'.format(custom_lang[cus]['lang_code'])] = str( - list1[cus][i]) + " Steps" + list1[cus][i][0]) + " Steps" + # Append modified date + dic1['{}_modified'.format(custom_lang[cus]['lang_code'])] = list1[cus][i][1] + dic2.update(dic1) procDict.update(dic1) i += 1 @@ -193,6 +202,7 @@ def appendToDic3(mapData, procSize, j, indent, header, procedure): return mapDataAppend + def modifyChildData(childData, indent, header): for a in childData: a.update({'indent': indent}) @@ -240,10 +250,11 @@ def removeDuplicateAndHeader(data1): k['workflow_state'] = "" if k['indent'] == 4: k.pop('active_status') + k.pop('modified') return data1 -def get_columns(): +def getColumns(): columns = [ { "fieldname": "procedure_name", @@ -261,7 +272,7 @@ def get_columns(): "fieldname": "modified", "label": _("Last Modified date"), "fieldtype": "Data", - "width": 165 + "width": 200 }, { "fieldname": "active_status", @@ -272,7 +283,7 @@ def get_columns(): }, { "fieldname": "en_workflow_state", - "label": _("English"), + "label": _("Workflow State"), "fieldtype": "Link", "options": "Procedure", "width": 150 @@ -284,19 +295,27 @@ def get_columns(): for i in custom_lang: lang_status = { "fieldname": "{}_active_status".format(i['lang_code']), - "label": _("{}_Status".format(i['lang_code'].upper())), + "label": _("{} Status".format(i['lang_code'].upper())), + "fieldtype": "Data", + "options": "", + "width": 200 + } + lang_modified = { + "fieldname": "{}_modified".format(i['lang_code']), + "label": _("{} Last Modified".format(i['lang_code'].upper())), "fieldtype": "Data", "options": "", "width": 200 } lang_workflow = { "fieldname": "{}_workflow_state".format(i['lang_code']), - "label": _("{}_workflow_state".format(i['lang_code'].upper())), + "label": _("{} Workflow State".format(i['lang_code'].upper())), "fieldtype": "Link", "options": "Procedure", "width": 150 } lang.append(lang_status) lang.append(lang_workflow) + lang.append(lang_modified) columns += lang return columns