0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"; } // Try main.inc.php using relative path if (!$res && file_exists("../main.inc.php")) { $res = @include "../main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } $product_id = GETPOST('product_id', 'alpha'); $function = GETPOST('function', 'alpha'); $selectedDate = GETPOST('selectedDate', 'alpha'); function checkEvent($product_id, $db) { $sql = "SELECT bbbs.is_event FROM public.llx_product_extrafields as pre INNER JOIN llx_bbus_basicservices as bbbs ON CAST(bbbs.rowid AS VARCHAR) = pre.basic_service WHERE pre.fk_object = {$product_id}"; $result = $db->query($sql); if ($db->num_rows($result) > 0) { while ($row = $db->fetch_object($result)) { print $row->is_event == 1 ? 'true' : 'false'; } } } function GetAllEventsOfTheSelectedProduct($product_id, $db) { $date_from = date("Y-m-d", dol_now()); $sql = "SELECT ac.id, ac.datep, ace.max_num, ace.participants, ace.buffer FROM llx_actioncomm as ac LEFT JOIN llx_actioncomm_extrafields as ace ON ace.fk_object = ac.id INNER JOIN llx_eventwizard_eventdetails as ed ON ac.fk_element = ed.rowid INNER JOIN llx_eventwizard_eventproduct as ep ON ep.fk_eventdetails = ac.fk_element WHERE ac.code = 'AC_EVENT' AND ep.fk_product = {$product_id} AND ac.datep > '{$date_from} 00:00:00' ORDER BY ac.datep ASC"; $result = $db->query($sql); $datesArray = []; if ($db->num_rows($result) > 0) { while ($row = $db->fetch_object($result)) { $date = []; $date = explode(' ', $row->datep); $datesArray[] = $date[0]; //print $row->datep; } if(!empty($datesArray)){ print json_encode($datesArray); }else{ print ''; } } } function GetAllTimesOfTheSelectedEvent($product_id, $selectedDate, $db) { $date = new DateTime($selectedDate); $date->modify('+1 day'); $date_to = $date->format('Y-m-d'); $sql = "SELECT ac.id, ac.datep, ace.max_num, ace.participants, ace.buffer FROM llx_actioncomm as ac LEFT JOIN llx_actioncomm_extrafields as ace ON ace.fk_object = ac.id INNER JOIN llx_eventwizard_eventdetails as ed ON ac.fk_element = ed.rowid INNER JOIN llx_eventwizard_eventproduct as ep ON ep.fk_eventdetails = ac.fk_element WHERE ac.code = 'AC_EVENT' AND ep.fk_product = {$product_id} AND ac.datep > '{$selectedDate} 00:00:00' AND ac.datep2 < '{$date_to} 00:00:00' ORDER BY ac.datep ASC"; $result = $db->query($sql); if ($db->num_rows($result) > 0) { $datesArray = []; while ($row = $db->fetch_object($result)) { $date = []; $date = explode(' ', $row->datep); $time = explode(':', $date[1]); $datesArray[$row->id] = $time[0] . ':' . $time[1]; } print json_encode($datesArray); } } if ($function == 'checkEvent') { checkEvent($product_id, $db); } if ($function == 'GetAllEventsOfTheSelectedProduct') { GetAllEventsOfTheSelectedProduct($product_id, $db); } if ($function == 'GetAllTimesOfTheSelectedEvent') { GetAllTimesOfTheSelectedEvent($product_id, $selectedDate, $db); }