Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/public/js/calender-init-tenant.js
Назад
async function fetchData() { try { const data = await $.ajax({ url: '/get-events', method: 'GET', dataType: 'json', }); // console.log(data); // Process the data as needed return data; } catch (error) { console.error('Error fetching data:', error); } } document.addEventListener('DOMContentLoaded', async function () { var calendarEl = document.getElementById('calendar'); let objectDate = new Date(); let month = objectDate.getMonth(); // console.log(month + 1); const today = new Date(); // Get the current date components const year = today.getFullYear(); const month_n = String(today.getMonth() + 1).padStart(2, '0'); // Months are zero-based const day = String(today.getDate()).padStart(2, '0'); // Format the date as "yyyy-mm-dd" const formattedDate = `${year}-${month_n}-${day}`; // console.log('This is formated Date',formattedDate); var event_ajax = await fetchData(); // console.log('This is inside: ',event_ajax); var calendar = new FullCalendar.Calendar(calendarEl, { // height:'auto', headerToolbar: { // left: 'prev,next today', // left: 'prev,next', right: 'customButton', center: 'prev title next', // right: 'dayGridMonth,timeGridWeek,timeGridDay', left: 'dayGridYear,timeGridWeek,dayGridMonth,timeGridDay', }, dateClick: function (info) { }, // customButtons: false, customButtons: { customButton: { text: 'New Event', click: function () { $('#eventTitle').val(''); $("#eventModal").modal("show"); } } }, // initialDate: '2023-05-08', initialDate: formattedDate, initialView: 'timeGridWeek', // events: [ // { // title: 'Event 1', // start: '2023-05-16T10:00:00', // end: '2023-09-16T12:00:00', // }, // { // title: 'Event 2', // start: '2023-09-17T14:00:00', // end: '2023-09-17T16:00:00', // }, // // Add more events here // ], views: { timeGridWeek: { // name of view titleFormat: { month: 'short', day: '2-digit' } // other view-specific options here } }, dayHeaderFormat: { weekday: 'long', day: 'numeric', }, dayHeaderContent: (args) => { return moment(args.date).format('dddd D') // return 'abc' }, columnFormat: 'dddd', slotLabelInterval: { minutes: 30 }, // timeGrid: true, // timeFormat: 'HH:mm', scrollTime: '00:00:00', allDaySlot: false, navLinks: true, selectable: true, // slotWidth: 200, selectMirror: true, eventAfterRender: function (event, element, view) { // console.log('asd'); }, eventClick: async function (info) { var eventId = info.event.id; showLoading(); await $.ajax({ url: '/tenant/get_single_event/'+eventId, type: 'get', success: function(response){ if(response.code == 200 || response.code == 400){ var event = response.event; var capitalizedType = response.event.type; capitalizedType = capitalizedType.replace(/_/g, ' ').split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); // Set the title input $('#openhouseModal input[name="title"]').val(event.task); // Set the type input (assuming you want to set the type of event) $('#openhouseModal input[name="type"]').val(event.type); $('#openhouseModal .select-selected').html(capitalizedType); // Set the select for property_id $('#openhouseModal select[name="property_id"]').val(event.property_id); // Set the date input $('#openhouseModal input[name="date"]').val(event.date); // Set the time inputs $('#openhouseModal input[name="edit_from_time"]').val(event.from_time); $('#openhouseModal input[name="edit_to_time"]').val(event.to_time); // Set the email input $('#openhouseModal input[name="edit_email"]').val(event.email); // Set the note input $('#openhouseModal input[name="edit_note"]').val(event.note); $('#openhouseModal input[name="event_id"]').val(event.id); var propertiesSelect = $('#openhouseModal select[name="property_id"]'); propertiesSelect.empty(); // Remove previous options // console.log(); // $.each(response.property, function(index, property) { var option = $('<option>', { value: response.properties.id, text: response.properties.name }); // if (property.id === event.event_property.id) { // option.attr('selected', 'selected'); // Select the matching option // } propertiesSelect.append(option); // }); var unitSelect = $('#openhouseModal select[name="unit_id"]'); unitSelect.empty(); // Remove previous options $.each(response.units, function(index, unit) { var option = $('<option>', { value: unit.id, text: unit.number }); if (unit.id === event.unit.id) { option.attr('selected', 'selected'); // Select the matching option } unitSelect.append(option); }); var categorySelect = $('#openhouseModal .category_container select'); categorySelect.empty(); $.each(response.categories, function(index, category) { var option = $('<option>', { value: category.id, text: category.name }); if(event.type == "maintenance"){ if (category.id === event.category_id) { option.attr('selected', 'selected'); // Select the matching option } } categorySelect.append(option); }); if(event.type == 'maintenance'){ $('#openhouseModal .category_container').removeClass('dsk-none'); categorySelect.attr('disabled',true); } $('#datepickerEdit').datepicker('update', event.date); $('#datepickerEdit #date').val(event.date); $('#datepickerEdit #date').attr('disabled',true); }else{ TopEndPopUp('warning','No Records') } swal.close(); // console.log(response); }, error: function(XMLHttpRequest, textStatus, errorThrown) { swal.close() TopEndPopUp('warning',errorThrown) } }); $('#openhouseModal').modal('show'); }, editable: false, dayMaxEvents: true, events: event_ajax, // events: [ // { // "title": "Change Door", // "start": "2023-12-02T18:00:00", // "end": "2023-12-02T19:00:00", // "backgroundColor": "#808000", // "textColor": "#4D5E80", // "classNames": [ // "primary", // "all-events" // ], // "extendedProps": { // "userDisplay": true, // "users": [ // "Tenant", // "Landlord" // ] // }, // } // ], // events: [ // { // title: 'Lorem Ipsum', // // start: '2023-05-06T24:23:00', // // end: '2023-05-12T1:23:30', // start: '2023-05-07T00:00:00', // end: '2023-05-07T01:00:00', // backgroundColor: '#33bfff0d', // textColor: '#4D5E80', // classNames: ['primary', 'all-events'], // extendedProps: { // userDisplay: true, // users: ['Martin', 'William'] // } // }, // { // title: 'Lorem Ipsum', // // start: '2023-05-06T24:23:00', // // end: '2023-05-12T1:23:30', // start: '2023-05-08T01:00:00', // end: '2023-05-08T01:30:00', // backgroundColor: '#29cc390d', // textColor: '#4D5E80', // classNames: ['success', 'all-events'], // extendedProps: { // userDisplay: true, // users: ['Quintin'] // } // }, // { // title: 'Modok Ipsum', // // start: '2023-05-06T24:23:00', // // end: '2023-05-12T1:23:30', // start: '2023-05-10T00:30:00', // end: '2023-05-10T01:30:00', // backgroundColor: '#29cc390d', // textColor: '#4D5E80', // classNames: ['success', 'all-events'], // extendedProps: { // userDisplay: true, // users: ['Rick', 'Rick'] // } // }, // { // title: 'Cehck Ipsum', // // start: '2023-05-06T24:23:00', // // end: '2023-05-12T1:23:30', // start: '2023-05-10T02:00:00', // end: '2023-05-10T02:30:00', // backgroundColor: '#29cc390d', // textColor: '#4D5E80', // classNames: ['success', 'all-events'], // extendedProps: { // userDisplay: true, // users: ['Quintin', 'Quintin'] // } // }, // { // title: 'Lorem Ipsum', // // start: '2023-05-06T24:23:00', // // end: '2023-05-12T1:23:30', // start: '2023-05-11T00:30:00', // end: '2023-05-11T01:30:00', // backgroundColor: '#29cc390d', // textColor: '#4D5E80', // classNames: ['primary', 'all-events'], // extendedProps: { // userDisplay: true, // users: ['Rick', 'William'] // } // }, // { // title: 'Lorem Vellum Ipsum Aut Lorem', // // start: '2023-05-06T24:23:00', // // end: '2023-05-12T1:23:30', // start: '2023-05-08T02:00:00', // end: '2023-05-08T03:00:00', // backgroundColor: '#33bfff0d', // textColor: '#4D5E80', // classNames: ['purple', 'all-events'], // extendedProps: { // userDisplay: true, // users: ['Saint','Frank'] // } // }, // { // title: 'Lorem Ipsum', // // start: '2023-05-06T24:23:00', // // end: '2023-05-12T1:23:30', // start: '2023-05-13T00:00:00', // end: '2023-05-13T01:00:00', // backgroundColor: '#33bfff0d', // textColor: '#4D5E80', // classNames: ['primary', 'all-events'], // extendedProps: { // userDisplay: true, // users: ['Rick', 'William'] // } // }, // { // title: 'Long Event', // start: '2023-01-07', // end: '2023-01-10' // }, // { // groupId: 999, // title: 'Repeating Event', // start: '2023-01-09T16:00:00' // }, // { // groupId: 999, // title: 'Repeating Event', // start: '2023-01-16T16:00:00' // }, // { // title: 'Conference', // start: '2023-01-11', // end: '2023-01-13' // }, // { // title: 'Meeting', // start: '2023-01-12T10:30:00', // end: '2023-01-12T12:30:00' // }, // { // title: 'Lunch', // start: '2023-01-12T12:00:00' // }, // { // title: 'Meeting', // start: '2023-01-12T14:30:00' // }, // { // title: 'Happy Hour', // start: '2023-01-12T17:30:00' // }, // { // title: 'Dinner', // start: '2023-01-12T20:00:00' // }, // { // title: 'Birthday Party', // start: '2023-01-13T07:00:00' // }, // { // title: 'Click for Google', // url: 'http://google.com/', // start: '2023-01-28' // } // ], eventDidMount: function (info) { // console.log(info); // {description: "Lecture", department: "BioChemistry"} }, eventDidMount: function (info) { // Access and log the event information // console.log(info.event.extendedProps); const userDisplay = info.event?.extendedProps?.userDisplay ?? false; if (userDisplay) { // console.log($(info.el).closest('.all-events')) const parentElement = $(info.el).closest('.all-events'); let newDiv = `<div class="custom-div">`; // Replace with your HTML content const users = info.event?.extendedProps?.users ?? []; for (let index = 0; index < users.length; index++) { const user = users[index]; newDiv += `<span class="user-display">${user[0]}</span>`; } newDiv += `</div>` parentElement.append(newDiv); } // var $successParent = $(info.el).closest('.success'); // if ($successParent.length > 0) { // // Create an HTML div element with your desired content // var newDiv = '<div class="custom-div">Custom Content</div>'; // Replace with your HTML content // // Append the new div to the success parent element using jQuery // $successParent.append(newDiv); // } }, }); calendar.render(); }); // custom select ds-calendar // custom select function toggleSelectOptions($customSelect) { const $options = $customSelect.find(".select-options"); // Close all other select options except the current one $(".custom-select").not($customSelect).find(".select-options").slideUp(); if (!$options.is(":animated")) { $options.slideToggle(); } } // Handle click on select items // 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"); $(this).next('.select-arrow').toggleClass('active'); // Toggle the options panel with a slide animation $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); toggleCategory(value) $('#hidden_option').val(value); closeSelectOptions(); // Close the options panel // selectValidation(); // You can customize the behavior when an option is selected here // console.log("Selected Value:", value); } }); $(document).ready(function(){ $('#datepicker,#datepickerEdit').datepicker({ startDate: "0", format: 'yyyy-mm-dd', autoclose: true, }); // $(document).on('click','#event_edit_btn',function(){ // document.getElementById('event_edit_btn').disabled = true; // $('#event_edit_btn').addClass('disabled'); // // Enable all fields inside the form (assuming the form has an id openhouseForm) // $('#openhouseModal form :input').prop('disabled', false); // $('.select-selected').removeClass('disable_custom_select'); // }); // $('#event_edit_btn').on('click', function() { // // Disable the button // // $('#event_edit_btn').attr('disabled', 'disabled'); // document.getElementById('event_edit_btn').disabled = true; // $('#event_edit_btn').addClass('disabled'); // // Enable all fields inside the form (assuming the form has an id openhouseForm) // $('#openhouseModal form :input').prop('disabled', false); // }); $('#new_unit_modal_form').submit(function(e) { // var selectedValue = $('#customSelect .select-selected').attr('data-value'); var selectedValue = $('#hidden_option').val(); // console.log('This is selected Value: ',selectedValue); $('#customSelect-error').css('display','none'); if (!selectedValue) { // If the custom select is not selected, prevent form submission e.preventDefault(); // Add red shadow or any other styling to indicate the error $('#customSelect .select-selected').addClass('error-shadow'); $('#customSelect-error').css('display','block'); // console.log('Null Found'); }else{ $('#new_unit_modal_form').submit(); // console.log('form submitted'); } // e.preventDefault(); return; }); }); // Close the dropdowns when clicking outside $(document).on("click", function () { closeSelectOptions(); }); // Prevent clicks inside the dropdown from closing it $(".select-options").on("click", function (e) { e.stopPropagation(); }); // $(document).ready(function(){ // $('#datepicker').datepicker({ // startDate: "0", // format: 'yyyy-mm-dd', // autoclose: true, // }); // }); function toggleCategory(event_type){ if(event_type == "Maintenance" || event_type == "maintenance"){ $('#category_container').removeClass('dsk-none'); $('#category_container select').prop('required', true); }else{ $('#category_container').addClass('dsk-none'); $('#category_container select').prop('required', false); } } // custom select ds-calendar
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка