コード例 #1
0
ファイル: booking.php プロジェクト: AymericFrey/ProjetBooking
            $dateStart = new DateTime(date("Y-m-d H:i:s"));
        }
    } else {
        Tools::redirect("home");
    }
} else {
    Tools::redirect("home");
}
//PRISE D'UN RENDEZ-VOUS
if (isset($_POST['date-rdv']) and isset($_POST['time-rdv']) and isset($_POST['tk']) and $_POST['tk'] == $_SESSION['token2'] and $_SESSION['user']->getIdMember() != $_GET['doctor']) {
    if (Tools::checkDate($_POST['date-rdv']) and Tools::checkTime($_POST['time-rdv']) and isset($_POST['valid-rdv'])) {
        $sc = new Schedule();
        $sc->setIdDoctor($doctor->getIdMember());
        $sc->setIdMember($_SESSION['user']->getIdMember());
        $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") {
コード例 #2
0
                            $block->setDateStart($datedebut + 24 * 3600 * 7 * $i);
                            //Ajout de i semaine (i x 7 jours x 24 heures x 3600 secondes) à la date de fin
                            $block->setDateStop($datefin + 24 * 3600 * 7 * $i);
                            $block->setNote($_POST['infos']);
                            $block->setRecursion('7');
                            $block->setIdDoctor($_SESSION['user']->getIdMember());
                            $errors['blocage-horaires'] = SchedulesManager::instance()->addBlock($block);
                        }
                    }
                } else {
                    $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") {
コード例 #3
0
         }
     }
     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);
 $dateStart = $previous->getDateStop() + floor(($dateStart - $previous->getDateStop()) / ($doctor->getRdvDuration() * 60)) * ($doctor->getRdvDuration() * 60);
 for ($i = 0; $i < $nbrBlocks; $i++) {
     if ($dateStart + $i * $duration * 60 + $duration * 60 <= $dayStartHour or $dateStart + $i * $duration * 60 + $duration * 60 > $dayEndHour) {
         continue;
     }
     $cur = $dateStart + $i * $duration * 60;