Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/public/js/add-properties.js
Назад
$(function () { var radioValues; // Function to initialize SmartTab function initSmartTab() { var element = document.querySelector('#smarttab'); if (!element) { console.error('Element not found. Stopping function.'); return; // Stop the function if the element does not exist } const $tabs = $('#smarttab').smartTab({ selected: 0, // Set the selected tab to 0 (first tab) keyboard: { keyNavigation: false, keyLeft: [37, 38], // Left key code keyRight: [39, 40], // Right key code keyHome: [36], // Home key code keyEnd: [35], // End key code }, backButtonSupport: true, enableUrlHash: false, autoAdjustHeight: false, }); $('#smarttab').on('showTab', function (e, anchorObject, tabIndex) { // Check if the first tab is shown if (tabIndex === 0) { $('#prev-btn').hide(); } else { $('#prev-btn').show(); } // if (tabIndex === 4) {//for last tab // $('#prev-btn').hide(); // } }); $('#prev-btn').on('click', function () { $('#smarttab').smartTab('prev'); }); $('#next-btn , #save_and_exit').on('click', function (e) { e.preventDefault(); var clickedButtonId = this.id; let info = $('#smarttab').smartTab("getInfo"); var flag = checkFields(info.currentPage); // console.log(info.currentPage); if(info.currentPage == 2){ const checkboxForm = document.getElementById("format_styles"); const checkboxes = checkboxForm.querySelectorAll('input.format_checkbox'); const checkedCount = Array.from(checkboxes).filter((checkbox) => checkbox.checked).length; if (checkedCount !== 1) { swalPop('error','Required Fields','Required fields can not be left empty'); return 0; } let format = $('input[name="format_styles"]:checked').val(); let units_count = $('input[name="number_of_units"]').val(); // console.log('these are formar value: ',format); // console.log('these are formar unit counts: ',units_count); let units = printUnits(format,units_count); // var amenitiesContainer = document.getElementById("amenitiesContainer"); var myHtml=''; // var amenities = units; // Replace this with your array of amenities for (let i = 0; i < units.length; i++) { if (i % 7 === 0) { if (i !== 0) { myHtml += '</div>'; } myHtml += '<div class="select-unit-radio-main">'; } myHtml += ` <div class="unit-options md-am-opt"> <input type="checkbox" name="units_diff_selected[]" class="units_diff_selected" value="${units[i]}" /> <input type="hidden" name="units_generated[]" value="${units[i]}" /> <p>${units[i]}</p> </div> `; if (i === units.length - 1) { myHtml += '</div>'; } } $("#amenitiesContainer").append(''); $("#amenitiesContainer").append(myHtml); getPartialSelectedUnits(function(selectedUnits) { // console.log('thses are selected units: ',selectedUnits); var special_units_check = false; var lease_term,monthly_rent,size; $('input.units_diff_selected').each(function() { // Get the value of the current input element var inputValue = $(this).val(); // console.log('this is input val: ',inputValue); var isMatched = selectedUnits.some(function(obj) { if(obj.number === inputValue){ lease_term = obj.lease_term monthly_rent = obj.monthly_rent size = obj.size } return obj.number === inputValue; }); // console.log('this is monthly rent: ',monthly_rent); $(".lease_term_different").val(lease_term).trigger('change'); $('input[name="monthly_rent_diff"]').val(monthly_rent); $('input[name="unit_size_diff"]').val(size); // If a match is found, mark the input as checked if (isMatched) { $(this).prop('checked', true); special_units_check = true; } }); if(special_units_check){ $('input[type="radio"][name="special_units_check"][value="no"]').prop('checked', true); } }); // console.log(units); } if(info.currentPage == 3){ let special_units = $('input[name="special_units_check"]:checked').val(); // console.log('These ',special_units); if(special_units == 'no'){ // console.log('I.O here '); var special_units_select = $('input[name=units_diff_selected]:checked'); var lease_diff = $('.lease_term_different').find(":selected").val(); var unit_size_diff = $('input[name=monthly_rent_diff]').val(); var monthly_rent_diff = $('input[name=unit_size_diff]').val(); var amenities_diff = $('.amenities_diff').find(":selected").val(); if(!special_units_select || !lease_diff || !unit_size_diff || !monthly_rent_diff || !amenities_diff){ swalPop('error','Required Fields','Please specify units an fill the fields'); return 0; } } } if(!flag){ if(clickedButtonId === 'save_and_exit'){ window.location.href = "/landlord/dashboard"; }else{ swalPop('error','Required Fields','Required fields can not be left empty'); } return 0; } $('input[name="step_count"]').val(info.currentPage); showLoading(); $.ajax({ url: '/landlord/add/property', type: 'post', dataType: 'json', data: $('#add_landlord_property').serialize(), success: function(response){ swal.close() // console.log('This is ajax response',response); if(response.data){ // TopEndPopUp('success', response.message) if(info.currentPage == 4){ if(response.payment){ window.location.href = "/landlord/new_unit/payment"; //Take to the payment page }else{ window.location.href = "/landlord/dashboard"; } }else{ if(clickedButtonId === 'save_and_exit'){ window.location.href = "/landlord/dashboard"; }else{ $('#smarttab').smartTab('next'); $('input[name="step_count"]').val((info.currentPage + 1)); if(info.currentPage == 2 || info.currentPage == 3){ $('input[name="property_id"]').val(response.property_id); } } } }else{ TopEndPopUp('warning',response.message) } }, error: function(XMLHttpRequest, textStatus, errorThrown) { swal.close() TopEndPopUp('warning',errorThrown) } }); // $('#smarttab').smartTab('next'); }); } // Initialize SmartTab initSmartTab(); // tab end //Select2 initiate here $('.default_select').select2({ minimumResultsForSearch: -1 }); $('.select2_with_search').select2(); $('.amenities_select2').select2({ // templateResult: resultState }).on('select2:open', () => { $('.special_insertion').remove(); $(".select2-results:not(:has(a))").append('<button type="button" class="v-select-all special_insertion" data-bs-toggle="modal" data-bs-target="#exampleModal">View all</button>'); }); //Modal Select2 $(".modal_select2").select2({ minimumResultsForSearch: -1, dropdownParent: $('#sepcialselectModal .modal-content') }); $(".modal_select2_with_search").select2({ width: '100%', height: '30px', placeholder: "Select Amenities", dropdownParent: $('#sepcialselectModal .modal-content') }); function resultState(data, container) { if(data.element) { $(container).addClass($(data.element).attr("class")); } return data.text; } function checkFields(step) { const stepDiv = document.querySelector(`div#tab-${step}`); if (!stepDiv) { // console.error(`Step ${step} not found.`); return false; } const requiredFields = stepDiv.querySelectorAll('[required]'); let allFieldsFilled = true; requiredFields.forEach((field) => { if (field.value.trim() === '') { allFieldsFilled = false; } }); return allFieldsFilled; } // $(document).on('change','#country',function(){ // // console.log( this.value); // showLoading(); // $.ajax({ // method: "GET", // url: "/admin/getStates/"+this.value, // success: function(response){ // // console.log(response); // $("#state").empty() // $("#city").empty() // response.forEach(function(data){ // // console.log(data) // $("#state").append("<option value='"+data.id+"'>"+data.name+"</option>") // }) // $("#state").select2("destroy").select2(); // swal.close() // }, // error: function(XMLHttpRequest, textStatus, errorThrown) { // alert("Status: " + textStatus); alert("Error: " + errorThrown); // swal.close() // } // }) // }); // $(document).on('change','#state',function(){ // showLoading(); // $.ajax({ // method: "GET", // url: "/admin/getCities/"+this.value, // success: function(response){ // // console.log(response); // $("#city").empty() // response.forEach(function(data){ // // console.log(data) // $("#city").append("<option value='"+data.id+"'>"+data.name+"</option>") // }) // $("#city").select2("destroy").select2(); // swal.close() // }, // error: function(XMLHttpRequest, textStatus, errorThrown) { // alert("Status: " + textStatus); alert("Error: " + errorThrown); // swal.close() // } // }) // // console.log( this.value); // }); $('.wizard-nav a').on('click',function(e){ e.preventDefault(); var ids = $(this).attr('href'); // console.log(ids); }); $(document).on('click', 'input.format_checkbox', function() { $('input[type="checkbox"]').not(this).prop('checked', false); }); $('#datepicker,#datepickerAvailable').datepicker({ startDate: "0", format: 'yyyy-mm-dd', autoclose: true, }); // Function to close all select options let currentOpenSelect = null; // Function to close all select options function closeSelectOptions() { $(".select-options").slideUp(); $('.select-arrow').removeClass('active') } $(".select-selected, .select-arrow").on("click", function (e) { e.stopPropagation(); const $customSelect = $(this).closest(".custom-select"); const $selectOptions = $customSelect.find(".select-options"); if (currentOpenSelect && currentOpenSelect[0] !== $customSelect[0]) { // Close the previously opened select closeSelectOptions(); } currentOpenSelect = $customSelect; $(this).next('.select-arrow').toggleClass('active'); $selectOptions.slideToggle(); }); $(".select-option").on("click", function () { const value = $(this).data("value"); const text = $(this).text(); const $customSelect = $(this).closest(".custom-select"); const isMultiple = $customSelect.data("multiple"); if (isMultiple) { $(this).toggleClass("selected"); const selectedOptions = $customSelect .find(".select-option.selected") .map(function () { return $(this).data("value"); }) .get(); $customSelect.find(".select-selected").text(selectedOptions.join(", ")); $customSelect.find(".select-selected").attr("data-value", selectedOptions.join(", ")); selectValidation();//IF NULL } else { $customSelect.find(".select-selected").text(text); $customSelect.find(".select-selected").attr("data-value", value); $(".select-selected").addClass('selected-opt') closeSelectOptions(); // Close the options panel selectValidation(); // You can customize the behavior when an option is selected here // console.log("Selected Value:", value); } }); // Close the dropdowns when clicking outside $(document).on("click", function () { closeSelectOptions(); }); $(".v-select-all").on("click", function () { closeSelectOptions(); }); // Prevent clicks inside the dropdown from closing it $(".select-options").on("click", function (e) { e.stopPropagation(); }); $('#datepicker').datepicker({ startDate: "0", format: 'yyyy-mm-dd', autoclose: true, }); $('#datepicker2').datepicker({ startDate: "0", format: 'yyyy-mm-dd', autoclose: true, }); $('.slect-all-btn').click(function () { $('input[name="amenities[]"]').prop('checked', true); if ($('input[name="amenities[]"]:checked').length === 0) { $('.selected-btn').prop("disabled", true); } else { radioValues = $('input[name="amenities[]"]:checked').map(function () { return $(this).val(); }).get(); $('.selected-btn').prop("disabled", false); } }); $('input[name="amenities[]"]').on('change', function () { radioValues = $('input[name="amenities[]"]:checked').map(function () { return $(this).val(); }).get(); // console.log('Selected radio button values:', radioValues); var getValue = 'wifi'; if (radioValues.includes(getValue)) { // console.log('The value ' + getValue + ' is selected.'); } $('.selected-btn').prop("disabled", false); if ($('input[name="amenities[]"]:checked').length === 0) { $('.selected-btn').prop("disabled", true); } else { $('.selected-btn').prop("disabled", false); } }); $('.selected_amenities_modal_btn').on('click',function(){ $(".amenities_select2").select2("destroy").select2(); $(".amenities_select2").val(radioValues).trigger("change"); $('#exampleModal').modal('hide'); // console.log('Selected radio button values( Button Click ):', radioValues); }); // Get references to the input and Select2 fields and the button const modalContainerPersonal = document.getElementById("modal_input_container_special"); const inputFields = modalContainerPersonal.querySelectorAll("input"); const select2Fields = modalContainerPersonal.querySelectorAll("select"); // Adjust the selector as needed const submitButton = document.getElementById("add_details_to_units"); // Replace "submitButton" with your button's ID // Function to check if all fields are filled function areAllFieldsFilled() { let allFieldsFilled = true; // Check input fields inputFields.forEach(function (input) { if (input.value.trim() === "") { allFieldsFilled = false; return; } }); // Check Select2 fields select2Fields.forEach(function (select2) { const select2Value = $(select2).val(); if (!select2Value || select2Value.length === 0) { allFieldsFilled = false; return; } }); return allFieldsFilled; } // Add event listeners to input and Select2 fields inputFields.forEach(function (input) { input.addEventListener("input", function () { submitButton.disabled = !areAllFieldsFilled(); }); }); select2Fields.forEach(function (select2) { $(select2).on("change", function () { submitButton.disabled = !areAllFieldsFilled(); }); }); $('#add_details_to_units').on('click',function(){ $('#sepcialselectModal').modal('hide'); }); // $('.sve-exit-btn').on('click',function(){ // $('input[name="submission_by"]').val('partial'); // $('#add_landlord_property').submit(); // }); });
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка