/** * @brief Retourne l'instance de la classe et permet d'instancier un SchedulesManager si c'est le premier appel. * @return SchedulesManager Retourne l'instance de la classe */ public static function instance() { if (self::$instance == null) { self::$instance = new SchedulesManager(); } return self::$instance; }
<?php defined("_nova_district_token_") or die(''); if (isset($_GET['rdvc']) and $_GET['rdvc'] != "" and isset($_GET['d']) and $_GET['d'] != "" and $_SESSION['id-member'] == $_GET['d'] or isset($_GET['rdva']) and $_GET['rdva'] != "" and isset($_GET['d']) and $_GET['d'] != "" and $_SESSION['id-member'] == $_GET['d']) { $result = SchedulesManager::instance()->cancelSchedule($_SESSION['user']->getIdMember(), $_GET['rdvc']); if (Tools::getClass($result) == "Schedule") { AlertsManager::instance()->generateAutomaticMessage($_SESSION['user']->getIdMember(), $result, 4); $errors['cancel'] = new Error("Le rendez-vous a bien été annulé. Le patient recevra bientôt une alerte pour le prévenir", 'info'); } else { $errors['cancel'] = $result; } } //On inclut la vue include dirname(__FILE__) . '/../views/doctor-cancel.php';
/** * @brief Permet de générer le code HTML d'un emploi du temps depuis une date de départ pour un praticien en particulier * @param DateTime $dateStart Date de départ * @param Doctor $doctor Praticien * @return String Code HTML */ public function getDoctorCalendar($dateStart, $doctor) { //var générales $dateStart->setTime($doctor->getStartHour("h"), 0, 0); $fromDate = $dateStart->getTimestamp(); $toDate = $dateStart->getTimestamp() + $this->nbrDays * 24 * 3600; $roundStart = true; //on commence à une heure PILE $roundEnd = true; //on fini à une heure PILE if ($doctor->getStartHour("m") > 0) { $roundStart = false; } if ($doctor->getEndHour("m") > 0) { $roundEnd = false; } //init $days = $this->getInterval($dateStart, $this->nbrDays); //tableau de DateTime $rdv = SchedulesManager::instance()->getSchedule($doctor->getIdMember(), $fromDate, $toDate); $rdv2 = SchedulesManager::instance()->getBlockSchedule($doctor->getIdMember(), $fromDate, $toDate); $rdv = array_merge($rdv, $rdv2); //vars de boucle $hours = ""; $result = ""; $nbrHours = ceil($doctor->getWorkTime() / 60.0); $hoursToHTML = $doctor->getWorkTime() * 60; //on corrige si endHour Minute < start hour ! if ($doctor->getStartHour('m') > 0) { if ($doctor->getEndHour('m') <= $doctor->getStartHour('m')) { $nbrHours++; } } $firstHourOfFirstDay = 0; // heure du premier jour de la quinzaine stocké en INT $hourWidth = floor(($this->width - $nbrHours) / $nbrHours); //px (on retire le border qui ajoute 1px) $d = 0; //début du draw $result .= "<div class='calendar-info-hours'>\n\t\t\t\t\t\t<div class='calendar-info-hour calendar-info-hour-first'></div>"; for ($i = 0; $i < $nbrHours; $i++) { $result .= "<div class='calendar-info-hour' style='width: " . $hourWidth . "px'>" . ($doctor->getStartHour('h') + $i) . "h</div>"; } $result .= "</div>"; foreach ($days as $day) { //chaque jours de la quinzaine récupérée if ($firstHourOfFirstDay == 0) { $firstHourOfFirstDay = $day->getTimestamp(); } $dayName = $this->days[$day->format('w')]; $dayNbr = $day->format('d'); $result .= "<div class='calendar-item'>\n\t\t\t\t\t\t\t<div class='calendar-day'>\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t" . $dayName . " " . $dayNbr . "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class='calendar-hours' data-calendar-startHour='" . ($firstHourOfFirstDay + $doctor->getStartHour('m') * 60 + $d * 3600 * 24) . "' data-calendar-endHour='" . ($firstHourOfFirstDay + $doctor->getStartHour('m') * 60 + $d * 3600 * 24 + $hoursToHTML) . "'>"; for ($i = 0; $i < $nbrHours; $i++) { $cur = $firstHourOfFirstDay + $i * 3600 + $d * 3600 * 24; $result .= "<div class='calendar-hour' style='width: " . $hourWidth . "px' data-calendar-day='" . $cur . "' data-calendar-hour='" . ($doctor->getStartHour('h') + $i) . "'>"; $baseCalcul = $hourWidth / 3600; $left = 0; $width = 0; if ($i == 0 && $roundStart == false) { //on a un départ décalé $width = round($baseCalcul * ($doctor->getStartHour('m') * 60)); $result .= "<div class='calendar-rdv calendar-block' style='left: " . $left . "px; width: " . $width . "px'></div>"; } if ($i == $nbrHours - 1 && $roundEnd == false) { //on a un départ décalé $left = round($baseCalcul * ($doctor->getEndHour('m') * 60)); $width = $hourWidth - $left; $result .= "<div class='calendar-rdv calendar-block' style='left: " . $left . "px; width: " . $width . "px'></div>"; } foreach ($rdv as $sched) { $left = 0; $width = 0; if ($sched->getDateStart() >= $cur and $sched->getDateStart() <= $cur + 3600) { //le start est dans l'heure if ($sched->getDateStop() >= $cur and $sched->getDateStop() <= $cur + 3600) { //stop dans l'heure AUSSI $left = round($baseCalcul * ($sched->getDateStart() - $cur)); $width = round($baseCalcul * ($sched->getDateStop() - $sched->getDateStart())); } else { //stop pas dans l'heure $left = round($baseCalcul * ($sched->getDateStart() - $cur)); $width = $hourWidth - $left; } } else { if ($sched->getDateStop() >= $cur and $sched->getDateStop() <= $cur + 3600) { // le stop est dans l'heure mais pas le start $width = round($baseCalcul * ($sched->getDateStop() - $cur)); } else { if ($sched->getDateStop() >= $cur + 3600 and $sched->getDateStart() <= $cur) { //le stop et le start ne sont pas dans l'heure mais ils sont au delà et avant ! $width = $hourWidth; } } } if ($width != 0) { //si on doit dessiner un rdv/bloquage $class = "calendar-reserved"; $tmp = $sched->getIdMember(); if (!isset($tmp)) { $class = "calendar-block"; } $result .= "<div class='calendar-rdv " . $class . "' style='left: " . $left . "px; width: " . $width . "px'></div>"; } } $result .= "</div>"; } $result .= "</div></div>"; $d++; } return $result; }
<?php defined("_nova_district_token_") or die(''); //suppression d'un RDV par le membre if (isset($_GET['rdv']) and is_numeric($_GET['rdv']) and isset($_GET['doctor']) and is_numeric($_GET['doctor'])) { $result = SchedulesManager::instance()->cancelSchedule($_SESSION['user']->getIdMember(), intval($_GET['rdv'])); if (Tools::getClass($result) == "Schedule") { AlertsManager::instance()->generateAutomaticMessage(intval($_GET['doctor']), $result, 4); AlertsManager::instance()->generateAutomaticMessage($_SESSION['user']->getIdMember(), $result, 0); } else { $errors['cancel'] = $result; } } //On inclut le modèle $futursRdv = SchedulesManager::instance()->getFutureSchedule($_SESSION['user']->getIdMember()); $favorites = UsersManager::instance()->getFavoritesDoc($_SESSION['user']->getIdMember()); //On inclut la vue include dirname(__FILE__) . '/../views/home.php';
$errors['blocage-horaires'] = new Error("Veuillez indiquer le nombre de semaines pour la récursivité"); } } else { $block = new Schedule(); $block->setDateStart(strtotime($_POST['ddebut'] . " " . $_POST['hdebut'] . ":0")); $block->setDateStop(strtotime($_POST['dfin'] . " " . $_POST['hfin'] . ":0")); $block->setNote($_POST['infos']); $block->setRecursion('0'); $block->setIdDoctor($_SESSION['user']->getIdMember()); $errors['blocage-horaires'] = SchedulesManager::instance()->addBlock($block); } } else { $errors['blocage-horaires'] = new Error("Veuillez remplir tous les champs correctement"); } } else { $errors['blocage-horaires'] = new Error("Veuillez remplir tous les champs correctement"); } } //Suppresion d'un blocage if (isset($_GET['del']) and isset($_GET['id'])) { if ($_GET['del'] == "delete") { //SchedulesManager::instance()->deleteBlock($_GET['id']); SchedulesManager::instance()->deleteBlock($_SESSION['user']->getIdMember(), $_GET['id']); } } // Récupération des blocages récursifs $recursiveblocks = SchedulesManager::instance()->getRecursiveSchedule($_SESSION['user']->getIdMember()); // Récupération des blocages non récursifs $blocks = SchedulesManager::instance()->getRecursiveSchedule($_SESSION['user']->getIdMember(), 0); //vue include dirname(__FILE__) . '/../../views/modules/gestion-block.php';
defined("_nova_district_token_") or die(''); //RECUPERATION DE LA DATE SELECTIONNEE OU PAR DEFAUT $day = mktime(0, 0, 0, date('m'), date('d'), date('Y')); if (isset($_GET['chosen-date']) and Tools::checkDate($_GET['chosen-date'])) { $temp = explode('-', $_GET['chosen-date']); if (isset($temp[0]) and isset($temp[1]) and isset($temp[2])) { $day = mktime(0, 0, 0, intval($temp[1]), intval($temp[2]), intval($temp[0])); } } //SUPPRESSION D'UN RDV if (isset($_GET['a']) and $_GET['a'] == "del" and isset($_GET['rdv']) and is_numeric($_GET['rdv'])) { $result = SchedulesManager::instance()->cancelSchedule($_SESSION['user']->getIdMember(), intval($_GET['rdv'])); if (Tools::getClass($result) == "Error") { $errors['daily-delete'] = $result; } else { AlertsManager::instance()->generateAutomaticMessage($result->getIdMember(), $result, 4); } } //VALIDATION D'UN RDV if (isset($_GET['a']) and $_GET['a'] == "val" and isset($_GET['rdv']) and is_numeric($_GET['rdv'])) { $result = SchedulesManager::instance()->confirmSchedule($_SESSION['user']->getIdMember(), intval($_GET['rdv'])); if (Tools::getClass($result) == "Error") { $errors['daily-validate'] = $result; } else { AlertsManager::instance()->generateAutomaticMessage($result->getIdMember(), $result, 5); } } $dailyScheduleList = SchedulesManager::instance()->getScheduleList($_SESSION['user']->getIdMember(), $day, $day + 24 * 3600); //vue include dirname(__FILE__) . '/../../views/modules/gestion-daily.php';
$sc->setDateStart(strtotime($_POST['date-rdv'] . " " . $_POST['time-rdv'] . ":00")); $sc->setDateStop($sc->getDateStart() + $doctor->getRdvDuration() * 60); if ($doctor->getRdvConfirm() == 0) { $sc->setValidate(1); } if (isset($_POST['note'])) { $sc->setNote(Tools::secure($_POST['note'])); } $dayStartHour = strtotime($_POST['date-rdv'] . " " . $doctor->getStartHour('h') . ":" . $doctor->getStartHour('m') . ":00"); $result = SchedulesManager::instance()->getLastBlockedBlockHour($doctor->getIdMember(), $dayStartHour, $sc->getDateStart()); $calage = abs($sc->getDateStart() - $result); $calage = $calage % ($doctor->getRdvDuration() * 60); if ($calage != 0) { $errors['rdv'] = new Error("Vous ne pouvez pas prendre un rendez-vous en dehors des heures fixées par le calendrier."); } else { $result = SchedulesManager::instance()->add($sc); if (Tools::getClass($result) == "Error") { $errors["rdv"] = $result; } else { $errors['rdv'] = new Error("Le rendez-vous a bien été pris auprès de votre médecin", "info"); } } } else { $errors['rdv'] = new Error("Les informations entrées ne sont pas valides"); } } //AJOUT DU MEDECIN AUX FAVORIS ! if (isset($_POST['add-to-favorite'])) { $errors['add-to-favorite'] = UsersManager::instance()->addDoctorToFavorites($_SESSION['user']->getIdMember(), $doctor->getIdMember()); } if (isset($_POST['remove-to-favorite'])) {
<?php defined("_nova_district_token_") or die(''); include "views/modules/small-profile.php"; ?> <script type='text/javascript'> $(document).ready(function() { $(".cancel-rdv-by-user").click(function(){ var url = $(this).attr("href"); var tel = $(this).attr('data-dialog-info'); App.Dialog.add( "Etes-vous sûr de vouloir supprimer ce rendez-vous ?", "Vous supprimerez définitivement ce rendez-vous, le médecin en sera informé.<br /><br />"+ "<strong>Attention !</strong> <br />Si le rendez-vous intervient dans moins de <?php echo SchedulesManager::instance()->getMaxTimeToCancel(); ?> h vous ne pourrez pas le supprimer. "+ "<br />Il faudra contacter votre praticien à ce numéro de téléphone : <strong>" + tel + "</strong>", new Array('oui', 'non'), function (result){ if(result) document.location.href = url; } ); return false; }); }); </script> <div id="content"> <?php include "views/modules/search.php"; ?>
$found = true; } else { if ($sched->getDateStop() >= $dateStart + $duration * 60 and $sched->getDateStart() <= $dateStart) { //le stop et le start ne sont pas dans l'heure mais ils sont au delà et avant ! $found = true; } } } if ($found) { $previous = $sched; break; } } //si pas de créneau on récupere le précédent dans la journée (bloquage ou schedule) if (!$found) { $previous = SchedulesManager::instance()->getPreviousSchedule($doctor, $dayStartHour, $dateStart); if (get_class($previous) != "Schedule") { // pas trouvé de départ bloqué. On prend l'heure de démarrage de la journée $previous = new Schedule(); $temp = intval(date('i', $dayStartHour)); $previous->setDateStart($dayStartHour - $temp * 60); $previous->setDateStop($dayStartHour); } //$rdv[] = $previous; } $result = ""; $hourWidth = 800 / $nbrBlocks; //pixel - border * 2 $baseCalcul = $hourWidth / ($duration * 60); /** Au choix ici, on peut choisir de conserver l'organisation générale des créneaux ou s'adapter par rapport au dernier pris **/ //$dateStart = $dayStartHour + floor(($dateStart - $dayStartHour) / ($doctor->getRdvDuration() * 60)) * ($doctor->getRdvDuration() * 60);