Browse Source

Merge branch 'version2' of http://65.1.227.215:3000/Administrator/smart_service into version2

version2
venkata akhil 1 year ago
parent
commit
e4d104142f
  1. 2
      smart_service/apis/v2/master.py
  2. 10
      smart_service/masters/doctype/role_master/role_master.json
  3. 115
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  4. 11
      smart_service/phase_2/doctype/feature_finder/feature_finder.json
  5. 7
      smart_service/phase_2/doctype/feature_finder/feature_finder.py
  6. 1
      smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js
  7. 0
      smart_service/phase_2/doctype/feature_finder_publish_data/__init__.py
  8. 124
      smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json
  9. 8
      smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.py
  10. 5
      smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json
  11. 541
      smart_service/phase_2/doctype/publish_test/publish_test.js
  12. 4
      smart_service/phase_2/doctype/publish_test/publish_test.json
  13. 227
      smart_service/phase_2/doctype/publish_test/publish_test.py
  14. 12
      smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js
  15. 7
      smart_service/phase_2/doctype/repair_service_master/repair_service_master.js
  16. 3
      smart_service/phase_2/doctype/repair_service_master/repair_service_master.json
  17. 43
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
  18. 6
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
  19. 1
      smart_service/phase_2/doctype/training_information_master/training_information_master.js

2
smart_service/apis/v2/master.py

