| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590 |
- <?php
- /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
- * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
- * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
- * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
- * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
- * Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
- * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/custom/booking/booking_agenda.php
- * \ingroup agenda
- * \brief Home page of calendar events
- */
- // Load Dolibarr environment
- require '../../main.inc.php';
- require_once DOL_DOCUMENT_ROOT . '/custom/booking/reservation.class.php';
- if (isModEnabled('project')) {
- require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
- }
- if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
- $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
- }
- if (empty($conf->global->AGENDA_EXT_NB)) {
- $conf->global->AGENDA_EXT_NB = 5;
- }
- $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
- $disabledefaultvalues = GETPOST('disabledefaultvalues', 'int');
- $check_holiday = GETPOST('check_holiday', 'int');
- $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
- $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
- $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
- $showbirthday = empty($conf->use_javascript_ajax) ? GETPOST("showbirthday", "int") : 1;
- // If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user.
- if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
- $filtert = $user->id;
- }
- $newparam = '';
- $sortfield = GETPOST('sortfield', 'aZ09comma');
- $sortorder = GETPOST('sortorder', 'aZ09comma');
- $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
- if (empty($page) || $page == -1) {
- $page = 0;
- } // If $page is not defined, or '' or -1
- $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
- $offset = $limit * $page;
- if (!$sortorder) {
- $sortorder = "ASC";
- }
- if (!$sortfield) {
- $sortfield = "a.datec";
- }
- // Security check
- $socid = GETPOST("search_socid", "int") ? GETPOST("search_socid", "int") : GETPOST("socid", "int");
- if ($user->socid) {
- $socid = $user->socid;
- }
- if ($socid < 0) {
- $socid = '';
- }
- $canedit = 1;
- if (empty($user->rights->agenda->myactions->read)) {
- accessforbidden();
- }
- if (empty($user->rights->agenda->allactions->read)) {
- $canedit = 0;
- }
- if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me
- $filtert = $user->id;
- }
- $action = GETPOST('action', 'aZ09');
- $time1 = GETPOST('time1', 'none');
- $time2 = GETPOST('time2', 'none');
- $facilitie = GETPOST('facilitie', 'numeric');
- $area = GETPOST('area', 'numeric');
- $profile = GETPOST('profile', 'numeric');
- $daterange = GETPOST('daterange', 'none');
- $addreservation = GETPOST('addreservation', 'numeric');
- $mode = GETPOST('mode', 'aZ09');
- if (empty($mode) && preg_match('/show_/', $action)) {
- $mode = $action; // For backward compatibility
- }
- // Load translation files required by the page
- $langs->loadLangs(array('agenda', 'other', 'commercial'));
- // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
- $hookmanager->initHooks(array('agenda'));
- $result = restrictedArea($user, 'agenda', 0, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
- if ($user->socid && $socid) {
- $result = restrictedArea($user, 'societe', $socid);
- }
- $reshook = $hookmanager->executeHooks('beforeAgenda', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
- $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
- llxHeader('', $langs->trans("Agenda"), $help_url);
- $form = new Form($db);
- $reservation = new Reservation();
- $facilities = ["1" => "Gellért fürdő", "2" => "Széchenyi fürdő", "3" => "Lukács fürdő"];
- $area2 = [
- "1" => ["1" => "Medence_1", "2" => "Medence_2", "3" => "Focipálya"],
- "2" => ["1" => "Medence_1", "2" => "Medence_2"],
- "3" => ["1" => "Medence_1", "2" => "Focipálya"]
- ];
- $areas = ["1" => "Medence_1", "2" => "Medence_2", "3" => "Focipálya"];
- $profiles = [
- "1" => ["id" => 1, "idclass" => "SwimmingPoolLine", "name" => "SwimmingPool", "lines" => "6", "type" => 'H', "frameName" => "SwimmingPoolTitle"],
- "2" => ["id" => 2, "idclass" => "PoolLine", "name" => "Pool", "lines" => "4", "type" => 'V', "frameName" => "PoolTitle"],
- "3" => ["id" => 3, "idclass" => "PoloLine", "name" => "Polo", "lines" => "3", "type" => 'V', "frameName" => "PoloTitle"]
- ];
- //print_r($_REQUEST);
- if ($addreservation == 1) {
- print_r($_REQUEST);
- /* $reservation = new stdClass();
- $reservation->facilitie = $facilitie;
- $reservation->area = $area;
- $reservation->daterange = $daterange;
- $reservation->profile = $profile;
- $reservation->fromtime = $time1;
- $reservation->totime = $time2;
- print_r($reservation);exit; */
- }
- // Fürdő és Medence választás
- print '<div class="container mt-5"><h2>' . $langs->trans("reservationTitle") . '</h2><form id="reservatonForm" name="reservatonForm" onsubmit="return validatePage()">';
- print '<div class="container2">';
- print '<div style="width:100%; text-align:center; margin-top: 20px; margin-bottom: 20px;">
- <button type="button" style="width:25%;margin: 0em; margin-top: 20px;" class="butSetDefault" onclick="setDefault()">' . $langs->trans('SetDefault') . '</button></div>';
- print '</div>';
- print '<div class="container2">';
- if ($daterange == '') {
- $daterange = date("Y-m-d", dol_now()) . ' - ' . date("Y-m-d", dol_now());
- }
- $reservation->generateSelectorInput('facilitie', $facilities, $facilitie);
- print '<div class="box areaClass displayNone"></div>';
- $reservation->generateSelectorDateInput('date', $daterange);
- print '<div class="box profileClass displayNone"></div>';
- print '</div>';
- $time1Value = $time1 == '' ? '06:00' : $time1;
- $time2Value = $time2 == '' ? '22:00' : $time2;
- //$reservation->generateTimerLine($time1Value, $time2Value);
- print '<div class="timerClass displayNone" style="margin: 20px 5px 0px 5px; text-align: center; background-color: lightgrey; padding-top: 10px; padding-bottom: 10px;">
- <button type="button" onclick="adjustTime(\'time1\',\'decrease\')">-</button>
- <input style="text-align: center;" type="text" pattern="[0-9]+:[0-9]{2}$" placeholder="hh:mm" id="time1" name="time1" maxlength="5" value="' . $time1Value . '" readonly>
- <button type="button" onclick="adjustTime(\'time1\',\'increase\')">+</button>
- -
- <button type="button" onclick="adjustTime(\'time2\',\'decrease\')">-</button>
- <input style="text-align: center;" type="text" pattern="[0-9]+:[0-9]{2}$" placeholder="hh:mm" id="time2" name="time2" maxlength="5" value="' . $time2Value . '" readonly>
- <button type="button" onclick="adjustTime(\'time2\',\'increase\')">+</button>
- </div>';
- print '<div class="profileTypeClass"></div>';
- print '<div style="width:100%; margin: 0px 5px 0px 5px;"><button style="width:100%;margin: 0em; margin-top: 20px;" id="addreservation" name="addreservation" type="submit" value="1" class="butAction">Küldés</button></div>';
- print '</div>';
- print '</form></div>';
- ?>
- <link rel="stylesheet" type="text/css" href="reservation.css">
- <script>
- var gen = {
- setElem: "ok",
- init: function() {
- var now = new Date;
- $("#date-range").attr("date-start", now.toISOString().slice(0, 10));
- $("#date-range").attr("date-end", now.toISOString().slice(0, 10));
- $(document).on("input", ".timestart", function(event) {
- if (gen.setElem == "ok") {
- gen.setElem = "input";
- var elem = $(this);
- var a = (elem.val()).split(":");
- var b = (elem.parent().find(".durationtime").val()).split(":");
- var time = new Date();
- time.setHours(parseInt(a[0]), parseInt(a[1]), 00, 000);
- time.setMinutes(time.getMinutes() + parseInt(b[1]));
- time.setHours(time.getHours() + parseInt(b[0]));
- // var c = [time.getHours(), time.getMinutes()];
- elem.parent().find(".timeend").val(time.getHours() + ":" + time.getMinutes())
- var minutes = [parseInt(a[0]) * 60 + parseInt(a[1]), parseInt(b[0]) * 60 + parseInt(b[1])];
- if (isNaN(minutes[0])) {
- minutes[0] = 0;
- }
- if (isNaN(minutes[1])) {
- minutes[1] = 0;
- }
- elem.parent().parent().find(".time_slider").slider("values", 0, minutes[0]);
- elem.parent().parent().find(".time_slider").slider("values", 1, minutes[0] + minutes[1]);
- elem.parent().find(".timestart").attr("info", minutes[0]);
- elem.parent().find(".timeend").attr("info", minutes[0] + minutes[1]);
- // elem.parent().find(".durationtime").attr("info",minutes[1]);
- gen.setElem = "ok";
- }
- });
- $(document).on("input", ".durationtime", function(event) {
- if (gen.setElem == "ok") {
- gen.setElem = "input";
- var elem = $(this);
- var a = (elem.parent().find(".timestart").val()).split(":");
- var b = (elem.val()).split(":");
- var time = new Date();
- time.setHours(parseInt(a[0]), parseInt(a[1]), 00, 000);
- time.setMinutes(time.getMinutes() + parseInt(b[1]));
- time.setHours(time.getHours() + parseInt(b[0]));
- // var c = [time.getHours(), time.getMinutes()];
- elem.parent().find(".timeend").val(time.getHours() + ":" + time.getMinutes())
- var minutes = [parseInt(a[0]) * 60 + parseInt(a[1]), parseInt(b[0]) * 60 + parseInt(b[1])];
- if (isNaN(minutes[0])) {
- minutes[0] = 0;
- }
- if (isNaN(minutes[1])) {
- minutes[1] = 0;
- }
- // console.log(minutes);
- elem.parent().parent().find(".time_slider").slider("values", 0, minutes[0]);
- elem.parent().parent().find(".time_slider").slider("values", 1, minutes[0] + minutes[1]);
- elem.parent().find(".timestart").attr("info", minutes[0]);
- elem.parent().find(".timeend").attr("info", minutes[0] + minutes[1]);
- // elem.parent().find(".durationtime").attr("info",minutes[1]);
- gen.setElem = "ok";
- }
- });
- var option = {
- //autoUpdateInput: false,
- locale: {
- "format": "YYYY-MM-DD",
- cancelLabel: "Mégse",
- applyLabel: "Ok",
- "monthNames": [
- "január",
- "február",
- "március",
- "április",
- "május",
- "június",
- "július",
- "augusztus",
- "szeptember",
- "október",
- "november",
- "december"
- ],
- "daysOfWeek": [
- "Vas",
- "Hé",
- "Ke",
- "Sze",
- "Csüt",
- "Pé",
- "Szo"
- ],
- }
- };
- $("#date-range").daterangepicker(option, function(start, end, label) {
- $("#date-range").attr("date-start", start.format("YYYY-MM-DD"));
- $("#date-range").attr("date-end", end.format("YYYY-MM-DD"));
- });
- },
- };
- $(function() {
- gen.init();
- });
- </script>
- <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css">
- <script>
- $("form").on("keydown", function(event) {
- if (event.key === "Enter") {
- event.preventDefault();
- }
- });
- /* document.getElementById("time1").addEventListener("input", function() {
- let input = this.value.replace(/[^0-9]/g, ""); // Csak számokat enged meg
- let hours = input.slice(0, 2);
- let minutes = input.slice(2, 4);
- if (hours.length === 1 && hours > "2") {
- hours = "0" + hours;
- } else if (hours.length === 2 && parseInt(hours, 10) > 23) {
- hours = "23";
- }
- if (minutes.length === 2 && parseInt(minutes, 10) > 59) {
- minutes = "59";
- }
- this.value = hours + (minutes ? ':' + minutes : '');
- });
- document.getElementById("time2").addEventListener("input", function() {
- let input = this.value.replace(/[^0-9]/g, ""); // Csak számokat enged meg
- let hours = input.slice(0, 2);
- let minutes = input.slice(2, 4);
- if (hours.length === 1 && hours > "2") {
- hours = "0" + hours;
- } else if (hours.length === 2 && parseInt(hours, 10) > 23) {
- hours = "23";
- }
- if (minutes.length === 2 && parseInt(minutes, 10) > 59) {
- minutes = "59";
- }
- this.value = hours + (minutes ? ':' + minutes : '');
- });
- */
- function lineClick(profile, timeline, lineNumber, idclass) {
- var currentClass = $('#' + idclass + '_' + timeline + '_' + lineNumber).attr('class');
- if (currentClass.includes('LineRed')) {
- $('#' + idclass + '_' + timeline + '_' + lineNumber).removeClass('LineRed').addClass('LineGreen');
- var hiddenInput = document.getElementById(idclass + '_' + timeline);
- var arr = JSON.parse(hiddenInput.value);
- arr[lineNumber - 1] = 0;
- hiddenInput.value = arr;
- console.log("New value of hidden input:", arr);
- }
- if (currentClass.includes('LineGreen')) {
- $('#' + idclass + '_' + timeline + '_' + lineNumber).removeClass('LineGreen').addClass('LineRed');
- var hiddenInput = document.getElementById(idclass + '_' + timeline);
- var arr = JSON.parse(hiddenInput.value);
- arr[lineNumber - 1] = 1;
- hiddenInput.value = JSON.stringify(arr);
- console.log("New value of hidden input:", arr);
- }
- }
- function lineFullClick(profile, timeline, lineNumber, idclass) {
- for (i = 1; i < lineNumber; i++) {
- var currentClass = $('#' + idclass + '_' + timeline + '_' + i).attr('class');
- if (currentClass.includes('LineRed')) {
- $('#' + idclass + '_' + timeline + '_' + i).removeClass('LineRed').addClass('LineGreen');
- var hiddenInput = document.getElementById(idclass + '_' + timeline);
- var arr = JSON.parse(hiddenInput.value);
- arr[i - 1] = 0;
- hiddenInput.value = JSON.stringify(arr);
- }
- if (currentClass.includes('LineGreen')) {
- $('#' + idclass + '_' + timeline + '_' + i).removeClass('LineGreen').addClass('LineRed');
- var hiddenInput = document.getElementById(idclass + '_' + timeline);
- var arr = JSON.parse(hiddenInput.value);
- arr[i - 1] = 1;
- hiddenInput.value = JSON.stringify(arr);
- }
- }
- }
- </script>
- <script>
- function setDefault() {
- var fullUrl = window.location.origin;
- window.location.href = fullUrl + "/custom/booking/reservation.php";
- }
- function adjustTime(inputId, action) {
- var input = document.getElementById(inputId);
- var currentTime = input.value || "06:00"; // Alapértelmezett idő, ha nincs megadva
- var parts = currentTime.split(':');
- var hours = parseInt(parts[0], 10);
- var minutes = parseInt(parts[1], 10);
- // Növelés vagy csökkentés 30 perccel
- if (action === 'increase') {
- minutes += 30;
- } else if (action === 'decrease') {
- minutes -= 30;
- }
- // Kezelés a túlcsordulásokra
- if (minutes >= 60) {
- hours += 1;
- minutes = minutes % 60;
- } else if (minutes < 0) {
- hours -= 1;
- minutes = 60 + minutes;
- }
- if (hours >= 24) {
- hours = 0;
- } else if (hours < 0) {
- hours = 23;
- }
- // Formázás, hogy mindig kétjegyű legyen az óra és perc
- var formattedTime = ("0" + hours).slice(-2) + ":" + ("0" + minutes).slice(-2);
- input.value = formattedTime;
- var from = document.getElementById("time1");
- var to = document.getElementById("time2");
- var selectedProfileVal = $("#profile").find("option:selected").val();
- var xhrIntervalChange = new XMLHttpRequest();
- xhrIntervalChange.open("POST", "reservation_intervalchange.php", true);
- xhrIntervalChange.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhrIntervalChange.send("from=" + encodeURIComponent(from.value) + "&to=" + encodeURIComponent(to.value) + "&profile=" + selectedProfileVal);
- xhrIntervalChange.onload = function() {
- if (xhrIntervalChange.status === 200) {
- const profileTypeDiv = document.querySelector('.profileTypeClass');
- profileTypeDiv.innerHTML = xhrIntervalChange.responseText;
- } else {
- alert("Request failed");
- }
- };
- //document.getElementById('reservatonForm').submit();
- }
- function validatePage() {
- var selectfac = document.getElementById("facilitie");
- var selectarea = document.getElementById("area");
- var selectprof = document.getElementById("profile");
- var selectdaterange = document.getElementById("date-range");
- if ((!selectfac || selectfac.value == -1) ||
- (!selectarea || selectarea.value == -1) ||
- (!selectprof || selectprof.value == -1) ||
- (!selectdaterange || selectdaterange.value == '')) {
- if (!selectfac || selectfac.value == -1) {
- $("#request_facilitie").removeClass("displayNone").addClass("displayBlock");
- } else {
- $("#request_facilitie").addClass("displayNone");
- }
- if (!selectarea || selectarea.value == -1) {
- $("#request_area").removeClass("displayNone").addClass("displayBlock");
- } else {
- $("#request_area").addClass("displayNone");
- }
- if (!selectdaterange || selectdaterange.value == '') {
- console.log('date-range: ' + (selectdaterange ? selectdaterange.value : 'N/A'));
- $("#request_date").removeClass("displayNone").addClass("displayBlock");
- } else {
- $("#request_date").addClass("displayNone");
- }
- if (!selectprof || selectprof.value == -1) {
- $("#request_profile").removeClass("displayNone").addClass("displayBlock");
- } else {
- $("#request_profile").addClass("displayNone");
- }
- return false;
- } else {
- $("#request_facilitie").addClass("displayNone");
- $("#request_area").addClass("displayNone");
- $("#request_date").addClass("displayNone");
- $("#request_profile").addClass("displayNone");
- alert('Mentve');
- }
- }
- var facilitiesSelect = $("#facilitie");
- var areaSelect = $("#area");
- var profileSelect = $("#profile");
- var daterangeInput = $("#date-range");
- facilitiesSelect.select2();
- areaSelect.select2();
- profileSelect.select2();
- facilitiesSelect.on("change", function(e) {
- var selectedFacilityValue = $(this).val();
- var selectedFacilityText = $(this).find("option:selected").text();
- if (selectedFacilityValue == -1) {
- $("#date-range, #time1, #time2").val("");
- $("#time1, #time2, #area, #date-range, #profile").prop("disabled", true);
- var fullUrl = window.location.origin;
- window.location.href = fullUrl + "/custom/booking/reservation.php";
- } else {
- var xhr = new XMLHttpRequest();
- xhr.open("POST", "reservation_area.php", true);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- // Kérés elküldése
- xhr.send("facilitie=" + encodeURIComponent(selectedFacilityValue) /* + "&email=" + encodeURIComponent('valami2')*/ );
- // Válasz kezelése
- xhr.onload = function() {
- if (xhr.status === 200) {
- $("#area").prop("disabled", false);
- $(".areaClass").removeClass("displayNone").addClass("displayBlock");
- const areaDiv = document.querySelector('.areaClass');
- areaDiv.innerHTML = xhr.responseText;
- var areaSelect = $("#area");
- areaSelect.on("change", function(e) {
- var selectedAreaVal = $(this).find("option:selected").val();
- if (selectedAreaVal == -1) {
- $("#time1, #time2").val("").prop("disabled", true);
- $(".profilesClass, .profileClass, .timerClass, .dateClass")
- .removeClass("displayBlock")
- .addClass("displayNone");
- } else {
- var xhrArea = new XMLHttpRequest();
- xhrArea.open("POST", "reservation_profile.php", true);
- xhrArea.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhrArea.send("area=" + encodeURIComponent(selectedAreaVal));
- xhrArea.onload = function() {
- if (xhrArea.status === 200) {
- $(".dateClass").removeClass("displayNone").addClass("displayBlock");
- $("#profile").prop("disabled", false);
- $(".profileClass").removeClass("displayNone").addClass("displayBlock");
- const profileDiv = document.querySelector('.profileClass');
- profileDiv.innerHTML = xhrArea.responseText;
- var profileSelect = $("#profile");
- profileSelect.on("change", function(e) {
- $(".timerClass").removeClass("displayNone").addClass("displayBlock");
- var selectedProfileVal = $(this).find("option:selected").val();
- if (selectedProfileVal == -1) {
- $("#time1, #time2").val("").prop("disabled", true);
- $(".profilesClass").removeClass("displayBlock").addClass("displayNone");
- } else {
- $("#time1").val("06:00");
- $("#time2").val("22:00");
- var selectedProfileText = $(this).find("option:selected").text();
- var xhrProfile = new XMLHttpRequest();
- xhrProfile.open("POST", "reservation_profile_type.php", true);
- xhrProfile.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhrProfile.send("profile=" + encodeURIComponent(selectedProfileVal));
- xhrProfile.onload = function() {
- if (xhrProfile.status === 200) {
- const profileTypeDiv = document.querySelector('.profileTypeClass');
- profileTypeDiv.innerHTML = xhrProfile.responseText;
- } else {
- alert("Request failed");
- }
- };
- }
- });
- } else {
- alert("Request failed");
- }
- };
- }
- });
- } else {
- alert("Request failed");
- }
- };
- }
- });
- daterangeInput.on("change", function(e) {
- $("#request_date").removeClass("displayBlock").addClass("displayNone");
- })
- </script>
|