diff --git a/smart_service/add_ons/doctype/app_preference/app_preference.json b/smart_service/add_ons/doctype/app_preference/app_preference.json index 8ca78ba..8efdf09 100644 --- a/smart_service/add_ons/doctype/app_preference/app_preference.json +++ b/smart_service/add_ons/doctype/app_preference/app_preference.json @@ -18,7 +18,8 @@ "mahindra_login_api", "technician_login_api", "remarks", - "active" + "active", + "user_mail" ], "fields": [ { @@ -87,11 +88,16 @@ "fieldname": "application_server_url", "fieldtype": "Data", "label": "Application Server URL" + }, + { + "fieldname": "user_mail", + "fieldtype": "Data", + "label": "User Mail" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2022-01-28 12:43:00.846057", + "modified": "2022-02-07 20:52:21.403876", "modified_by": "Administrator", "module": "Add Ons", "name": "App Preference", diff --git a/smart_service/apis/__pycache__/addon_api.cpython-38.pyc b/smart_service/apis/__pycache__/addon_api.cpython-38.pyc index 3535bea..6e69930 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 ee0e18b..2959aab 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__/master_api.cpython-38.pyc b/smart_service/apis/__pycache__/master_api.cpython-38.pyc index 6054e3a..a9c0920 100644 Binary files a/smart_service/apis/__pycache__/master_api.cpython-38.pyc and b/smart_service/apis/__pycache__/master_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 f4f43ad..5269fac 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 1164db6..677fbe0 100644 --- a/smart_service/apis/addon_api.py +++ b/smart_service/apis/addon_api.py @@ -9,7 +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","circular_image", "valid_till"]) + "Circular", fields=["name", "title", "status", "description","circular_image", "valid_till"], + filters={"valid_till": [">=", frappe.utils.today()]}) for i in api: if i["status"] == "Active": @@ -37,7 +38,7 @@ def addon(args): elif args == "teknet_module": api = frappe.db.get_list( "Teknet Module", - fields=["name", "teknet_module_name", "active_status"], + fields=["name", "teknet_module_name", "active_status","flvl_id"], ) for i in api: if i["active_status"] == "Active": diff --git a/smart_service/apis/update_validation.py b/smart_service/apis/update_validation.py index 5d0ee42..eba021d 100644 --- a/smart_service/apis/update_validation.py +++ b/smart_service/apis/update_validation.py @@ -43,6 +43,7 @@ def check_all_vehicle_updates(vehicle_list): data_append.append(d) Vehicle_req_list.append(data_append) response['LanguageID'] = lang + if len(Vehicle_req_list) != 0: response['VehicleReqList'] = Vehicle_req_list[0] return response @@ -211,16 +212,14 @@ def check_vehicle_update(vehicle_list): else: subsys['active_status'] = False - kms = frappe.db.sql( - '''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) + # '''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 FROM {}.`tabKilometer Mapping_Items` where sub_systems='{}' + and parent Like '{}' and substring(parent,-5,2) = '{}' order by kilometer_IDX;'''.format(current_db_name, j, d+"%",l_id), as_dict=True) - # % ( - # current_db_name, j,l_id), as_dict=True) subsys['Config Kilometer'] = kms diff --git a/smart_service/mahindra_smart_service/report/_file_structure/__pycache__/_file_structure.cpython-38.pyc b/smart_service/mahindra_smart_service/report/_file_structure/__pycache__/_file_structure.cpython-38.pyc index 08f3841..ca2502e 100644 Binary files a/smart_service/mahindra_smart_service/report/_file_structure/__pycache__/_file_structure.cpython-38.pyc and b/smart_service/mahindra_smart_service/report/_file_structure/__pycache__/_file_structure.cpython-38.pyc differ 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 bb48ca6..4327793 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/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc b/smart_service/masters/doctype/vehicle/__pycache__/vehicle.cpython-38.pyc index 9393353..9ce82b6 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 9aa6e70..c8b525f 100644 --- a/smart_service/masters/doctype/vehicle/vehicle.py +++ b/smart_service/masters/doctype/vehicle/vehicle.py @@ -26,30 +26,3 @@ def update_km_mapping(doc,vehicle,type,skm_initial): if type == "Deleted": for sub_system in system_mapping.get("system_sub_systems"): frappe.db.sql("""delete from `tabKilometer Mapping_Items` where parent = %s and sub_systems=%s and mat=%s and kilometer=%s""",(kilometer_mapping.name,str(sub_system.sub_systems),str(sub_system.mat),str(skm_initial)),as_dict=True) -###This method called from login.js for password validation(CMS login task) -@frappe.whitelist(allow_guest=True) -def login(login): - user = frappe.db.sql("""select pwd from `tabnumlock` where id=%s""",login,as_dict=True) - if user: - for pwd in user: - return pwd.pwd -###This methed called from user clien script(CMS login task) -@frappe.whitelist(allow_guest=True) -def login_user(login,pwd): - numlock = frappe.db.sql("""select name from `tabnumlock` where id = %s""",login,as_dict=True) - if numlock: - for p in numlock: - frappe.db.sql("""update `tabnumlock` set pwd=%s where name = %s""",(pwd,p.name),as_dict=True) - else: - num = frappe.new_doc("numlock") - num.id = login - num.pwd = pwd - num.save() -###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/templates/includes/login/_login.js b/smart_service/templates/includes/login/_login.js index 5778931..bf73e51 100644 --- a/smart_service/templates/includes/login/_login.js +++ b/smart_service/templates/includes/login/_login.js @@ -77,8 +77,18 @@ isSubmit=1; if(parseJson){ if(parseJson.IsSuccessfull=='1'){ let user = $("#login_email").val(); + if(user){ frappe.call({ - method: "smart_service.masters.doctype.vehicle.vehicle.login", + method: "smart_service.www.login.create_user", + args: {'login':user, + }, + callback: function(r){ + } + + }) + } + frappe.call({ + method: "smart_service.www.login.login", args: {'login':user, }, callback: function(r){ @@ -341,20 +351,18 @@ login.login_handlers = (function () { } }, 401: function (data) { - frappe.msgprint(data.message) - var usr = ($("#login_email").val() || "").trim(); + let usr = $("#login_email").val(); if (usr){ - frappe.call({ - method: "smart_service.masters.doctype.vehicle.vehicle.login_user", - args: {'login':usr, - }, - callback: function(r){ - if(r.message == 'None'){ - login.set_status('{{ _("Please contact Admin.") }}', 'red'); + frappe.call({ + method: "smart_service.www.login.login_user", + args: {'login':usr, + }, + callback: function(r){ + if(r.message != 'None'){ + login.set_status('{{ _("Not Allowed Disabled User Please Contact Admin.") }}', 'red'); + } } - } - }) - + }) } login.set_status('{{ _("Invalid Login. Try again.") }}', 'red'); captchaNumGen(); diff --git a/smart_service/transactions/doctype/procedure_details/procedure_details.json b/smart_service/transactions/doctype/procedure_details/procedure_details.json index 4ccb902..6237618 100644 --- a/smart_service/transactions/doctype/procedure_details/procedure_details.json +++ b/smart_service/transactions/doctype/procedure_details/procedure_details.json @@ -14,7 +14,7 @@ ], "fields": [ { - "columns": 1, + "columns": 2, "fieldname": "procedure_name", "fieldtype": "Link", "in_list_view": 1, @@ -32,7 +32,7 @@ "reqd": 1 }, { - "columns": 1, + "columns": 2, "fieldname": "content_type", "fieldtype": "Select", "in_list_view": 1, @@ -45,27 +45,29 @@ "fieldname": "content", "fieldtype": "Small Text", "in_list_view": 1, - "label": "Content" + "label": "Content", + "read_only_depends_on": "eval:doc.content_type == \"Link\"" }, { - "columns": 2, "fieldname": "file", "fieldtype": "Attach", - "in_list_view": 1, - "label": "File" + "label": "File", + "read_only_depends_on": "eval: doc.content_type != \"File\"" }, { "fieldname": "content1", - "fieldtype": "Data", + "fieldtype": "Small Text", + "hidden": 1, "label": "Content1", "options": "URL", - "read_only": 1 + "print_hide": 1, + "read_only_depends_on": "eval:doc.content_type == \"Link\"" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2022-02-04 11:18:15.633049", + "modified": "2022-02-08 16:47:51.532893", "modified_by": "Administrator", "module": "Transactions", "name": "Procedure_Details", diff --git a/smart_service/transactions/doctype/variant_mapping/__pycache__/variant_mapping.cpython-38.pyc b/smart_service/transactions/doctype/variant_mapping/__pycache__/variant_mapping.cpython-38.pyc index ab54e6f..6e86c68 100644 Binary files a/smart_service/transactions/doctype/variant_mapping/__pycache__/variant_mapping.cpython-38.pyc and b/smart_service/transactions/doctype/variant_mapping/__pycache__/variant_mapping.cpython-38.pyc differ diff --git a/smart_service/transactions/doctype/variant_mapping/variant_mapping.js b/smart_service/transactions/doctype/variant_mapping/variant_mapping.js index efe61ce..3e6309f 100644 --- a/smart_service/transactions/doctype/variant_mapping/variant_mapping.js +++ b/smart_service/transactions/doctype/variant_mapping/variant_mapping.js @@ -1,8 +1,16 @@ // Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors // For license information, please see license.txt +cur_frm.fields_dict['variant'].get_query = function(doc, cdt, cdn) { + return { + query:"smart_service.transactions.doctype.variant_mapping.variant_mapping.variant", + // filters: {'doc': doc.name} + } + } + frappe.ui.form.on('Variant Mapping', { - // refresh: function(frm) { - // } + refresh: function(frm) { + + } }); diff --git a/smart_service/transactions/doctype/variant_mapping/variant_mapping.py b/smart_service/transactions/doctype/variant_mapping/variant_mapping.py index 45dd043..e83b24f 100644 --- a/smart_service/transactions/doctype/variant_mapping/variant_mapping.py +++ b/smart_service/transactions/doctype/variant_mapping/variant_mapping.py @@ -1,8 +1,15 @@ # Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors # For license information, please see license.txt -# import frappe +import frappe from frappe.model.document import Document class VariantMapping(Document): - pass + def validate(self): + pass +@frappe.whitelist() +def variant(doctype, txt, searchfield, start, page_len, filters): + #return frappe.db.sql("""SELECT name,variant,vehicle,vehicle_segment,active_status FROM _d6463952657fa86c.tabVariant order by creation desc""") + return frappe.db.sql(""" select name,variant,vehicle,vehicle_segment,active_status + FROM _d6463952657fa86c.tabVariant where + (name like "%%%(txt)s%%" or variant like "%%%(txt)s%%") limit %(start)s, %(page_len)s order by creation"""%{'txt': txt, 'start': start, 'page_len': page_len}) 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 7034e3c..801ff6a 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.py b/smart_service/transactions/report/audit_report/audit_report.py index 8033ac7..1b7172a 100644 --- a/smart_service/transactions/report/audit_report/audit_report.py +++ b/smart_service/transactions/report/audit_report/audit_report.py @@ -7,7 +7,7 @@ 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( +custom_lang = frappe.db.sql('''SELECT lang_code,lang_name FROM {0}.`tabCustom Languages` where lang_code <> 'en'; '''.format( current_db_name), as_dict=True) def execute(filters=None): @@ -17,25 +17,25 @@ def execute(filters=None): def getData(filters): + data = [] fil = None if filters.variant_mapping != None: fil = filters.variant_mapping + "%" - data = frappe.db.sql( - """ - select `tabSystem Mapping_Sub System`.parent,`tabSystem Mapping_Sub System`.systems,`tabSystem Mapping_Sub System`.sub_systems,`tabSystem Mapping_Sub System`.`procedure` , - `tabProcedure_Details`.idx ,`tabProcedure_Details`.procedure_name ,`tabProcedure_Details`.step_name, - `tabProcedure`.active_status,`tabProcedure`.workflow_state,`tabProcedure_Details`.modified - from (`tabSystem Mapping_Sub System` - inner join tabProcedure_Details - on `tabSystem Mapping_Sub System`.`procedure` = `tabProcedure_Details`.parent ) - inner join tabProcedure - on `tabSystem Mapping_Sub System`.`procedure` = tabProcedure.name - where `tabSystem Mapping_Sub System`.parent LIKE %s - and substring(`tabProcedure_Details`.parent,-2) = 'en' - GROUP by `tabSystem Mapping_Sub System`.`procedure` ,tabProcedure_Details.procedure_name ,tabProcedure_Details.step_name - order by `tabSystem Mapping_Sub System`.systems ,`tabSystem Mapping_Sub System`.sub_systems,`procedure`,idx; - """, fil, as_dict=True) + data = frappe.db.sql( + """ + select `tabSystem Mapping_Sub System`.parent,`tabSystem Mapping_Sub System`.systems,`tabSystem Mapping_Sub System`.sub_systems,`tabSystem Mapping_Sub System`.`procedure` , + `tabProcedure_Details`.idx ,`tabProcedure_Details`.procedure_name ,`tabProcedure_Details`.step_name, + `tabProcedure`.active_status,`tabProcedure`.workflow_state,`tabProcedure_Details`.modified + from ({0}.`tabSystem Mapping_Sub System` + inner join {0}.`tabProcedure_Details` + on `tabSystem Mapping_Sub System`.`procedure` = `tabProcedure_Details`.parent ) + inner join {0}.`tabProcedure` + on `tabSystem Mapping_Sub System`.`procedure` = `tabProcedure`.`name` + where `tabSystem Mapping_Sub System`.parent LIKE '{1}' + and substring(`tabProcedure_Details`.parent, -2) = 'en' GROUP BY `tabSystem Mapping_Sub System`.`procedure` ,`tabProcedure_Details`.procedure_name ,`tabProcedure_Details`.step_name + order by `tabSystem Mapping_Sub System`.systems ,`tabSystem Mapping_Sub System`.sub_systems,`procedure`,idx; + """.format(current_db_name,fil), as_dict=True) filterData = filters.variant_mapping if filterData != None and len(data) > 0: @@ -49,6 +49,7 @@ def modifyData(dataInput, filterParent): parentAppend = addParent(filterParent, indent=0, header=1) sMap, sSize = getParentMap(inputData, 'systems') systemSize="" + if len(sSize)==1: systemSize = str(len(sMap)) + " System" else: @@ -60,6 +61,7 @@ def modifyData(dataInput, filterParent): for i in sMap: sMap1, sSize1 = getParentMap(sMap[i], 'systems') + print(i) sMapAppend = appendToDic1(sMap1, indent=1, header=0) ssMap, ssSize = getParentMap(sMap[i], 'sub_systems') ssMapAppend = appendToDic2(ssMap, indent=2, header=1) @@ -103,6 +105,7 @@ def appendToDic1(mapData, indent, header): 'Type' : 'System' } mapDataAppend.append(keyDict) + return mapDataAppend @@ -128,8 +131,8 @@ def appendToDic2(mapData, indent, header): other_proc = da['procedure'] other_proc = other_proc[:-2]+c['lang_code'] others = frappe.db.sql('''select tabProcedure.active_status,count(distinct(`tabProcedure_Details`.procedure_name)) as syscount,tabProcedure.workflow_state - from (_d6463952657fa86c.`tabProcedure_Details` inner join _d6463952657fa86c.`tabProcedure` on `tabProcedure_Details`.`parent` = `tabProcedure`.`name`) - where `tabProcedure`.name = '{}'; '''.format(other_proc), as_dict=True) + from ({0}.`tabProcedure_Details` inner join {0}.`tabProcedure` on `tabProcedure_Details`.`parent` = `tabProcedure`.`name`) + where `tabProcedure`.name = '{1}'; '''.format(current_db_name ,other_proc), as_dict=True) if len(others) > 0: others = others[0] @@ -159,7 +162,7 @@ def appendToDic3(mapData, procSize, j, indent, header, procedure): procedure = procedure[:-2]+c['lang_code'] colmodified = c['lang_code'] + '_modified' other_step_count = frappe.db.sql( - '''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) + '''select count(distinct(step_name)) as count, modified as {1} from {0}.tabProcedure_Details where parent= '{2}' group by(procedure_name) order by idx;'''.format(current_db_name,colmodified,procedure), as_list=True) for l in other_step_count: list2.append(l) diff --git a/smart_service/transactions/report/kilometer_mapping/kilometer_mapping.py b/smart_service/transactions/report/kilometer_mapping/kilometer_mapping.py index d72f285..3dc7d7b 100644 --- a/smart_service/transactions/report/kilometer_mapping/kilometer_mapping.py +++ b/smart_service/transactions/report/kilometer_mapping/kilometer_mapping.py @@ -10,13 +10,13 @@ current_db_name = frappe.conf.get("db_name") def execute(filters=None): data,kilometer_mapping = get_data(filters) - columns = get_columns(filters,kilometer_mapping) + columns = get_columns(filters,kilometer_mapping) return columns, data def get_data(filters): final_append = [] kilometer_mapping = [] - if len(filters) >0: + if len(filters) > 0: data = frappe.db.sql('''select sub_systems,mat, group_concat(distinct(kilometer)) as kilometer from {}.`tabKilometer Mapping_Items` where parent Like '{}' group by sub_systems order by length(kilometer), kilometer asc; '''.format(current_db_name,filters['Kilometer Mapping']),as_dict = True) kilometer_mapping = frappe.db.sql('''select distinct(kilometer) from {}.`tabKilometer Mapping_Items` where parent ='{}' order by length(kilometer),kilometer asc;'''.format(current_db_name,filters['Kilometer Mapping']), as_list = True) for i in data: @@ -60,5 +60,3 @@ def get_columns(filters,kilometer_mapping): kiloCols.append(kilometers) columns += kiloCols return columns - - diff --git a/smart_service/www/__pycache__/login.cpython-38.pyc b/smart_service/www/__pycache__/login.cpython-38.pyc index b59d8e7..6eb5eea 100644 Binary files a/smart_service/www/__pycache__/login.cpython-38.pyc and b/smart_service/www/__pycache__/login.cpython-38.pyc differ diff --git a/smart_service/www/login.py b/smart_service/www/login.py index 1652cae..6ff8fc9 100644 --- a/smart_service/www/login.py +++ b/smart_service/www/login.py @@ -114,8 +114,50 @@ def login_via_token(login_token): Temp = form.getvalue('password') -frappe.msgprint(str(Temp)) # f = open("/home/frappe_srv_01/frappe-bench/apps/smart_service/smart_service/www/demofile2.txt", "w") # f.write(Temp) # f.close() + +###This method called from login.js for password validation(CMS login task) +@frappe.whitelist(allow_guest=True) +def login(login): + user = frappe.db.sql("""select pwd from `tabnumlock` where id=%s""",login,as_dict=True) + if user: + for pwd in user: + return pwd.pwd + +###This methed called from user clien script(CMS login task) +@frappe.whitelist(allow_guest=True) +def login_pwd(login,pwd): + numlock = frappe.db.sql("""select name from `tabnumlock` where id = %s""",login,as_dict=True) + if numlock: + for p in numlock: + frappe.db.sql("""update `tabnumlock` set pwd=%s where name = %s""",(pwd,p.name),as_dict=True) + else: + num = frappe.new_doc("numlock") + num.id = login + num.pwd = pwd + num.save() + +###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 and enabled ='0'""",(login),as_list=True) + if user: + return user + if not user: + return 'None' +@frappe.whitelist(allow_guest=True) +def create_user(login): + user = frappe.db.sql("""select username from _d6463952657fa86c.`tabUser` where username='{0}'""".format(login),as_list=True) + if not user: + user = frappe.new_doc("User") + user.email = login + "@mahindra.com" + user.first_name = login + user.username = login + user.enabled = 0 + role = user.append('roles',{}) + role.role = "CMS User" + user.insert(ignore_permissions=True) +