File manager - Edit - /home/autoph/public_html/data03252025consolidation/dist/js/customer_update/activity_modal.js
Back
(function ($, undefined) { $.fn.getCursorPosition = function () { var el = $(this).get(0); var pos = 0; if ('selectionStart' in el) { pos = el.selectionStart; } else if ('selection' in document) { el.focus(); var Sel = document.selection.createRange(); var SelLength = document.selection.createRange().text.length; Sel.moveStart('character', -el.value.length); pos = Sel.text.length - SelLength; } return pos; } })(jQuery); const $customerActFrm = $('.customer-activity-form'); const $customerInsuranceActFrm = $('.customer-activity-close-deal-form'); function templateEvt() { $customerActFrm.find('.customer-activity-template').each(function () { $(this).on('click', function (e) { var position = $customerActFrm.find("[name=activity]").getCursorPosition() var content = $customerActFrm.find("[name=activity]").val(); var newContent = content.substr(0, position) + $(this).text()+ content.substr(position); $customerActFrm.find("[name=activity]").val(newContent); $customerActFrm.find("[name=activity]").trigger("focus"); }); }); } function closeDealEvt() { $customerActFrm.find('.btn-close-deal').on("click", function (e) { $('#modal-customer-activity').modal('hide'); $('#modal-customer-activity-close-deal').modal('show'); $('#modal-customer-activity-close-deal').off('hidden.bs.modal').on('hidden.bs.modal', function () { $('#modal-customer-activity').modal('show'); }); return false; Swal.fire({ icon: 'question', html: 'Are you sure you want to close the deal?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, showClass: { backdrop: "swal2-noanimation", // disable backdrop animation popup: "", // disable popup animation icon: "", // disable icon animation }, hideClass: { popup: "", // disable popup fade-out animation }, }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "/customer", method: "POST", dataType: 'json', data: { apiKey: '3695340036334748', customer_id: customer_record_id }, beforeSend: function () { sweetAlertSimple('info', 'Oops...', 'Removing customer...') }, success: function (result) { if (parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); var url = location_url + "customer.php"; window.location.href = url; } else { sweetAlertSimple('error', 'Oops...', result.message) } }, error: function () { sweetAlertSimple('error', 'Oops...', 'Error has been occurred, please try again.mmmm') } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }); }); } function activityFrmEvt() { $customerActFrm.on("submit",function (event) { var formData = new FormData(this); formData.append( "csrf_token", $("meta[name='csrf-token']").attr("content") ); formData.append("id", (typeof activity_id === 'undefined') ? "" : activity_id); formData.append("customer_id", (typeof customer_record_id === 'undefined') ? "" : customer_record_id); formData.append("vehicle_id", (typeof vehicle_record_id === 'undefined') ? "" : vehicle_record_id); $.ajax({ url: "/customer/activity/store", // url: url.store, type: "POST", data: formData, // timeout: 9000, processData: false, contentType: false, beforeSend: function () { $customerActFrm.find("button[type=submit]").prop("disabled", true); }, success: function (result) { $customerActFrm.find("button[type=submit]").prop("disabled", false); if (parseInt(result.status) === 1) { sweetAlertSimple('success', '', result.message); $customerActFrm.trigger("reset"); $('#modal-customer-activity').modal('hide'); } else { sweetAlertSimple('error', '', result.message) } }, error: function () { sweetAlertSimple('error', '', 'Error has occured.') $customerActFrm.find("button[type=submit]").prop("disabled", false); }, }); event.preventDefault(); }); } function activityInsuranceFrmEvt() { $customerInsuranceActFrm.on("submit",function (event) { var formData = new FormData(this); formData.append( "csrf_token", $("meta[name='csrf-token']").attr("content") ); formData.append("id", (typeof activity_insurance_id === 'undefined') ? "" : activity_insurance_id); formData.append("customer_id", (typeof customer_record_id === 'undefined') ? "" : customer_record_id); formData.append("vehicle_id", (typeof vehicle_record_id === 'undefined') ? "" : vehicle_record_id); $.ajax({ url: "/customer/activity/insurance/store", // url: url.store, type: "POST", data: formData, // timeout: 9000, processData: false, contentType: false, beforeSend: function () { $customerInsuranceActFrm.find("button[type=submit]").prop("disabled", true); }, success: function (result) { $customerInsuranceActFrm.find("button[type=submit]").prop("disabled", false); if (parseInt(result.status) === 1) { // alert("1") $customerInsuranceActFrm.trigger("reset"); $customerActFrm.trigger("reset"); $('#modal-customer-activity-close-deal').off('hidden.bs.modal'); $('#modal-customer-activity-close-deal').modal('hide'); sweetAlertSimple('success', '', result.message); } else { sweetAlertSimple('error', '', result.message) } }, error: function () { sweetAlertSimple('error', '', 'Error has occured.') $customerInsuranceActFrm.find("button[type=submit]").prop("disabled", false); }, }); event.preventDefault(); }); } function initDateFields() { $(".activity-date").datetimepicker({ format: "L", }); } function refreshTableActivities() { var $table = $('#activity-table') $table.bootstrapTable('destroy').bootstrapTable(); $(function() { $table.bootstrapTable('refresh', { url: 'app/table/customer_activity.php' }); }) } function queryParamsActivities(params) { return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, customer_id: ((typeof customer_record_id === 'undefined') ? "" : customer_record_id), vehicle_id: ((typeof vehicle_record_id === 'undefined') ? "" : vehicle_record_id), }; } $(function () { $('#datetimepicker2').datetimepicker({ format: 'DD/MM/YYYY' }); // alert(vehicle_record_id) if (typeof vehicle_record_id !== 'undefined') { if (vehicle_record_id) { // hide vehicle information $customerInsuranceActFrm.find(".activity-vehicle-info").hide(); // $customerInsuranceActFrm.find("[name=conduction_sticker]").hide(); } } initDateFields(); activityFrmEvt(); activityInsuranceFrmEvt(); templateEvt(); closeDealEvt(); });
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings