var view_order = { div_order_collect: "div_order_collect", collect: { init: function () { $('.selectpicker').selectpicker(); shared.CreateControl.DatePicker('.datetimepicker'); view_order.share.change_active_date(); // shared.CreateControl.BirthdayPicker("#txt_buyer_birthday"); var minDate = new Date(this.year - 100, this.month, this.day); shared.CreateControl.DateBOD('#txt_buyer_birthday', minDate, new Date()); $('#txt_buyer_birthday').val(""); $(".input_string_number").blur(function () { shared.Other.onlyGetNumber("#" + this.id); }); $(".input_number").blur(function () { shared.Other.onlyGetNumber("#" + this.id); Format.FormatNumberCurrency("#" + this.id); }); $(".input_string").blur(function () { $("#" + this.id).val($("#" + this.id).val().replaceAll(" ", "")) }); shared.ViewFunc.LoadValueSelectFirst('#drl_kind_customer'); shared.ViewFunc.LoadValueSelectFirst('#drl_year_buy'); view_order.collect.payment_init(); }, payment_init: function () { let dd_root = $('#e2d5d9944a3a'); dd_root.find('[name=payment-type]').change(function () { console.log($(this).val()) dd_root.find('.e2d5d9944a3a-input-2').toggleClass('d-none'); }); }, change_city: function (_city_control_id, _district_control_id) { shared.ViewFunc.SelectPicker_Single_Remove_Option(_district_control_id); var dd = { root_id: $("#" + _city_control_id).val() }; dd = API.CreateDataSend('base/load/district', dd); API.POST(dd, function (e) { Loading.Hide(); var dd_json = JSON.parse(e); shared.ViewFunc.SelectPickerAddOption(dd_json, "2", _district_control_id); }); }, //save: function () { // var dd = shared.GetInput.Div(view_order.div_order_collect); // dd = API.CreateDataSend('sale/order/collect/save', dd); // API.POST(dd, function (data) { // $('#div_order').html(data); // shared.ViewFunc.ScrollId('#' + view_order.div_order_collect); // Loading.Hide(); // }); //}, save: function () { var dd = shared.GetInput.Div(view_order.div_order_collect); dd = API.CreateDataSend('sale/order/collect/save', dd); API.POST(dd, function (e) { view_order.collect.file(e); }); }, load_final: function () { let dd = shared.GetInput.Div('div_add_document'); dd = API.CreateDataSend('sale/order/collect/final', dd); API.POST(dd, function (e) { $('#div_order').html(e); shared.ViewFunc.ScrollId('#' + view_order.div_order_collect); Loading.Hide(); }); }, file: function (_order_id) { $('#hdf_order_id').val(_order_id); let dd = shared.GetInput.Div('div_add_document'); dd = API.CreateDataSend('sale/order/collect/document', dd); API.POST(dd, function (e) { let total_file = parseInt($('#hdf_total_file').val()); view_order.collect.add_submit_file(1, total_file, _order_id, e); }); }, add_submit_file: function (_index, _total_file, _order_id, _parent_id) { if (_index > _total_file) { view_order.collect.load_final(_order_id); return; } let dd = shared.GetInput.Div('div_add_document'); dd.edit_file_name = $('#edit_file_name' + _index).val(); dd.file_kind = $('#file_kind' + _index).val(); dd.file_kind_name = $('#file_kind' + _index + ' option:selected').text(); dd.parent_id = _parent_id; dd.upload_file_data = $('#hdf_upload_file_data' + _index).val(); dd.upload_file_type = $('#hdf_upload_file_type' + _index).val(); dd.upload_file_name = $('#hdf_upload_file_name' + _index).val(); dd = API.CreateDataSend('sale/order/collect/add/file', dd); API.POST(dd, function (e) { view_order.collect.add_submit_file(_index + 1, _total_file, e, _parent_id); }); } }, receive: { show: function (_cer, _order_id) { func_notification.YesNo("Tiếp nhận hợp đồng số: " + _cer, "Xác nhận", function (e) { if (e) { let dd = { order_id: _order_id }; dd = API.CreateDataSend('sale/order/receive', dd); API.POST(dd, function (e) { func_notification.Success(e); view_order.report.item(_order_id); Loading.Hide(); }); } }); } }, release: { init: function () { $('.selectpicker').selectpicker(); shared.CreateControl.BirthdayPicker('.release-timepicker'); shared.DateTimeFunc.loadValueByClass('datetimepicker'); shared.ViewFunc.LoadValueSelect(); $(".input_number").blur(function () { shared.Other.onlyGetNumber("#" + this.id); Format.FormatNumberCurrency("#" + this.id); }); $(".input_string_number").blur(function () { shared.Other.onlyGetNumber("#" + this.id); }); $(".input_string").blur(function () { $("#" + this.id).val($("#" + this.id).val().replaceAll(" ", "")) }); }, show: function (_order_id) { //$('#hdf_order_id').val(_order_id); //shared.ModalFunc.ModalShow('div_sale_release'); //view_order.release.init(); let dd = API.CreateDataSend('sale/order/release/show', { order_id: _order_id }); API.POST(dd, function (e) { $('#div_contain_sale_release').html(e); shared.ModalFunc.ModalShow('div_sale_release'); //view_order.release.init(); Loading.Hide(); }); }, check_core: function () { var dd = shared.GetInput.Div('div_sale_release'); dd = API.CreateDataSend('sale/order/release/check/core', dd); API.POST(dd, function (e) { $('#div_sale_release_body').html(''); $('#div_sale_release_body').html(e); //view_order.release.init(); Loading.Hide(); }); }, save: function (_callback) { var dd = shared.GetInput.Div('div_sale_release'); dd = API.CreateDataSend('sale/order/release/save', dd); API.POST(dd, function (e) { Loading.Hide(); if (_callback != null) _callback(e); else { shared.ModalFunc.ModalHide('div_sale_release'); view_order.report.item(e); } }); }, cancel: function () { shared.ModalFunc.ModalHide('div_sale_release'); /*$('#div_contain_sale_release').html("");*/ }, charge_premium: function (_index) { //debugger var premium_amount = 0; var premium_payment = 0; var premium_compulsory = 0; var premium_voluntary = 0; var premium_pre_tax = 0; var premium_tax = premium_tax = Number($('txt_premium_tax').val());; if (_index == 1) { premium_compulsory = Number($('txt_premium_compulsory').val()); premium_voluntary = Number($('txt_premium_voluntary').val()); premium_amount = premium_compulsory + premium_voluntary; $('txt_premium_pre_tax').val(Format.FormatNumberCurrencyNoUnit(premium_amount - premium_tax)); } else { premium_pre_tax = Number($('txt_premium_pre_tax').val()); premium_amount = premium_pre_tax + premium_tax; } var premium_discount = Number($('txt_premium_discount').val()); premium_payment = premium_amount - premium_discount; $('txt_premium_amount').val(Format.FormatNumberCurrencyNoUnit(premium_amount)); $('txt_premium_payment').val(Format.FormatNumberCurrencyNoUnit(premium_payment)); } }, report: { init: function () { $('.selectpicker').selectpicker(); let date = new Date(); let startDate = new Date(date.getFullYear(), date.getMonth(), 1); let endDate = new Date(date.getFullYear(), date.getMonth() + 1, 0); shared.CreateControl.DateSearchPicker("#txt_from_date", startDate); shared.CreateControl.DateSearchPicker("#txt_to_date", endDate); $(".input_string_number").blur(function () { shared.Other.onlyGetNumber("#" + this.id); }); $(".input_string").blur(function () { $("#" + this.id).val($("#" + this.id).val().replaceAll(" ", "")) }); }, list: function () { $('#tab_report a[href="#div_list"]').tab('show'); $('#div_detail').html(''); let dd = shared.GetInput.Div('div_filter_report'); dd = API.CreateDataSend('sale/order/report/list', dd); API.POST(dd, function (e) { $('#div_list').html(e); shared.CreateControl.DataTable.Render('#tbl_order_list'); Loading.Hide(); }); }, item: function (_order_id) { $('#tab_report a:last').tab('show'); $('#div_detail').html(''); let dd = { order_id: _order_id }; dd = API.CreateDataSend('sale/order/report/item', dd); API.POST(dd, function (e) { $('#div_detail').html(e); Loading.Hide(); }); }, document_init: function () { shared.CreateControl.DataTable.Render('#tbl_document_list'); }, }, register: { record: function (_order_id) { let dd = API.CreateDataSend('sale/order/register/record', { order_id: _order_id }); API.POST(dd, function (e) { view_order.report.item(e); }); } }, payment: { active_show: function (_certificate_code, _order_id) { let dd = { certificate_code: _certificate_code, order_id: _order_id }; dd = API.CreateDataSend('sale/order/payment/active/show', dd); API.POST(dd, function (e) { $('#div_contain_active_payment').html(e); shared.ModalFunc.ModalShow('div_confirm_active_payment'); $('.selectpicker').selectpicker(); shared.ViewFunc.LoadValueSelectFirst('#drl_update_active_date'); Loading.Hide(); }); }, active_complete: function () { let dd = shared.GetInput.Div('div_confirm_active_payment'); dd = API.CreateDataSend('sale/order/payment/active/complete', dd); API.POST(dd, function () { Loading.Hide(); shared.ModalFunc.ModalHide('div_confirm_active_payment'); let order_id = $('#hdf_order_id').val(); view_order.report.item(order_id); }); }, active_cancel: function () { shared.ModalFunc.ModalHide('div_confirm_active_payment'); $('#div_contain_active_payment').html(""); }, approval_show: function (_order_id) { let dd = API.CreateDataSend('sale/order/payment/approval/show', { order_id: _order_id }); API.POST(dd, function (e) { $('#div_contain_approval_payment').html(e); shared.ModalFunc.ModalShow('div_confirm_approval_payment'); let date = new Date(); let startDate = new Date(date.getFullYear(), date.getMonth(), 1); shared.CreateControl.DateSearchPicker("#txt_transfer_date", startDate); $('.selectpicker').selectpicker(); shared.ViewFunc.LoadValueSelectFirst('#drl_update_active_date'); Loading.Hide(); }); }, approval_cancel: function () { shared.ModalFunc.ModalHide('div_confirm_approval_payment'); $('#div_contain_approval_payment').html(""); }, approval_complete: function () { let dd = shared.GetInput.Div('div_confirm_approval_payment'); dd = API.CreateDataSend('sale/order/payment/approval/complete', dd); API.POST(dd, function (e) { let total_file = parseInt($('#hdf_total_file').val()); view_order.payment.approval_submit_file(1, total_file, e); Loading.Hide(); }); }, approval_submit_file: function (_index, _total_file, _parent_id) { if (_index > _total_file) { func_notification.Success("Tạo lệnh thanh toán thành công"); shared.ModalFunc.ModalHide('div_confirm_approval_payment'); view_order.report.list(); Loading.Hide(); return; } let dd = shared.GetInput.Div('div_confirm_approval_payment'); dd.document_kind_name = $('#document_kind').text(); dd.upload_file_data = $('#hdf_upload_file_data' + _index).val(); dd.upload_file_type = $('#hdf_upload_file_type' + _index).val(); dd.upload_file_name = $('#hdf_upload_file_name' + _index).val(); dd.parent_id = _parent_id; this.submit_file(dd, function () { view_order.payment.approval_submit_file(_index + 1, _total_file, _parent_id); }); //dd = API.CreateDataSend('sale/order/payment/approval/file', dd); //API.POST(dd, function () { // view_order.payment.approval_submit_file(_index + 1, _total_file, _parent_id); //}); }, submit_file: function (_inputs, _callback) { let dd = API.CreateDataSend('sale/order/payment/approval/file', _inputs); API.POST(dd, function (e) { _callback(e); }); }, test_update_core: function (_order_id) { let dd = API.CreateDataSend('sale/order/payment/test/update/core', { order_id: _order_id }); API.POST(dd, function (e) { func_notification.Success(e); Loading.Hide(); }); } }, appraisal: { change_email: function () { if ($('#chk_send_email').is(":checked")) { $("#div_contain_email_content").removeClass("d-none"); } else { $("#div_contain_email_content").addClass("d-none"); } }, show: function (_cer, _order_id) { $("#sp_certificate_code").text(_cer); $("#hdf_order_approval_appraisal").val(_order_id); shared.ModalFunc.ModalShow('div_confirm_approval_appraisal'); $('.selectpicker').selectpicker(); }, approval: function () { var dd = shared.GetInput.Div('div_confirm_approval_appraisal'); dd.kind_action_name = $("#drl_kind_action option:selected").text(); dd = API.CreateDataSend('sale/order/appraisal/approval/complete', dd); API.POST(dd, function (e) { Loading.Hide(); shared.ModalFunc.ModalHide('div_confirm_approval_appraisal'); view_order.report.item(e); }); }, }, remove: { vab_show: function (_cer, _order_id) { func_notification.YesNo("Xoá hợp đồng: " + _cer, "Xác nhận", function (e) { if (e) { let dd = { order_id: _order_id }; dd = API.CreateDataSend('sale/order/vab/remove', dd); API.POST(dd, function (e) { func_notification.Success(e); view_order.report.list(); Loading.Hide(); }); } }); }, bhv_show: function (_cer, _order_id) { func_notification.YesNo("Xoá hợp đồng: " + _cer, "Xác nhận", function (e) { if (e) { let dd = { order_id: _order_id }; dd = API.CreateDataSend('sale/order/bhv/remove', dd); API.POST(dd, function (e) { func_notification.Success(e); view_order.report.list(); Loading.Hide(); }); } }); }, document: function (_order_map_id) { func_notification.YesNo("Xoá tập tin", "Xác nhận", function (e) { if (e) { let dd = { order_map_id: _order_map_id }; dd = API.CreateDataSend('sale/order/document/remove', dd); API.POST(dd, function (e) { Loading.Hide(); view_order.report.item(e); }); } }); }, }, document: { approval_show: function (_cer, _order_id) { func_notification.YesNo("Duyệt hồ sơ hợp đồng: " + _cer, "Xác nhận", function (e) { if (e) { let dd = { order_id: _order_id }; dd = API.CreateDataSend('sale/order/document/approval/complete', dd); API.POST(dd, function () { view_order.report.item(_reg); }); } }); }, add_show: function (_order_id) { let dd = API.CreateDataSend('sale/order/document/add/show', { order_id: _order_id }); API.POST(dd, function (e) { $('#div_contain_add_document').html(e); shared.ModalFunc.ModalShow('div_add_document'); $('.selectpicker').selectpicker(); Loading.Hide(); }); }, add_complete: function () { let dd = shared.GetInput.Div('div_add_document'); dd = API.CreateDataSend('sale/order/document/add/complete', dd); API.POST(dd, function (e) { let total_file = parseInt($('#hdf_total_file').val()); let order_id = $('#hdf_order_id').val(); view_order.document.add_submit_file(1, total_file, order_id, e); }); }, add_submit_file: function (_index, _total_file, _order_id, _parent_id) { if (_index > _total_file) { func_notification.Success("Thêm hồ sơ thành công"); shared.ModalFunc.ModalHide('div_add_document'); view_order.report.item(_order_id); return; } let dd = shared.GetInput.Div('div_add_document'); dd.edit_file_name = $('#edit_file_name' + _index).val(); dd.file_kind = $('#file_kind' + _index).val(); dd.file_kind_name = $('#file_kind' + _index + ' option:selected').text(); dd.parent_id = _parent_id; dd.upload_file_data = $('#hdf_upload_file_data' + _index).val(); dd.upload_file_type = $('#hdf_upload_file_type' + _index).val(); dd.upload_file_name = $('#hdf_upload_file_name' + _index).val(); this.submit_file(dd, function (e) { view_order.document.add_submit_file(_index + 1, _total_file, e, _parent_id); }); //dd = API.CreateDataSend('sale/order/document/add/file', dd); //API.POST(dd, function (e) { // view_order.document.add_submit_file(_index + 1, _total_file, e, _parent_id); //}); }, submit_file: function (_inputs, _callback) { let dd = API.CreateDataSend('sale/order/document/add/file', _inputs); API.POST(dd, function (e) { _callback(e); }); }, add_more_file: function () { let total_file = parseInt($('#hdf_total_file').val()) + 1; let upload_file = ''; upload_file += '
  • '; upload_file += '
    '; upload_file += '
    '; upload_file += ''; upload_file += ''; upload_file += '
    '; upload_file += '
    '; upload_file += ''; upload_file += ''; upload_file += '
    '; upload_file += '
    '; upload_file += '
    '; upload_file += '
    '; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += '
    '; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += '
    '; upload_file += '
    '; upload_file += '
    '; upload_file += '
  • '; $("#list_group_control").append(upload_file); $('#hdf_total_file').val(total_file); $('.selectpicker').selectpicker(); }, remove_file: function (_index) { $("#item_group_control" + _index).remove(); }, cancel: function () { shared.ModalFunc.ModalHide('div_add_document'); $('#div_contain_add_document').html(""); }, }, share: { change_active_date: function (_id) { if (_id == null) _id = ""; var date = shared.DateTimeFunc.stringToDate($("#active_date" + _id).val(), "dd/MM/yyyy"); var year_buy = parseInt($("#drl_year_buy option:selected").text()); date = shared.DateTimeFunc.date_add_year(date, year_buy); $("#inactive_date" + _id).val(shared.DateTimeFunc.convertDatetoString(date)); //shared.DateTimeFunc.control_input_lock('#inactive_date' + _id, true); }, }, file: { add_more_file: function () { let total_file = parseInt($('#hdf_total_file').val()) + 1; let upload_file = ''; upload_file += '
    '; upload_file += '
    '; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += '
    '; upload_file += ''; upload_file += ''; upload_file += ''; upload_file += '
    '; $("#upload_file").append(upload_file); $('#hdf_total_file').val(total_file); }, upload_file: function (_this, _index) { let fileSize = _this.files[0].size / 1024 / 1024; // in MB if (fileSize > 5) { func_notification.Info('Tập tin không được quá 5 MB'); } else { let fileName = $(_this).val().split("\\").pop(); $(_this).siblings("#custom-file-label" + _index).addClass("selected").html(fileName); shared.File.FiletoBase64(_this, function (e, t, n) { $('#hdf_upload_file_data' + _index).val(e); $('#hdf_upload_file_type' + _index).val(t); $('#hdf_upload_file_name' + _index).val(n); }) } }, remove: function (_index) { $("#custom_file" + _index).remove(); }, }, certificate: { open: function (_certificate_code, _order_id) { shared.ModalFunc.ModalShow('div_confirm_add_certificate'); }, upload_file: function (_this) { let fileSize = _this.files[0].size / 1024 / 1024; // in MB if (fileSize > 5) { func_notification.Info('Tập tin không được quá 5 MB'); } else { let fileName = $(_this).val().split("\\").pop(); $(_this).siblings("#custom-file-label").addClass("selected").html(fileName); shared.File.FiletoBase64(_this, function (e, t, n) { $('#hdf_upload_file_data').val(e); $('#hdf_upload_file_type').val(t); $('#hdf_upload_file_name').val(n); }) } }, save: function () { let dd = shared.GetInput.Div('div_confirm_add_certificate'); dd = API.CreateDataSend('sale/order/certificate/save', dd); API.POST(dd, function (e) { shared.ModalFunc.ModalHide('div_confirm_add_certificate'); view_order.report.item(e); Loading.Hide(); }); }, display: function () { var pay_status = $("#hdf_pay_status").val(); if (shared.Valid.String(pay_status)) { var cer_path = $("#hdf_cer_path").val(); shared.Other.ChangeUrlPath(cer_path); } else { func_notification.Error('Vui lòng thanh toán trước khi xem giấy chứng nhận!'); } } }, };