diff --git a/Consultations.php b/Consultations.php index a4b0228..6e5c4c6 100755 --- a/Consultations.php +++ b/Consultations.php @@ -22,8 +22,8 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null; - + diff --git a/Dashboard.php b/Dashboard.php index 8144dd3..583ed34 100755 --- a/Dashboard.php +++ b/Dashboard.php @@ -18,8 +18,8 @@ if(!Authentification::checkUser(0)){ - + diff --git a/Medecins.php b/Medecins.php index faa031d..f6d909c 100755 --- a/Medecins.php +++ b/Medecins.php @@ -24,8 +24,8 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null; - + @@ -82,8 +82,8 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;

-
-
+
+

diff --git a/Patients.php b/Patients.php index 7832167..1f1c3d8 100755 --- a/Patients.php +++ b/Patients.php @@ -24,8 +24,8 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null; - + @@ -94,8 +94,8 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;

Ajout d'un nouveau patient



-
-
+
+


Code postal
diff --git a/css/global.css b/css/global.css index e7a69da..7218cc2 100755 --- a/css/global.css +++ b/css/global.css @@ -56,6 +56,14 @@ body{ /* z axis */ z-index: 100; + + /* extra */ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } #NOTIFBAR.active{ diff --git a/js/lib/API.js b/js/lib/API.js index 12beffe..319c529 100755 --- a/js/lib/API.js +++ b/js/lib/API.js @@ -26,7 +26,7 @@ APIClass.prototype = { * 3. on passe une fonction qui utilise un argument (sera la réponse de API.php) (sous forme d'objet) * */ - send: function(pRequest, pHandler){ + send: function(pCommand, pRequest, pHandler){ // on efface les requêtes qui sont terminées (toutes celles de this.xhr) for( var i = 0 ; i < this.xhr.length ; i++ ){ @@ -68,9 +68,12 @@ APIClass.prototype = { // on créé un formulaire POST (virtuel) var form = new FormData(); - form.append('json', JSON.stringify(pRequest) ); // on créé la variable $_POST['json']=>request + form.append('command', pCommand ); // on créé la variable $_POST['json']=>request + // on envoie l'objet sous forme de _POST distincts + for( obj in pRequest ) + form.append(obj, pRequest[obj]); - this.xhr[i].open('POST', 'managers/', true); + this.xhr[i].open('POST', '/managers/', true); this.xhr[i].send( form ); } diff --git a/js/lib/adjust.js b/js/lib/adjust.js index 8e5102c..d7cfe3e 100755 --- a/js/lib/adjust.js +++ b/js/lib/adjust.js @@ -69,4 +69,10 @@ function notif(pType, pTitle, pMessage){ notifElement.children[1].children[1].innerHTML = pMessage; // on attribue le texte addClass(notifElement, 'active'); // on affiche la boite -} \ No newline at end of file +} + + + + + +var API = new APIClass(); \ No newline at end of file diff --git a/js/medecins.js b/js/medecins.js index 711feb6..dfbf9aa 100755 --- a/js/medecins.js +++ b/js/medecins.js @@ -7,9 +7,10 @@ var notifBar = document.getElementById('NOTIFBAR'); -var crPrenom = document.getElementById('crPrenom'); -var crNom = document.getElementById('crNom'); -var sbCreer = document.getElementById('sbCreer'); +var crPrenom = document.getElementById('crPrenom'); +var crNom = document.getElementById('crNom'); +var crCivilites = document.querySelectorAll('.crCiv'); +var sbCreer = document.getElementById('sbCreer'); /* VERIFICATION DES SAISIES */ @@ -67,7 +68,20 @@ sbCreer.addEventListener('click', function(e){ }} if( checker ){ // si tout es ok uniquement, on submit() - sbCreer.parentNode.submit(); + var request = { + prenom: crPrenom.value, + nom: crNom.value, + civilite: (crCivilites[0].checked) ? crCivilites[0].value : crCivilites[1].value + }; + + API.send('Medecin:add', request, function(e){ + notif(e.status, e.title, e.message); + + if( e.status == 'success' ) // on vide le formulaire si on a 'success' + sbCreer.parentNode.reset(); + }, false); + + }else{ // sinon on affiche l'erreur notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.'); } diff --git a/js/patients.js b/js/patients.js index 6a7f8c6..2de5999 100755 --- a/js/patients.js +++ b/js/patients.js @@ -6,16 +6,18 @@ var notifBar = document.getElementById('NOTIFBAR'); -var inPrenom = document.getElementById('crPrenom'); -var inNom = document.getElementById('crNom'); -var inAdr = document.getElementById('crAdr'); -var inAdr2 = document.getElementById('crAdr2'); -var inCP = document.getElementById('crCP'); -var inVille = document.getElementById('crVille'); -var inDN = document.getElementById('crDN'); -var inLN = document.getElementById('crLN'); -var inSecu = document.getElementById('crSecu'); -var sbCreer = document.getElementById('sbCreer'); // SUBMIT +var inPrenom = document.getElementById('crPrenom'); +var inNom = document.getElementById('crNom'); +var inAdr = document.getElementById('crAdr'); +var inAdr2 = document.getElementById('crAdr2'); +var inCP = document.getElementById('crCP'); +var inVille = document.getElementById('crVille'); +var inDN = document.getElementById('crDN'); +var inLN = document.getElementById('crLN'); +var inSecu = document.getElementById('crSecu'); +var inMedecin = document.getElementById('crMedecin'); +var inCivil = document.querySelectorAll('.crCiv'); +var sbCreer = document.getElementById('sbCreer'); // SUBMIT var inCk = new inputChecker(); // format de la date @@ -159,6 +161,31 @@ sbCreer.addEventListener('click', function(e){ var inputCheckerValid = inCk.checkAll(); - if( inputCheckerValid && checker ) // si tout es ok uniquement, on submit() - sbCreer.parentNode.submit(); + if( inputCheckerValid && checker ){ // si tout es ok uniquement, on submit() + + var request = { + prenom: inPrenom.value, + nom: inNom.value, + civilite: (inCivil[0].checked) ? inCivil[0].value : inCivil[1].value, + adresse: inAdr.value, + adresse2: inAdr2.value, + code_postal: inCP.value, + ville: inVille.value, + date_naissance: inDN.value, + lieu_naissance: inLN.value, + num_secu: inSecu.value, + medecin_traitant: inMedecin.value + }; + + API.send('Patient:add', request, function(e){ + notif(e.status, e.title, e.message); + + if( e.status == 'success' ) // on vide le formulaire si on a 'success' + sbCreer.parentNode.reset(); + }, false); + + + }else{ // sinon on affiche l'erreur + notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.'); + } }, false); \ No newline at end of file diff --git a/managers/Medecin.class.php b/managers/Medecin.class.php index c0d2285..78202ca 100755 --- a/managers/Medecin.class.php +++ b/managers/Medecin.class.php @@ -10,25 +10,24 @@ class Medecin { public function add($params){ if(MedecinRepo::add($params['civilite'],strtolower($params['prenom']),strtolower($params['nom'])) !==FALSE){ - $response = new Response(); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=creation"); - $response->send(); + Response::quickResponse(200, json_encode([ + 'status' => 'success', + 'title' => 'Création enregistrée!', + 'message' => 'Le médecin '.$params['prenom'].' '.$params['nom'].' a bien été créé.' + ])); }else{ - $response = new Response(500); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error"); - $response->send(); + Response::quickResponse(200, json_encode([ + 'status' => 'error', + 'title' => 'Erreur de création!' + ])); } } public function delete($params){ if(MedecinRepo::delete($params['id_medecin']) !==FALSE){ - $response = new Response(); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=supression"); - $response->send(); + Response::quickResponse(200, json_encode(['status'=>'success'])); }else{ - $response = new Response(500); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error"); - $response->send(); + Response::quickResponse(200, json_encode(['status'=>'error'])); } } diff --git a/managers/Patient.class.php b/managers/Patient.class.php index c79ac05..0bc99ab 100755 --- a/managers/Patient.class.php +++ b/managers/Patient.class.php @@ -11,16 +11,14 @@ class Patient public function add($params){ $params['date_naissance'] = DateTime::createFromFormat('d/m/Y', $params['date_naissance']); if(PatientRepo::add($params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['code_postal'], - $params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){ - // $response = new Response(); - // $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=creation"); - // $response->send(); - Response::quickResponse(200, json_encode(['status'=>'success'])); + $params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !== FALSE){ + Response::quickResponse(200, json_encode([ + 'status' => 'success', + 'title' => 'Création enregistrée!', + 'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.' + ])); }else{ - Response::quickResponse(200, json_encode(['status'=>'error'])); - // $response = new Response(500); - // $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error"); - // $response->send(); + Response::quickResponse(200, json_encode([ 'status' => 'error' ])); } } @@ -28,25 +26,17 @@ class Patient $params['date_naissance'] = DateTime::createFromFormat('d/m/Y', $params['date_naissance']); if(PatientRepo::update($params['id_patient'],$params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['cope_postal'], $params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){ - $response = new Response(); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=creation"); - $response->send(); + Response::quickResponse(200, json_encode(['status'=>'success'])); }else{ - $response = new Response(500); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error"); - $response->send(); + Response::quickResponse(200, json_encode(['status'=>'error'])); } } public function delete($params){ if(PatientRepo::delete($params['id_patient']) !==FALSE){ - $response = new Response(); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=supression"); - $response->send(); + Response::quickResponse(200, json_encode(['status'=>'success'])); }else{ - $response = new Response(500); - $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error"); - $response->send(); + Response::quickResponse(200, json_encode(['status'=>'error'])); } } diff --git a/repositories/StaticRepo.php b/repositories/StaticRepo.php index 6c79c16..a923d17 100755 --- a/repositories/StaticRepo.php +++ b/repositories/StaticRepo.php @@ -118,7 +118,7 @@ class StaticRepo{ switch($dbtype){ // [1] 'M' / 'F' case 'Civilite': - $checker = $checker && is_string($variable) && in_array($variable,['M','F']); + $checker = $checker && is_string($variable) && in_array($variable, ['M','F']); break; // [2] Chaine de caractère (longueur variable)