File manager - Edit - /home/autoph/public_html/data03252025consolidation/resources/views/common/scripts/car_club.php
Back
<script> function common() { document.getElementById("dropdown-filter").addEventListener('click', function(event) { event.stopPropagation(); }); } function carClubNameEvt() { var xhr = null; $('#txt_name').autoComplete({ resolver: 'custom', noResultsText: '', events: { search: function(qry, callback) { // let's do a custom ajax call if (xhr != null) { //kill the request xhr.abort() } xhr = $.ajax( '/api/car_club/car_club.php', { data: { 'search': qry, offset: 0, limit: 10, 'apiKey': '81c753aa8afe11eca54300ff70631b9a' } } ).done(function(res) { // console.log(res) results = JSON.parse(res) // console.log(results.rows); callback(results.rows) }); } } }); $('#txt_name').on('autocomplete.select', function(evt, item) { $('#txt_name_id').val(item.id); }); $("#txt_name").on("keyup change", function(e) { $("#txt_name_id").val(''); }) } function assignedPersonEvt() { var xhr = null; $('#txt_assigned_person').autoComplete({ resolver: 'custom', noResultsText: '', events: { search: function(qry, callback) { // let's do a custom ajax call if (xhr != null) { //kill the request xhr.abort() } xhr = $.ajax( '/api/car_club/car_club.php', { data: { 'search': qry, offset: 0, limit: 10, 'apiKey': '4958c8c78b0811eca54300ff70631b9a' } } ).done(function(res) { // console.log(res) results = JSON.parse(res) // console.log(results.rows); callback(results.rows) }); } } }); $('#txt_assigned_person').on('autocomplete.select', function(evt, item) { $('#txt_assigned_person_id').val(item.id); }); $("#txt_assigned_person").on("keyup change", function(e) { $("#txt_assigned_person_id").val(''); }) } function officerPosEvt($el) { var xhr = null; $el.autoComplete({ resolver: 'custom', noResultsText: '', events: { search: function(qry, callback) { // let's do a custom ajax call if (xhr != null) { //kill the request xhr.abort() } xhr = $.ajax( '/api/car_club/car_club.php', { data: { 'search': qry, offset: 0, limit: 5, 'apiKey': '0e2858e48b1211eca54300ff70631b9a' } } ).done(function(res) { // console.log(res) results = JSON.parse(res) // console.log(results.rows); callback(results.rows) }); } } }); $el.on('autocomplete.select', function(evt, item) { // $('#txt_name_id').val(item.id); }); $el.on("keyup change", function(e) { // $("#txt_name_id").val(''); }) } function initSelect2Element() { $("#dd_brand").select2({ tags: true, // minimumResultsForSearch: -1, placeholder: "All", allowClear: true, escapeMarkup: function(markup) { return markup; }, ajax: { url: '/api/brand/brand.php', dataType: 'json', delay: 250, data: function(data) { return { apiKey: '6019050878857324', search: data.term // search term }; }, processResults: function(response) { return { results: response }; }, cache: true } }); $('#dd_club_status').select2({ minimumResultsForSearch: -1 }); $('#dd_member_status').select2({ minimumResultsForSearch: -1 }); $('#dd_model').select2({ placeholder: "All", minimumResultsForSearch: -1, language: { noResults: function() { return 'Select brand first' } } }); $('#dd_brand').on('select2:select select2:unselecting change', function(e) { $('#dd_model').val('').trigger('change'); // $('#dd_model').select2('destroy'); $('#dd_model').val(null).empty().trigger('change').select2('destroy') if (isEmpty($('#dd_brand').val())) { $('#dd_model').select2({ placeholder: "All", minimumResultsForSearch: -1, language: { noResults: function() { return 'Select brand first' } } }); } else { $("#dd_model").select2({ tags: true, placeholder: "All", allowClear: true, "language": { "noResults": function() { return 'Select brand first' } }, escapeMarkup: function(markup) { return markup; }, ajax: { url: '/api/model/model.php', dataType: 'json', delay: 250, data: function(data) { return { brand_id: $("#dd_brand").val(), apiKey: '8732194955663346', search: data.term // search term }; }, processResults: function(response) { return { results: response }; }, cache: true } }); } }); $('#filter_club_status').select2({ placeholder: "Status (All)", minimumResultsForSearch: -1, allowClear: true }); $('#filter_member_status').select2({ placeholder: "Member Status (All)", minimumResultsForSearch: -1, allowClear: true }); $("#filter_brand").select2({ // tags: true, minimumResultsForSearch: -1, placeholder: "Brand (All)", allowClear: true, escapeMarkup: function(markup) { return markup; }, ajax: { url: '/api/brand/brand.php', dataType: 'json', delay: 250, data: function(data) { return { apiKey: '6019050878857325', search: data.term // search term }; }, processResults: function(response) { return { results: response }; }, cache: true } }); $('#filter_brand').on('select2:select select2:unselecting change', function(e) { $('#filter_model').val('').trigger('change'); $('#filter_model').val(null).empty().trigger('change').select2('destroy') if (isEmpty($('#filter_brand').val())) { $('#filter_model').select2({ placeholder: "Model (All)", minimumResultsForSearch: -1, language: { noResults: function() { return 'Select brand first' } } }); } else { $("#filter_model").select2({ // tags: true, placeholder: "Model (All)", minimumResultsForSearch: -1, allowClear: true, "language": { "noResults": function() { return 'Select brand first' } }, escapeMarkup: function(markup) { return markup; }, ajax: { url: '/api/model/model.php', dataType: 'json', delay: 250, data: function(data) { return { brand_id: $("#filter_brand").val(), apiKey: '8732194955663346', search: data.term // search term }; }, processResults: function(response) { return { results: response }; }, cache: true } }); } }); $('#filter_model,#filter_club_status').on('select2:select select2:unselecting change', function(e) { refreshCarClubTableSilent(); }); $('#filter_member_status').on('select2:select select2:unselecting change', function(e) { refreshCarClubTableSilentMembers(); }); $('#filter_model').select2({ placeholder: "Model (All)", minimumResultsForSearch: -1, language: { noResults: function() { return 'Select brand first' } } }); } function initOfficers() { $('#addRowOfficers').click(function() { var validate_data_contact_person = checkIfContactPersonIncomplete(); if (!validate_data_contact_person[0] && $('#contact-person-list-table tbody tr').length > 0) { sweetAlertSimple('error', 'Oops...', 'Complete the data of officer first') } else if (!validate_data_contact_person[1]) { sweetAlertSimple('error', 'Oops...', 'Officer mobile is invalid') } else { addCustomerContactPerson(); } }); $("#contact-person-list").on("click", ".btnRemoveContactPerson", function() { $(this).closest("tr").remove(); }); } function checkIfContactPersonIncomplete() { rows = getAllContactPersonTableData(); var contactPersonJsonRow = rows; var hasMatch = []; hasMatch[0] = true; hasMatch[1] = true; for (var index = 0; index < contactPersonJsonRow.length; ++index) { var contactPersonJson = contactPersonJsonRow[index]; if (contactPersonJson.Position == "" || contactPersonJson.Firstname == "" || contactPersonJson.Lastname == "" ) { hasMatch[0] = false; break; } if (!isEmpty(contactPersonJson.Mobile)) { if (contactPersonJson.Mobile.length < 10) { hasMatch[1] = false; break; } } } // alert(hasMatch) return hasMatch; } function getAllContactPersonTableData() { var $table = $("#contact-person-list-table") rows = [], header = []; $table.find("thead th").each(function() { header.push($(this).html()); }); $table.find("tbody tr").each(function() { var row = {}; $(this).find("td").each(function(i) { var key = header[i], value = $(this).find('input').val(); row[key] = value; }); rows.push(row); }); // alert(JSON.stringify(rows)); // return JSON.stringify(rows); return rows; } function addCustomerContactPerson() { var contact_person_list = document.getElementById('contact-person-list'); const contact_person_list_base = document.querySelector('#contact-person-list-clone tbody tr'); contact_person_list.appendChild(contact_person_list_base.cloneNode(true)); // Generate a unique ID for the select> in the new row. var generatedId = uniqId(); var newContactPersonPosId = 'contact-person-position-' + generatedId; var newContactPersonFirstnameId = 'contact-person-firstname-' + generatedId; var newContactPersonLastnameId = 'contact-person-lastname-' + generatedId; var newContactPersonMobileId = 'contact-person-mobile-' + generatedId; var item = []; item[0] = (newContactPersonPosId); item[1] = (newContactPersonFirstnameId); item[2] = (newContactPersonLastnameId); item[3] = (newContactPersonMobileId); $('#txt_officer_pos').attr('id', newContactPersonPosId); officerPosEvt($('#' + newContactPersonPosId)); $('#txt_officer_fname').attr('id', newContactPersonFirstnameId); $('#txt_officer_lname').attr('id', newContactPersonLastnameId); $('#txt_officer_mobile').attr('id', newContactPersonMobileId); return item; } function showDuplicateCarclubMsg(id) { Swal.fire({ icon: 'warning', html: 'Car club already exist.', showDenyButton: false, showCancelButton: true, confirmButtonText: `View`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { var url = "/car_club/" + id; window.location.href = url; } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } function resetCarClubModal() { $("#contact-person-list-table > tbody").empty(); $('#dd_brand').val(null).empty().trigger('change'); $('#dd_model').val(null).empty().trigger('change'); $('#dd_club_status').val('1').trigger('change'); $('#modal_car_club') .find("input,textarea") .val('') .end() .find("input[type=checkbox], input[type=radio]") .prop("checked", "") .end(); } function resetCarClubMemberModal() { $('#dd_member_status').val('1').trigger('change'); $('#modal_car_club_members') .find("input,textarea") .val('') .end() .find("input[type=checkbox], input[type=radio]") .prop("checked", "") .end(); } function proceedBtnListener() { $('#proceed-button').on('click', function(evt) { if (check_if_empty_field($('#txt_name'), 'Car club name is required.')) { return; } if (check_if_empty_field($('#txt_assigned_person'), 'Assigned person is required.')) { return; } var validate_data_contact_person = checkIfContactPersonIncomplete(); if (!validate_data_contact_person[0] && $('#contact-person-list-table tbody tr').length > 0) { $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Complete the data of officer first') return; } else if (!validate_data_contact_person[1]) { $('#contact-person-list-table input').first().focus(); sweetAlertSimple('error', 'Oops...', 'Officer mobile is invalid') return; } var $element = $("[json-modal]"); var json_data = generate_json('json-modal', $element); var officers = getAllContactPersonTableData(); // alert(json_data); // alert(JSON.stringify(officers)); $.ajax({ url: '/api/car_club/car_club.php', type: "GET", dataType: 'json', data: { apiKey: '8b932f1f8ba111ec9f3e00ff70631b9a', id: car_club_record_id, json_data: json_data, officers: JSON.stringify(officers) }, beforeSend: function() { $('#proceed-button').prop("disabled", true); }, success: function(result) { if (result.status == '1') { sweetAlertSimple('success', 'Oops...', result.message); resetCarClubModal(); $('#modal_car_club').modal('hide'); if (isEmpty(car_club_record_id)) { refreshCarClubTableSilent(); } else { // car_club_officers loadCarClubInformation(); if (officers.length > 0) { refreshCarClubTableSilentMembers(); } } } else if (result.status == '2') { // sweetAlertSimple('error', 'Oops...', result.message); showDuplicateCarclubMsg(result.id); } $('#proceed-button').prop("disabled", false); }, error: function(xhr, status, error) { sweetAlertSimple('error', 'Oops...', 'Error has occurred, Try again...'); $('#proceed-button').prop("disabled", false); } }); }); } function proceedBtnListenerMember() { $('#proceed-button-member').on('click', function(evt) { if (check_if_empty_field($('#txt_member_fname'), 'Firstname is required.')) { return; } if (check_if_empty_field($('#txt_member_lname'), 'Lastname is required.')) { return; } if (!isEmpty($('#txt_member_mobile').val())) { if ($('#txt_member_mobile').val().length < 10) { toastr.remove(); toastr.error("Invalid mobile number."); return; } } var $element = $("[json-modal-member]"); var json_data = generate_json('json-modal-member', $element); $.ajax({ url: '/api/car_club/car_club.php', type: "POST", dataType: 'json', data: { apiKey: '21f8621b8ed411ecb64500ff70631b9a', id: car_club_record_id, member_id: global_car_club_member_data, json_data: json_data }, beforeSend: function() { $('#proceed-button-member').prop("disabled", true); }, success: function(result) { if (result.status == '1') { sweetAlertSimple('success', 'Oops...', result.message); resetCarClubMemberModal(); $('#modal_car_club_members').modal('hide'); // if(isEmpty(car_club_record_id)){ refreshCarClubTableSilentMembers(); // }else{ // // car_club_officers // loadCarClubInformation(); // } } $('#proceed-button-member').prop("disabled", false); }, error: function(xhr, status, error) { sweetAlertSimple('error', 'Oops...', 'Error has occurred, Try again...'); $('#proceed-button-member').prop("disabled", false); } }); }); } function refreshCarClubTableSilent() { var $table = $('#car_club_table') $(function() { try { $table.bootstrapTable('refresh', { url: '/api/car_club/car_club.php' }); } catch (e) { console.log('reply from viewer. error: ' + e) } }) } function initTicketList() { var $table = $('#car_club_table'); $table.bootstrapTable('destroy').bootstrapTable({ sidePagination: 'server', formatSearch: function() { return 'Search...' }, onLoadSuccess: function() { // initTicketActionColVisibility(); // initTicketActionEvent(); }, exportOptions: { fileName: function() { return 'titile' } } }); } function queryParams(params) { return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, apiKey: 'a6fea5ab8d4111ecb31800ff70631b9a', brand_id: $('#filter_brand').val(), model_id: $('#filter_model').val(), club_status: $('#filter_club_status').val() }; } /////////////////////////////// function refreshCarClubTableSilentMembers() { var $table = $('#car_club_members_table') $(function() { try { $table.bootstrapTable('refresh', { url: '/api/car_club/car_club.php' }); } catch (e) { console.log('reply from viewer. error: ' + e) } }) } function initTicketListMembers() { var $table = $('#car_club_members_table'); $table.bootstrapTable('destroy').bootstrapTable({ sidePagination: 'server', formatSearch: function() { return 'Search...' }, onLoadSuccess: function() { $("[member-action-edit]").each(function() { // if (this.id.startsWith('released_')) { $(this).on('click', function(evt) { global_car_club_member_data = (this.getAttribute('member-action-edit-id')); $('#modal_car_club_members').modal('show'); $.ajax({ url: '/api/car_club/car_club.php', method: "POST", dataType: 'json', data: { apiKey: 'b70507fa8ef211ecb64500ff70631b9a', id: global_car_club_member_data }, beforeSend: function() {}, success: function(result) { $('#txt_member_fname').val(result.firstname) $('#txt_member_lname').val(result.lastname) $('#txt_member_mobile').val(result.mobile) $('#dd_member_status').val(result.member_status).trigger('change') }, error: function() { sweetAlertSimple('error', 'Oops...', 'Error has been occurred, please try again.') } }); //read member data }) }) $("[member-action-remove]").each(function() { // if (this.id.startsWith('released_')) { $(this).on('click', function(evt) { var member_id = (this.getAttribute('member-action-remove')); Swal.fire({ icon: 'question', html: 'Are you sure you want to remove this member?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { $.ajax({ url: '/api/car_club/car_club.php', method: "POST", dataType: 'json', data: { apiKey: '2b5e93968ef011ecb64500ff70631b9a', id: member_id, car_club_id: car_club_record_id }, beforeSend: function() { sweetAlertSimple('info', 'Oops...', 'Removing...') }, success: function(result) { sweetAlertSimple('success', 'Nice...', result.message); refreshCarClubTableSilentMembers(); }, error: function() { sweetAlertSimple('error', 'Oops...', 'Error has been occurred, please try again.') } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) }) }) }, exportOptions: { fileName: function() { return 'titile' } } }); } function queryParamsMembers(params) { return { search: params.search, offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, car_club_id: car_club_record_id, apiKey: '1e9afe598ee811ecb64500ff70631b9a', member_status: $('#filter_member_status').val() }; } ////////////////////////////// function field_formatter(value, row, index) { if (isEmpty(value)) { return "-"; } return value; } function member_action_formatter(value, row, index) { return ` <a style="cursor:pointer;" member-action-edit-id=` + row.id + ` member-action-edit=` + row.member_id + ` class="edit m-1 btn btn-primary btn-icon btn-sm" title="Edit"><i class="fa fa-pen "></i></a> <a style="cursor:pointer;" member-action-remove=` + row.member_id + ` class="remove m-1 btn btn-sm btn-danger" title="Remove"><i class="fa fa-trash "></i></a> `; } function carClubTableCellClickEvt() { $('#car_club_table').on('click-cell.bs.table', function(field, value, row, $el) { window.location.href = 'car_club/' + $el.id; return; }); } function removeCarClub() { $('#btn_remove_car_club').on('click', function(evt) { Swal.fire({ icon: 'question', html: 'Are you sure you want to remove this car club?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { $.ajax({ url: '/api/car_club/car_club.php', method: "POST", dataType: 'json', data: { apiKey: '6eaafd758d6211ecb31800ff70631b9a', id: car_club_record_id }, beforeSend: function() { $('#btn_update_car_club').prop("disabled", true); sweetAlertSimple('info', 'Oops...', 'Removing...') }, success: function(result) { if (result.status == '1') { sweetAlertSimple('success', 'Nice...', result.message); window.location.href = '/car_club' } else { sweetAlertSimple('error', 'Oops...', result.message) $('#btn_update_car_club').prop("disabled", false); } }, error: function() { sweetAlertSimple('error', 'Oops...', 'Error has been occurred, please try again.') $('#btn_update_car_club').prop("disabled", false); } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) }); } function updateCarClub() { $('#btn_update_car_club').on('click', function(evt) { resetCarClubModal(); $('#modal_car_club').modal('show'); $('.customer-modal-overlay').hide(); //load car club information var information = global_car_club_data['information']; // console.log(information); $('#txt_name').val(information.name); $('#txt_name_id').val(information.name_id); $('#txt_fee').val(information.fee); $('#txt_assigned_person').val(information.assigned_person); $('#txt_assigned_person_id').val(information.assigned_person_id); $('#txt_members_count').val(information.members_count); $('#txt_active_members_count').val(information.active_members_count); $('#txt_fb_members_count').val(information.fb_members_count); $('#dd_club_status').val(information.car_club_status_id).trigger('change'); var newBrand = new Option(information.brand, information.brand_id, true, true); $("#dd_brand").append(newBrand).trigger('change'); var newModel = new Option(information.model, information.model_id, true, true); $("#dd_model").append(newModel).trigger('change'); $.each(global_car_club_data['officers'], function(i, n) { var elements_ids = addCustomerContactPerson(); setTimeout(function timer() { $('#' + elements_ids[0]).val(n.position); $('#' + elements_ids[1]).val(n.firstname); $('#' + elements_ids[2]).val(n.lastname); $('#' + elements_ids[3]).val(n.mobile); }, 500); }); }); } function readCarClubField() { $.ajax({ url: '/api/car_club/car_club.php', type: "POST", dataType: 'json', data: { apiKey: 'd50fdb5292b011ecb80c00ff70631b9a', }, beforeSend: function() {}, success: function(result) { // console.log(result[1].field) $("#txt_field_name").val(result[1].field); $("#txt_field_brand").val(result[2].field); $("#txt_field_model").val(result[3].field); $("#txt_field_fee").val(result[4].field); $("#txt_field_president").val(result[5].field); $("#txt_field_members_count").val(result[6].field); $("#txt_field_active_members_count").val(result[7].field); $("#txt_field_fb_members_count").val(result[8].field); $("#txt_field_assigned_person").val(result[9].field); $("#txt_field_club_status").val(result[10].field); }, error: function(xhr, status, error) { sweetAlertSimple('error', 'Oops...', 'Error has occurred...'); } }); } function loadCarClubInformation() { $.ajax({ url: '/api/car_club/car_club.php', type: "POST", dataType: 'json', data: { apiKey: 'e3a50dda8d6e11ecb31800ff70631b9a', id: car_club_record_id }, beforeSend: function() { $('#car_club_officers').html(''); }, success: function(result) { global_car_club_data = result; $.each(result['information'], function(i, n) { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') }); $.each(result['officers'], function(i, n) { $('#car_club_officers').append(` <tr> <td>` + n.position + `</td> <td>` + n.name + `</td> <td>` + n.mobilef + `</td> </tr> `); }); }, error: function(xhr, status, error) { sweetAlertSimple('error', 'Oops...', 'Error has occurred...'); } }); } </script>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings