1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
Accommodation_Management/controller/reservation.php

40 lines
1.5 KiB
PHP
Raw Normal View History

2021-01-18 13:36:04 +01:00
<?php
if ($_SESSION['USER']->isLoggedIn() && $_SESSION['USER']->getType() == 'Staff') {
if(isset($path[1])){
switch ($path[1]){
case 'date':
if(isset($path[2])){
$dates = [];
$reservation = AccomodationReservation::fetchByUserEmail($path[2]);
forEach($reservation as $reserv){
$start = date_create($reserv->getStartDate());
$end = date_create($reserv->getEndDate());
$end->add(new DateInterval('P1D'));
$period = new DatePeriod(
$start,
new DateInterval('P1D'),
$end
);
foreach ($period as $key => $value) {
if(!in_array($value->format('Y-m-d'), $dates)){
$dates[] = $value->format('Y-m-d');
}
}
}
echo json_encode($dates);
}
die();
default:
die();
}
}
$alert = '';
$bornes_date = array_keys(AccomodationLoad::getRange());
$bornes_date = [$bornes_date[0], $bornes_date[count($bornes_date) - 1]];
$vips = User::fetch(array(['UserTypeName', '=', 'VIP']));
require_once(VIEW_PATH . $path[0] . '.php');
} else {
redirect('login');
}