projet-php/Consultations.php

202 lines
7.5 KiB
PHP
Executable File

<?php session_start();
require('autoloader.php');
if(!Authentification::checkUser(0)){
header("Location: http://".$_SERVER['HTTP_HOST']."/index.php");
die();
};
/* REPONSE DU MANAGER */
$managerStatus = (isset($_GET['status'])) ? $_GET['status'] : null;
$managerTitle = (isset($_GET['title'])) ? $_GET['title'] : 'Oups!';
$managerMessage = (isset($_GET['message'])) ? $_GET['message'] : 'Erreur interne!';
/* AFFINAGE CALENDRIER */
$patientOpt = (isset($_POST['id_patient'])) ? $_POST['id_patient'] : null;
$medecinOpt = (isset($_POST['id_medecin'])) ? $_POST['id_medecin'] : null;
$moisOpt = (isset($_POST['mois'])) ? $_POST['mois'] : null;
?>
<!DOCTYPE html>
<html>
<head>
<title>Consultations</title>
<meta charset='utf-8'/>
<meta name='description' value='Site de test'/>
<meta name='author' value='{xdrm} & SeekDaSky'/>
<link rel='stylesheet' href='css/font.css'/>
<link rel='stylesheet' href='css/animations.css'/>
<link rel='stylesheet' href='css/global.css'/>
<link rel='stylesheet' href='css/responsive.css'/>
<script type='text/javascript' src='js/lib/API.js'></script>
<script type='text/javascript' src='js/lib/adjust.js'></script>
<script type='text/javascript' src='js/lib/input-checker.js'></script>
</head>
<body>
<!-- BARRE DE NOTIFICATIONS -->
<div id='NOTIFBAR' class='<?php echo ($managerStatus!=null) ? 'active '.$managerStatus : $managerStatus; ?>'>
<div></div>
<div>
<h3><?php echo $managerTitle; ?></h3>
<p><?php echo $managerMessage; ?></p>
<a href='?'><input type='button' value='Fermer'></a>
</div>
</div>
<!-- WRAPPER DE LA PAGE -->
<div id='WRAPPER'>
<!-- MENU DE LA PAGE -->
<nav id='MENU'>
<a href='Dashboard.php' id='ICON'></a>
<div>
<a href='Dashboard.php' id='dashboard'>Tableau de bord</a>
<a href='Consultations.php' id='consultations' class='active'>Consultations</a>
<a href='Medecins.php' id='medecin'>Gestion des médecins</a>
<a href='Patients.php' id='patient'>Gestion des patients</a>
</div>
</nav>
<!-- CONTAINER DE LA PAGE -->
<section id='CONTAINER'>
<!-- FIL D'ARIANE -->
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Consultations.php'>Consultations</a></a> </div>
<?php/********************************/
/* CONSULTER LES RENDEZ-VOUS */
/*************************************/
?>
<article data-title="Calendrier des consultations">
<div><form action='' method='POST'>
<!-- [1] Choix du mois et l'année d'affichage -->
<?php
if( $moisOpt != null )
echo "<input type='text' id='csMonth' name='mois' placeholder='12/2015' value='".$moisOpt."'>Mois à afficher.<br>";
else
echo "<input type='text' id='csMonth' name='mois' placeholder='12/2015'>Mois à afficher.<br>";
?>
<select id='csPatient' name='id_patient'>
<?php
echo "<option value='*'>Tous les patients:</option>";
foreach(PatientRepo::getAll() as $PATIENT){
if( $PATIENT['Id'] == $patientOpt ) // selection par défaut
echo "<option value='".$PATIENT['Id']."' data-medecin='".$PATIENT['MedecinTraitant']."' selected>".$PATIENT['Nom']." ".$PATIENT['Prenom']."</option>";
else // sinon
echo "<option value='".$PATIENT['Id']."' data-medecin='".$PATIENT['MedecinTraitant']."'>".$PATIENT['Nom']." ".$PATIENT['Prenom']."</option>";
}
?>
</select>
<select id='csMedecin' name='id_medecin'>
<option value='*'>Tous les médecins:</option>
<?php
foreach(MedecinRepo::getAll() as $MEDECIN){
if( $MEDECIN['Id'] == $medecinOpt ) // selection par défaut
echo "<option value='".$MEDECIN['Id']."' selected>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
else
echo "<option value='".$MEDECIN['Id']."'>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
}
?>
</select>
<!-- <input type='hidden' name='command' value='RDV:getSVG'> -->
<input type='submit' value='Affiner'>
</form></div>
<!-- HERE COMES THE SVG -->
<div id='calendar'><?php
$rdv = new RDV();
if( $moisOpt != null && preg_match('/^(\d{2})\/(\d{4})$/', $moisOpt, $m) ){
$mois = $m[1];
$annee = $m[2];
// $rdv->getSVG(['mois'=>$moisOpt]);
// on affiche les consutations en fonction de l'affinage
// var_dump( RDVRepo::getForMonth($mois, $annee) );
foreach(RDVRepo::getForMonth($mois, $annee) as $RDV){
echo "<div class='RDV'>";
/* MODIFICATION */
echo "<form action='managers/' method='POST'>";
echo "<input type='text' class='jour' name='jour' value='".date('d/m/Y', strtotime($RDV['DateRDV']))."'>";
echo "<input type='text' class='heure' name='heure' value='".date('H:i', strtotime($RDV['DateRDV']))."'>";
echo "<input type='text' class='duree' name='Duree' value='".date('i:s', strtotime($RDV['Duree']))."'>";
echo "<input type='text' readonly class='Medecin' value='Medecin: ".$RDV['M_Prenom']." ".$RDV['M_Nom']."'>";
echo "<input type='text' readonly class='Patient' value='Patient: ".$RDV['P_Prenom']." ".$RDV['P_Nom']."'>";
echo "<input type='hidden' name='id_consultation' value='".$RDV['Id']."'>";
echo "<input type='hidden' name='command' value='RDV:update'>";
echo "<input type='submit' value=''>";
echo "</form>";
/* SUPPRESSION */
echo "<form action='managers/' method='POST'>";
echo "<input type='hidden' name='id_consultation' value='".$RDV['Id']."'>";
echo "<input type='hidden' name='command' value='RDV:delete'>";
echo "<input type='submit' value=''>";
echo "</form>";
echo "</div>";
}
}
?></div>
</article>
<?php/*************************************/
/* SAISIR UN RENDEZ-VOUS */
/*************************************/ ?>
<article data-title="Saisir un rendez-vous">
<form method='POST' action='managers/'>
<div>
<select id='newRDVPatient' name='id_patient'>
<option value='*'>Patient:</option>
<?php
foreach(PatientRepo::getAll() as $PATIENT)
echo "<option value='".$PATIENT['Id']."' data-medecin='".$PATIENT['MedecinTraitant']."'>".$PATIENT['Nom']." ".$PATIENT['Prenom']."</option>";
?>
</select>
</div><div>
<select id='newRDVMedecin' name='id_medecin'>
<option value='*'>Medecins:</option>
<?php
foreach(MedecinRepo::getAll() as $MEDECIN)
echo "<option value='".$MEDECIN['Id']."'>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
?>
</select><span class='associated'>Médecin traitant du patient.</span>
</div><br>
<input type='text' id='inDate' name='date' placeholder='jj/mm/aaaa' required><span class='info'>Date de la consultation</span><br>
<input type='text' id='inHeure' name='heure' placeholder='HH:MM' required><span class='info'>Heure de la consultation</span><br>
<input type='text' id='inDuree' name='duree' placeholder='minutes' required><span class='info'>Durée de la consultation</span><br>
<br>
<input type='hidden' name='command' value='RDV:add'>
<input type='submit' id='sbCreer' value='Enregistrer la consultation'>
</form>
</article>
</section>
</div>
<script type='text/javascript' src='js/consultations.js'></script>
</body>
</html>