From 500a4c4cfbbe1f10152f17cdc23bae12a3a8b7d3 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Wed, 9 Aug 2023 16:52:48 +0530 Subject: [PATCH] Publish phase2 --- smart_service/apis/master_api.py | 13 +- smart_service/apis/v2/master.py | 67 +- .../doctype/feature_finder/feature_finder.js | 693 +++++++++++------- .../feature_finder/feature_finder.json | 29 +- .../doctype/feature_finder/feature_finder.py | 146 ++-- .../feature_finder_category_master.js | 28 +- .../feature_finder_content.json | 11 +- .../feature_finder_images.json | 11 +- .../feature_finder_master.json | 10 +- .../feature_finder_specification.json | 3 +- .../mst_information_assets.py | 7 +- .../doctype/publish_test/publish_test.js | 194 ++++- .../doctype/publish_test/publish_test.json | 13 +- .../doctype/publish_test/publish_test.py | 141 +++- .../repair_service_mapping.js | 128 ++-- .../repair_service_mapping.json | 8 +- .../repair_service_mapping.py | 11 +- .../repair_service_master.js | 23 +- .../repair_service_master_mapping.json | 13 +- .../repair_service_publish_data.json | 23 +- .../special_tool_information.js | 62 +- .../special_tool_information.json | 14 +- .../training_information.js | 24 +- .../training_information.json | 15 +- .../training_information.py | 6 +- .../training_information_content_reference.py | 4 +- .../training_information_master.js | 15 +- .../training_information_master.py | 29 +- smart_service/public/js/common_fun.js | 75 +- .../transactions/doctype/publish/publish.js | 6 +- 30 files changed, 1237 insertions(+), 585 deletions(-) diff --git a/smart_service/apis/master_api.py b/smart_service/apis/master_api.py index ec43ef0..35011a0 100644 --- a/smart_service/apis/master_api.py +++ b/smart_service/apis/master_api.py @@ -357,12 +357,13 @@ def variant(LSD, language): mahindra_special_tool_information as 'Mahindra Special Tool Information',training_information as 'Training Information', qwik_service as 'QWIK Service',pdi_inspection as 'PDI Inspection', torque_information_nm as 'Torque Information NM' - FROM grmtest.`tabModule Publish Mapping` where vehicle='Thar' and variant='ZLX';''', as_dict=1) - - d['modules'] = [{'title': k, 'active_status': v, 'app_menu_id': - frappe.db.sql(f'''select app_menu_id from `tabModule Master` where module_name = '{k}' ;''', as_dict=1)[0]['app_menu_id']} - for k, v in modules[0].items()] - + FROM `tabModule Publish Mapping`where variant="{d['variant_name']}" ;''', as_dict=1) + if modules: + d['modules'] = [{'title': k, 'active_status': v, 'app_menu_id': + frappe.db.sql(f'''select app_menu_id from `tabModule Master` where module_name = '{k}' ;''', as_dict=1)[0]['app_menu_id']} + for k, v in modules[0].items()] + else: + d['modules'] = [] return {"status": 1, "error": None, 'data': data} except Exception as e: diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py index afaf730..aeff3d9 100644 --- a/smart_service/apis/v2/master.py +++ b/smart_service/apis/v2/master.py @@ -49,11 +49,18 @@ def get_role_mapping(): @frappe.whitelist(methods=["POST"], allow_guest=1) def get_repair_service_mapping(vehicle, language): try: - repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,check_list_name,active_status,display_order,my_id from - `tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}'; """, as_dict=1) + repair_service_details = [] + if language != 'en': + repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,check_list_name,active_status,display_order,my_id from + `tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}'; """, as_dict=1) + else: + repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,translated_check_list_name as check_list_name,active_status, + display_order,my_id from `tabRepair Service Mapping` where vehicle = '{vehicle}' and + language = '{language}'; """, as_dict=1) + for d in repair_service_details: - d['complaint'] = frappe.db.sql(f""" select complaint,remedial_action_ok,remedial_action_not_ok,idx as display_order,active_status from `tabRepair Service Child` - where parent = '{d['name']}' order by display_order ;""", as_dict=1) + d['complaint'] = frappe.db.sql(f""" select complaint,remedial_action_ok,remedial_action_not_ok,idx as display_order,active_status from + `tabRepair Service Child` where parent = '{d['name']}' order by display_order ;""", as_dict=1) return True, repair_service_details except Exception as e: @@ -90,11 +97,23 @@ def old_get_feature_finder(vehicle, variant, language): @frappe.whitelist(methods=["POST"], allow_guest=1) def get_feature_finder(vehicle, variant, language): try: - feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language,ff.features_names as feature_name, - ff.feature_category,ff.display_order,ff.active_status,ffm.feature_pdf as pdf from `tabFeature Finder` ff - left join grmtest.`tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name - where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}" and ff.variant = "{variant}" - and ff.language = "{language}"; """, as_dict=1) + feature_finder_details = [] + if language == 'en': + feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language, + ff.features_names as feature_name,ff.feature_category,ff.display_order,ff.active_status, + ffm.feature_pdf as pdf from grmtest.`tabFeature Finder` ff left join grmtest.`tabFeature Finder Master` ffm on + ff.features_names = ffm.feature_name + where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}" and ff.variant = "{variant}" + and ff.language = "{language}"; + """, as_dict=1) + else: + feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language, + ff.translated_feature_name as feature_name,ff.feature_category, + ff.display_order,ff.active_status,ffm.feature_pdf as pdf from grmtest.`tabFeature Finder` ff + left join grmtest.`tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name + where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}" and ff.variant = "{variant}" + and ff.language = "{language}"; """, as_dict=1) + for f in feature_finder_details: f['disclaimer'] = frappe.db.sql(f''' SELECT name,content,active_status,idx as display_order FROM `tabFeature Finder Disclaimer` @@ -112,8 +131,7 @@ def get_feature_finder(vehicle, variant, language): f['sop'] = {'content': sop_content, 'images': sop_images, 'specificaton': sop_specification} - post_vin_data = frappe.db.sql(f''' - select name,idx as display_order,post_vin_cutoff_name,post_vin_cutoff_id + post_vin_data = frappe.db.sql(f'''select name,idx as display_order,post_vin_cutoff_name,post_vin_cutoff_id from `tabPost Vin Cutoff ID` where parent = '{f['name']}';''', as_dict=1) for p in post_vin_data: @@ -130,7 +148,6 @@ def get_feature_finder(vehicle, variant, language): p['specificaton'] = vin_specification f['post_vin'] = post_vin_data - return True, feature_finder_details except Exception as e: return False, e @@ -140,11 +157,11 @@ def get_feature_finder(vehicle, variant, language): def get_training_information(vehicle, language): try: training_information = frappe.db.sql(f"""select name,vehicle,category,topic,language,active_status from`tabTraining Information` - where vehicle = "{vehicle}" and language = "{language}"; """,as_dict=1) - + where vehicle = "{vehicle}" and language = "{language}"; """, as_dict=1) + for t in training_information: t['content'] = frappe.db.sql(f''' select content_type,content,image_video,idx as display_order,active_status from - `tabTraining Information Content Reference` where parent = '{t['name']}';''',as_dict=1) + `tabTraining Information Content Reference` where parent = '{t['name']}';''', as_dict=1) return True, training_information except Exception as e: return False, e @@ -171,6 +188,9 @@ def new_publish(): elif module == 'Training Information': flag, data = get_training_information(vehicle, language) + elif module == "Mahindra Special Tool Information": + flag, data = get_special_tool_information(vehicle) + if flag: return {'status': 1, 'error': None, 'data': data} else: @@ -179,15 +199,16 @@ def new_publish(): except Exception as e: frappe.local.response['http_status_code'] = 400 return {'status': 0, 'error': "Parameter's missing: " + str(e), 'data': None} - -@frappe.whitelist(methods=['POST'],allow_guest=1) + +@frappe.whitelist(methods=['POST'], allow_guest=1) def get_special_tool_information(vehicle): try: - special_tool_details=frappe.db.sql(''' select vehicle,category,sub_category,display_order, my_id from grmtest.`tabSpecial Tool Information` ;''',as_dict=1) - for d in special_tool_details: - d['tool_usage_content']=frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status from `tabMST Information Assets` - where parent = '{d['name']}' order by display_order;''',as_dict=1) - return True, special_tool_details,d['tool_usage_content'] + special_tool_details = frappe.db.sql(f''' select name,vehicle,category,sub_category,display_order, my_id from grmtest.`tabSpecial Tool Information` + where vehicle="{vehicle}";''', as_dict=1) + for s in special_tool_details: + s['tool_usage_content'] = frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status from `tabMST Information Assets` + where parent = '{s['name']}' order by display_order;''', as_dict=1) + return True, special_tool_details except Exception as e: - return False, e \ No newline at end of file + return False, e diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.js b/smart_service/phase_2/doctype/feature_finder/feature_finder.js index 0f0feb5..5e49ce0 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.js +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.js @@ -9,39 +9,76 @@ frappe.ui.form.on('Feature Finder', { refresh: function (frm) { // filter_value = "SOP" // set_default_tab(frm,filter_value) + setTimeout(function mysam(){ + if (!frm.doc.feature_finder_images){ + console.log("calling 1") + $(cur_frm.fields_dict.image_html.wrapper).empty(); + } + if (!frm.is_new()) { + custom_tab_html(frm) + } + },2000) + - custom_tab_html(frm) set_display_order(frm) - show_images(frm) + // show_images(frm) }, onload: function (frm) { // filter_value = "SOP" // set_default_tab(frm,filter_value) - custom_tab_html(frm) + setTimeout(function mysam(){ + if (!frm.doc.feature_finder_images){ + console.log("calling 1") + $(cur_frm.fields_dict.image_html.wrapper).empty(); + } + if (!frm.is_new()) { + custom_tab_html(frm) + } + },2000) + + set_display_order(frm) - show_images(frm) + // show_images(frm) + - }, variant: function (frm) { + frm.doc.features_names = "" + frm.doc.feature_name = "" + cur_frm.refresh_fields("features_names") + cur_frm.refresh_fields("feature_name") + if (frm.doc.variant) { + frm.toggle_display('feature_name', true) + frm.toggle_display('features_names', true) + } else + { + frm.toggle_display('features_names', false) + frm.toggle_display('feature_name', false) + } set_display_order(frm) - - + + }, - features_names:function(frm){ - if(frm.doc.features_names){ - frappe.db.get_list('Feature Finder Master', { - fields: ['name'], - filters: { - feature_name: frm.doc.feature_name, - vehicle:frm.doc.vehicle - } - }).then(records => { + features_names: function (frm) { + + frappe.db.get_list('Feature Finder Master', { + fields: ['name'], + filters: { + feature_name: frm.doc.features_names, + vehicle: frm.doc.vehicle + } + }).then(records => { + console.log(records) + if(records.length>0){ frm.doc.feature_name = records[0].name cur_frm.refresh_fields("feature_name") - - }) - } + }else{ + frm.doc.feature_name = "" + cur_frm.refresh_fields("feature_name") + } + + }) + }, create_feature_finder_images: function (frm) { if (click_count == 0) { @@ -54,12 +91,27 @@ frappe.ui.form.on('Feature Finder', { } }, language: function (frm) { + console.log('Language trigger'); + if (frm.doc.language == "en") { frm.toggle_display('translated_feature_name', false) frm.doc.translated_feature_name = "" cur_frm.refresh_fields("translated_feature_name") + } else { frm.toggle_display('translated_feature_name', true) + frappe.call({ + method: "smart_service.phase_2.doctype.feature_finder.feature_finder.get_feature_list", + args: { + vehicle: frm.doc.vehicle, + language: frm.doc.language + }, + callback: function (r) { + console.log(r.message) + frm.set_df_property('features_names', 'options', r.message); + frm.refresh_field('features_names') + } + }) } }, // feature_type: function (frm) { @@ -113,19 +165,21 @@ frappe.ui.form.on('Feature Finder', { frm.reload_doc() } }); -function show_images(frm) { - var res = $(cur_frm.fields_dict.image_html.wrapper).empty(); - if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0) { - var img_html = "" - img_html += "
" - cur_frm.doc.feature_finder_images.forEach((val) => - img_html += "
" - ); - img_html += "
" - $(res).append(img_html) - } -} -function custom_tab_html(frm){ +// function show_images(frm) { +// var res = $(cur_frm.fields_dict.image_html.wrapper).empty(); +// if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0) { +// var img_html = "" + +// img_html += "
" +// cur_frm.doc.feature_finder_images.forEach((val) => +// img_html += "
" + +// ); +// img_html += "
" +// $(res).append(img_html) +// } +// } +function custom_tab_html(frm) { // $('[data-fieldname="specification"]').show() // $('[data-fieldname="feature_finder_images"]').show() @@ -137,7 +191,7 @@ function custom_tab_html(frm){ // $('[data-fieldname="specification"]').css('border-left','1px solid var(--table-border-color)') // $('[data-fieldname="specification"]').css('padding-right','20px') // $('[data-fieldname="specification"]').css('padding-left','20px') - + // $('[data-fieldname="feature_finder_images"]').css('margin-bottom','unset') // $('[data-fieldname="feature_finder_images"]').css('border-right','1px solid var(--table-border-color)') @@ -155,13 +209,14 @@ function custom_tab_html(frm){ var res = $(cur_frm.fields_dict.test_html.wrapper).empty(); var ret = '
' res.append(ret) - + $(res).find('.main').append(`
`) $(res).find('.main').append(`
`) $(res).find('.main').append(`
`) res.append(``) - - var specification ="" + + var specification = "" var feature_finder_images = "" var feature_finder_content = "" - specification = frm.doc.specification.filter(o => o.feature_type == "SOP") - feature_finder_images = frm.doc.feature_finder_images.filter(o => o.feature_type == "SOP") - feature_finder_content = frm.doc.feature_finder_content.filter(o => o.feature_type == "SOP") + + if (frm.doc.specification && frm.doc.feature_finder_images && frm.doc.feature_finder_content){ + specification = frm.doc.specification.filter(o => o.feature_type == "SOP") + feature_finder_images = frm.doc.feature_finder_images.filter(o => o.feature_type == "SOP") + feature_finder_content = frm.doc.feature_finder_content.filter(o => o.feature_type == "SOP") + + specification.sort((a, b) => a.display_order - b.display_order); + feature_finder_images.sort((a, b) => a.display_order - b.display_order); + feature_finder_content.sort((a, b) => a.display_order - b.display_order); + } + var spec_dialog_value = "" - var image_dialog_value ="" - var content_dialog_value ="" + var image_dialog_value = "" + var content_dialog_value = "" var nav_spec = {} nav_spec.feature_type = "SOP" all_tabs() + show_images() - $('.main').find('.nav-link').click(function(event){ + $('.main').find('.nav-link').click(function (event) { console.log($(this)[0].id) - if($(this)[0].id=="SOP"){ - nav_spec.feature_type= "SOP" + if ($(this)[0].id == "SOP") { + nav_spec.feature_type = "SOP" nav_spec.post_vin_cutoff_name = "" specification = frm.doc.specification.filter(o => o.feature_type == $(this)[0].id) feature_finder_images = frm.doc.feature_finder_images.filter(o => o.feature_type == $(this)[0].id) feature_finder_content = frm.doc.feature_finder_content.filter(o => o.feature_type == $(this)[0].id) + + specification.sort((a, b) => a.display_order - b.display_order); + feature_finder_images.sort((a, b) => a.display_order - b.display_order); + feature_finder_content.sort((a, b) => a.display_order - b.display_order); + } - else{ - nav_spec.feature_type= "Post Vin CutOff" + else { + nav_spec.feature_type = "Post Vin CutOff" nav_spec.post_vin_cutoff_name = $(this)[0].id specification = frm.doc.specification.filter(o => o.post_vin_cutoff_name == $(this)[0].id) feature_finder_images = frm.doc.feature_finder_images.filter(o => o.post_vin_cutoff_name == $(this)[0].id) - console.log(feature_finder_images,"---feature_finder_images") + console.log(feature_finder_images, "---feature_finder_images") feature_finder_content = frm.doc.feature_finder_content.filter(o => o.post_vin_cutoff_name == $(this)[0].id) + + specification.sort((a, b) => a.display_order - b.display_order); + feature_finder_images.sort((a, b) => a.display_order - b.display_order); + feature_finder_content.sort((a, b) => a.display_order - b.display_order); + } - + all_tabs() + show_images() }) - - - - function all_tabs(){ + + + function show_images(frm) { + var res = $(cur_frm.fields_dict.image_html.wrapper).empty(); + if (feature_finder_images.length > 0) { + var img_html = "" + + img_html += "
" + feature_finder_images.forEach((val) => + img_html += "
" + + ); + img_html += "
" + $(res).append(img_html) + } + } + function all_tabs() { //heading @@ -235,7 +323,7 @@ function custom_tab_html(frm){ ` spec_custom_dt += "" - + var image_custom_dt = "" image_custom_dt += ` @@ -275,83 +363,83 @@ function custom_tab_html(frm){ //list var specification_count = 0 - if(specification.length>0){ + if (specification.length > 0) { specification.map(val => { specification_count += 1 - // spec_custom_dt += '' - spec_custom_dt += '' - spec_custom_dt += '' - spec_custom_dt += '' - spec_custom_dt += '' - spec_custom_dt += '' - spec_custom_dt += '' - if(val.post_vin_cutoff_name){ - spec_custom_dt += '' + spec_custom_dt += '' + // spec_custom_dt += '' + spec_custom_dt += '' + spec_custom_dt += '' + spec_custom_dt += '' + spec_custom_dt += '' + spec_custom_dt += '' + if (val.post_vin_cutoff_name) { + spec_custom_dt += '' } - else{ + else { spec_custom_dt += '' } - - spec_custom_dt += '' - spec_custom_dt += '' - + + spec_custom_dt += '' + spec_custom_dt += '' + }) - }else{ + } else { spec_custom_dt += '' } var image_count = 0 - if(feature_finder_images.length){ + if (feature_finder_images.length) { feature_finder_images.map(val => { image_count += 1 - // spec_custom_dt += '' - image_custom_dt += '' - image_custom_dt += '' - image_custom_dt += '' - image_custom_dt += '' - image_custom_dt += '' - if(val.post_vin_cutoff_name){ - image_custom_dt += '' + image_custom_dt += '' + // image_custom_dt += '' + image_custom_dt += '' + image_custom_dt += '' + image_custom_dt += '' + image_custom_dt += '' + if (val.post_vin_cutoff_name) { + image_custom_dt += '' } - else{ + else { image_custom_dt += '' } - - image_custom_dt += '' - image_custom_dt += '' - + + image_custom_dt += '' + image_custom_dt += '' + }) - }else{ + } else { image_custom_dt += '' } - + var content_count = 0 - if(feature_finder_content.length){ + if (feature_finder_content.length) { feature_finder_content.map(val => { content_count += 1 - // spec_custom_dt += '' - content_custom_dt += '' - content_custom_dt += '' - content_custom_dt += '' - content_custom_dt += '' - content_custom_dt += '' - if(val.post_vin_cutoff_name){ - content_custom_dt += '' + content_custom_dt += '' + // content_custom_dt += '' + content_custom_dt += '' + content_custom_dt += '' + content_custom_dt += '' + content_custom_dt += '' + if (val.post_vin_cutoff_name) { + content_custom_dt += '' } - else{ + else { content_custom_dt += '' } - - content_custom_dt += '' - content_custom_dt += '' - + + content_custom_dt += '' + content_custom_dt += '' + }) - }else{ + } else { content_custom_dt += '' } - + //list end //buttons @@ -360,7 +448,7 @@ function custom_tab_html(frm){ spec_custom_dt += '' spec_custom_dt += '' spec_custom_dt += '' - + image_custom_dt += '' image_custom_dt += '
'+specification_count+''+val.specification+''+val.value+''+val.active_status+''+val.feature_type+''+val.post_vin_cutoff_name+'
' + specification_count + '' + val.specification + '' + val.value + '' + val.active_status + '' + val.feature_type + '' + val.post_vin_cutoff_name + ' Edit
Edit
No Records Found
'+image_count+''+val.image+''+val.active_status+''+val.feature_type+''+val.post_vin_cutoff_name+'
' + image_count + '' + val.image + '' + val.active_status + '' + val.feature_type + '' + val.post_vin_cutoff_name + ' Edit
Edit
No Records Found
'+content_count+''+val.content+''+val.active_status+''+val.feature_type+''+val.post_vin_cutoff_name+'
' + content_count + '' + val.content + '' + val.active_status + '' + val.feature_type + '' + val.post_vin_cutoff_name + ' Edit
Edit
No Records Found
' @@ -392,29 +480,30 @@ function custom_tab_html(frm){ $(res).find('.feature_contbl').empty() $(res).find('.feature_contbl').append(content_custom_dt) - $(res).append(``) - - $(res).append(``) + + $(res).append(``) - $(res).append(``) //append end //add button - $(res).find('.feature_imgbl').find('.image_custom_add').click(function(event){ - image_dialog_value = "" - image_dialog_value = nav_spec - image_dialog_view() - }) - $(res).find('.specification_bl').find('.spec_custom_add').click(function(event){ + $(res).find('.specification_bl').find('.spec_custom_add').click(function (event) { spec_dialog_value = "" spec_dialog_value = nav_spec spec_dialog_view() }) - $(res).find('.feature_contbl').find('.content_custom_add').click(function(event){ + $(res).find('.feature_imgbl').find('.image_custom_add').click(function (event) { + image_dialog_value = "" + image_dialog_value = nav_spec + image_dialog_view() + }) + + $(res).find('.feature_contbl').find('.content_custom_add').click(function (event) { content_dialog_value = "" content_dialog_value = nav_spec content_dialog_view() @@ -422,82 +511,134 @@ function custom_tab_html(frm){ //end add button + //save function + $(res).find('.specification_bl').find('.spec_custom_save').click(function (event) { + var spec_id_dis = [] + $(document).ready(function () { + $('.specification_bl').find('table > tbody > tr').each(function (index, tr) { + spec_id_dis.push(this.id); + }); + set_display_order_child("Feature Finder Specification", spec_id_dis) + }) + }) + + $(res).find('.feature_imgbl').find('.image_custom_save').click(function (event) { + var image_id_dis = [] + $(document).ready(function () { + $('.feature_imgbl').find('table > tbody > tr').each(function (index, tr) { + image_id_dis.push(this.id); + }); + set_display_order_child("Feature Finder Images", image_id_dis) + }) + }) + + $(res).find('.feature_contbl').find('.content_custom_save').click(function (event) { + var cont_id_dis = [] + $(document).ready(function () { + $('.feature_contbl').find('table > tbody > tr').each(function (index, tr) { + cont_id_dis.push(this.id); + }); + set_display_order_child("Feature Finder Content", cont_id_dis) + }) + }) + + + + function set_display_order_child(doctype_name, values) { + frappe.call({ + method: "smart_service.phase_2.doctype.feature_finder.feature_finder.set_display_order", + args: { + doctype_name: doctype_name, + values: values + }, + callback: function (r) { + console.log(r.message.status, '-rmessage') + if (r.message.status == "success") { + cur_frm.reload_doc() + } + } + }) + } + + + //end save function + //edit button - $(res).find('.feature_imgbl').find('.image_edit_row').click(function(event){ + $(res).find('.feature_imgbl').find('.image_edit_row').click(function (event) { image_dialog_value = frm.doc.feature_finder_images.filter(o => o.name == $(this)[0].id)[0] image_dialog_view() }) - $(res).find('.specification_bl').find('.spec_edit_row').click(function(event){ + $(res).find('.specification_bl').find('.spec_edit_row').click(function (event) { spec_dialog_value = frm.doc.specification.filter(o => o.name == $(this)[0].id)[0] spec_dialog_view() }) - $(res).find('.feature_contbl').find('.content_edit_row').click(function(event){ + $(res).find('.feature_contbl').find('.content_edit_row').click(function (event) { content_dialog_value = frm.doc.feature_finder_content.filter(o => o.name == $(this)[0].id)[0] content_dialog_view() }) //end edit button - + //delete all button - $(res).find('.feature_imgbl').find('.feature_image').find('input[type=checkbox]').change(function() { - $(".imagecheck").prop('checked', $(this).prop('checked')); - if(this.checked) { - $(res).find('.feature_imgbl').find('.image_custom_delete').css("display","inline-block") - }else{ - $(res).find('.feature_imgbl').find('.image_custom_delete').css("display","None") - } + $(res).find('.feature_imgbl').find('.feature_image').find('input[type=checkbox]').change(function () { + $(".imagecheck").prop('checked', $(this).prop('checked')); + if (this.checked) { + $(res).find('.feature_imgbl').find('.image_custom_delete').css("display", "inline-block") + } else { + $(res).find('.feature_imgbl').find('.image_custom_delete').css("display", "None") + } }) - $(res).find('.specification_bl').find('.specifiction').find('input[type=checkbox]').change(function() { + $(res).find('.specification_bl').find('.specifiction').find('input[type=checkbox]').change(function () { $(".speccheck").prop('checked', $(this).prop('checked')); - if(this.checked) { - $(res).find('.specification_bl').find('.spec_custom_delete').css("display","inline-block") - }else{ - $(res).find('.specification_bl').find('.spec_custom_delete').css("display","None") + if (this.checked) { + $(res).find('.specification_bl').find('.spec_custom_delete').css("display", "inline-block") + } else { + $(res).find('.specification_bl').find('.spec_custom_delete').css("display", "None") } }) - $(res).find('.feature_contbl').find('.feature_content').find('input[type=checkbox]').change(function() { + $(res).find('.feature_contbl').find('.feature_content').find('input[type=checkbox]').change(function () { $(".contentcheck").prop('checked', $(this).prop('checked')); - if(this.checked) { - $(res).find('.feature_contbl').find('.content_custom_delete').css("display","inline-block") - }else{ - $(res).find('.feature_contbl').find('.content_custom_delete').css("display","None") + if (this.checked) { + $(res).find('.feature_contbl').find('.content_custom_delete').css("display", "inline-block") + } else { + $(res).find('.feature_contbl').find('.content_custom_delete').css("display", "None") } }) //end delete all button //individual delete button - $(res).find('.feature_imgbl').find('.imagecheck').change(function() { - if(this.checked) { - $(res).find('.feature_imgbl').find('.image_custom_delete').css("display","inline-block") - }else{ - $(res).find('.feature_imgbl').find('.image_custom_delete').css("display","None") - } + $(res).find('.feature_imgbl').find('.imagecheck').change(function () { + if (this.checked) { + $(res).find('.feature_imgbl').find('.image_custom_delete').css("display", "inline-block") + } else { + $(res).find('.feature_imgbl').find('.image_custom_delete').css("display", "None") + } - }) - - $(res).find('.specification_bl').find('.speccheck').change(function() { - if(this.checked) { - $(res).find('.specification_bl').find('.spec_custom_delete').css("display","inline-block") - }else{ - $(res).find('.specification_bl').find('.spec_custom_delete').css("display","None") - } + }) + + $(res).find('.specification_bl').find('.speccheck').change(function () { + if (this.checked) { + $(res).find('.specification_bl').find('.spec_custom_delete').css("display", "inline-block") + } else { + $(res).find('.specification_bl').find('.spec_custom_delete').css("display", "None") + } }) - $(res).find('.feature_contbl').find('.contentcheck').change(function() { - if(this.checked) { - $(res).find('.feature_contbl').find('.content_custom_delete').css("display","inline-block") - }else{ - $(res).find('.feature_contbl').find('.content_custom_delete').css("display","None") - } + $(res).find('.feature_contbl').find('.contentcheck').change(function () { + if (this.checked) { + $(res).find('.feature_contbl').find('.content_custom_delete').css("display", "inline-block") + } else { + $(res).find('.feature_contbl').find('.content_custom_delete').css("display", "None") + } }) @@ -506,84 +647,84 @@ function custom_tab_html(frm){ //delete function - $(res).find('.specification_bl').find('.spec_custom_delete').click(function(event){ + $(res).find('.specification_bl').find('.spec_custom_delete').click(function (event) { var arr = [] $(res).find('.specification_bl').find("input[type=checkbox]").each(function () { var self = $(this); if (self.is(':checked')) { - console.log(self.attr("id"),"sdcdcd") + console.log(self.attr("id"), "sdcdcd") arr.push(self.attr("id")); } }); - if(arr[0]=="checkAll"){ + if (arr[0] == "checkAll") { arr = arr.slice(1) } - - console.log(arr,"-------------------") + + console.log(arr, "-------------------") frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.delete_spec_data", args: { - values:arr + values: arr }, - callback:function(r){ - console.log(r.message.status,'-rmessage') - if(r.message.status=="success"){ + callback: function (r) { + console.log(r.message.status, '-rmessage') + if (r.message.status == "success") { cur_frm.reload_doc() } } }) }) - $(res).find('.feature_imgbl').find('.image_custom_delete').click(function(event){ + $(res).find('.feature_imgbl').find('.image_custom_delete').click(function (event) { var arr = [] $(res).find('.feature_imgbl').find("input[type=checkbox]").each(function () { var self = $(this); if (self.is(':checked')) { - console.log(self.attr("id"),"sdcdcd") + console.log(self.attr("id"), "sdcdcd") arr.push(self.attr("id")); } }); - if(arr[0]=="checkAll"){ + if (arr[0] == "checkAll") { arr = arr.slice(1) } - - console.log(arr,"-------------------") + + console.log(arr, "-------------------") frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.delete_image_data", args: { - values:arr + values: arr }, - callback:function(r){ - console.log(r.message.status,'-rmessage') - if(r.message.status=="success"){ + callback: function (r) { + console.log(r.message.status, '-rmessage') + if (r.message.status == "success") { cur_frm.reload_doc() } } }) }) - $(res).find('.feature_contbl').find('.content_custom_delete').click(function(event){ + $(res).find('.feature_contbl').find('.content_custom_delete').click(function (event) { var arr = [] $(res).find('.feature_contbl').find("input[type=checkbox]").each(function () { var self = $(this); if (self.is(':checked')) { - console.log(self.attr("id"),"sdcdcd") + console.log(self.attr("id"), "sdcdcd") arr.push(self.attr("id")); } }); - if(arr[0]=="checkAll"){ + if (arr[0] == "checkAll") { arr = arr.slice(1) } - - console.log(arr,"-------------------") + + console.log(arr, "-------------------") frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.delete_content_data", args: { - values:arr + values: arr }, - callback:function(r){ - console.log(r.message.status,'-rmessage') - if(r.message.status=="success"){ + callback: function (r) { + console.log(r.message.status, '-rmessage') + if (r.message.status == "success") { cur_frm.reload_doc() } } @@ -592,9 +733,9 @@ function custom_tab_html(frm){ //delete function end } - - function spec_dialog_view(){ - + + function spec_dialog_view() { + let spec_dia = new frappe.ui.Dialog({ title: 'Enter details', fields: [ @@ -602,59 +743,59 @@ function custom_tab_html(frm){ label: 'Name', fieldname: 'name', fieldtype: 'Data', - default:spec_dialog_value.name, - hidden:1 + default: spec_dialog_value.name, + hidden: 1 }, { label: 'Specification', fieldname: 'specification', fieldtype: 'Link', - options:"Feature Finder Specification Master", - default:spec_dialog_value.specification + options: "Feature Finder Specification Master", + default: spec_dialog_value.specification }, { label: 'Value', fieldname: 'value', fieldtype: 'Data', - default:spec_dialog_value.value + default: spec_dialog_value.value }, { label: 'Active Status', fieldname: 'active_status', fieldtype: 'Select', - options:"Active\nInactive", - default:spec_dialog_value.active_status + options: "Active\nInactive", + default: spec_dialog_value.active_status }, { label: 'Feature Type', fieldname: 'feature_type', fieldtype: 'Data', - default:spec_dialog_value.feature_type, - read_only:1 + default: spec_dialog_value.feature_type, + read_only: 1 }, { label: 'Post Vin Cutoff Name', fieldname: 'post_vin_cutoff_name', fieldtype: 'Data', - default:spec_dialog_value.post_vin_cutoff_name, - depends_on:"eval:doc.feature_type=='Post Vin CutOff'", - + default: spec_dialog_value.post_vin_cutoff_name, + depends_on: "eval:doc.feature_type=='Post Vin CutOff'", + }, ], // size: 'small', // small, large, extra-large primary_action_label: 'Submit', primary_action(values) { - console.log(values,"values"); - if (values){ + console.log(values, "values"); + if (values) { frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_spec_data", args: { - doc_name:frm.doc.name, - values:values + doc_name: frm.doc.name, + values: values }, - callback:function(r){ - console.log(r.message.status,'-rmessage') - if(r.message.status=="success"){ + callback: function (r) { + console.log(r.message.status, '-rmessage') + if (r.message.status == "success") { cur_frm.reload_doc() } } @@ -663,13 +804,13 @@ function custom_tab_html(frm){ spec_dia.hide(); } }); - console.log(spec_dia,"spec_dia") + console.log(spec_dia, "spec_dia") spec_dia.show(); } - - function image_dialog_view(){ - + + function image_dialog_view() { + let spec_dia = new frappe.ui.Dialog({ title: 'Enter details', fields: [ @@ -677,54 +818,55 @@ function custom_tab_html(frm){ label: 'Name', fieldname: 'name', fieldtype: 'Data', - default:image_dialog_value.name, - hidden:1 + default: image_dialog_value.name, + hidden: 1 }, { label: 'Image', fieldname: 'image', fieldtype: 'Attach', - + }, { label: 'Active Status', fieldname: 'active_status', fieldtype: 'Select', - options:"Active\nInactive", - default:image_dialog_value.active_status + options: "Active\nInactive", + default: image_dialog_value.active_status }, { label: 'Feature Type', fieldname: 'feature_type', fieldtype: 'Data', - default:image_dialog_value.feature_type, - read_only:1 + default: image_dialog_value.feature_type, + read_only: 1 }, { label: 'Post Vin Cutoff Name', fieldname: 'post_vin_cutoff_name', fieldtype: 'Data', - default:image_dialog_value.post_vin_cutoff_name, - depends_on:"eval:doc.feature_type=='Post Vin CutOff'", - read_only:1 + default: image_dialog_value.post_vin_cutoff_name, + depends_on: "eval:doc.feature_type=='Post Vin CutOff'", + read_only: 1 }, ], // size: 'small', // small, large, extra-large primary_action_label: 'Submit', primary_action(values) { - console.log(values,"values"); - if (values){ - console.log(values,"---values") + console.log(values, "values"); + if (values && values.image) { + console.log(values, "---values") frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_image_data", args: { - doc_name:frm.doc.name, - values:values + doc_name: frm.doc.name, + values: values }, - callback:function(r){ - console.log(r.message.status,'-rmessage') - if(r.message.status=="success"){ - cur_frm.reload_doc() + callback: function (r) { + console.log(r.message.status, '-rmessage') + if (r.message.status == "success") { + cur_frm.refresh() + // cur_frm.reload_doc() } } }) @@ -732,14 +874,14 @@ function custom_tab_html(frm){ spec_dia.hide(); } }); - console.log(spec_dia,"spec_dia") + console.log(spec_dia, "spec_dia") spec_dia.show(); } - - function content_dialog_view(){ - + + function content_dialog_view() { + let spec_dia = new frappe.ui.Dialog({ title: 'Enter details', fields: [ @@ -747,54 +889,54 @@ function custom_tab_html(frm){ label: 'Name', fieldname: 'name', fieldtype: 'Data', - default:content_dialog_value.name, - hidden:1 + default: content_dialog_value.name, + hidden: 1 }, { label: 'Content', fieldname: 'content', fieldtype: 'Data', - default:content_dialog_value.content, - + default: content_dialog_value.content, + }, { label: 'Active Status', fieldname: 'active_status', fieldtype: 'Select', - options:"Active\nInactive", - default:content_dialog_value.active_status + options: "Active\nInactive", + default: content_dialog_value.active_status }, { label: 'Feature Type', fieldname: 'feature_type', fieldtype: 'Data', - default:content_dialog_value.feature_type, - read_only:1 + default: content_dialog_value.feature_type, + read_only: 1 }, { label: 'Post Vin Cutoff Name', fieldname: 'post_vin_cutoff_name', fieldtype: 'Data', - default:content_dialog_value.post_vin_cutoff_name, - depends_on:"eval:doc.feature_type=='Post Vin CutOff'", - read_only:1 + default: content_dialog_value.post_vin_cutoff_name, + depends_on: "eval:doc.feature_type=='Post Vin CutOff'", + read_only: 1 }, ], // size: 'small', // small, large, extra-large primary_action_label: 'Submit', primary_action(values) { - console.log(values,"values"); - if (values){ - console.log(values,"---values") + console.log(values, "values"); + if (values) { + console.log(values, "---values") frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_content_data", args: { - doc_name:frm.doc.name, - values:values + doc_name: frm.doc.name, + values: values }, - callback:function(r){ - console.log(r.message.status,'-rmessage') - if(r.message.status=="success"){ + callback: function (r) { + console.log(r.message.status, '-rmessage') + if (r.message.status == "success") { cur_frm.reload_doc() } } @@ -803,19 +945,19 @@ function custom_tab_html(frm){ spec_dia.hide(); } }); - console.log(spec_dia,"spec_dia") + console.log(spec_dia, "spec_dia") spec_dia.show(); } - - + + // $("#specification").click(function(){ // $('[data-fieldname="specification"]').show() // $('[data-fieldname="feature_finder_images"]').hide() // $('[data-fieldname="feature_finder_content"]').hide() // }); - + // $("#images").click(function(){ // $('[data-fieldname="specification"]').hide() // $('[data-fieldname="feature_finder_images"]').show() @@ -827,7 +969,7 @@ function custom_tab_html(frm){ // $('[data-fieldname="feature_finder_images"]').hide() // $('[data-fieldname="feature_finder_content"]').show() // }); - $('.nav-link').click(function(event){ + $('.nav-link').click(function (event) { // console.log($(this)[0].id) // filter_value = $(this)[0].id // frappe.call({ @@ -851,7 +993,7 @@ function custom_tab_html(frm){ // } // }) }) - + } // function set_default_tab(frm,filter_value){ // frappe.call({ @@ -863,23 +1005,17 @@ function custom_tab_html(frm){ // callback: function (r) { // console.log(r.message) // frm.doc.specification = [] - + // cur_frm.refresh_fields("specification") // frm.doc.specification= r.message[0] // cur_frm.refresh_fields("specification") - + // } // }) - + // } function set_display_order(frm) { - if(frm.doc.variant){ - frm.toggle_display('feature_name', true) - frm.toggle_display('features_names', true) - }else{ - frm.toggle_display('feature_name', false) - frm.toggle_display('features_names', false) - } + // if (frm.doc.feature_type == "Post VIN Cutoff") { // frm.toggle_display('post_vin_cutoff_id', true) // } @@ -887,11 +1023,12 @@ function set_display_order(frm) { // frm.toggle_display('post_vin_cutoff_id', false) // } - if(frm.doc.variant && frm.doc.vehicle){ + if (frm.doc.variant && frm.doc.vehicle && frm.doc.language) { frappe.call({ method: "smart_service.phase_2.doctype.feature_finder.feature_finder.get_feature_list", args: { - vehicle:frm.doc.vehicle + vehicle: frm.doc.vehicle, + language: frm.doc.language }, callback: function (r) { frm.set_df_property('features_names', 'options', r.message); @@ -933,20 +1070,20 @@ frappe.ui.form.on('Feature Finder Specification', { // }); // refresh_field("specification"); // }, - - specification_add: function(frm,cdt,cdn){ - console.log(locals[cdt][cdn],"locals[cdt][cdn]") + + specification_add: function (frm, cdt, cdn) { + console.log(locals[cdt][cdn], "locals[cdt][cdn]") var child2 = locals[cdt][cdn]; child2.post_vin_cutoff_name = filter_value refresh_field("specification"); } - + }) frappe.ui.form.on('Feature Finder Content', { - feature_finder_content_add: function(frm,cdt,cdn){ + feature_finder_content_add: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; child.post_vin_cutoff_name = filter_value refresh_field("feature_finder_content"); @@ -955,7 +1092,7 @@ frappe.ui.form.on('Feature Finder Content', { frappe.ui.form.on('Feature Finder Images', { - feature_finder_images_add: function(frm,cdt,cdn){ + feature_finder_images_add: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; child.post_vin_cutoff_name = filter_value refresh_field("feature_finder_images"); diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.json b/smart_service/phase_2/doctype/feature_finder/feature_finder.json index f937df8..14f0d56 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.json +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.json @@ -17,6 +17,7 @@ "vehicle", "feature_name", "features_names", + "translated_feature_name", "feature_category", "section_break_u9bx1", "image_html", @@ -61,17 +62,17 @@ "in_standard_filter": 1, "label": "Variant", "options": "Variant Mapping", - "reqd": 1 + "reqd": 1, + "set_only_once": 1 }, { "depends_on": "eval:doc.variant!=\"\"", "fieldname": "feature_name", "fieldtype": "Link", "hidden": 1, - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Feature Name", + "label": "Feature Name1", "options": "Feature Finder Master", + "read_only": 1, "set_only_once": 1 }, { @@ -134,7 +135,8 @@ "fieldname": "features_names", "fieldtype": "Select", "label": "Feature Name", - "reqd": 1 + "reqd": 1, + "set_only_once": 1 }, { "fieldname": "test_html", @@ -148,21 +150,30 @@ "options": "Post Vin Cutoff ID" }, { - "fetch_from": "variant_mapping.vehicle_id", + "fetch_from": "variant.vehicle_id", "fieldname": "vehicle_id", "fieldtype": "Int", + "hidden": 1, "label": "Vehicle Id" }, { - "fetch_from": "variant_mapping.variant_id", + "fetch_from": "variant.name", "fieldname": "variant_id", - "fieldtype": "Int", + "fieldtype": "Data", + "hidden": 1, "label": "Variant Id" + }, + { + "fieldname": "translated_feature_name", + "fieldtype": "Data", + "label": "Translated Feature Name", + "mandatory_depends_on": "eval:doc.language!=\"en\"", + "read_only_depends_on": "eval:doc.language==\"en\"" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-07 18:05:41.690172", + "modified": "2023-08-09 12:50:40.680301", "modified_by": "Administrator", "module": "Phase-2", "name": "Feature Finder", diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.py b/smart_service/phase_2/doctype/feature_finder/feature_finder.py index 03f4cea..5f1660d 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.py +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.py @@ -5,6 +5,7 @@ import frappe from frappe.model.document import Document import json + class FeatureFinder(Document): # def validate(self): # if self.feature_name and self.feature_type=="SOP": @@ -25,11 +26,14 @@ class FeatureFinder(Document): try: if self.is_new(): if self.variant and self.language and self.feature_name: - check_exe = frappe.db.get_list("Feature Finder", - filters={"variant": self.variant, "language": "en", - "feature_name": self.feature_name, - "name": ["!=", self.name]}, - fields={"name", "language", "display_order", "active_status"}) + # check_exe = frappe.db.get_list("Feature Finder", + # filters={"variant": self.variant, "language": "en", + # "features_names": self.features_names, + # "name": ["!=", self.name]}, + # fields={"name", "language", "display_order", "active_status"}) + check_exe = frappe.db.sql(f''' select * from `tabFeature Finder` where variant='{self.variant}' and features_names='{self.features_names}' + and language='en' and name != '{self.name}' ; + ''', as_dict=1) if check_exe: if self.language != "en": for d in check_exe: @@ -48,6 +52,7 @@ class FeatureFinder(Document): # for k in specification: # set_idx +=1 # k[''] + except Exception as e: raise e @@ -56,7 +61,7 @@ class FeatureFinder(Document): try: check_exe = frappe.db.get_list("Feature Finder", filters={"variant": self.variant, "language": ["!=", "en"], - "feature_name": self.feature_name, + "feature_name": self.feature_name, "name": ["!=", self.name]}, fields={"name", "language", "display_order", "active_status"}) if check_exe: @@ -71,135 +76,132 @@ class FeatureFinder(Document): @frappe.whitelist() -def get_feature_list(vehicle): - features_list = frappe.db.sql(f"""select feature_name from `tabFeature Finder Master` where vehicle='{vehicle}'""",as_list=1) +def get_feature_list(vehicle, language): + features_list = frappe.db.sql( + f"""select feature_name from `tabFeature Finder Master` where vehicle='{vehicle}' and language = '{language}';""", as_list=1) return features_list - + @frappe.whitelist() -def get_list_data(name,val): - specification = frappe.db.sql(f"""select *,'Feature Finder Specification' as doctype from `tabFeature Finder Specification` where parent = '{name}' and post_vin_cutoff_name='{val}'""",as_dict=1) - feature_finder_images = frappe.db.sql(f"""select * from `tabFeature Finder Images` where parent = '{name}' and post_vin_cutoff_name='{val}'""",as_dict=1) - feature_finder_content = frappe.db.sql(f"""select * from `tabFeature Finder Content` where parent = '{name}' and post_vin_cutoff_name='{val}'""",as_dict=1) - return specification,feature_finder_images,feature_finder_content - +def get_list_data(name, val): + specification = frappe.db.sql( + f"""select *,'Feature Finder Specification' as doctype from `tabFeature Finder Specification` where parent = '{name}' and post_vin_cutoff_name='{val}'""", as_dict=1) + feature_finder_images = frappe.db.sql( + f"""select * from `tabFeature Finder Images` where parent = '{name}' and post_vin_cutoff_name='{val}'""", as_dict=1) + feature_finder_content = frappe.db.sql( + f"""select * from `tabFeature Finder Content` where parent = '{name}' and post_vin_cutoff_name='{val}'""", as_dict=1) + return specification, feature_finder_images, feature_finder_content @frappe.whitelist() -def insert_spec_data(doc_name,values): +def insert_spec_data(doc_name, values): try: val = json.loads(values) - if val.get('name')!=None: - doc = frappe.get_doc("Feature Finder Specification",val['name']) + if val.get('name') != None: + doc = frappe.get_doc("Feature Finder Specification", val['name']) doc.specification = val.get('specification') doc.value = val.get('value') doc.active_status = val.get('active_status') doc.feature_type = val.get('feature_type') doc.save() frappe.db.commit() - + else: - res = frappe.get_doc("Feature Finder",doc_name) - res.append("specification",val) + res = frappe.get_doc("Feature Finder", doc_name) + res.append("specification", val) res.save() - - return {"status":"success"} + + return {"status": "success"} except Exception as e: - frappe.log_error("insert_spec_data",str(e)) - return {"status":"failure"} + frappe.log_error("insert_spec_data", str(e)) + return {"status": "failure"} @frappe.whitelist() def delete_spec_data(values): try: val = json.loads(values) - if len(val)>0: + if len(val) > 0: for d in val: - frappe.delete_doc("Feature Finder Specification",d) + frappe.delete_doc("Feature Finder Specification", d) frappe.db.commit() - return {"status":"success"} + return {"status": "success"} except Exception as e: - frappe.log_error("delete_spec_data",str(e)) - - + frappe.log_error("delete_spec_data", str(e)) @frappe.whitelist() -def insert_image_data(doc_name,values): +def insert_image_data(doc_name, values): try: val = json.loads(values) - if val.get('name')!=None: - doc = frappe.get_doc("Feature Finder Images",val['name']) + if val.get('name') != None: + doc = frappe.get_doc("Feature Finder Images", val['name']) doc.image = val.get('image') doc.active_status = val.get('active_status') doc.feature_type = val.get('feature_type') doc.save() frappe.db.commit() - + else: - res = frappe.get_doc("Feature Finder",doc_name) - res.append("feature_finder_images",val) + res = frappe.get_doc("Feature Finder", doc_name) + res.append("feature_finder_images", val) res.save() frappe.db.commit() - - return {"status":"success"} - except Exception as e: - frappe.log_error("insert_image_data",str(e)) - return {"status":"failure"} + return {"status": "success"} + except Exception as e: + frappe.log_error("insert_image_data", str(e)) + return {"status": "failure"} @frappe.whitelist() def delete_image_data(values): try: val = json.loads(values) - if len(val)>0: + if len(val) > 0: for d in val: - frappe.delete_doc("Feature Finder Images",d) + frappe.delete_doc("Feature Finder Images", d) frappe.db.commit() - return {"status":"success"} + return {"status": "success"} except Exception as e: - frappe.log_error("delete_image_data",str(e)) - + frappe.log_error("delete_image_data", str(e)) @frappe.whitelist() -def insert_content_data(doc_name,values): +def insert_content_data(doc_name, values): try: val = json.loads(values) - if val.get('name')!=None: - doc = frappe.get_doc("Feature Finder Content",val['name']) + if val.get('name') != None: + doc = frappe.get_doc("Feature Finder Content", val['name']) doc.content = val.get('content') doc.active_status = val.get('active_status') doc.feature_type = val.get('feature_type') doc.save() frappe.db.commit() - + else: - res = frappe.get_doc("Feature Finder",doc_name) - res.append("feature_finder_content",val) + res = frappe.get_doc("Feature Finder", doc_name) + res.append("feature_finder_content", val) res.save() frappe.db.commit() - - return {"status":"success"} + + return {"status": "success"} except Exception as e: - frappe.log_error("insert_content_data",str(e)) - return {"status":"failure"} - - + frappe.log_error("insert_content_data", str(e)) + return {"status": "failure"} @frappe.whitelist() def delete_content_data(values): try: val = json.loads(values) - if len(val)>0: + if len(val) > 0: for d in val: - frappe.delete_doc("Feature Finder Content",d) + frappe.delete_doc("Feature Finder Content", d) frappe.db.commit() - return {"status":"success"} + return {"status": "success"} except Exception as e: - frappe.log_error("delete_image_data",str(e)) + frappe.log_error("delete_image_data", str(e)) # res.append("specification",{ @@ -208,3 +210,21 @@ def delete_content_data(values): # "active_status":val.get('active_status'), # "feature_type":val.get('feature_type') # }) + + +@frappe.whitelist() +def set_display_order(doctype_name, values): + try: + val = json.loads(values) + if len(val) > 0: + count_val = 0 + for k in val: + count_val += 1 + res = frappe.get_doc(doctype_name, k) + # frappe.msgprint(str(k)+"-"+str(count_val)) + res.display_order = count_val + res.save() + frappe.db.commit() + return {"status": "success"} + except Exception as e: + frappe.log_error("set_display_order", str(e)) diff --git a/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js b/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js index 561d937..ae0caf5 100644 --- a/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js +++ b/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js @@ -2,7 +2,29 @@ // For license information, please see license.txt frappe.ui.form.on('Feature Finder Category Master', { - // refresh: function(frm) { - - // } + validate: function (frm) { + check_field_character(frm.doc.feature_category) + check_field_character(frm.doc.feature_name) + } }); +function check_field_character(field_name) { + if (field_name) { + var alphanum = /^[a-zA-Z]+/; + if (field_name.length > 1) { + if (field_name.length > 50) { + frappe.throw("Feature Finder Category Master: Only 50 characters are allowed") + frappe.validated = false; + } else { + if (alphanum.test(field_name) === true) { + frappe.validated = true; + } else if (field_name) { + frappe.throw(__("Feature Finder Category Master: Enter letter or alpha numeric characters only.")); + frappe.validated = false; + } + } + } else { + frappe.throw("Feature Finder Category Master: Single character not allowed") + frappe.validated = false; + } + } +} \ No newline at end of file diff --git a/smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.json b/smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.json index 06e1740..63a078a 100644 --- a/smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.json +++ b/smart_service/phase_2/doctype/feature_finder_content/feature_finder_content.json @@ -9,7 +9,8 @@ "content", "active_status", "feature_type", - "post_vin_cutoff_name" + "post_vin_cutoff_name", + "display_order" ], "fields": [ { @@ -35,12 +36,18 @@ "fieldtype": "Data", "in_list_view": 1, "label": "Post Vin Cutoff Name" + }, + { + "fieldname": "display_order", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Display Order" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2023-08-04 17:42:23.562696", + "modified": "2023-08-08 10:42:40.213885", "modified_by": "Administrator", "module": "Phase-2", "name": "Feature Finder Content", diff --git a/smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.json b/smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.json index 2dc16e3..9b1ea6d 100644 --- a/smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.json +++ b/smart_service/phase_2/doctype/feature_finder_images/feature_finder_images.json @@ -9,7 +9,8 @@ "image", "active_status", "feature_type", - "post_vin_cutoff_name" + "post_vin_cutoff_name", + "display_order" ], "fields": [ { @@ -35,12 +36,18 @@ "fieldtype": "Data", "in_list_view": 1, "label": "Post Vin Cutoff Name" + }, + { + "fieldname": "display_order", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Display Order" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2023-08-04 17:42:08.111627", + "modified": "2023-08-08 10:43:06.101130", "modified_by": "Administrator", "module": "Phase-2", "name": "Feature Finder Images", diff --git a/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json b/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json index 84e8184..fae596d 100644 --- a/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json +++ b/smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json @@ -51,14 +51,18 @@ { "fieldname": "vehicle", "fieldtype": "Link", + "in_list_view": 1, "label": "Vehicle", - "options": "Vehicle" + "options": "Vehicle", + "reqd": 1 }, { "fieldname": "language", "fieldtype": "Link", + "in_list_view": 1, "label": "Language", - "options": "Custom Languages" + "options": "Custom Languages", + "reqd": 1 }, { "fetch_from": "feature_name.feature_category", @@ -69,7 +73,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-04 17:45:51.699581", + "modified": "2023-08-09 12:10:38.658905", "modified_by": "Administrator", "module": "Phase-2", "name": "Feature Finder Master", diff --git a/smart_service/phase_2/doctype/feature_finder_specification/feature_finder_specification.json b/smart_service/phase_2/doctype/feature_finder_specification/feature_finder_specification.json index 65c1540..2dc14ba 100644 --- a/smart_service/phase_2/doctype/feature_finder_specification/feature_finder_specification.json +++ b/smart_service/phase_2/doctype/feature_finder_specification/feature_finder_specification.json @@ -47,13 +47,14 @@ { "fieldname": "display_order", "fieldtype": "Data", + "in_list_view": 1, "label": "Display Order" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2023-08-07 15:35:30.309157", + "modified": "2023-08-08 10:42:51.401310", "modified_by": "Administrator", "module": "Phase-2", "name": "Feature Finder Specification", diff --git a/smart_service/phase_2/doctype/mst_information_assets/mst_information_assets.py b/smart_service/phase_2/doctype/mst_information_assets/mst_information_assets.py index 0880573..9df19c7 100644 --- a/smart_service/phase_2/doctype/mst_information_assets/mst_information_assets.py +++ b/smart_service/phase_2/doctype/mst_information_assets/mst_information_assets.py @@ -1,8 +1,11 @@ # Copyright (c) 2023, 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 MSTInformationAssets(Document): - pass + def validate(self): + if self.content: + self.content = self.content.strip() + diff --git a/smart_service/phase_2/doctype/publish_test/publish_test.js b/smart_service/phase_2/doctype/publish_test/publish_test.js index b3db8f2..4af73d0 100644 --- a/smart_service/phase_2/doctype/publish_test/publish_test.js +++ b/smart_service/phase_2/doctype/publish_test/publish_test.js @@ -10,25 +10,34 @@ cur_frm.fields_dict['variant_mapping'].get_query = function (doc, cdt, cdn) { } }; }; -var selected_module=0 +var selected_module='' cur_frm.fields_dict['vehicle'].get_query = function (doc, cdt, cdn) { return { query: "smart_service.masters.doctype.vehicle.vehicle.vehicle_filter", }; }; let lang_set_first_time = true; frappe.ui.form.on('Publish Test', { - publish_module:function(frm){ - if(frm.doc.publish_module=='Automotive'){4 - selected_module=1 + // publish_module:function(frm){ + // if(frm.doc.publish_module=='Automotive'){ + // selected_module=1 - } - else{ - selected_module=0 + // } + // else{ + // selected_module=0 - } + // } - }, + // }, onload: function (frm) { + // $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish") + if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module=='Others') { + $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish") + } + if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global"&& frm.doc.publish_module=='Others') { + $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Global Publish") + } + + $(document).on('mouseover', function (events) { $("a:contains(Copy to Clipboard)").css({ 'pointer-events': 'none' }), $("a:contains(Duplicate)").css({ 'pointer-events': 'none' }); @@ -49,7 +58,30 @@ frappe.ui.form.on('Publish Test', { }, refresh: function (frm) { - if(selected_module==1){ + // if (frm.doc.docstatus == 1 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module=='Others') { + // frm.add_custom_button(__('Global Publish'), function () { + // // frappe.call({ + // // method: "tsmcvcms.transactions.doctype.publish_details.publish_details.generate_global_publish", + // // args: { + // // name: frm.doc.name + // // }, + // // callback: function (r) { + // // if (r.message.status == "success") { + // // window.location.href = r.message.url + "/app/publish-details" + "/" + r.message.message + // // } + // // } + // // }) + // }).addClass("btn-primary"); + // } + + // $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish") + if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global") { + $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish") + } + if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global") { + $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Global Publish") + } + if(frm.doc.publish_module=='Automotive'){ cur_frm.set_df_property('system_mapping', "read_only", 1); cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-add-row').hide(); cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-upload').hide(); @@ -211,6 +243,8 @@ frappe.ui.form.on('Publish Test', { frm.set_read_only(); frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1); } + + if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') { frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () { @@ -289,10 +323,77 @@ frappe.ui.form.on('Publish Test', { } } + + if (frm.doc.docstatus == 1 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module=='Others') { + + + frm.add_custom_button(__('Global Publish'), function () { + frappe.call({ + method: "smart_service.phase_2.doctype.publish_test.publish_test.generate_global_publish", + args: { + name: frm.doc.name + }, + callback: function (r) { + debugger + if (r.message.status == "success") { + frm.set_df_property('repair_checksheet_publish','hidden',0) + frm.refresh_field('repair_checksheet_publish') + window.location.href = r.message.url + "/app/publish-test" + "/" + r.message.message + } + } + }) + }).addClass("btn-primary"); + } + + // if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher') && frm.doc.publish_module=='Others') { + + // frm.add_custom_button(__('Global Publish'), function () { + // frappe.confirm('Are you sure you want to Publish?', + // () => { + // // action to perform if Yes is selected + // if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type) { + // frappe.call({ + // method: 'smart_service.phase_2.doctype.publish_test.publish_test.repair_checksheet_publish', + // args: { + // vehicle: frm.doc.vehicle, + // language: frm.doc.language, + // publish_type: frm.doc.publish_type, + // release_description:frm.doc.release_description, + // vehicle_id:frm.doc.vehicle_id, + // variant:frm.doc.variant_mapping + + // }, + // callback: (r) => { + + // if(r.message[0]==1){ + // frappe.msgprint({ + // title: __('Notification'), + // message: __('Successfully Published: ' + r.message[1]), + // primary_action: { + // action(values) { + // frm.save('Update'); + // } + // } + // }); + + // } + + // }, + // }) + // } + // }, () => { + // // action to perform if No is selected + // }); + // }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' }); + // } else if (frm.doc.publish_status == 'Published') { + // frm.set_read_only(); + // // frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1); + // } + }, validate: function (frm) { - if(selected_module==1){ + if(frm.doc.publish_module=='Automotive'){ let regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/; if (regex.test(frm.doc.release_description) === true) { frm.doc.release_description = ''; @@ -310,7 +411,14 @@ frappe.ui.form.on('Publish Test', { } } - + //check for atleast one data to publish + if(frm.doc.publish_module=='Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish')){ + debugger + + frappe.throw('No Data Found To Publish') + + + } }, variant_mapping: function (frm) { frappe.db.get_value('Variant Mapping', { name: frm.doc.variant_mapping }, ['fuel', 'transmission', 'drive'], (r) => { @@ -350,7 +458,7 @@ frappe.ui.form.on('Publish Test', { }, km_active_status: function (frm) { - if (frm.doc.variant_mapping && selected_module==1) { + if (frm.doc.variant_mapping && frm.doc.publish_module=='Automotive') { frappe.show_alert({ message: __('Please wait until variant mapping details are loaded.'), indicator: 'yellow' @@ -358,7 +466,7 @@ frappe.ui.form.on('Publish Test', { } if (frm.doc.km_active_status === "" || frm.doc.km_active_status === null) { return; } let filter = frm.doc.variant_mapping + "-" + frm.doc.language + "-SM"; - if (frm.doc.variant_mapping_status == "Active" && frm.doc.km_active_status == "Active" && selected_module==1) { + if (frm.doc.variant_mapping_status == "Active" && frm.doc.km_active_status == "Active" && frm.doc.publish_module=='Automotive') { frappe.call({ "method": "smart_service.transactions.doctype.publish.publish.get_system", "args": { @@ -431,7 +539,7 @@ frappe.ui.form.on('Publish Test', { }) } else { - if (frm.doc.variant_mapping_status && selected_module==1) { + if (frm.doc.variant_mapping_status && frm.doc.publish_module=='Automotive') { frappe.msgprint({ title: __('Notification'), indicator: 'red', @@ -442,7 +550,7 @@ frappe.ui.form.on('Publish Test', { }, add_variant_mapping_to_publish: function (frm) { let dulicate = false; - if (frm.doc.publish_documents && selected_module==1) { + if (frm.doc.publish_documents && frm.doc.publish_module=='Automotive') { frm.doc.publish_documents.forEach(publishrow => { if (frm.doc.variant_mapping == publishrow.variant_mapping && publishrow.systems === undefined && publishrow.sub_systems === undefined && publishrow.procedure === undefined) { dulicate = true; @@ -450,7 +558,7 @@ frappe.ui.form.on('Publish Test', { }); frappe.msgprint("Variant Mapping already added"); } - if (dulicate === false && selected_module==1) { + if (dulicate === false && frm.doc.publish_module=='Automotive') { let child = cur_frm.add_child("publish_documents"); child.variant_mapping = frm.doc.variant_mapping; child.item_category = "Variant Mapping"; @@ -482,13 +590,30 @@ frappe.ui.form.on('Publish Test', { } }); - if (frm.doc.vehicle === undefined || frm.doc.vehicle === null && selected_module==1) { return; } + if (frm.doc.vehicle === undefined || frm.doc.vehicle === null && frm.doc.publish_module=='Automotive') { return; } $("[data-fieldname=variant_mapping]").focus(); if (frm.doc.vehicle) { frm.set_df_property('vehicle', 'read_only', 1); } + //other modules-Repair Checksheet + if(frm.doc.publish_module=='Others'){ + if (frm.doc.repair_checksheet_publish && frm.doc.repair_checksheet_publish.length > 0) { + content_flag = 1 + cur_frm.clear_table("repair_checksheet_publish"); + cur_frm.refresh_fields('repair_checksheet_publish'); + + } + add_to_publish(frm) + + + + } + }, language: function (frm) { + if(frm.doc.publish_module=='Others'){ + add_to_publish(frm) + } if (!lang_set_first_time) { frappe.confirm('This will clear all the data, are you sure you want to proceed?', () => { @@ -502,6 +627,7 @@ frappe.ui.form.on('Publish Test', { }, () => { // action to perform if No is selected }); + } else { lang_set_first_time = false; } }, auto_version_update: function (frm) { @@ -536,3 +662,35 @@ frappe.ui.form.on('Publish_Temp Doc', { frm.fields_dict.system_mapping.grid.wrapper.find('.grid-insert-row').hide(); }, }) + +function add_to_publish(frm){ + frappe.call({ + method: "smart_service.phase_2.doctype.publish_test.publish_test.get_service_repair", + args: { vehicle: frm.doc.vehicle, language_label: frm.doc.language, publish_type: frm.doc.publish_type }, + callback: function (r) { + if (r.message) { + cur_frm.set_df_property('repair_checksheet_publish','hidden',0) + var records = r.message + debugger + records.map(v => { + var childTable = cur_frm.add_child("repair_checksheet_publish"); + childTable.parent_name = v['name']; + childTable.vehicle = v['vehicle']; + childTable.language = v['language']; + childTable.lang_myid = v['lang_myid']; + childTable.display_order = v['display_order']; + childTable.check_list_name = v['check_list_name']; + + childTable.active_status = v['active_status']; + childTable.my_id = v['my_id']; + childTable.lang_myid = v['lang_myid']; + }) + + cur_frm.refresh_fields("repair_checksheet_publish"); + } + } + }) + + + +} \ No newline at end of file diff --git a/smart_service/phase_2/doctype/publish_test/publish_test.json b/smart_service/phase_2/doctype/publish_test/publish_test.json index ec98d10..482f365 100644 --- a/smart_service/phase_2/doctype/publish_test/publish_test.json +++ b/smart_service/phase_2/doctype/publish_test/publish_test.json @@ -43,6 +43,7 @@ "variant_mapping_assets", "section_break_5", "publish_documents", + "repair_checksheet_publish", "amended_from" ], "fields": [ @@ -303,7 +304,15 @@ "fieldname": "publish_module", "fieldtype": "Select", "label": "Publish Module", - "options": "Automotive\nOthers" + "options": "\nAutomotive\nOthers", + "reqd": 1 + }, + { + "fieldname": "repair_checksheet_publish", + "fieldtype": "Table", + "hidden": 1, + "label": "Repair Checksheet Publish", + "options": "Repair Service Publish Data" }, { "fieldname": "amended_from", @@ -318,7 +327,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2023-08-07 17:55:10.923830", + "modified": "2023-08-08 10:29:25.863957", "modified_by": "Administrator", "module": "Phase-2", "name": "Publish Test", diff --git a/smart_service/phase_2/doctype/publish_test/publish_test.py b/smart_service/phase_2/doctype/publish_test/publish_test.py index 0cc2c3f..98e7332 100644 --- a/smart_service/phase_2/doctype/publish_test/publish_test.py +++ b/smart_service/phase_2/doctype/publish_test/publish_test.py @@ -4,14 +4,28 @@ import sys from html import unescape import frappe +import os from frappe.model.document import Document import json +from datetime import date +from frappe.utils import cstr +from frappe.utils import logger current_db_name = frappe.conf.get("db_name") sys.tracebacklimit = 0 +site_name = cstr(frappe.local.site) +base_url = os.path.expanduser( + "~") + "/frappe-bench/sites/" + site_name + "/public"+"/json_files"+"/Other_Module" +frappe.utils.logger.set_log_level("DEBUG") + + +success_reponse={"status":1,"data":"","message":""} +failure_reponse={"status":0,"data":"","error":""} class PublishTest(Document): def validate(self): + self.published_date = str(date.today()) + self.published_by = frappe.session.user # Selected variant and kilometer mapping details list variant = [] for vm in self.get('publish_documents'): @@ -32,7 +46,16 @@ class PublishTest(Document): for km_mapping in km_mapping_record: self.kilometer_mapping_details = self.kilometer_mapping_details + \ str(km_mapping.name) + '\n' + def on_submit(self): + if self.docstatus==1 and self.publish_status == 'To Publish' and self.publish_module=='Others' and self.publish_type=='Internal': + repair_checksheet_publish(self.vehicle,self.vehicle_id,self.language,self.publish_type,self.release_description,self.variant) + update_publish_status=frappe.db.sql("""update `tabPublish Test` set publish_status='Published' where name='{0}'""".format(self.name)) + if self.docstatus==1 and self.publish_module=='Others' and self.publish_type=='Global': + update_published_docs(self) + repair_checksheet_publish(self.vehicle,self.vehicle_id,self.language,self.publish_type,self.release_description,self.variant) + + def onload1(self): current_db_name = frappe.conf.get("db_name") # To validate updated procedure status @@ -218,8 +241,23 @@ def global_publish(doc): doc.global_publish = publish_record.name doc.save() frappe.msgprint('Global Publish Created for ' + publish_record.name) - - +@frappe.whitelist() +def generate_global_publish(name): + try: + res = frappe.get_doc("Publish Test", name) + ret = frappe.get_doc({ + "doctype": "Publish Test", + "vehicle": res.vehicle, + "publish_type": "Global", + "language":res.language, + "release_description":res.release_description, + "publish_module":res.publish_module, + "repair_checksheet_publish":res.repair_checksheet_publish + }) + ret.insert() + return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()} + except Exception as e: + frappe.throw(str(e)) @frappe.whitelist() def old_publish(vehicle, language): current_db_name = frappe.conf.get("db_name") @@ -386,6 +424,103 @@ def update_procedure_value(name, file_path): @ frappe.whitelist() def get_service_repair(vehicle, language_label, publish_type): data = frappe.db.sql(f''' - select * from `tabRepair Service Master Mapping` where vehicle = '{vehicle}' and language_label = '{language_label}' and is_published = 0; + select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0; ''', as_dict=1) return data + + +def repair_checksheet_publish(vehicle,vehicle_id,language,publish_type,release_description,variant): + try: + logger_file=f'{vehicle}-{language}-{publish_type}' + logger = frappe.logger(logger_file, allow_site=True, file_count=100) + logger.info(f'Repair Checksheet Started-{vehicle}-{language}-{publish_type}') + + folder_url=base_url+"/"+vehicle.replace(' ', '-') + "/"+language + logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}') + + '''Publish Ready Flags''' + publish_repair_checksheet=0 + + '''Create Folder For Publish''' + create_publish_folders(folder_url) + file_path = folder_url + "/" + publish_type + "/" + vehicle.replace(' ', + '-') +'.json' + try: + '''Append Published Data to Json''' + logger.info(f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}') + vehicle_data = { + 'vehicle': vehicle, + 'vehicle_myid': vehicle_id, + 'publish_type': publish_type, + 'publish_description': release_description, + 'publish_language': language, + 'data':'' + } + repair_checksheet=repair_checksheet_data(vehicle,language,publish_type) + if repair_checksheet['status']==1: + publish_repair_checksheet=1 + if publish_repair_checksheet==1: + """ Save publish file """ + vehicle_data['data']={'repair_checksheet':repair_checksheet['data']} + with open(file_path, 'w') as outfile: + outfile.write(json.dumps(vehicle_data,indent=4,default=str)) + else: + logger.error(f'{vehicle}-{language}-{publish_type} error in json creation') + + return 1,file_path + except Exception as e: + logger.info(f'{vehicle}-{language}-{publish_type} error in json creation'+str(e)) + return e + + + except Exception as e: + return e +def update_published_docs(self): + try: + if self.repair_checksheet_publish: + try: + for d in self.repair_checksheet_publish: + frappe.db.sql( + """UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(d.parent_name)) + frappe.db.commit() + except Exception as e: + frappe.throw(str(e)) + + + except: + frappe.throw(str(e)) + +def create_publish_folders(folder_url): + try: + + if not os.path.isdir(folder_url + "/" + "Global"): + os.makedirs(folder_url + "/" + "Global") + + if not os.path.isdir(folder_url + "/" + "Internal"): + os.makedirs(folder_url + "/" + "Internal") + return True + + except Exception as e: + frappe.throw(str(e)) + return False + +def repair_checksheet_data(vehicle=None,language=None,publish_type=None): + try: + logger_file=f'{vehicle}-{language}-{publish_type}' + logger = frappe.logger(logger_file, allow_site=True, file_count=100) + logger.info(f"start of fetching repair checksheet data-{vehicle}-{language}") + repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,check_list_name,active_status,display_order,my_id from + `tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}' and active_status='Active'""", as_dict=1) + for d in repair_service_details: + d['complaint'] = frappe.db.sql(f""" select complaint,remedial_action_ok,remedial_action_not_ok,idx as display_order,active_status from `tabRepair Service Child` + where parent = '{d['name']}' order by display_order ;""", as_dict=1) + + logger.info(f"end of fetching repair checksheet data {vehicle}-{language}") + success_reponse['data']=repair_service_details + success_reponse['message']=f'Repair Checksheet Fecthed Succesfully for {vehicle}-{language}' + return success_reponse + + except Exception as e: + failure_reponse['error']=f"{vehicle}-{language} has following error-" +str(e) + logger.error('error in repair checksheet'+str(e)) + return failure_reponse \ No newline at end of file diff --git a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js index 4d1c043..0376e69 100644 --- a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js +++ b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js @@ -3,90 +3,53 @@ var original_display_order = 0; var vehicle_count = 0; -frappe.require('assets/smart_service/js/utils.js', () => { }) +// frappe.require('assets/smart_service/js/utils.js', () => { }) frappe.ui.form.on('Repair Service Mapping', { onload: function (frm) { // Set Display Order - if (frm.is_new()) { - frm.set_df_property('display_order', 'read_only', 1); - } else { - frm.set_df_property('display_order', 'read_only', 0); - } - frappe.db.count('Repair Service Mapping', { - filters: { - "vehicle": cur_frm.doc.vehicle, - "language": frm.doc.language - } - }).then(count => { - vehicle_count = count + 1; - if (frm.is_new()) { - frm.set_value("display_order", vehicle_count); - } else { - original_display_order = frm.doc.display_order; - } - }); + set_display_order(frm) }, refresh: function (frm) { // Set Display Order - if (frm.is_new()) { - frm.set_df_property('display_order', 'read_only', 1); - } else { - frm.set_df_property('display_order', 'read_only', 0); - } - - frappe.db.count('Repair Service Mapping', { - filters: { - "vehicle": cur_frm.doc.vehicle, - "language": frm.doc.language - } - }).then(count => { - vehicle_count = count + 1; - if (frm.is_new()) { - frm.set_value("display_order", vehicle_count); - } else { - original_display_order = frm.doc.display_order; - } - }); + set_display_order(frm) }, validate: function (frm) { //For Display Order - cur_frm.refresh_fields("display_order") - // console.log(module_name_count,"----",original_display_order) + // cur_frm.refresh_fields("display_order") - // if (frm.doc.display_order && frm.doc.name && !frm.is_new()) { - // //***check if there is same display_order - // frappe.db.get_list('Repair Service Mapping', { - // fields: ['display_order', 'name'], - // filters: { - // display_order: frm.doc.display_order, - // name: ["!=", frm.doc.name], - // vehicle: frm.doc.vehicle, - // language:frm.doc.language - // } - // }).then(records => { - // if (records.length) { - // frappe.db.set_value('Repair Service Mapping', records[0].name,{ - // display_order: original_display_order - // }).then(r => { - // // console.log(records) - // let doc = r.message; - // frappe.show_alert({ - // message: __('Swapped display order with: ' + records[0].name), - // indicator: 'green' - // }, 5); - // }); - // } else { - // if (frm.doc.display_order >= vehicle_count) { - // let display_name_count = vehicle_count - 1; - // msgprint('There are only ' + display_name_count +" "+frm.doc.doctype); - // frappe.validated = false; - // } - // } - // }); - // } - display_order_validation(frm, vehicle_count, original_display_order, frm.doc.vehicle) + if (frm.doc.display_order && frm.doc.name && !frm.is_new()) { + //***check if there is same display_order + frappe.db.get_list('Repair Service Mapping', { + fields: ['display_order', 'name'], + filters: { + display_order: frm.doc.display_order, + name: ["!=", frm.doc.name], + vehicle: frm.doc.vehicle, + language: frm.doc.language, + } + }).then(records => { + if (records.length) { + frappe.db.set_value('Repair Service Mapping', records[0].name, { + display_order: original_display_order + }).then(r => { + let doc = r.message; + frappe.show_alert({ + message: __('Swapped display order with: ' + records[0].name), + indicator: 'green' + }, 5); + }); + } else { + if (frm.doc.display_order >= vehicle_count) { + let display_vehicle_count = vehicle_count - 1; + msgprint('There are only ' + display_vehicle_count + " " + frm.doc.doctype); + frappe.validated = false; + } + } + }); + } + }, after_save: function (frm) { @@ -95,7 +58,26 @@ frappe.ui.form.on('Repair Service Mapping', { }); - +function set_display_order(frm){ + if (frm.is_new()) { + frm.set_df_property('display_order', 'read_only', 1); + } else { + frm.set_df_property('display_order', 'read_only', 0); + } + frappe.db.count('Repair Service Mapping', { + filters: { + "vehicle": cur_frm.doc.vehicle, + "language": frm.doc.language + } + }).then(count => { + vehicle_count = count + 1; + if (frm.is_new()) { + frm.set_value("display_order", vehicle_count); + } else { + original_display_order = frm.doc.display_order; + } + }); +} diff --git a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json index d9d4459..5624840 100644 --- a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json +++ b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.json @@ -51,7 +51,9 @@ "in_list_view": 1, "in_standard_filter": 1, "label": "Language", - "options": "Custom Languages" + "options": "Custom Languages", + "reqd": 1, + "set_only_once": 1 }, { "fieldname": "column_break_sjvew", @@ -64,6 +66,7 @@ "in_standard_filter": 1, "label": "Check List Name", "options": "Repair Service Master", + "reqd": 1, "set_only_once": 1 }, { @@ -117,12 +120,13 @@ "fetch_from": "vehicle.myid", "fieldname": "vehicle_id", "fieldtype": "Int", + "hidden": 1, "label": "Vehicle Id" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-07 16:28:34.938285", + "modified": "2023-08-09 14:28:17.586504", "modified_by": "Administrator", "module": "Phase-2", "name": "Repair Service Mapping", diff --git a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.py b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.py index 3b57fbe..a9d5fe6 100644 --- a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.py +++ b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.py @@ -17,6 +17,9 @@ class RepairServiceMapping(Document): if self.vehicle: self.vehicle = self.vehicle.strip() + + if self.translated_check_list_name: + self.translated_check_list_name=self.translated_check_list_name.strip() try: @@ -40,14 +43,6 @@ class RepairServiceMapping(Document): except Exception as e: raise e - # def autoname(self): - # if self.is_new(): - # count = frappe.db.sql('''select max(my_id) as max_count from `tabRepair Service Mapping`;''') - # if count[0][0] is not None: - # self.my_id = count[0][0] + 1 - # else: - # self.my_id = 1 - def on_update(self): if self.language == "en": try: diff --git a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js index d03be5c..4b3ecfe 100644 --- a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js +++ b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js @@ -48,8 +48,27 @@ frappe.ui.form.on('Repair Service Master', { validate: function (frm){ //For Display Order cur_frm.refresh_fields("display_order") - // console.log(module_name_count,"----",original_display_order) - // display_order_validation(frm, repair_service_count, original_display_order,frm.doc.vehicle) + if(frm.doc.repairservicename) { + let alphanum = /^[a-zA-Z]+/; + + if (frm.doc.repairservicename.length > 1) { + if (frm.doc.repairservicename.length > 140) { + frappe.throw(__("Repair/ServiceName: Only 140 characters are allowed")) + frappe.validate=false; + + } else { + if (alphanum.test(frm.doc.repairservicename) === true) { + frappe.validated = false; + } else if (frm.doc.repairservicename) { + frappe.throw(__("Repair/ServiceName: Enter letter or alpha numeric characters only.")); + frappe.validate=false; + } + } + } else { + frappe.throw(__("Repair/ServiceName: Single character not allowed")) + frappe.validate=true; + } + } } }); diff --git a/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json b/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json index 946d8ca..6d76437 100644 --- a/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json +++ b/smart_service/phase_2/doctype/repair_service_master_mapping/repair_service_master_mapping.json @@ -20,7 +20,8 @@ "display_order", "section_break_ecyyc", "description", - "my_id" + "my_id", + "lang_myid" ], "fields": [ { @@ -72,7 +73,8 @@ "default": "0", "fieldname": "published", "fieldtype": "Check", - "label": "Published" + "label": "Published", + "read_only": 1 }, { "fieldname": "section_break_ci53z", @@ -97,11 +99,16 @@ { "fieldname": "column_break_azh0p", "fieldtype": "Column Break" + }, + { + "fieldname": "lang_myid", + "fieldtype": "Int", + "label": "Lang MyId" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-07 16:27:20.861818", + "modified": "2023-08-08 12:11:28.469998", "modified_by": "Administrator", "module": "Phase-2", "name": "Repair Service Master Mapping", diff --git a/smart_service/phase_2/doctype/repair_service_publish_data/repair_service_publish_data.json b/smart_service/phase_2/doctype/repair_service_publish_data/repair_service_publish_data.json index f98b1b1..497522d 100644 --- a/smart_service/phase_2/doctype/repair_service_publish_data/repair_service_publish_data.json +++ b/smart_service/phase_2/doctype/repair_service_publish_data/repair_service_publish_data.json @@ -12,8 +12,8 @@ "check_list_name", "active_status", "display_order", - "description", - "my_id" + "my_id", + "lang_myid" ], "fields": [ { @@ -25,24 +25,28 @@ { "fieldname": "parent_name", "fieldtype": "Link", + "in_list_view": 1, "label": "Parent Name", - "options": "Repair Service Master Mapping" + "options": "Repair Service Mapping" }, { "fieldname": "language", "fieldtype": "Link", + "in_list_view": 1, "label": "Language", "options": "Custom Languages" }, { "fieldname": "check_list_name", "fieldtype": "Link", + "in_list_view": 1, "label": "Check List Name", "options": "Repair Service Master" }, { "fieldname": "active_status", "fieldtype": "Select", + "in_list_view": 1, "label": "Active Status", "options": "Active\nInactive" }, @@ -51,22 +55,21 @@ "fieldtype": "Int", "label": "Display Order" }, - { - "fieldname": "description", - "fieldtype": "Table", - "label": "Description", - "options": "Repair Service Child" - }, { "fieldname": "my_id", "fieldtype": "Int", "label": "My Id" + }, + { + "fieldname": "lang_myid", + "fieldtype": "Int", + "label": "Lang MyId" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2023-08-07 18:47:20.666082", + "modified": "2023-08-09 12:35:45.411733", "modified_by": "Administrator", "module": "Phase-2", "name": "Repair Service Publish Data", diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js index 4243f1d..72eb6b6 100644 --- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js +++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js @@ -1,53 +1,20 @@ // Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors // For license information, please see license.txt var original_display_order = 0; -var vehicle_count=0; -// var counter = 0; -// frappe.require('assets/smart_service/js/utils.js', () => {}) +var vehicle_count = 0; frappe.ui.form.on('Special Tool Information', { onload: function (frm) { // Set Display Order - if (frm.is_new()) { - frm.set_df_property('display_order', 'read_only', 1); - } else{ - frm.set_df_property('display_order', 'read_only', 0); - } - frappe.db.count('Special Tool Information') - .then(count => { - vehicle_count = count + 1; - if (frm.is_new()) { - frm.set_value("display_order", vehicle_count); - } else { - original_display_order = frm.doc.display_order; - } - }); + set_display_order(frm) }, refresh: function (frm) { // Set Display Order - if (frm.is_new()) { - frm.set_df_property('display_order', 'read_only', 1); - } else { - frm.set_df_property('display_order', 'read_only', 0); - } - - frappe.db.count('Special Tool Information') - .then(count => { - vehicle_count = count + 1; - if (frm.is_new()) { - frm.set_value("display_order", vehicle_count); - } else { - original_display_order = frm.doc.display_order; - } - }); + set_display_order(frm) }, - // after_save:function(frm){ - // cur_frm.refresh_fields("display_order") - // }, - validate:function(frm){ //For Display Order cur_frm.refresh_fields("display_order") @@ -89,3 +56,26 @@ frappe.ui.form.on('Special Tool Information', { }); +function set_display_order(frm){ + if (frm.is_new()) { + frm.set_df_property('display_order', 'read_only', 1); + } else { + frm.set_df_property('display_order', 'read_only', 0); + } + + frappe.db.count('Special Tool Information',{ + filters:{ + "vehicle":frm.doc.vehicle, + } + }) + .then(count => { + vehicle_count = count + 1; + if (frm.is_new()) { + frm.set_value("display_order", vehicle_count); + } else { + original_display_order = frm.doc.display_order; + } + }); + +} + diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json index ec1d921..acbc060 100644 --- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json +++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json @@ -9,6 +9,8 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ + "published", + "column_break_cyo0a", "vehicle", "category", "sub_category", @@ -60,11 +62,21 @@ "fieldtype": "Table", "label": "Tool Usage Content", "options": "MST Information Assets" + }, + { + "default": "0", + "fieldname": "published", + "fieldtype": "Check", + "label": "Published" + }, + { + "fieldname": "column_break_cyo0a", + "fieldtype": "Section Break" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-07 10:38:16.791578", + "modified": "2023-08-08 12:12:55.927631", "modified_by": "Administrator", "module": "Phase-2", "name": "Special Tool Information", diff --git a/smart_service/phase_2/doctype/training_information/training_information.js b/smart_service/phase_2/doctype/training_information/training_information.js index e932fe7..40f3309 100644 --- a/smart_service/phase_2/doctype/training_information/training_information.js +++ b/smart_service/phase_2/doctype/training_information/training_information.js @@ -26,5 +26,27 @@ frappe.ui.form.on('Training Information', { } }); }, - + validate:function(frm){ + if(frm.doc.topic) { + let alphanum = /^[a-zA-Z]+/; + + if (frm.doc.topic.length > 1) { + if (frm.doc.topic.length > 140) { + frappe.throw(__("Topic: Only 140 characters are allowed")) + frappe.validate=false; + + } else { + if (alphanum.test(frm.doc.topic) === true) { + frappe.validated = false; + } else if (frm.doc.topic) { + frappe.throw(__("Topic: Enter letter or alpha numeric characters only.")); + frappe.validate=false; + } + } + } else { + frappe.throw(__("Topic: Single character not allowed")) + frappe.validate=true; + } + } + }, }); diff --git a/smart_service/phase_2/doctype/training_information/training_information.json b/smart_service/phase_2/doctype/training_information/training_information.json index 617d33b..7e27572 100644 --- a/smart_service/phase_2/doctype/training_information/training_information.json +++ b/smart_service/phase_2/doctype/training_information/training_information.json @@ -7,6 +7,8 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ + "published", + "section_break_jqjts", "vehicle", "category", "topic", @@ -33,6 +35,7 @@ "options": "Training Information Master" }, { + "fetch_from": "category.topic", "fieldname": "topic", "fieldtype": "Data", "label": "Topic" @@ -79,11 +82,21 @@ "fieldname": "display_order", "fieldtype": "Int", "label": "Display Order" + }, + { + "default": "0", + "fieldname": "published", + "fieldtype": "Check", + "label": "Published" + }, + { + "fieldname": "section_break_jqjts", + "fieldtype": "Section Break" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-07 10:25:28.869989", + "modified": "2023-08-08 18:17:00.667481", "modified_by": "Administrator", "module": "Phase-2", "name": "Training Information", diff --git a/smart_service/phase_2/doctype/training_information/training_information.py b/smart_service/phase_2/doctype/training_information/training_information.py index 5a8148d..f9866b2 100644 --- a/smart_service/phase_2/doctype/training_information/training_information.py +++ b/smart_service/phase_2/doctype/training_information/training_information.py @@ -5,10 +5,14 @@ import frappe from frappe.model.document import Document class TrainingInformation(Document): - def validate(self): + def autoname(self): if self.is_new(): count = frappe.db.sql('''select max(my_id) as max_count from `tabTraining Information`;''') if count[0][0] is not None: self.my_id = count[0][0] + 1 else: self.my_id = 1 + + def validate(self): + if self.topic: + self.topic=self.topic.strip() diff --git a/smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.py b/smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.py index 3b33941..fe2e9bb 100644 --- a/smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.py +++ b/smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.py @@ -5,4 +5,6 @@ from frappe.model.document import Document class TrainingInformationContentReference(Document): - pass + def validate(self): + if self.content: + self.content=self.content.strip() diff --git a/smart_service/phase_2/doctype/training_information_master/training_information_master.js b/smart_service/phase_2/doctype/training_information_master/training_information_master.js index ffff8c1..c829949 100644 --- a/smart_service/phase_2/doctype/training_information_master/training_information_master.js +++ b/smart_service/phase_2/doctype/training_information_master/training_information_master.js @@ -2,35 +2,32 @@ // For license information, please see license.txt frappe.ui.form.on('Training Information Master', { - // refresh: function(frm) { + // refresh: function(frm) { - // } + // } validate: function (frm) { check_field_character(frm.doc.category) check_field_character(frm.doc.topic) - } + } }); function check_field_character(field_name) { if (field_name) { var alphanum = /^[a-zA-Z]+/; - if (field_name.length > 1) { if (field_name.length > 50) { - frappe.msgprint("Training Information Master: Only 50 characters are allowed") + frappe.throw("Training Information Master: Only 50 characters are allowed") frappe.validated = false; } else { if (alphanum.test(field_name) === true) { frappe.validated = true; } else if (field_name) { - - frappe.msgprint(__("Training Information Master: Enter letter or alpha numeric characters only.")); + frappe.throw(__("Training Information Master: Enter letter or alpha numeric characters only.")); frappe.validated = false; } } } else { - frappe.msgprint("Training Information Master: Single character not allowed") + frappe.throw("Training Information Master: Single character not allowed") frappe.validated = false; } } - } diff --git a/smart_service/phase_2/doctype/training_information_master/training_information_master.py b/smart_service/phase_2/doctype/training_information_master/training_information_master.py index 2afd374..e1f3879 100644 --- a/smart_service/phase_2/doctype/training_information_master/training_information_master.py +++ b/smart_service/phase_2/doctype/training_information_master/training_information_master.py @@ -1,21 +1,22 @@ # Copyright (c) 2023, 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 TrainingInformationMaster(Document): - def validate(self): - if self.category: - self.category = self.category.strip() - if self.topic: - self.topic = self.topic.strip() - - if self.is_new(): - count = frappe.db.sql('''select max(my_id) as max_count from `tabTraining Informations`;''') - if count[0][0] is not None: - self.my_id = count[0][0] + 1 - else: - self.my_id = 1 +class TrainingInformationMaster(Document): + def validate(self): + if self.category: + self.category = self.category.strip() + if self.topic: + self.topic = self.topic.strip() + + def autoname(self): + if self.is_new(): + count = frappe.db.sql('''select max(my_id) as max_count from `tabTraining Informations`;''') + if count[0][0] is not None: + self.my_id = count[0][0] + 1 + else: + self.my_id = 1 diff --git a/smart_service/public/js/common_fun.js b/smart_service/public/js/common_fun.js index f570023..6eaca8a 100644 --- a/smart_service/public/js/common_fun.js +++ b/smart_service/public/js/common_fun.js @@ -1,4 +1,6 @@ var row; +var row1; +var row2; function dragstartFunction(evt){ row = evt.target; } @@ -12,12 +14,12 @@ function dragovertFunction(evt){ var count = 1 var unchecked_value = 0 children.map(h => { - console.log($(h),"------------------h----------") - console.log($(h).find('#count'),"---------$(h).find('#count')------") - console.log($(h).find('#count').val(),"---------$(h).find('#count').val(count)------") var html = ''+count+'' - $(h).find('#count').html(html) - $(h).find('.spec_custom_save').css("display","inline-block") + $(h).find('#spec_count').html(html) + $( document ).ready(function() { + $('.specification_bl').find('.spec_custom_save').css("display","inline-block") + }) + count +=1 }) //end @@ -27,4 +29,67 @@ function dragovertFunction(evt){ else{ e.target.parentNode.before(row); } +} + + +function dragstartFunction_1(evt){ + row1= evt.target; +} + +function dragovertFunction_1(evt){ + var global_name = 1 + var e = evt; + e.preventDefault(); + let children= Array.from(e.target.parentNode.parentNode.children); + //change count value + var count = 1 + var unchecked_value = 0 + children.map(h => { + var html = ''+count+'' + $(h).find('#image_count').html(html) + $( document ).ready(function() { + $('.feature_imgbl').find('.image_custom_save').css("display","inline-block") + }) + + count +=1 + }) + //end + if(children.indexOf(e.target.parentNode)>children.indexOf(row1)){ + e.target.parentNode.after(row1); + } + else{ + e.target.parentNode.before(row1); + } +} + + + +function dragstartFunction_2(evt){ + row2 = evt.target; +} + +function dragovertFunction_2(evt){ + var global_name = 1 + var e = evt; + e.preventDefault(); + let children= Array.from(e.target.parentNode.parentNode.children); + //change count value + var count = 1 + var unchecked_value = 0 + children.map(h => { + var html = ''+count+'' + $(h).find('#cont_count').html(html) + $( document ).ready(function() { + $('.feature_contbl').find('.content_custom_save').css("display","inline-block") + }) + + count +=1 + }) + //end + if(children.indexOf(e.target.parentNode)>children.indexOf(row2)){ + e.target.parentNode.after(row2); + } + else{ + e.target.parentNode.before(row2); + } } \ No newline at end of file diff --git a/smart_service/transactions/doctype/publish/publish.js b/smart_service/transactions/doctype/publish/publish.js index 7309b87..46267af 100644 --- a/smart_service/transactions/doctype/publish/publish.js +++ b/smart_service/transactions/doctype/publish/publish.js @@ -434,7 +434,7 @@ frappe.ui.form.on('Publish', { }, add_variant_mapping_to_publish: function (frm) { let dulicate = false; - if (frm.doc.publish_documents && selected_module==1) { + if (frm.doc.publish_documents) { frm.doc.publish_documents.forEach(publishrow => { if (frm.doc.variant_mapping == publishrow.variant_mapping && publishrow.systems === undefined && publishrow.sub_systems === undefined && publishrow.procedure === undefined) { dulicate = true; @@ -481,7 +481,7 @@ frappe.ui.form.on('Publish', { } }, language: function (frm) { - if (!lang_set_first_time && selected_module==1) { + if (!lang_set_first_time) { frappe.confirm('This will clear all the data, are you sure you want to proceed?', () => { // action to perform if Yes is selected @@ -497,7 +497,7 @@ frappe.ui.form.on('Publish', { } else { lang_set_first_time = false; } }, auto_version_update: function (frm) { - if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type && selected_module==1) { + if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type) { frappe.call({ method: 'smart_service.transactions.doctype.publish.publish.cal_ver', args: {