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 = `