From e270a350621cca100da1e3e4a03591c4fae67ab0 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 3 Jan 2016 16:01:38 +0100 Subject: [PATCH] =?UTF-8?q?Modifications=20majeures=20=C3=A9parses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Consultations.php | 73 +++++-- css/global.css | 142 ++++++++++++- js/consultations.js | 9 + managers/RDV.class.php | 367 +++++++++++++++++---------------- managers/config/managers.json | 2 +- repositories/StaticRepo.php | 4 +- repositories/repos/RDVRepo.php | 28 ++- test.php | 2 +- 8 files changed, 428 insertions(+), 199 deletions(-) diff --git a/Consultations.php b/Consultations.php index 8d61ce3..5772436 100755 --- a/Consultations.php +++ b/Consultations.php @@ -9,6 +9,11 @@ $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; + ?> @@ -66,18 +71,27 @@ $managerMessage = (isset($_GET['message'])) ? $_GET['message'] : 'Erreur interne + /*************************************/ + ?>
-
+
- Mois à afficher.
- + Mois à afficher.
"; + else + echo "Mois à afficher.
"; + ?> @@ -85,21 +99,56 @@ $managerMessage = (isset($_GET['message'])) ? $_GET['message'] : 'Erreur interne - + -

+
getSVG(['mois'=>'10/2015']); + 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 "
"; + + /* MODIFICATION */ + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo "
"; + + /* SUPPRESSION */ + echo "
"; + echo ""; + echo ""; + echo ""; + echo "
"; + + echo "
"; + } + } ?>
diff --git a/css/global.css b/css/global.css index 29f780c..502d6f9 100755 --- a/css/global.css +++ b/css/global.css @@ -817,6 +817,144 @@ input[type=radio]:checked + label:before{ height: auto; } -#Textday_3:hover{ - background: red; +/* cases */ +#calendar rect[class^="day_"]{ + transition: all .2s ease-in-out; + -moz-transition: all .2s ease-in-out; + -webkit-transition: all .2s ease-in-out; + -ms-transition: all .2s ease-in-out; + -o-transition: all .2s ease-in-out; + + cursor: pointer; +} + +#calendar rect[class^="day_"]:hover{ + fill: #f09108 !important; +} + +#calendar rect[class^="day_"]:hover + [class^="Textday_"]{ + fill: #fff !important; + cursor: pointer; + pointer-events: none; +} + + +/* Liste des rendez-vous */ +.RDV{ + /* position */ + display: inline-block; + position: relative; + width: calc( 100% - 2*1em - 10em ); + margin-bottom: .5em; + padding: 2em 1em; + + /* border */ + border-radius: 3px; + border: 1px solid #c7c7c7; + + /* background */ + background: transparent; + + /* animation */ + transition: all .2s ease-in-out; + -moz-transition: all .2s ease-in-out; + -webkit-transition: all .2s ease-in-out; + -ms-transition: all .2s ease-in-out; + -o-transition: all .2s ease-in-out; + + /* extra */ + cursor: pointer; +} + +.RDV:hover{ + border-color: #898989; +} + + +/* les champs */ +.RDV > form:nth-child(1) > input{ + /* position */ + display: inline-block !important; + position: absolute !important; + margin: 0 !important; + padding: 0 !important; + padding-right: 2em !important; + + /* border */ + border: 0 !important; + + /* foreground */ + color: #6a6a6a; + + /* event */ + /*pointer-events: none;*/ +} + +.RDV:hover > span{ + /* foreground */ + color: #000; +} + +/* JOUR */ +.RDV > form:nth-child(1) > input.jour{ + top: 1em; +} + +/* HEURE */ +.RDV > form:nth-child(1) > input.heure{ + top: 3em; +} + +/* DUREE */ +.RDV > form:nth-child(1) > input.duree{ + position: relative !important; + margin-left: 10em !important; +} + +/* PATIENT */ +.RDV > form:nth-child(1) > input.Patient{ + margin-left: -10em !important; + top: 1em; +} +/* MEDECIN */ +.RDV > form:nth-child(1) > input.Medecin{ + margin-left: -10em !important; + top: 3em; +} + +/* SUPPRESSION */ +.RDV > form:nth-child(2){ + display: inline-block; + position: absolute; + top: calc( 100% - .5em - 1.5em ); + left: calc( 100% - 2em ); + width: 2em; + height: 2em; +} + +/* BOUTON SUPPRESSION */ +.RDV > form > input[type=submit]{ + /* position */ + display: inline-block; + position: absolute; + left: calc( 100% - 4em ); + top: -2em; + + padding: .5em 1em !important; + + /* border */ + border: 0 !important; + + /* background */ + background-color: transparent !important; + background-image: url(../src/svg/invalid.svg) !important; + background-position: center center !important; +} + + +/* BOUTON MODIFICATION */ +.RDV > form:nth-child(1) > input[type=submit]{ + left: calc( 100% - 3em ); + top: .5em; + background-image: url(../src/svg/edit.svg) !important; } \ No newline at end of file diff --git a/js/consultations.js b/js/consultations.js index 933deb9..9b05efd 100755 --- a/js/consultations.js +++ b/js/consultations.js @@ -177,3 +177,12 @@ csMonth.addEventListener('keyup', function(e){ /* [3] Affinage du calendrier ======================================================*/ +var dayCells = document.querySelectorAll('#calendar rect[class^="day_"]'); + + +// pour chaque jour, on créé l'évènement +for( var i = 0 ; i < dayCells.length ; i++ ){ + dayCells[i].addEventListener('click', function(e){ + console.log( e.target ); + }, false); +} \ No newline at end of file diff --git a/managers/RDV.class.php b/managers/RDV.class.php index 5165f51..79a6fb2 100755 --- a/managers/RDV.class.php +++ b/managers/RDV.class.php @@ -51,71 +51,92 @@ class RDV } public function delete($params){ - if(RDVRepo::delete($params['id_consultation']) !==FALSE){ - if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ - Response::quickResponse(200, json_encode([ - 'status' => 'success', - 'title' => 'Supression effectuée!', - 'message' => 'La consultation a bien été supprimée.' - ])); - }else{ + if(RDVRepo::delete($params['id_consultation']) !== FALSE){ + $_status = 'success'; + $_title = 'Suppression effectuée!'; + $_message = 'La consultation a bien été supprimée.'; + + 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?type=supression"); + $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Consultations.php?status='.$_status.'&title='.$_title.'&message='.$_message); $response->send(); - } + } }else{ - if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ - Response::quickResponse(200, json_encode([ - 'status' => 'error', - 'title' => 'Erreur lors de la supression!' - ])); - }else{ - $response = new Response(); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error"); - $response->send(); + $_status = 'error'; + $_title = 'Erreur lors de la suppression!'; + $_message = 'La suppression de la consultation a échoué!'; + + 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); } } } public function update($params){ - if(StaticRepo::checkParam($params['date_naissance'],'Date')) { - $params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']); - if (RDVRepo::updateDateTime($params['id_consultation'], $params['date']->format('Y-m-d') . ' ' . $params['heure'] . ':00') !== FALSE) { - if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ - $response = new Response(); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=maj"); - $response->send(); - }else{ - Response::quickResponse(200, json_encode([ - 'status' => 'success', - 'title' => 'Modification effectuée!', - 'message' => 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].'a bien été mis àjour.' - ])); - } - }else{ - if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ - $response = new Response(); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error"); - $response->send(); - }else{ - Response::quickResponse(200, json_encode([ - 'status' => 'error', - 'title' => 'Erreur de mise a jour!' - ])); - } - } - }else{ - if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ + // 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']); + 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.'; + 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?type=error"); - $response->send(); - }else{ - Response::quickResponse(200, json_encode([ - 'status' => 'error', - 'title' => 'Erreur de paramètre', - 'message' => 'Date incorrecte' - ])); - } + $response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Consultations.php?status='.$_status.'&title='.$_title.'&message='.$_message); + } + }else{ + $_status = 'error'; + $_title = 'Erreur lors de la modifiction!'; + $_message = 'La consultation n\'a pas pu être modifiée!'; + + 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); + } + } + }else{ + $_status = 'error'; + $_title = 'Erreur de paramètre!'; + $_message = 'Date Incorrecte!'; + + 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); + } + } + } + + public function getConsultationsForMonth($month){ + // conversion du mois + if( preg_match('/^(\d{2})\/(\d{4})$/', $month, $m) ){ + $mois = $m[1]; $annee = $m[2]; + }else{ + $mois = '12'; $annee = '2015'; + } + + /* RECHERCHE REUSSIE */ + if( ($rdvList=RDVRepo::getForMonth($mois, $annee)) !== FALSE ){ + + foreach($rdvList as $RDV){ + var_dump($RDV); + } + + }else{ + echo "error"; } } @@ -138,7 +159,7 @@ class RDV version='1.1' width='80%' height='auto' - viewbox='0 0 7700 6000' + viewbox='0 0 7700 7000' id='svg2'> @@ -161,9 +182,8 @@ class RDV $RDVTemp = RDVRepo::getByMonth($current); $RDVs = []; foreach($RDVTemp as $rdv){ - if(!isset($RDVs[date('j',strtotime($rdv['DateRDV']))])){ + if(!isset($RDVs[date('j',strtotime($rdv['DateRDV']))])) $RDVs[date('j',strtotime($rdv['DateRDV']))] = []; - } array_push($RDVs[date('j',strtotime($rdv['DateRDV']))],$rdv); } @@ -180,41 +200,43 @@ class RDV } //fond général + affichage de la date - $svgCalendar .= ' - - - - - ' . $day . ' - - - - ' . $date . ' - - - '; + $svgCalendar .= ' + + + + + + ' . $day . ' + + + + + ' . $date . ' + + + '; //on défini le tableau si jamais if (!isset($RDVs[$day])) { @@ -232,93 +254,90 @@ class RDV //du svg blablabla $yConsult = 1500 + 700 * $key; $svgCalendar .= ' - - ' . date('G:i', strtotime($rdv['DateRDV'])) . ' - - ' . $rdv['Minute'] . 'mn - - ' . $medecin['Prenom'] . ' - ' . $medecin['Nom'] . ' - - - ' . $patient['Prenom'] . ' - ' . $patient['Nom'] . ' - - '; + class="ConsultationGroupDay' . $day . 'Consult' . $key . '" + data-patient="' . $rdv['Patient_Id'] . '" + data-medecin="' . $rdv['Medecin_id'] . '"> + + ' . date('G:i', strtotime($rdv['DateRDV'])) . ' + + ' . $rdv['Minute'] . 'mn + + ' . $medecin['Prenom'] . ' + ' . $medecin['Nom'] . ' + + + ' . $patient['Prenom'] . ' + ' . $patient['Nom'] . ' + + '; } $svgCalendar .= ''; } //on met u fond (sinon on voit les consultation en arrière plan) - $svgCalendar .= ''; + $svgCalendar .= ''; $svgCalendar.=''; //position x;y de base des jours du calendrier @@ -345,7 +364,7 @@ class RDV ry="90" x="'.$x.'" y="'.$y.'" - id="day_'.$days[$day].'" + class="day_'.$days[$day].'" style="fill:#'.$color.';fill-opacity:1;stroke:none" />'; }else{ if($days[$day] % 2 != 0){$color='f0f0f0';}else{$color='fff';} @@ -355,18 +374,18 @@ class RDV ry="90" x="'.$x.'" y="'.$y.'" - id="day_'.$days[$day].'" + class="day_'.$days[$day].'" style="fill:#'.$color.';fill-opacity:1;stroke:none" />'; } $svgCalendar.=''.$day_nbr.''; + class="TextDay_'.$days[$day].'">'.$day_nbr.''; $x+=1100; if($days[$day] == 6){ $i=0; diff --git a/managers/config/managers.json b/managers/config/managers.json index 7050409..53d5164 100755 --- a/managers/config/managers.json +++ b/managers/config/managers.json @@ -21,7 +21,7 @@ "delete":{"method": "delete", "role": 0, "strict": false}, - "updateDateTime":{"method": "update", + "update":{"method": "update", "role": 0, "strict": false}, "getSVG":{"method": "getSVG", diff --git a/repositories/StaticRepo.php b/repositories/StaticRepo.php index 6cd1239..a984f11 100755 --- a/repositories/StaticRepo.php +++ b/repositories/StaticRepo.php @@ -149,11 +149,11 @@ class StaticRepo{ break; case 'Date': - $checker = $checker && !is_null($variable) && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $variable) ); + $checker = $checker && !is_null($variable) && is_string($variable) && ( preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $variable) || preg_match('/^\d{4}-\d{2}-\d{2}$/', $variable) ); break; case 'Heure': - $checker = $checker && !is_null($variable) && is_string($variable) && preg_match('/(\d+):(\d+)/is',$variable); + $checker = $checker && !is_null($variable) && is_string($variable) && preg_match('/^\d{1,2}:\d{1,2}$/', $variable); break; // [N] Type inconnu diff --git a/repositories/repos/RDVRepo.php b/repositories/repos/RDVRepo.php index cd37b93..09f55a4 100755 --- a/repositories/repos/RDVRepo.php +++ b/repositories/repos/RDVRepo.php @@ -19,6 +19,18 @@ 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 + FROM RDV, Patient, Medecin + WHERE Patient.Id = RDV.Patient_Id + AND Medecin.Id = RDV.Medecin_Id + AND MONTH(DateRDV) = :month + AND YEAR(DateRDV) = :year + ORDER BY DateRDV ASC"); + $req->execute(array( ':month' => $month, ':year' => $year )); + return $req->fetchAll(); + } + public static function getByDate($date){ if(!StaticRepo::checkParam($date,'Date')){return false;} @@ -31,7 +43,7 @@ class RDVRepo public static function delete($idRDV){ - if(!StaticRepo::checkParam($idRDV,'Integer')){return false;} + if(!StaticRepo::checkParam($idRDV,'Numeric')){return false;} $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); return $req->execute(['id' => $idRDV]); @@ -56,14 +68,16 @@ class RDVRepo else{return false;} } - public static function updateDateTime($idRDV,$dateTime){ + public static function updateDateTime($idRDV, $dateRdv, $duree){ - if(!StaticRepo::checkParam($idRDV,'Integer')){return false;} + if(!StaticRepo::checkParam($idRDV, 'Numeric')){return false;} - $date = date('Y-m-d H:i:s',strtotime($dateTime)); - $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); - return $req->execute(['date' => $date, - 'id' => $idRDV]); + $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date_rdv, Duree = :duree WHERE id = :id'); + return $req->execute([ + ':date_rdv' => $dateRdv, + ':duree' => $duree, + ':id' => $idRDV + ]); } public static function getByPatientAndDate($idPatient,$date){ diff --git a/test.php b/test.php index f690e81..dd1f2d8 100755 --- a/test.php +++ b/test.php @@ -17,4 +17,4 @@ $rdv = new RDV(); echo $rdv->getSVG(['mois' => '10/2015']); ?> - + \ No newline at end of file