Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/public/js/lease.js
Назад
$(function () { // Cache jQuery selectors var $toolbarListItems = $('.toolbar-list li'); var $pdfViewMain = $('.pdf-view-main'); var $pdfListingView = $('.pdf-listing-view'); var $pdfTypeInputs = $('input[name="lease_id[]"]'); var $lsOptions = $('.ls-options'); var $cdParent = $('.cd-parent'); $pdfListingView.hide(); // Toolbar item click handling $toolbarListItems.click(function () { $toolbarListItems.removeClass('fill'); $(this).toggleClass('fill'); }); // Initialize select2 plugin $('.js-example-basic-single').select2({ minimumResultsForSearch: -1 }); // Four-grid view click handling $('.four-grid').click(function () { $pdfViewMain.removeClass('column-grid').show(); $pdfListingView.hide(); }); // One-grid view click handling $('.one-grid').click(function () { $pdfViewMain.addClass('column-grid').show(); $pdfListingView.hide(); }); // Select-all click handling $('.select-all').click(function (e) { e.preventDefault(); $pdfTypeInputs.prop('checked', true); $lsOptions.hide(); $cdParent.show(); }); // Individual PDF type input click handling $(document).on('click', 'input[name="lease_id[]"]', function () { var isChecked = $pdfTypeInputs.is(':checked'); $lsOptions.toggle(!isChecked); $cdParent.toggle(isChecked); }); // Cancel button click handling $('.cncl-btn').click(function () { $cdParent.hide(); $lsOptions.show(); $pdfTypeInputs.prop('checked', false); }); $('.name_container img').on('click',function(){ $('.name_container input').attr('disabled',false); }); // List-view-tool click handling $('.list-view-tool').click(function () { $pdfViewMain.hide(); $pdfListingView.show(); }); $('#upload_lease_doc').on('click',function(){ $("#lease_upload").trigger("click"); }); $("#lease_upload").on("change", function() { // Get the selected file var file = this.files[0]; if (file) { // Perform the file upload using Ajax var formData = new FormData(); formData.append("file", file); showLoading(); // Ajax request to handle file upload $.ajax({ url: "/landlord/upload-lease-document", // Adjust the URL to your server endpoint type: "POST", data: formData, processData: false, contentType: false, success: function(response) { swal.close(); // console.log("File uploaded successfully", response); // Handle success response if(!response){ toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.error(error); }else{ toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.success('Uploaded, Redirecting now'); window.location.href = '/landlord/detail-lease?doc_id='+response.id; } }, error: function(error) { swal.close(); // Handle error response console.error("Error uploading file", error.responseJSON.message); // console.error("Error uploading file", error.responseText); toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.error(error.responseJSON.message); } }); } }); $(document).on('click','.template_lease',function(){ // Remove 'selected' class from all templates $('.template_lease').removeClass('selected'); // Add 'selected' class to the clicked template $(this).addClass('selected'); // Get the document ID from the selected template var docId = $(this).data('doc-id'); // Update the href of the anchor with the selected document ID var href = "/landlord/detail-lease?doc_id=" + docId; $('#lease_doc_continue_btn').attr('href', href).removeAttr('disabled'); }); $('#send_lease_form').on('submit',function(e){ e.preventDefault(); var email = $('#lease_to_email').val(); var doc_id = $('#doc_id').val(); var doc_name = $('#document_name').val(); showLoading(); // Ajax request to handle file upload $.ajax({ url: "/landlord/send_lease", // Adjust the URL to your server endpoint type: "POST", data: { email:email, doc_id:doc_id, doc_name:doc_name, }, headers: { 'X-CSRF-TOKEN': $('input[name="_token"]').val() }, success: function(response) { swal.close(); // console.log(response); // Handle success response if(response.success != 200){ if(response.success == 301){ toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.success(response.message); window.location.href = response.url; } }else{ toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.success(response.message); window.location.href = '/landlord/lease/sent?lease_id='+response.lease_id; } }, error: function(error) { swal.close(); // Handle error response console.error("Error uploading file", error.responseJSON.message); // console.error("Error uploading file", error.responseText); toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.error(error.responseJSON.message); } }); }); $('#search_leases img').on('click', function(){ $('#search_leases').submit(); }); $('.sort-select .dropdown-menu a').on('click', function(e) { e.preventDefault(); // Get the data-value attribute of the clicked option var selectedValue = $(this).data('val'); // Get the current URL var currentUrl = window.location.href; // Check if there are existing query parameters var separator = currentUrl.indexOf('?') !== -1 ? '&' : '?'; // Check if there's already a sort parameter var sortParamIndex = currentUrl.indexOf('sort='); if (sortParamIndex !== -1) { // Replace the existing sort value var nextAmpIndex = currentUrl.indexOf('&', sortParamIndex); var replaceStr = currentUrl.substring(sortParamIndex, nextAmpIndex !== -1 ? nextAmpIndex : currentUrl.length); currentUrl = currentUrl.replace(replaceStr, 'sort=' + selectedValue); } else { // Add the sort parameter currentUrl += separator + 'sort=' + selectedValue; } // Reload the page with the new URL window.location.href = currentUrl; }); $('#per_page_select').on('change', function() { // Get the selected value var selectedValue = $(this).val(); // Get the current URL var currentUrl = window.location.href; // Check if "per_page" parameter already exists in the URL var perPageParamIndex = currentUrl.indexOf('per_page='); if (perPageParamIndex !== -1) { // Replace the existing "per_page" value var nextAmpIndex = currentUrl.indexOf('&', perPageParamIndex); var replaceStr = currentUrl.substring(perPageParamIndex, nextAmpIndex !== -1 ? nextAmpIndex : currentUrl.length); currentUrl = currentUrl.replace(replaceStr, 'per_page=' + selectedValue); } else { // Add the "per_page" parameter currentUrl += currentUrl.includes('?') ? '&' : '?'; currentUrl += 'per_page=' + selectedValue; } // Reload the page with the new URL window.location.href = currentUrl; }); $('#delete_selected_btn').on('click',function(){ var isConfirmed = confirm("Are you sure? This action cannot be undone."); // Check if the user clicked 'OK' in the confirmation dialog if (isConfirmed) { // Array to store selected lease IDs var selectedLeaseIds = []; // Iterate through all checkboxes with the name 'lease_id[]' $('input[name="lease_id[]"]:checked').each(function () { // Push the value (lease ID) to the array selectedLeaseIds.push($(this).val()); }); // Check if any leases are selected if (selectedLeaseIds.length > 0) { // console.log('show ids',selectedLeaseIds); // Perform AJAX POST request showLoading(); $.ajax({ url: '/landlord/delete_ids', // Replace with your backend endpoint method: 'POST', data: { lease_ids: selectedLeaseIds }, success: function (response) { swal.close(); // Handle success response // console.log(response); if(response.success == 200){ toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.success(response.message); location.reload(); }else{ toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.error(response.message); } }, error: function (error) { // Handle error console.error(error); swal.close(); toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.error(error.responseJSON.message); } }); } else { // No leases selected, you can show a message or perform other actions alert('No leases selected for deletion.'); } } }); // $('#sendLeaseModal select[name="property_id"]').on('change', async function(){ // var property_id = $(this).val(); // showLoading(); // await $.ajax({ // url: '/landlord/get_single_unit/'+property_id, // type: 'get', // success: function(response){ // var selectElement = $('#sendLeaseModal select[name="unit_id"]'); // // Remove existing options // selectElement.empty(); // selectElement.append('<option value="">Please Select Unit</option>'); // // Append new options based on the received data // $.each(response.units, function(index, unit) { // selectElement.append('<option value="' + unit.id + '">' + unit.number + '</option>'); // }); // swal.close(); // console.log(response.units); // }, // error: function(XMLHttpRequest, textStatus, errorThrown) { // swal.close() // TopEndPopUp('warning',errorThrown) // } // }); // }); });
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка