Modifications et rectifications RDV mineures

This commit is contained in:
xdrm-brackets 2016-01-03 16:10:48 +01:00
parent e270a35062
commit 5ccc823c13
3 changed files with 37 additions and 26 deletions

View File

@ -14,6 +14,9 @@ $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;
$patientOpt = (!is_numeric($patientOpt)) ? null : $patientOpt;
$medecinOpt = (!is_numeric($medecinOpt)) ? null : $medecinOpt;
?>
<!DOCTYPE html>
@ -122,31 +125,34 @@ $moisOpt = (isset($_POST['mois'])) ? $_POST['mois'] : null;
$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'>";
// affinage par médecin
if( $medecinOpt == null || $medecinOpt == $RDV['Medecin_Id'] ){
if( $patientOpt == null || $patientOpt == $RDV['Patient_Id'] ){
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']."'>";
/* 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>";
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>";
/* 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>";
echo "</div>";
}}
}
}
?></div>

View File

@ -79,20 +79,20 @@ class RDV
public function update($params){
// si params ok
var_dump($params['duree']);
if( StaticRepo::checkParam($params['id_consultation'], 'Numeric') && StaticRepo::checkParam($params['jour'], 'Date') && StaticRepo::checkParam($params['heure'], 'Heure') && StaticRepo::checkParam($params['Duree'], 'Heure') ){
$params['date'] = DateTime::createFromFormat('d/m/Y H:i', $params['jour'].' '.$params['heure']);
$params['dureeTime'] = $params['duree'].':00';
var_dump($params['dureeTime']);
$params['dureeTime'] = $params['Duree'].':00';
// var_dump($params['dureeTime']);
if (RDVRepo::updateDateTime($params['id_consultation'], $params['date']->format('Y-m-d H:i:00'), $params['dureeTime'] ) !== FALSE) {
$_status = 'success';
$_title = 'Modification effectuée!';
$_message = 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].'a bien été mise à jour.';
$_message = 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].' a bien été mise à jour.';
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
Response::quickResponse(200, json_encode([ 'status' => $_status, 'title' => $_title, 'message' => $_message ]));
else{
$response = new Response();
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Consultations.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}else{
$_status = 'error';
@ -104,6 +104,7 @@ class RDV
else{
$response = new Response();
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Consultations.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
}else{
@ -116,6 +117,7 @@ class RDV
else{
$response = new Response();
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Consultations.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
}

View File

@ -20,7 +20,7 @@ class RDVRepo
}
public static function getForMonth($month, $year){
$req = StaticRepo::getConnexion()->prepare("SELECT RDV.Id, RDV.DateRDV, RDV.Duree, Medecin.Prenom as M_Prenom, Medecin.Nom as M_Nom, Patient.Prenom as P_Prenom, Patient.Nom as P_Nom
$req = StaticRepo::getConnexion()->prepare("SELECT RDV.Id, RDV.DateRDV, RDV.Medecin_Id, RDV.Patient_Id, RDV.Duree, Medecin.Prenom as M_Prenom, Medecin.Nom as M_Nom, Patient.Prenom as P_Prenom, Patient.Nom as P_Nom
FROM RDV, Patient, Medecin
WHERE Patient.Id = RDV.Patient_Id
AND Medecin.Id = RDV.Medecin_Id
@ -70,8 +70,11 @@ class RDVRepo
public static function updateDateTime($idRDV, $dateRdv, $duree){
if(!StaticRepo::checkParam($idRDV, 'Numeric')){return false;}
if(!StaticRepo::checkParam($idRDV, 'Numeric')) return false;
var_dump($idRDV);
var_dump($dateRdv);
var_dump($duree);
$req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date_rdv, Duree = :duree WHERE id = :id');
return $req->execute([
':date_rdv' => $dateRdv,