api=frappe.db.sql('''SELECT name,title,status,description,circular_image as FileUrl,valid_till as validity from {}.tabCircular WHERE valid_till >='{}''''.format(current_db_name,frappe.utils.today()),as_dict=True)
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)
api=frappe.db.sql('''SELECT name,title,status,description,circular_image as FileUrl,valid_till as validity from {}.tabCircular WHERE valid_till >='{}''''.format(current_db_name,frappe.utils.today()),as_dict=True)
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)
api={'message':'No such function. Check argument: args'}
except:
api={"isSuccessful":False}
returnapi
deflabels_json():
labels_lst=frappe.db.sql(
"""SELECT `tabApp Labels`.name as name,`tabApp Labels`.page_name as menu_type, `tabApp Labels`.english_label as element, `tabApp Labels`.language as lang, `tabApp Labels`.label as label, `tabApp Labels`.parent_app_labels as parent FROM {0}.`tabApp Labels` order by name asc""".format(current_db_name),
"""SELECT `tabApp Labels`.name as name,`tabApp Labels`.page_name as menu_type, `tabApp Labels`.english_label as element, `tabApp Labels`.language as lang, `tabApp Labels`.label as label, `tabApp Labels`.parent_app_labels as parent FROM {0}.`tabApp Labels` order by name asc""".format(
'''SELECT procedure_link, system, sub_system FROM %s.`tabPublish_Docs` WHERE parent='%s'; '''%(current_db_name,args),
as_dict=True)
fordinlist1:
frappe.db.sql(
"""UPDATE %s.`tabSystem Mapping_Sub System` SET procedure_status = '%s', procedure_is_published='1' where procedure_status = '%s' and `tabSystem Mapping_Sub System`.procedure='%s' and systems='%s' and sub_systems='%s'"""%(
'''SELECT procedure_link, system, sub_system FROM %s.`tabPublish_Docs` WHERE parent='%s'; '''%(current_db_name,args),
as_dict=True)
fordinlist1:
frappe.db.sql(
"""UPDATE %s.`tabSystem Mapping_Sub System` SET procedure_status = '%s', procedure_is_published='1' where procedure_status = '%s' and `tabSystem Mapping_Sub System`.procedure='%s' and systems='%s' and sub_systems='%s'"""%(
'''SELECT publish_type FROM {}.`tabApp Device` where name='{}';'''.format(current_db_name,iid),as_list=True)
ifpublish_type[0][0]!=None:
forvinvehicle_data:
v_id=v['Vehicle']
current_version=float(v['CurrentVersion'])
data1=frappe.db.sql('''SELECT name,max(version) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
data=frappe.db.sql('''SELECT name,CAST(version AS DECIMAL(10,2)) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
'''SELECT publish_type FROM {}.`tabApp Device` where name='{}';'''.format(current_db_name,iid),as_list=True)
ifpublish_type[0][0]!=None:
forvinvehicle_data:
v_id=v['Vehicle']
current_version=float(v['CurrentVersion'])
data1=frappe.db.sql('''SELECT name,max(version) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
data=frappe.db.sql('''SELECT name,CAST(version AS DECIMAL(10,2)) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
"message":"Hello {{ doc.full_name }}\r\n<br>A new account has been created with the below details.</br>\r\n<br>Login ID: {{ doc.username }} </br>\r\n<br>Email ID: {{ doc.name }}</br>\r\n\r\n<br>Complete the registration by setting the desired role and enable the user account.</br>\r\n<br>On completion a welcome mail will be sent to the user.</br> \r\n\r\n\r\n\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS.</br>\r\n",
"message":"<p>Hello Admin, </p>\r\n<p> </p>\r\n<p>A new account has been created with the below details </p>\r\n<p>Login ID: {{ doc.username }}</p>\r\n<p>Email ID: {{ doc.name }} </p>\r\n<p> </p>\r\n<p>Complete the registration by setting the desired role and enable the user account.</p>\r\n<p>On completion a welcome mail will be sent to the user. </p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"message":"Welcome to Smart Service CMS !!! \r\n<br>Hello {{ doc.full_name }},</br> \r\n<br>A new account has been created for you at {{ doc.creation }}.</br>\r\n<br>Your login id is: {{ doc.username }} </br>\r\n<br>Role: CMS User</br>\r\n\r\n<br>Please use Mahindra credentials for accessing your account.</br>\r\n\r\n<br>Click on the link below to access the CMS Portal.</br>\r\n<br>http://192.168.1.58:81/</br>\r\n\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin. </br>\r\n",
"message":"<p>Hello {{ doc.full_name }}, </p>\r\n<p>Welcome to Guided Smart Service CMS !!! </p>\r\n<p> </p>\r\n<p>A new account has been created on {{ doc.creation }}.</p>\r\n<p>Your login id is: {{ doc.username }} </p>\r\n<p>Role: CMS User </p>\r\n<br>Please use Mahindra credentials for accessing your account.</br>\r\n<br>Click on the link below to access the CMS Portal.</br>\r\n<p>http://192.168.1.58:81/ </p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"method":null,
"modified":"2022-02-22 10:40:15.721507",
"modified":"2022-03-08 10:58:11.969504",
"module":null,
"name":"Mahindra User Enabled",
"parent":null,
@ -67,7 +67,7 @@
"recipients":[
{
"bcc":null,
"cc":"jecinthamarym@hnsonline.com",
"cc":"",
"condition":null,
"parent":"Mahindra User Enabled",
"parentfield":"recipients",
@ -82,7 +82,93 @@
"sender_email":"cms@guidedsmartservice.com",
"set_property_after_alert":null,
"slack_webhook_url":null,
"subject":"Welcome to Smart Service CMS !!! ",
"subject":"Welcome to Guided Smart Service CMS !!! ",
"value_changed":"enabled"
},
{
"attach_print":0,
"channel":"Email",
"condition":"doc.enabled==1 and doc.location==\"Mahindra\"",
"date_changed":null,
"days_in_advance":0,
"docstatus":0,
"doctype":"Notification",
"document_type":"User",
"enabled":1,
"event":"Value Change",
"is_standard":0,
"message":"<p>Hello Admin, </p>\r\n<p> </p>\r\n<p>The account with the below details has been successfully enabled. </p>\r\n<p>Login ID: {{ doc.username }}</p>\r\n<p>Email ID: {{ doc.name }} </p>\r\n<p> </p>\r\n<p>The user can now access the account.</p>\r\n<p>A welcome mail has been sent to the user as well. </p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"message":"<p>Hello Smart Service User,</p>\n<br>New <b>{{doc.publish_type}}</b> publish for <b>{{doc.vehicle}}</b> has been published successfully as <b>{{doc.name}}</b>.</br>\n<p> </p>\n<br>Thanks,</br>\n<br>Smart Service CMS Admin</br>",
frappe.db.sql("""update {0}.`tabPublish` set version = '{1}' where name = '{2}'""".format(current_db_name,v,doc.name))
frappe.db.commit()
returnv
@frappe.whitelist()
defglobal_publish(doc):
doc=frappe.get_doc("Publish",doc)
current_db_name=frappe.conf.get("db_name")
procedure=frappe.db.sql("""select parent,name from {0}.`tabPublish_Docs` where parent = '{1}' and procedure_status='Publish Ready'""".format(current_db_name,doc.name))
ifnotprocedure:
frappe.throw("There is no item for global publish")
max_internal_ver=frappe.db.sql('''SELECT max(version) as max_version,name as name FROM {}.tabPublish where vehicle='{}' and language ='{}' and publish_type ='Internal';'''.format(current_db_name,doc.vehicle,doc.language),as_dict=True)
forvinmax_internal_ver:
ifdoc.version<v.max_version:
frappe.throw('Please publish Internal Publish Version '+v.max_version+' for '+v.name)
frappe.msgprint('Global Publish Created for '+publish_record.name)
#update_mapping(doc.variant_mapping,doc.name)
@frappe.whitelist()
defold_publish(vehicle,language):
current_db_name=frappe.conf.get("db_name")
publish_record=frappe.db.sql("""select name from {0}.`tabPublish` where vehicle = '{1}' and language = '{2}' and publish_status='To Publish' and publish_type = 'Internal' and docstatus != '2'""".format(current_db_name,vehicle,language),as_list=True)
frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '1' where parent = '{1}' and category = '{2}'""".format(current_db_name,variant.variant_mapping,variant.asset_category))
frappe.db.commit()
ifvariant.item_category=="System Mapping":
system_mapping=frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = '{1}' and language = '{2}'""".format(current_db_name,variant.variant_mapping,doc.language),as_dict=True)
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '1' where parent = '{1}' and systems = '{2}'""".format(current_db_name,sm.name,variant.system))
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published = '1' where parent = '{1}' and systems = '{2}' and sub_systems = '{3}'""".format(current_db_name,sm.name,variant.system,variant.sub_system))
assets=frappe.db.sql("""select systems,idx,active_status,system_asset,remarks from {0}.`tabSystem Mapping_System Assets` where parent = '{1}'""".format(current_db_name,self.name),as_dict=True)
ifassets:
forxinassets:
foryinself.get("systems_assets"):
ifx.idx==y.idxandy.systems==x.systems:
ify.active_status!=x.active_status:
y.published="0"
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
ify.system_asset!=x.system_asset:
y.published="0"
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
ify.remarks!=x.remarks:
y.published="0"
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
forsysteminself.get("system_sub_systems"):
ifnotsystem.procedure:
frappe.throw('Procedure to be added in row no '+str(system.idx))
values=self.get('system_sub_systems')
foriinrange(0,len(values)):
ifvalues[i].systems:
@ -15,13 +68,22 @@ class SystemMapping(Document):
frappe.throw(("Warning: Same systems (with similar sub systems and procedure) has been entered multiple times."))
ifself.systems_assets:
forxinself.get("systems_assets"):
ifnotx.systems:
frappe.throw("Please choose the systems in row no "+str(x.idx))
ifnotx.system_asset:
frappe.throw("Please choose the system asset file in row no "+str(x.idx))
ifnotx.language:
frappe.throw("Please choose the language in row no "+str(x.idx))
ifx.active_status=="In Active":
ifnotx.remarks:
frappe.throw("Enter the remarks for In Active status in row no "+str(x.idx))
defupdate_procedure(current_db_name,name,idx):
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,name,idx))
vehicle_sk=frappe.db.sql("""select service_kilometers from `tabVehicle_SK` where parent = %s order by service_kilometers""",vehicle,as_dict=True)
vehicle_sk=frappe.db.sql("""select service_kilometers from {0}.`tabVehicle_SK` where parent = '{1}' order by service_kilometers""".format(current_db_name,vehicle),as_dict=True)
###Delete kilometer mapping item depends on Sub system
iftype=="Deleted":
frappe.db.sql("""delete from `tabKilometer Mapping_Items` where parent = %s and sub_systems=%s and mat=%s""",(kilometer_mapping.name,str(sub_systems),str(mat_initial)),as_dict=True)
frappe.db.sql("""delete from {0}.`tabKilometer Mapping_Items` where parent = '{1}' and sub_systems='{2}' and mat='{3}'""".format(current_db_name,kilometer_mapping.name,str(sub_systems),str(mat_initial)),as_dict=True)
@ -6,6 +6,20 @@ from frappe.model.document import Document
classVariantMapping(Document):
defvalidate(self):
current_db_name=frappe.conf.get("db_name")
assets=frappe.db.sql("""select category,idx,active_status,attach_file from {0}.`tabVariant Mapping_Assets` where parent = '{1}'""".format(current_db_name,self.name),as_dict=True)
forxinassets:
foryinself.get("assets"):
ifx.idx==y.idxandy.category==x.category:
ify.active_status!=x.active_status:
y.published="0"
frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
ify.attach_file!=x.attach_file:
y.published="0"
frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
ifself.is_new():
current_db_name=frappe.conf.get("db_name")
data=frappe.db.sql("""select name from {0}.`tabVariant Mapping`
@ -16,6 +30,8 @@ class VariantMapping(Document):
frappe.throw('Variant Mapping already created as {0} for {1}'.format(data[0]['name'],self.variant))
ifself.assets:
forxinself.get("assets"):
ifnotx.language:
frappe.throw("Please select the language in row no "+str(x.idx))
ifnotx.attach_file:
frappe.throw("Please select the attach file in row no "+str(x.idx))
data=frappe.db.sql('''select sub_systems,mat, group_concat(distinct(kilometer)) as kilometer from {}.`tabKilometer Mapping_Items` where parent Like '{}' and applicable='1' 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)
data=frappe.db.sql('''select sub_systems,mat, group_concat(distinct(kilometer)) as kilometer from {}.`tabKilometer Mapping_Items` where parent Like '{}' and applicable='1' 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)