/** * @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; }
/** * @brief Met à jour le profil d'un praticien * @param Doctor $doctor Praticien * @return Error Succès sous forme d'information */ public function updateProfile(Doctor $doctor) { $req = $this->bdd->prepare("UPDATE doctor SET \n\t\t rdv_duration = :rdv_duration,\t\t\t/* Mise à jour de la durée d un rendez-vous */\n\t\t info_pro = :info_pro,\t\t\t\t\t/* Mise à jour des informations professionnelles */\n\t\t start_hour = :str_hour,\t\t\t\t/* Mise à jour de l heure de début */\n\t\t end_hour = :end_hour,\t\t\t\t\t/* Mise à jour de l heure de fin */\n\t\t rdv_confirm = :rd_confirm\t\t\t\t/* mise à jour de l'option de confirmation d'un RDV */\n\t\tWHERE id_member = :id_member"); $req->bindValue(':rdv_duration', $doctor->getRdvDuration(), PDO::PARAM_INT); $req->bindValue(':info_pro', $doctor->getInfoPro(), PDO::PARAM_STR); $req->bindValue(':str_hour', $doctor->getStartHour('h') . ":" . $doctor->getStartHour('m') . ":" . $doctor->getStartHour('s'), PDO::PARAM_STR); $req->bindValue(':end_hour', $doctor->getEndHour('h') . ":" . $doctor->getEndHour('m') . ":" . $doctor->getEndHour('s'), PDO::PARAM_STR); $req->bindValue(':rd_confirm', $doctor->getRdvConfirm(), PDO::PARAM_INT); $req->bindValue(':id_member', $doctor->getIdMember(), PDO::PARAM_INT); $req->execute(); return new Error("Le profil a été mis à jour", "info"); }