File manager - Edit - /home/autoph/public_html/connectv1/dist/js.bak/vehicle/vehicle_view1.js
Back
var vehicle_form = false; function fetchVehicleInfo(vehicle_id, customer_record_id) { $('#loader').show(); $('#vehicle-information').show(); readCustomerInformationMain(customer_record_id); // readVehicleProfileMain(vehicle_id); setVehicleTab(); } function back() { window.history.back(); } function setVehicleTab() { hideTabActionButton(); removeTabActive(); var selected_tab = ''; if(isEmpty($.cookie("vehicle_selected_tab"))) { //set default tab $.cookie("vehicle_selected_tab",'custom-tabs-three-home-tab') selected_tab = $.cookie("vehicle_selected_tab"); }else{ selected_tab = $.cookie("vehicle_selected_tab"); } //show tab and content $('#'+selected_tab).addClass('active') $('#'+selected_tab+'-content').addClass('active').addClass('show') switch (selected_tab) { case 'custom-tabs-three-home-tab': $('#vehicle-info-button').show(); break; case 'custom-tabs-three-gallery-tab': $('#vehicle-info-button').show(); readVehicleImage(vehicle_record_id); break; case 'custom-tabs-sales-tab': $('#vehicle-info-button').show(); readBrandsOfferedMain(vehicle_record_id); readVehicleSaleDetailsMain(vehicle_record_id); break; case 'custom-tabs-service-tab': refreshServiceDates(); break; } } function readVehicleImage(vehicle_id) { $.ajax({ url: "api/vehicle/vehiclev2.php", type: "POST", dataType: 'json', data: { apiKey: '1164288154587287', vehicle_id: vehicle_id }, beforeSend: function() {}, success: function(result) { // result.total $('#customer-sales-image-data').html(''); $('#customer-sales-image-data').append(result.vehicle_image); } }); } function refreshServiceDates() { var $table = $('#vehicle-service-dates-table') $table.bootstrapTable('destroy').bootstrapTable(); $(function() { $table.bootstrapTable('refresh', { url: 'app/table/service.php' }); }) } function readVehicleProfileMain(vehicle_id) { $.ajax({ url: "api/vehicle/vehiclev2.php", method: "POST", dataType: 'json', data: { apiKey: '5169873963910872', vehicle_id: vehicle_id }, beforeSend: function() { }, success: function(result) { var json = JSON.stringify(result); data = JSON.parse(json)[0]; var count_delay = 0; // alert(data['mod-dd-model-name']); // alert(data['mod-dd-color-name']) $.each(data, function(i, n) { var excemptedFields = ["main_corporation_name", "main_first_name", "main_middle_name", "main_last_name", "information_modified_by", "information_date_modified" ]; if (excemptedFields.indexOf(i) < 0) { //excempted list $("#" + i).css('color', '') if (isEmpty(n)) { $("#" + i).text('(Not Provided)'); $("#" + i).val('(Not Provided)'); $("#" + i).css('color', 'red') } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') $("#" + i).css('color', '007bff') } } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') } }); if(isEmpty(data['information_modified_by'])){ $("#information_modified_by_span").hide(); }else{ $("#information_modified_by_span").show(); } if(isEmpty(data['information_date_modified'])){ $("#information_date_modified_span").hide(); }else{ $("#information_date_modified_span").show(); } $('#loader').hide(); // $("#profileDisplay").attr("src", "dist/img/brand/" + data['profileDisplay']); // $("#profileDisplay_pop").attr("href", "dist/img/brand/" + data['profileDisplay']); }, error: function(xhr, status, error) { $('#loader').hide(); back(); sweetAlertSimple('error', 'Oops...', 'Error has occurred, Try again...'); // toastr.remove(); // toastr.error('Error has occurred, Try again...'); } }); } function readCustomerInformationMain(customer_record_id) { // alert(customer_record_id) new_customer_record_id = isEmpty(customer_record_id) ? '-1' : customer_record_id; $.ajax({ url: "api/vehicle/vehiclev2.php", method: "POST", dataType: 'json', data: { apiKey: '8361020315855100', customer_id: new_customer_record_id }, beforeSend: function() {}, success: function(result) { var json = JSON.stringify(result); // console.log(json); data = JSON.parse(json)[0]; $.each(data, function(i, n) { var excemptedFields = ["main_corporation_name", "main_first_name", "main_middle_name", "main_last_name", "information_modified_by", "information_date_modified" ]; if (excemptedFields.indexOf(i) < 0) { //excempted list $("#" + i).css('color', '') $("#sales_" + i).css('color', '') if (isEmpty(n)) { $("#" + i).text('(Not Provided)'); $("#" + i).val('(Not Provided)'); $("#" + i).css('color', 'red') $("#sales_" + i).text('(Not Provided)'); $("#sales_" + i).val('(Not Provided)'); $("#sales_" + i).css('color', 'red') } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') $("#" + i).css('color', '007bff') $("#sales_" + i).text(n); $("#sales_" + i).val(n); $("#sales_" + i).trigger('change') $("#sales_" + i).css('color', '007bff') } } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') $("#sales_" + i).text(n); $("#sales_" + i).val(n); $("#sales_" + i).trigger('change') } }); var image_name = 'default.png'; if (!isEmpty(data['photo'])) { image_name = data['photo']; } $("#profileDisplay").attr("src", "dist/img/customer/" + image_name); $("#profileDisplay_pop").attr("href", "dist/img/customer/" + image_name); $(".contact-click").attr("href", "tel:" + $('#main_customer_mobile').text()) $(".landline-click").attr("href", "tel:" + $('#main_customer_landline').text()) $(".contact2-click").attr("href", "tel:" + $('#main_customer_mobile_2').text()) $(".business-click").attr("href", "tel:" + $('#main_customer_business_mobile').text()) $(".residential-click").attr("href", "tel:" + $('#main_customer_home_mobile').text()) $(".viber-click").attr("href", "viber://chat?number=" + $('#main_viber').text()) $(".facebook-click").attr("href", "http://www.facebook.com/" + $('#main_facebook').text()) $(".instagram-click").attr("href", "http://instagram.com/_u/" + $('#main_instagram').text()) $(".whatsapp-click").attr("href", "https://wa.me/" + $('#main_whatsapp').text()) $(".telegram-click").attr("href", "https://t.me/" + $('#main_telegram').text()) $(".website-click").attr("href", "http://" + $('#main_website_link').text()) $(".email1-click").attr("href", "mailto:" + $('#main_email').text()) $(".email2-click").attr("href", "mailto:" + $('#main_customer_email_2').text()) $(".main_name_click").attr("href", "customer_view.php?q=" + new_customer_record_id) $(".main_name_click").click(function() { $.cookie("customer_selected_tab", 'custom-tabs-three-home-tab'); }); // $(".main_name_click").attr("href", "customer_view.php?q=" + new_customer_record_id) }, error: function(xhr, status, error) { $('#loader').hide(); back(); sweetAlertSimple('error', 'Oops...', 'Error has occurred, Try again...'); // toastr.remove(); // toastr.error('Error has occurred, Try again...'); } }); } function sweetAlertSimple(icon, title, text) { // Swal.fire({ // icon: icon, // title: title, // text: text, // allowEnterKey: true // default value // }) toastr.remove(); switch (icon) { case 'success': toastr.success(text); break; case 'info': toastr.info(text); break; case 'warning': toastr.warning(text); break; case 'error': toastr.error(text); break; } } function getASANameByASAID(objectId, asa_id) { $.ajax({ url: 'https://www.autohub.ph/connect/LOAD_SALES_PERSON.php', type: "POST", dataType: 'json', data: { uid: asa_id, apiKey: '3892635489643867' }, beforeSend: function() {}, success: function(result) { // alert(result.u_fname) var name = result['rows'][0].u_fname + ' ' + result['rows'][0].u_lname; // alert(name) var newOption = new Option(name, asa_id, true, true); $("#" + objectId).append(newOption).trigger('change'); } }); } function queryServiceDates(params) { return { search: '', offset: params.offset, limit: params.limit, vehicle_id: vehicle_record_id //other filters hehe }; } function isEmpty(string) { var flag = false; if (string == '') { flag = true; } else if (string == null) { flag = true; } else if (typeof string === 'undefined') { flag = true; } else { try{ if (string.trim() == '') { flag = true; } }catch(err){ return true; } } return flag; } function removeImage(id) { // alert(id); Swal.fire({ icon: 'warning', html: 'Do you want to remove this image?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { // toastr.remove(); $.ajax({ url: "api/vehicle/vehiclev2.php", method: "POST", data: { apiKey: '9434631886897744', id: id }, cache: false, beforeSend: function() { sweetAlertSimple('info', 'Oops...', 'Removing image...'); }, success: function(data) { // fetchVehicleInfo(vehicle_record_id, customer_record_id) readVehicleImage(vehicle_record_id); sweetAlertSimple('success', 'Oops...', 'Image remove successfully.'); } }) } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } function readVehicleSaleDetailsMain(vehicle_id) { $.ajax({ url: "api/sales/salesv2.php", method: "POST", dataType: 'json', data: { apiKey: '9718832291017422', vehicle_id: vehicle_id }, beforeSend: function() { }, success: function(result) { var json = JSON.stringify(result); // alert(JSON.parse(json).length) if (JSON.parse(json).length < 1) { $('#vehicle-sales-information').hide(); $('#sales-information-footer').hide(); $('#information-sale-brand-div').hide(); $('#information-sale-model-div').hide(); $('#information-sale-conduction-sticker-div').hide(); $('#information-sale-model-variant-div').hide(); $('#no-vehicle-sales-information').show(); $('#action-sales').val('Add Sales'); has_sales_record = false; return; } $('#vehicle-sales-information').show(); $('#sales-information-footer').hide(); $('#information-sale-brand-div').hide(); $('#information-sale-conduction-sticker-div').hide(); $('#information-sale-model-div').hide(); $('#information-sale-model-variant-div').hide(); $('#no-vehicle-sales-information').hide(); $('#action-sales').val('Update Sales'); has_sales_record = true; data = JSON.parse(json)[0]; var count_delay = 0; // alert(data['mod-dd-model-name']); // alert(data['mod-dd-color-name']) $.each(data, function(i, n) { // alert('') var excemptedFields = ["main_corporation_name", "main_first_name", "main_middle_name", "main_last_name", "information_modified_by", "information_date_modified" ]; if (excemptedFields.indexOf(i) < 0) { //excempted list $("#" + i).css('color', '') if (isEmpty(n)) { $("#" + i).text('(Not Provided)'); $("#" + i).val('(Not Provided)'); $("#" + i).css('color', 'red') } else { if (i == 'information-sale-price' || i == 'information-sale-cost' || i == 'information-sale-discount') { var currency_format = addCommas(n); $("#" + i).text(currency_format); $("#" + i).val(currency_format); $("#" + i).trigger('change') $("#" + i).css('color', '007bff') } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') $("#" + i).css('color', '007bff') } } } else { if (i == 'information-sale-price' || i == 'information-sale-cost' || i == 'information-sale-discount') { var currency_format = addCommas(n); $("#" + i).text(currency_format); $("#" + i).val(currency_format); $("#" + i).trigger('change') $("#" + i).css('color', '007bff') } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') } } }); // $("#sales_profileDisplay").attr("src", data['sales_profileDisplay']); // $("#sales_profileDisplay_pop").attr("href", data['sales_profileDisplay']); // $("#profileDisplay").attr("src", data['sales_profileDisplay']); // $("#profileDisplay_pop").attr("href", data['sales_profileDisplay']); } }); } function addCommas(numberString) { numberString += ''; var x = numberString.split('.'), x1 = x[0], x2 = x.length > 1 ? '.' + x[1] : '', rgxp = /(\d+)(\d{3})/; while (rgxp.test(x1)) { x1 = x1.replace(rgxp, '$1' + ',' + '$2'); } return x1 + x2; } function readBrandsOfferedMain(vehicle_id) { $.ajax({ url: "api/sales/salesv2.php", method: "POST", dataType: 'json', data: { apiKey: '5339702066391571', vehicle_id: vehicle_id }, beforeSend: function() { }, success: function(result) { var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; $('#information_vehicle_offered_list').empty() $("#information_vehicle_offered_list").append( '<li class="list-group-item lbl-forms-sm-customer-main"><strong>Future Vehicle List</strong></li>' ); if (obj.length > 0) { $('#information_vehicle_offered_div').show(); } else { $('#information_vehicle_offered_div').hide(); } var count_delay = 0; $.each(obj, function(key, value) { setTimeout(function() { $("#information_vehicle_offered_list").append(` <li class="list-group-item lbl-forms-sm-customer-main"> <div class="row"> <div class="col-sm-3"><strong>Brand:</strong> ` + value.brand_name + ` </div> <div class="col-sm-3"><strong>Model:</strong> ` + value.model_name + ` </div> <div class="col-sm-6"><strong>Description:</strong> ` + value.description + ` </div> </div> </li> `); }, count_delay * 250); count_delay++; }); } }); } function checkIfEmpty(value, row, index) { // alert(value) //if((value != null && value.trim() == "") || value == "-"){ if (value == null || (value.trim() == "" || value == "-")) { return "<span style='color:red;'> (Not Provided) </span>"; } return value; } function removeTabActive() { $('.vehicle-tab').removeClass('active') $('.vehicle-tab-content').removeClass('active').removeClass('show') } function hideTabActionButton() { $('#vehicle-info-button').hide(); $('#action-sales-div').hide(); } function initVehicleSection() { if (!vehicle_form) { vehicle_form = true; $.ajax({ url: 'include/components/customer/modal/vehicle_form.php', type: 'post', beforeSend: function() { $('#customer-vehicle-button').attr('disabled', true); }, success: function(data) { $('#vehicle_form').html(data); $.ajax({ url: 'dist/js/vehicle/vehicle_form.js', type: 'post', success: function(data) { $('#customer-vehicle-button').attr('disabled', false); initVehicle(); }, error: function() { $('#vehicle_form').text('An error occurred'); } }); }, error: function() { $('#vehicle_form').text('An error occurred'); } }); } else { // $('#modal-vehicle').modal('show'); initUpdateVehicle(); } } function readBrandsOffered(vehicle_id) { $.ajax({ url: "api/sales/salesv2.php", method: "POST", dataType: 'json', data: { apiKey: '5339702066391571', vehicle_id: vehicle_id }, beforeSend: function() { }, success: function(result) { // alert(JSON.stringify(result)); var obj = jQuery.parseJSON(JSON.stringify(result)); var index = 0; // if (obj.length > 0) { // $('#intereset_hobbies_div').click(); // } $.each(obj, function(key, value) { // alert(value.brand_id) var brandsOfferedItem = addBrandsOfferedItem(); // let $elementBrandsOfferedBrand = $('#' + brandsOfferedItem[0]); // $elementBrandsOfferedBrand.val(value.brand_id).trigger('change'); if (parseInt(value.brand_id) != 0) { let $elementBrandsOfferedBrand = $('#' + brandsOfferedItem[0]); var newBrandsOfferedModel = new Option(value.brand_name, value .brand_id, true, true) $elementBrandsOfferedBrand.append(newBrandsOfferedModel).trigger('change'); } if (parseInt(value.model_id) != 0) { let $elementBrandsOfferedModel = $('#' + brandsOfferedItem[1]); var newBrandsOfferedModel = new Option(value.model_name, value .model_id, true, true) $elementBrandsOfferedModel.append(newBrandsOfferedModel).trigger('change'); } let $elementBrandsOfferedDescription = $('#' + brandsOfferedItem[2]); $elementBrandsOfferedDescription.val(value.description); }); } }); } function readVehicleSaleDetails(vehicle_id) { $.ajax({ url: "api/sales/salesv2.php", method: "POST", dataType: 'json', data: { apiKey: '4045810733767125', vehicle_id: vehicle_id }, beforeSend: function() { }, success: function(result) { // $('.vehicle-modal-overlay').hide(); var json = JSON.stringify(result); if (JSON.parse(json).length < 1) { $('#has_sales_record_div').show(); return; } $('#div-order-number').show(); $('#sales-info-1').show(); $('#sales-info-2').show(); $('#insurace-finance-section').show(); $('#vehicle-offered-section').show(); $('#has-sales-record').val('1'); $('#has_sales_record').prop('checked', true); $('#has_sales_record_div').hide(); data = JSON.parse(json)[0]; $.each(data, function(i, n) { if (i == 'mod-dd-group-manager' && n != 0) { var newOption = new Option(data['mod-dd-group-manager-name'], n, true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-dd-sales-consultant' && n != 0) { var newOption = new Option(data['mod-dd-sales-consultant-name'], n, true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-customer-number') { // var newOption = new Option(data['mod-dd-sales-consultant-name'], n, true, // true); // $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-dd-group-manager-asa' && n != 0) { getASANameByASAID('mod-dd-group-manager-asa', n); // var newOption = new Option(getASANameByASAID(n), n, true, // true); // $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-dd-sales-consultant-asa' && n != 0) { getASANameByASAID('mod-dd-sales-consultant-asa', n); // var newOption = new Option(getASANameByASAID(n), n, true, // true); // $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-dd-insurance-company' && n != 0) { var newOption = new Option(data['mod-dd-insurance-company-name'], data[ 'mod-dd-insurance-company-name'], true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-dd-finance-company' && n != 0) { var newOption = new Option(data['mod-dd-finance-company-name'], data[ 'mod-dd-finance-company-name'], true, true); $("#" + i).append(newOption).trigger('change'); } else { $("#" + i).val(n); $("#" + i).trigger('change') } }); } }); } function readVehicleProfile(vehicle_id) { $.ajax({ url: "api/vehicle/vehiclev2.php", method: "POST", dataType: 'json', data: { apiKey: '4785226316746539', vehicle_id: vehicle_id }, beforeSend: function() { $('#proceed-button-vehicle').attr('disabled', true); $('.vehicle-modal-overlay').show(); }, success: function(result) { var json = JSON.stringify(result); data = JSON.parse(json)[0]; var count_delay = 0; // alert(data['mod-dd-model-name']); // alert(data['mod-dd-color-name']) $.each(data, function(i, n) { // setTimeout(function() { if (i == 'mod-dd-color' && n != 0) { var newOption = new Option(data['mod-dd-color-name'], data[ 'mod-dd-color-name'], true, true); $("#" + i).append(newOption).trigger('change'); } else if (i == 'mod-dd-model-variant' && n != 0) { // alert(n); var newOption = new Option(data['mod-dd-model-variant-name'], data[ 'mod-dd-model-variant-name'], true, true); $("#" + i).append(newOption).trigger('change'); } else { $("#" + i).val(n); $("#" + i).trigger('change') } // }, count_delay * 25); count_delay++; }); // alert(data['mod-dd-model']) if (!isEmpty(data['mod-customer-number-name'] || parseInt(data['mod-customer-number']) === 0)) { var newOptionCustomer = new Option(data['mod-customer-number-name'], data[ 'mod-customer-number'], true, true); $("#mod-customer-number").append(newOptionCustomer).trigger('change'); } if (!(isEmpty(data['mod-dd-model-name']) || parseInt(data['mod-dd-model']) == 0)) { var newOptionModel = new Option(data['mod-dd-model-name'], data['mod-dd-model'], true, true); $("#mod-dd-model").append(newOptionModel).trigger('change'); } // var newOptionDMS = new Option(data['mod-dd-dms-name'], data['mod-dd-dms'], true, // true); // $("#mod-dd-dms").append(newOptionDMS).trigger('change'); var newOptionCompany = new Option(data['mod-dd-company-name'], data['mod-dd-company'], true, true); $("#mod-dd-company").append(newOptionCompany).trigger('change'); var newOptionDealer = new Option(data['mod-dd-dealer-name'], data['mod-dd-dealer'], true, true); $("#mod-dd-dealer").append(newOptionDealer).trigger('change'); $('.vehicle-modal-overlay').hide(); $('#proceed-button-vehicle').attr('disabled', false); } }); } function removeVehicle(vehicle_record_id){ Swal.fire({ icon: 'question', html: 'Are you sure you want to remove this vehicle?<br>Sales and service record of this vehicle will be removed also.', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "api/vehicle/vehiclev2.php", method: "POST", dataType: 'json', data: { apiKey: '4026781185955988', vehicle_id: vehicle_record_id }, beforeSend: function() { sweetAlertSimple('info', 'Oops...', 'Removing vehicle...') }, success: function(result) { if(parseInt(result.status) === 1) { sweetAlertSimple('success', 'Nice...', result.message); var url = location_url+"vehicle.php"; window.location.href = url; }else{ sweetAlertSimple('error', 'Oops...', result.message) } }, error: function() { sweetAlertSimple('error', 'Oops...', 'Error has been occurred, please try again.') } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $(document).ready(function(){ fetchVehicleInfo(vehicle_record_id, customer_record_id) $('.vehicle-tab').on('click',function(event){ console.log(this.id); $.cookie("vehicle_selected_tab", this.id); setVehicleTab(); }); $(document).on('click', '[data-toggle="lightbox"]', function(event) { event.preventDefault(); $(this).ekkoLightbox({ alwaysShowClose: true }); }); $('#customer-vehicle-button').click(function() { initVehicleSection(); }) $('#vehicle_delete_action').click(function() { removeVehicle(vehicle_record_id) }) });
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.1 |
proxy
|
phpinfo
|
Settings