@ -77,7 +77,7 @@ def get_feature_finder(vehicle, variant, language):
ffm.feature_pdf as pdf from `tabFeature Finder` ff left join `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}";
and ff.language = "{language}" and ffm.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,

10
smart_service/masters/doctype/role_master/role_master.json

@ -15,7 +15,8 @@
"active_status",
"display_order",
"my_id",
"modules"
"modules",
"skill_id"
],
"fields": [
{
@ -67,11 +68,16 @@
"fieldtype": "Small Text",
"hidden": 1,
"label": "Modules"
},
{
"fieldname": "skill_id",
"fieldtype": "Data",
"label": "Skill Id"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-07-21 15:15:43.988229",
"modified": "2023-08-14 12:33:27.319600",
"modified_by": "Administrator",
"module": "Masters",
"name": "Role Master",

115
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -139,6 +139,12 @@ frappe.ui.form.on('Feature Finder', {
}
});
}
// var specifiaction_data = $('.spec-table').find('tr').find('input[type="text"]');
// console.log(specifiaction_data,"specifiaction_data")
// specifiaction_data.each(function(){
// console.log($(this).val())
// });
},
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
@ -179,9 +185,10 @@ function custom_tab_html(frm) {
res.append(ret)
$(res).find('.main').append(`<div class="specification_bl"></div>`)
$(res).find('.main').append(`<div class="feature_imgbl"></div>`)
$(res).find('.main').append(`<div class="feature_contbl"></div>`)
$(res).find('.main').append(`<div class="feature_imgbl"></div>`)
$(res).find('.main').append(`<div class="specification_bl"></div>`)
res.append(`<style>.custom_tab{border:1px solid var(--table-border-color);}.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {background-color:lavender !important;}.nav-tabs {
border-bottom:none !important;}.feature_contbl{margin:10px;}.specification_bl{margin:10px;}.feature_imgbl{margin:10px;}.main{border: 1px solid var(--table-border-color);margin:15px 0px 15px 0px}.spec_custom_add{margin:10px 0px 0px 0px}</style>`)
@ -206,6 +213,7 @@ function custom_tab_html(frm) {
var content_dialog_value = ""
var nav_spec = {}
nav_spec.feature_type = "SOP"
nav_spec.active_status = "Active"
all_tabs()
$('.main').find('.nav-link').click(function (event) {
@ -243,14 +251,14 @@ function custom_tab_html(frm) {
//heading
var spec_custom_dt = ""
spec_custom_dt += `<label class="control-label">Specification</label><table class="table table-bordered table-editable" style='margin:0px !important'>
spec_custom_dt += `<label class="control-label">Specification</label><table class="table table-bordered table-editable spec-table" style='margin:0px !important'>
<thead>
<tr>
<th style="width: 7%;" class="specifiction"><input type="checkbox" id="checkAll"' class="grid-row-check pull-left"><span class='spec_check'>No</span></th>
<th>Specification</th>
<th>Value</th>
<th>Active Status</th>
<th>Feature Type</th>
<th id='postvin1'>Post Vin CutOff Name</th>
<th><a><svg class="icon icon-sm" style="filter: opacity(0.5)">
<use class="" href="#icon-setting-gear"></use>
@ -261,13 +269,13 @@ function custom_tab_html(frm) {
var image_custom_dt = ""
image_custom_dt += `<label class="control-label">Feature Finder Images</label><table class="table table-bordered table-editable" style='margin:0px !important'>
image_custom_dt += `<label class="control-label">Feature Finder Images</label><table class="table table-bordered table-editable image-table" style='margin:0px !important'>
<thead>
<tr>
<th style="width: 7%;" class="feature_image"><input type="checkbox" id="imgcheckAll"' class="grid-row-check pull-left"><span class='image_check'>No</span></th>
<th>Image</th>
<th>Active Status</th>
<th>Feature Type</th>
<th id='postvin2'>Post Vin CutOff Name</th>
<th><a><svg class="icon icon-sm" style="filter: opacity(0.5)">
<use class="" href="#icon-setting-gear"></use>
@ -278,13 +286,13 @@ function custom_tab_html(frm) {
var content_custom_dt = ""
content_custom_dt += `<label class="control-label">Feature Finder Content</label><table class="table table-bordered table-editable" style='margin:0px !important'>
content_custom_dt += `<label class="control-label">Feature Finder Content</label><table class="table table-bordered table-editable content-table" style='margin:0px !important'>
<thead>
<tr>
<th style="width: 7%;" class="feature_content"><input type="checkbox" id="contentcheckAll"' class="grid-row-check pull-left"><span class='content_check'>No</span></th>
<th>Content</th>
<th>Active Status</th>
<th>Feature Type</th>
<th id='postvin3'>Post Vin CutOff Name</th>
<th><a><svg class="icon icon-sm" style="filter: opacity(0.5)">
<use class="" href="#icon-setting-gear"></use>
@ -309,7 +317,7 @@ function custom_tab_html(frm) {
spec_custom_dt += '<td>' + val.specification + '</td>'
spec_custom_dt += '<td>' + val.value + '</td>'
spec_custom_dt += '<td>' + val.active_status + '</td>'
spec_custom_dt += '<td>' + val.feature_type + '</td>'
// spec_custom_dt += '<td>' + val.feature_type + '</td>'
if (val.post_vin_cutoff_name) {
spec_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
}
@ -336,7 +344,7 @@ function custom_tab_html(frm) {
image_custom_dt += '<td style="width: 7%;" id="image_count"><input id=' + val.name + ' type="checkbox" class="imagecheck grid-row-check pull-left"><span class="image_check">' + image_count + '</span></td>'
image_custom_dt += '<td>' + val.image + '</td>'
image_custom_dt += '<td>' + val.active_status + '</td>'
image_custom_dt += '<td>' + val.feature_type + '</td>'
// image_custom_dt += '<td>' + val.feature_type + '</td>'
if (val.post_vin_cutoff_name) {
image_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
}
@ -362,7 +370,7 @@ function custom_tab_html(frm) {
content_custom_dt += '<td style="width: 7%;" id="cont_count"><input id=' + val.name + ' type="checkbox" class="contentcheck grid-row-check pull-left"><span class="content_check">' + content_count + '</span></td>'
content_custom_dt += '<td>' + val.content + '</td>'
content_custom_dt += '<td>' + val.active_status + '</td>'
content_custom_dt += '<td>' + val.feature_type + '</td>'
// content_custom_dt += '<td>' + val.feature_type + '</td>'
if (val.post_vin_cutoff_name) {
content_custom_dt += '<td>' + val.post_vin_cutoff_name + '</td>'
}
@ -409,26 +417,28 @@ function custom_tab_html(frm) {
image_custom_dt += '</div>'
content_custom_dt += '</div>'
$(res).find('.specification_bl').empty()
$(res).find('.specification_bl').append(spec_custom_dt)
$(res).find('.feature_imgbl').empty()
$(res).find('.feature_imgbl').append(image_custom_dt)
$(res).find('.feature_contbl').empty()
$(res).find('.feature_contbl').append(content_custom_dt)
$(res).find('.feature_imgbl').empty()
$(res).find('.feature_imgbl').append(image_custom_dt)
$(res).find('.specification_bl').empty()
$(res).find('.specification_bl').append(spec_custom_dt)
if(nav_spec.feature_type=='SOP'){
$(res).find('#postvin1').hide()
$(res).find('#postvin2').hide()
$(res).find('#postvin3').hide()
}
$(res).append(`<style>.spec_check{padding:0px 5px 0px 5px !important}.spec_custom_save{display:none;margin:10px 0px 0px 10px;background-color:red !important;color:#fff !important;}.spec_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}</style>`)
$(res).append(`<style>th{color:var(--text-muted)}.spec_check{padding:0px 5px 0px 5px !important}.spec_custom_save{display:none;margin:10px 0px 0px 10px;background-color:red !important;color:#fff !important;}.spec_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}</style>`)
$(res).append(`<style>.image_check{padding:0px 5px 0px 5px !important}.image_custom_save{display:none;margin:10px 0px 0px 10px;background-color:red !important;color:#fff !important;}.image_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}
$(res).append(`<style>th{color:var(--text-muted)}.image_check{padding:0px 5px 0px 5px !important}.image_custom_save{display:none;margin:10px 0px 0px 10px;background-color:red !important;color:#fff !important;}.image_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}
.image_custom_add{margin:10px 0px 0px 0px</style>`)
$(res).append(`<style>.content_check{padding:0px 5px 0px 5px !important}.content_custom_save{display:none;margin:10px 0px 0px 10px;background-color:red !important;color:#fff !important;}.content_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}
$(res).append(`<style>th{color:var(--text-muted)}.content_check{padding:0px 5px 0px 5px !important}.content_custom_save{display:none;margin:10px 0px 0px 10px;background-color:red !important;color:#fff !important;}.content_custom_delete{margin:10px 10px 0px 0px;background-color:red !important;color:#fff !important;display:none}
.content_custom_add{margin:10px 0px 0px 0px</style>`)
//append end
@ -461,7 +471,7 @@ function custom_tab_html(frm) {
$('.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)
// set_display_order_child("Feature Finder Specification", spec_id_dis)
})
})
@ -665,6 +675,56 @@ function custom_tab_html(frm) {
})
//delete function end
// $(function () {
// // Start counting from the third row
// var counter = 3;
// $(".spec_custom_add").on("click", function (event) {
// event.preventDefault();
// var newRow = $('<tr draggable="true" ondragstart="dragstartFunction(event)" ondragover="dragovertFunction(event)">');
// var cols = '';
// frappe.call({
// method: "smart_service.phase_2.doctype.feature_finder.feature_finder.get_specification_list",
// args: {
// },
// callback: function (r) {
// if (r.message) {
// console.log("calling")
// cols += '<td style="width: 7%;" id="spec_count"><input type="checkbox" class="speccheck grid-row-check pull-left"><span class="spec_check"></span></td>'
// // cols += '<td><input class="form-control rounded-0" type="text" name="firstname" placeholder="Specification"></td>';
// cols += '<td><select id="specification" name="Specification">'
// r.message.map(v=>{
// cols += '<option value="'+v.name+'">'+v.name+'</option>'
// })
// cols += '</select></td>'
// cols += '<td><input class="form-control rounded-0" type="text" name="value" placeholder="value"></td>';
// cols += '<td><input class="form-control rounded-0" type="text" name="active_status" placeholder="active_status"></td>';
// // cols += '<td><button class="btn btn-danger rounded-0" id ="deleteRow"><i class="fa fa-trash"></i></button</td>';
// cols += '<td class="content_edit_row"><a><svg class="icon icon-xs" style=""><use class="" href="#icon-edit"></use></svg>Edit</a></td>'
// newRow.append(cols);
// $(".spec-table").append(newRow);
// $(res).find('.specification_bl').find('.spec_custom_save').css('display','inline-block')
// counter++;
// }
// }
// })
// });
// // Remove row when delete btn is clicked
// $(".spec-table").on("click", "#deleteRow", function (event) {
// $(this).closest("tr").remove();
// counter -= 1
// });
// });
}
function spec_dialog_view() {
@ -684,7 +744,13 @@ function custom_tab_html(frm) {
fieldname: 'specification',
fieldtype: 'Link',
options: "Feature Finder Specification Master",
default: spec_dialog_value.specification
default: spec_dialog_value.specification,
get_query() {
return {
filters: { 'Active Status': 'Active' }
}
}
},
{
label: 'Value',
@ -704,7 +770,8 @@ function custom_tab_html(frm) {
fieldname: 'feature_type',
fieldtype: 'Data',
default: spec_dialog_value.feature_type,
read_only: 1
read_only: 1,
hidden:1
},
{
label: 'Post Vin Cutoff Name',
@ -771,7 +838,8 @@ function custom_tab_html(frm) {
fieldname: 'feature_type',
fieldtype: 'Data',
default: image_dialog_value.feature_type,
read_only: 1
read_only: 1,
hidden:1
},
{
label: 'Post Vin Cutoff Name',
@ -839,7 +907,8 @@ function custom_tab_html(frm) {
fieldname: 'feature_type',
fieldtype: 'Data',
default: content_dialog_value.feature_type,
read_only: 1
read_only: 1,
hidden:1
},
{
label: 'Post Vin Cutoff Name',

11
smart_service/phase_2/doctype/feature_finder/feature_finder.json

@ -1,6 +1,6 @@
{
"_comments": "[]",
"_liked_by": "[]",
"_liked_by": "[\"Administrator\"]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{variant}-{features_names}-{language}",
@ -116,6 +116,8 @@
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Active Status",
"options": "Active\nIn Active"
},
@ -131,12 +133,17 @@
"fetch_from": "feature_name.feature_category",
"fieldname": "feature_category",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Feature Category"
},
{
"depends_on": "eval:doc.variant",
"fieldname": "features_names",
"fieldtype": "Select",
"in_global_search": 1,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Feature Name",
"reqd": 1,
"set_only_once": 1
@ -187,7 +194,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-10 13:41:34.327348",
"modified": "2023-08-14 17:49:28.825452",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder",

7
smart_service/phase_2/doctype/feature_finder/feature_finder.py

@ -228,3 +228,10 @@ def set_display_order(doctype_name, values):
return {"status": "success"}
except Exception as e:
frappe.log_error("set_display_order", str(e))
@frappe.whitelist()
def get_specification_list():
res = frappe.db.sql("""select name from `tabFeature Finder Specification Master`""",as_dict=1)
return res

1
smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js

@ -16,7 +16,6 @@ function check_field_character(field_name) {
frappe.validated = false;
} else {
if (alphanum.test(field_name) === true) {
frappe.validated = true;
} else if (field_name) {
frappe.throw(__("<b>Feature Finder Category Master:</b> Enter letter or alpha numeric characters only."));
frappe.validated = false;

0
smart_service/phase_2/doctype/feature_finder_publish_data/__init__.py

124
smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json

@ -0,0 +1,124 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-08-10 22:37:14.844640",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"variant",
"language",
"display_order",
"active_status",
"column_break_mmuuc",
"vehicle",
"feature_name",
"features_names",
"feature_category",
"vehicle_id",
"variant_id"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Variant",
"options": "Variant Mapping",
"set_only_once": 1
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Language",
"options": "Custom Languages",
"set_only_once": 1
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Display Order",
"read_only_depends_on": "eval:doc.language!=\"en\""
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"label": "Active Status",
"options": "Active\nIn Active"
},
{
"fieldname": "column_break_mmuuc",
"fieldtype": "Column Break"
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"read_only": 1
},
{
"depends_on": "eval:doc.variant!=\"\"",
"fieldname": "feature_name",
"fieldtype": "Link",
"hidden": 1,
"label": "Feature Name1",
"options": "Feature Finder Master",
"read_only": 1,
"set_only_once": 1
},
{
"depends_on": "eval:doc.variant",
"fieldname": "features_names",
"fieldtype": "Data",
"label": "Feature Name",
"set_only_once": 1
},
{
"depends_on": "eval:doc.feature_name",
"fetch_from": "feature_name.feature_category",
"fieldname": "feature_category",
"fieldtype": "Data",
"label": "Feature Category"
},
{
"fetch_from": "variant.vehicle_id",
"fieldname": "vehicle_id",
"fieldtype": "Int",
"hidden": 1,
"label": "Vehicle Id"
},
{
"fetch_from": "variant.name",
"fieldname": "variant_id",
"fieldtype": "Data",
"hidden": 1,
"label": "Variant Id"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-08-10 22:37:14.844640",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Publish Data",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class FeatureFinderPublishData(Document):
pass

5
smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json

@ -1,4 +1,5 @@
{
"_liked_by": "[\"Administrator\"]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{specification}",
@ -22,6 +23,8 @@
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Active Status",
"options": "Active\nInactive"
},
@ -35,7 +38,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-10 12:46:14.322512",
"modified": "2023-08-14 17:46:12.062394",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Specification Master",

541
smart_service/phase_2/doctype/publish_test/publish_test.js

@ -10,35 +10,25 @@ cur_frm.fields_dict['variant_mapping'].get_query = function (doc, cdt, cdn) {
}
};
};
var selected_module=''
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'){
// selected_module=1
// }
// 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') {
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') {
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")
}
if(frm.doc.status="Published" && frm.doc.publish_module=='Others'){
frm.set_df_property('repair_checksheet_publish','hidden',0)
if (frm.doc.status = "Published" && frm.doc.publish_module == 'Others') {
frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
frm.refresh_field('repair_checksheet_publish')
@ -86,250 +76,250 @@ frappe.ui.form.on('Publish Test', {
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'){
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();
cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-remove-rows').hide();
cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-insert-row').hide();
cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-append-row').hide();
frm.fields_dict.system_mapping.grid.wrapper.find('.grid-append-row').hide();
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();
cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-remove-rows').hide();
cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-insert-row').hide();
cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-append-row').hide();
frm.fields_dict.system_mapping.grid.wrapper.find('.grid-append-row').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-add-row').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-upload').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-remove-rows').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-insert-row').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-append-row').hide();
frm.fields_dict.variant_mapping_assets.grid.wrapper.find('.grid-append-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-add-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-upload').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-all-rows').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-rows').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete_all_rows').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-move-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-append-row').hide();
frm.fields_dict.publish_documents.grid.wrapper.find('.grid-append-row').hide();
document.querySelectorAll("[data-fieldname='km_report']")[1].style.backgroundColor = "#e31a37";
document.querySelectorAll("[data-fieldname='km_report']")[1].style.color = "#FFFFFF";
document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.backgroundColor = "#e31a37";
document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.color = "#FFFFFF";
if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.max_publish",
args: {
"doc": frm.doc.name,
},
callback: function (r) {
if (r.message) {
if (r.message == frm.doc.version) {
frm.add_custom_button(__('Global Publish'), function () {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.global_publish",
args: {
"doc": frm.doc.name,
},
callback: function (r) {
cur_frm.reload_doc();
}
});
}).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
}
}
}
})
}
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-add-row').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-upload').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-remove-rows').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-insert-row').hide();
cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-append-row').hide();
frm.fields_dict.variant_mapping_assets.grid.wrapper.find('.grid-append-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-add-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-upload').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-all-rows').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-rows').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete_all_rows').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-move-row').hide();
cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-append-row').hide();
frm.fields_dict.publish_documents.grid.wrapper.find('.grid-append-row').hide();
document.querySelectorAll("[data-fieldname='km_report']")[1].style.backgroundColor = "#e31a37";
document.querySelectorAll("[data-fieldname='km_report']")[1].style.color = "#FFFFFF";
document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.backgroundColor = "#e31a37";
document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.color = "#FFFFFF";
if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) {
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.max_publish",
args: {
"doc": frm.doc.name,
},
callback: function (r) {
if (r.message) {
if (r.message == frm.doc.version) {
frm.add_custom_button(__('Global Publish'), function () {
if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher')) {
frm.add_custom_button(__('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.transactions.doctype.publish.publish.global_publish",
method: 'smart_service.transactions.doctype.publish.publish.cal_ver',
args: {
"doc": frm.doc.name,
vehicle: frm.doc.vehicle,
lang: frm.doc.language,
publish_type: frm.doc.publish_type,
doc: frm.doc.name
},
callback: function (r) {
cur_frm.reload_doc();
}
});
}).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' });
}
}
}
})
}
callback: (r) => {
frm.set_value('version', r.message);
cur_frm.refresh_field('version')
if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish') {
frappe.call({
// method: "smart_service.apis.publish_api.api_procedure",
method: "smart_service.apis.publish_api.new_publish",
args: {
"args": frm.doc.name,
"publish_type": frm.doc.publish_type,
"vehicle": frm.doc.vehicle,
"language": frm.doc.language,
"version": frm.doc.version
},
callback: function (r) {
// if (r.message[0]) {
frm.set_value('publish_status', 'Published');
frm.page.clear_primary_action("Publish");
frm.set_value('actual_published_date', frappe.datetime.nowdate());
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
args: {
"name": frm.doc.name,
"file_path": r.message[1],
},
callback: (r) => {
// frm.save('Update');
}
})
frappe.msgprint({
title: __('Notification'),
message: __('<b>Successfully Published:</b> ' + r.message[1]),
primary_action: {
action(values) {
frm.save('Update');
}
}
});
// }
// else {
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Not Successfully Published:</b> ' + r.message[1]),
// // primary_action: {
// // action(values) {
// // frm.save('Update');
// // }
// // }
// });
// }
// if (r.message != "Failed to save file") {
// frm.set_value('publish_status', 'Published');
// frm.set_value('actual_published_date', frappe.datetime.nowdate());
// frappe.call({
// method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
// args: {
// "name": frm.doc.name,
// "file_path": r.message,
// },
// callback: (r) => {
// // frm.save('Update');
// }
// })
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Successfully Published:</b> ' + r.message),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
// });
// } else {
// frappe.msgprint('Publish Failed')
// }
}
});
}
},
})
}
}, () => {
// 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);
}
if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher')) {
frm.add_custom_button(__('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.transactions.doctype.publish.publish.cal_ver',
args: {
vehicle: frm.doc.vehicle,
lang: frm.doc.language,
publish_type: frm.doc.publish_type,
doc: frm.doc.name
},
callback: (r) => {
frm.set_value('version', r.message);
cur_frm.refresh_field('version')
if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish') {
frappe.call({
// method: "smart_service.apis.publish_api.api_procedure",
method: "smart_service.apis.publish_api.new_publish",
args: {
"args": frm.doc.name,
"publish_type": frm.doc.publish_type,
"vehicle": frm.doc.vehicle,
"language": frm.doc.language,
"version": frm.doc.version
},
callback: function (r) {
// if (r.message[0]) {
frm.set_value('publish_status', 'Published');
frm.page.clear_primary_action("Publish");
frm.set_value('actual_published_date', frappe.datetime.nowdate());
frappe.call({
method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
args: {
"name": frm.doc.name,
"file_path": r.message[1],
},
callback: (r) => {
// frm.save('Update');
}
})
frappe.msgprint({
title: __('Notification'),
message: __('<b>Successfully Published:</b> ' + r.message[1]),
primary_action: {
action(values) {
frm.save('Update');
}
}
});
// }
// else {
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Not Successfully Published:</b> ' + r.message[1]),
// // primary_action: {
// // action(values) {
// // frm.save('Update');
// // }
// // }
// });
// }
// if (r.message != "Failed to save file") {
// frm.set_value('publish_status', 'Published');
// frm.set_value('actual_published_date', frappe.datetime.nowdate());
// frappe.call({
// method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
// args: {
// "name": frm.doc.name,
// "file_path": r.message,
// },
// callback: (r) => {
// // frm.save('Update');
// }
// })
// frappe.msgprint({
// title: __('Notification'),
// message: __('<b>Successfully Published:</b> ' + r.message),
// primary_action: {
// action(values) {
// frm.save('Update');
// }
// }
// });
// } else {
// frappe.msgprint('Publish Failed')
// }
}
});
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
let topublish = [];
if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; }
frm.doc.system_mapping.forEach(row => {
if (topublish.indexOf(row.procedure_status) > -1) {
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
row.systems == publishrow.system &&
row.sub_systems == publishrow.sub_system && row.procedure == publishrow.procedure_link) {
dulicate = true;
}
},
})
});
}
if (dulicate === false) {
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.system = row.systems;
child.sub_system = row.sub_systems;
child.procedure_link = row.procedure;
child.procedure_status = row.procedure_status;
child.update_procedure_status = row.procedure_status;
child.item_category = "System Mapping";
child.variant = frm.doc.variant;
refresh_field("publish_documents");
added += 1;
}
}
}, () => {
// 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);
}
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
let topublish = [];
if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; }
frm.doc.system_mapping.forEach(row => {
if (topublish.indexOf(row.procedure_status) > -1) {
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
row.systems == publishrow.system &&
row.sub_systems == publishrow.sub_system && row.procedure == publishrow.procedure_link) {
dulicate = true;
}
});
}
if (dulicate === false) {
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.system = row.systems;
child.sub_system = row.sub_systems;
child.procedure_link = row.procedure;
child.procedure_status = row.procedure_status;
child.update_procedure_status = row.procedure_status;
child.item_category = "System Mapping";
child.variant = frm.doc.variant;
refresh_field("publish_documents");
added += 1;
}
}
if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
else { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.system_mapping.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
else { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.system_mapping.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
frm.doc.variant_mapping_assets.forEach(row => {
if (row.active_status == "Active" || row.active_status == "Inactive") {
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
row.category == publishrow.asset_category && row.attach_file == publishrow.attach_file) {
dulicate = true;
}
});
}
if (dulicate === false) {
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.asset_category = row.category;
child.item_category = "Variant Mapping Assets";
child.variant = frm.doc.variant;
child.attach_file = row.attach_file;
refresh_field("publish_documents");
added += 1;
}
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') {
frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
frm.doc.variant_mapping_assets.forEach(row => {
if (row.active_status == "Active" || row.active_status == "Inactive") {
let dulicate = false;
if (frm.doc.publish_documents) {
frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping &&
row.category == publishrow.asset_category && row.attach_file == publishrow.attach_file) {
dulicate = true;
}
});
}
if (dulicate === false) {
let child = cur_frm.add_child("publish_documents");
child.variant_mapping = frm.doc.variant_mapping;
child.asset_category = row.category;
child.item_category = "Variant Mapping Assets";
child.variant = frm.doc.variant;
child.attach_file = row.attach_file;
refresh_field("publish_documents");
added += 1;
}
}
}
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
else { frappe.msgprint(__("No Doc Added")); }
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added")); }
else { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
if (frm.doc.docstatus == 1) {
$(".grid-buttons").hide();
frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
if (frm.doc.docstatus == 1) {
$(".grid-buttons").hide();
}
}
}
if (frm.doc.docstatus == 1 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module=='Others') {
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 () {
@ -348,55 +338,10 @@ frappe.ui.form.on('Publish Test', {
}).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: __('<b>Successfully Published:</b> ' + 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(frm.doc.publish_module=='Automotive'){
if (frm.doc.publish_module == 'Automotive') {
let regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/;
if (regex.test(frm.doc.release_description) === true) {
frm.doc.release_description = '';
@ -415,7 +360,7 @@ 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')){
if (frm.doc.publish_module == 'Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish')) {
frappe.throw('No Data Found To Publish')
@ -459,7 +404,7 @@ frappe.ui.form.on('Publish Test', {
},
km_active_status: function (frm) {
if (frm.doc.variant_mapping && frm.doc.publish_module=='Automotive') {
if (frm.doc.variant_mapping && frm.doc.publish_module == 'Automotive') {
frappe.show_alert({
message: __('Please wait until variant mapping details are loaded.'),
indicator: 'yellow'
@ -467,7 +412,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" && frm.doc.publish_module=='Automotive') {
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": {
@ -540,7 +485,7 @@ frappe.ui.form.on('Publish Test', {
})
} else {
if (frm.doc.variant_mapping_status && frm.doc.publish_module=='Automotive') {
if (frm.doc.variant_mapping_status && frm.doc.publish_module == 'Automotive') {
frappe.msgprint({
title: __('Notification'),
indicator: 'red',
@ -551,7 +496,7 @@ frappe.ui.form.on('Publish Test', {
},
add_variant_mapping_to_publish: function (frm) {
let dulicate = false;
if (frm.doc.publish_documents && frm.doc.publish_module=='Automotive') {
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;
@ -559,7 +504,7 @@ frappe.ui.form.on('Publish Test', {
});
frappe.msgprint("Variant Mapping already added");
}
if (dulicate === false && frm.doc.publish_module=='Automotive') {
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";
@ -570,8 +515,8 @@ frappe.ui.form.on('Publish Test', {
km_report: function (frm, cdt, cdn) {
frappe.set_route("query-report", 'Kilometer Mapping', { 'kilometer_mapping': frm.doc.kilometer_mapping });
},
after_save:function(frm){
frm.set_df_property('repair_checksheet_publish','hidden',0)
after_save: function (frm) {
frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
frm.refresh_field('repair_checksheet_publish')
},
@ -596,13 +541,13 @@ frappe.ui.form.on('Publish Test', {
}
});
if (frm.doc.vehicle === undefined || frm.doc.vehicle === null && frm.doc.publish_module=='Automotive') { 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.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");
@ -617,7 +562,7 @@ frappe.ui.form.on('Publish Test', {
},
language: function (frm) {
if(frm.doc.publish_module=='Others'){
if (frm.doc.publish_module == 'Others') {
add_to_publish(frm)
}
if (!lang_set_first_time) {
@ -669,13 +614,13 @@ frappe.ui.form.on('Publish_Temp Doc', {
},
})
function add_to_publish(frm){
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)
cur_frm.set_df_property('repair_checksheet_publish', 'hidden', 0)
var records = r.message
debugger
records.map(v => {

4
smart_service/phase_2/doctype/publish_test/publish_test.json

@ -1,4 +1,5 @@
{
"_liked_by": "[\"Administrator\"]",
"actions": [],
"autoname": "format: {vehicle}-{language} -{creation}",
"creation": "2023-08-07 16:21:22.055887",
@ -141,6 +142,7 @@
"read_only": 1
},
{
"depends_on": "eval:doc.publish_module",
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"label": "Vehicle Details"
@ -327,7 +329,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-08-10 12:12:01.149289",
"modified": "2023-08-11 12:19:11.733139",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Publish Test",

227
smart_service/phase_2/doctype/publish_test/publish_test.py

@ -15,11 +15,12 @@ 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-bench/sites/" + site_name + "/public" + "/files" + "/json_files" + "/Other_Module"
frappe.utils.logger.set_log_level("DEBUG")
success_reponse={"status":1,"data":"","message":""}
failure_reponse={"status":0,"data":"","error":""}
success_reponse = {"status": 1, "data": "", "message": ""}
failure_reponse = {"status": 0, "data": "", "error": ""}
class PublishTest(Document):
def validate(self):
@ -45,18 +46,20 @@ 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,self.repair_checksheet_publish)
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':
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, self.repair_checksheet_publish)
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':
# for i in self.repair_checksheet_publish:
repair_checksheet_publish(self.vehicle,self.vehicle_id,self.language,self.publish_type,self.release_description,self.variant,self.repair_checksheet_publish)
repair_checksheet_publish(self.vehicle, self.vehicle_id, self.language, self.publish_type,
self.release_description, self.variant, self.repair_checksheet_publish)
update_published_docs(self)
update_publish_status=frappe.db.sql("""update `tabPublish Test` set publish_status='Published' where name='{0}'""".format(self.name))
update_publish_status = frappe.db.sql(
"""update `tabPublish Test` set publish_status='Published' where name='{0}'""".format(self.name))
def onload1(self):
current_db_name = frappe.conf.get("db_name")
@ -165,12 +168,16 @@ def update_procedure(vehicle, lang, publish_type, doc):
frappe.throw("There is no item for global publish")
# Generate Publish versions
def update_publish_status(self):
try:
update_status=frappe.db.sql("""update `tabPublish Test` set publish_status="Published" where name='{0}' """.format(self.name))
update_status = frappe.db.sql(
"""update `tabPublish Test` set publish_status="Published" where name='{0}' """.format(self.name))
except Exception as e:
return e
@frappe.whitelist()
def cal_ver(vehicle, lang, publish_type, doc):
update_procedure(vehicle, lang, publish_type, doc)
@ -247,6 +254,8 @@ 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:
@ -255,26 +264,28 @@ def generate_global_publish(name):
"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
"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")
publish_record = frappe.db.sql("""select name,publish_type from {0}.`tabPublish` where vehicle = "{1}" and language = "{2}"
and publish_status='To Publish' and publish_type = 'Internal' and docstatus != '2'""".format(
current_db_name, vehicle, language), as_dict=1)
current_db_name, vehicle, language), as_dict=1)
if publish_record:
return publish_record
global_publish_record = frappe.db.sql("""select name,publish_type from {0}.`tabPublish` where vehicle = "{1}" and language = "{2}"
and publish_status='To Publish' and publish_type = 'Global' and docstatus != '2'""".format(
current_db_name, vehicle, language), as_dict=1)
current_db_name, vehicle, language), as_dict=1)
if global_publish_record:
return global_publish_record
@ -321,29 +332,29 @@ def update_mapping(variant_mapping, doc):
@frappe.whitelist()
def get_vm_asset(doc,lang):
def get_vm_asset(doc, lang):
doc = frappe.get_doc("Variant Mapping", doc)
vm_assets = frappe.db.sql("""select category,language,attach_file,active_status from {0}.`tabVariant Mapping_Assets`
where parent = "{1}" and language '{2}' and published = '0'; """.format(current_db_name, doc.name,lang), as_dict=1)
where parent = "{1}" and language '{2}' and published = '0'; """.format(current_db_name, doc.name, lang), as_dict=1)
return vm_assets
@frappe.whitelist()
def get_sm_asset(doc, name,lang):
def get_sm_asset(doc, name, lang):
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = '{3}'; """.format(
current_db_name, doc, name,lang), as_dict=1)
current_db_name, doc, name, lang), as_dict=1)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping", s.name)
system_asset = frappe.db.sql("""select systems,language,active_status,system_asset from {0}.`tabSystem Mapping_System Assets`
where parent = "{1}" and language = "{2}" and published = '0'; """.format(current_db_name, s.name,lang), as_dict=1)
where parent = "{1}" and language = "{2}" and published = '0'; """.format(current_db_name, s.name, lang), as_dict=1)
return system_asset
@frappe.whitelist()
def get_system(doc, name,lang):
def get_system(doc, name, lang):
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = "{3}";""".format(
current_db_name, doc, name,lang), as_dict=1)
current_db_name, doc, name, lang), as_dict=1)
if system_map:
for s in system_map:
doc = frappe.get_doc("System Mapping", s.name)
@ -352,6 +363,7 @@ def get_system(doc, name,lang):
procedure_is_published = "0";""".format(current_db_name, s.name), as_dict=1)
return system
@frappe.whitelist()
def max_publish(doc):
doc = frappe.get_doc("Publish", doc)
@ -435,59 +447,82 @@ def get_service_repair(vehicle, language_label, publish_type):
return data
def repair_checksheet_publish(vehicle,vehicle_id,language,publish_type,release_description,variant,parent):
def repair_checksheet_publish(vehicle, vehicle_id,
language, publish_type, release_description,
variant, parent):
try:
logger_file=f'{vehicle}-{language}-{publish_type}'
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}-{parent}')
logger.info(
f'Repair Checksheet Started-{vehicle}-{language}-{publish_type}-{parent}')
folder_url=base_url+"/"+vehicle.replace(' ', '-') + "/"+language
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Publish Ready Flags'''
publish_repair_checksheet=0
publish_repair_checksheet = 0
repair_checksheet_tmp = []
'''Create Folder For Publish'''
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + vehicle.replace(' ',
'-')+'-repair_check_sheet' +'.json'
# try:
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-repair_check_sheet' + '.json'
'''Append Published Data to Json'''
logger.info(f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
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_tmp=[]
for i in parent:
repair_checksheet=repair_checksheet_data(vehicle,language,publish_type,i.parent_name)
if repair_checksheet['status']==1:
publish_repair_checksheet=1
if len(repair_checksheet['data']):
repair_checksheet_tmp.append(repair_checksheet['data'][0])
if publish_repair_checksheet==1:
""" Save publish file """
vehicle_data['data']={'repair_checksheet':repair_checksheet_tmp}
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data,indent=4,default=str))
'data': ''
}
'''update existing global json file'''
if os.path.isfile(file_path):
with open(file_path) as f:
published_data = json.load(f)
for i in parent:
repair_checksheet = repair_checksheet_data(vehicle, language,
publish_type, i.parent_name)
if repair_checksheet['status'] == 1:
publish_repair_checksheet = 1
if len(repair_checksheet['data']) > 0:
# Compare with existing
global_publish['data']['repair_checksheet'].append(
repair_checksheet['data'][0])
repair_checksheet_tmp = published_data['data']['repair_checksheet']
frappe.msgprint('file_exists' + str(published_data))
return 1,file_path
# except Exception as e:
# logger.info(f'{vehicle}-{language}-{publish_type} error in json creation'+str(e))
# frappe.throw('Failed To Publish')
else:
frappe.msgprint(str('new file'))
for i in parent:
repair_checksheet = repair_checksheet_data(
vehicle, language, publish_type, i.parent_name)
if repair_checksheet['status'] == 1:
publish_repair_checksheet = 1
if len(repair_checksheet['data']):
repair_checksheet_tmp.append(
repair_checksheet['data'][0])
if publish_repair_checksheet == 1:
""" Save publish file """
vehicle_data['data'] = repair_checksheet_tmp
# return e
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
return 1, file_path
except Exception as e:
logger.info(f'{vehicle}-{language}-{publish_type} error in json creation'+str(e))
logger.info(
f'{vehicle} - {language} - {publish_type} error in json creation' + str(e))
frappe.throw('Failed To Publish')
def update_published_docs(self):
try:
if self.repair_checksheet_publish:
@ -500,10 +535,10 @@ def update_published_docs(self):
except Exception as e:
frappe.throw(str(e))
except:
frappe.throw(str(e))
def create_publish_folders(folder_url):
try:
@ -517,30 +552,78 @@ def create_publish_folders(folder_url):
except Exception as e:
frappe.throw(str(e))
return False
'''New Module Publish Section'''
def repair_checksheet_data(vehicle=None,language=None,publish_type=None,parent=None):
def get_key_value_data(data):
module_dic = {}
for d in data['data']:
module_dic.update({d['name']: d})
return module_dic
def get_latest_data(prev_data, latest_data):
data_dic1 = get_key_value_data(prev_data)
data_dic2 = get_key_value_data(latest_data)
final_dic = data_dic1.copy()
for d1 in data_dic1:
if data_dic1[d1]['active_status'] == 'Inactive':
final_dic.pop(d1)
for d2 in data_dic2:
if data_dic2[d2]['active_status'] == 'Inactive':
final_dic.pop(d2)
else:
final_dic.update({d2: data_dic2[d2]})
final_list = list(final_dic.values())
return final_list
def repair_checksheet_data(vehicle=None, language=None,
publish_type=None, parent=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 name='{parent}'""", 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_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 name = '{parent}'""", 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}'
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))
failure_reponse['error'] = f"{vehicle} - {language} has following error - " + str(
e)
logger.error('error in repair checksheet' + str(e))
return failure_reponse
def feature_finder_data(vehicle=None,language=None,publish_type=None,parent=None):
def feature_finder_data(vehicle=None, language=None,
publish_type=None, parent=None):
try:
pass
except Exception as e:

12
smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js

@ -48,16 +48,22 @@ frappe.ui.form.on('Repair Service Mapping', {
}
});
}
},
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
},
vehicle:function(frm){
set_display_order(frm)
}
});
function set_display_order(frm){
if(!frm.doc.vehicle){
frm.toggle_display('display_order', false)
}
if(frm.doc.vehicle){
frm.toggle_display('display_order', true)
}
if (frm.is_new()) {
frm.set_df_property('display_order', 'read_only', 1);
} else {

7
smart_service/phase_2/doctype/repair_service_master/repair_service_master.js

@ -54,19 +54,18 @@ frappe.ui.form.on('Repair Service Master', {
if (frm.doc.repairservicename.length > 1) {
if (frm.doc.repairservicename.length > 140) {
frappe.throw(__("<b>Repair/ServiceName:</b> Only <b> 140 </b> characters are allowed"))
frappe.validate=false;
frappe.validated=false;
} else {
if (alphanum.test(frm.doc.repairservicename) === true) {
frappe.validated = false;
} else if (frm.doc.repairservicename) {
frappe.throw(__("<b>Repair/ServiceName:</b> Enter letter or alpha numeric characters only."));
frappe.validate=false;
frappe.validated=false;
}
}
} else {
frappe.throw(__("<b>Repair/ServiceName:</b> Single character not allowed"))
frappe.validate=true;
frappe.validated=false;
}
}
}

3
smart_service/phase_2/doctype/repair_service_master/repair_service_master.json

@ -46,12 +46,13 @@
{
"fieldname": "display_order",
"fieldtype": "Int",
"hidden": 1,
"label": "Display Order"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-07 15:55:31.517282",
"modified": "2023-08-14 17:47:39.860103",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Repair Service Master",

43
smart_service/phase_2/doctype/special_tool_information/special_tool_information.js

@ -25,6 +25,8 @@ frappe.ui.form.on('Special Tool Information', {
filters: {
display_order: frm.doc.display_order,
name: ["!=", frm.doc.name],
vehicle: frm.doc.vehicle,
}
}).then(records => {
if (records.length) {
@ -50,31 +52,28 @@ frappe.ui.form.on('Special Tool Information', {
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
frm.reload_doc()
}
},
});
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;
}
});
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.variant
}
})
.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;
}
});
}

6
smart_service/phase_2/doctype/special_tool_information/special_tool_information.json

@ -3,7 +3,7 @@
"_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{category}-",
"autoname": "format:{vehicle}-{category}-{sub_category}",
"creation": "2023-08-04 13:09:53.363093",
"doctype": "DocType",
"editable_grid": 1,
@ -23,6 +23,7 @@
"fieldname": "vehicle",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"options": "Vehicle",
"reqd": 1,
@ -32,6 +33,7 @@
"fieldname": "category",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Category",
"options": "New Tool\nCarry Over",
"set_only_once": 1
@ -76,7 +78,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-10 12:21:54.577165",
"modified": "2023-08-10 16:12:57.846488",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Information",

1
smart_service/phase_2/doctype/training_information_master/training_information_master.js

@ -19,7 +19,6 @@ function check_field_character(field_name) {
frappe.validated = false;
} else {
if (alphanum.test(field_name) === true) {
frappe.validated = true;
} else if (field_name) {
frappe.throw(__("<b>Training Information Master:</b> Enter letter or alpha numeric characters only."));
frappe.validated = false;

Loading…
Cancel
Save