résolution de conflit

This commit is contained in:
Lucas Mascaro 2015-12-26 13:25:56 +01:00
commit 37f96ceb63
34 changed files with 944 additions and 314 deletions

View File

@ -18,13 +18,14 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
<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/input-checker.js'></script>
<script type='text/javascript' src='js/lib/input-checker.js'></script>
</head>
<body>
@ -34,7 +35,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
<div>
<h3>Oups!</h3>
<p>Certains champs sont incorrects. Veuillez réessayer.</p>
<input type='button' value='Fermer'>
<a href='#'><input type='button' value='Fermer'></a>
</div>
</div>
@ -65,13 +66,48 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
echo '<span>';
switch($answerType){
case 'creation': echo 'Patient créé.'; break;
case 'modification': echo 'Patient modifié.'; break;
case 'suppression': echo 'Patient supprimé.'; break;
case 'error': echo 'Une erreur est survenue.'; break;
default: echo 'rien à déclarer ? Non!'; break;
}
echo '</span>';
}
/*************************************/
}/************************************/
/* CONSULTER LES RENDEZ-VOUS */
/*************************************/ ?>
<article data-title="Calendrier des consultations">
<div>
<input type='text' id='csMonth' placeholder='12/2015'>Mois à afficher.<br>
<select id='csPatient' name='id_patient'>
<option value='*'>Tous les patients:</option>
<?php
foreach(PatientRepo::getAll() as $PATIENT)
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)
echo "<option value='".$MEDECIN['Id']."'>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
?>
</select>
<input type='submit' value='Affiner'>
</div><br>
<!-- HERE COMES THE SVG -->
</article>
<?php/*************************************/
/* SAISIR UN RENDEZ-VOUS */
/*************************************/ ?>
<article data-title="Saisir un rendez-vous">
@ -105,23 +141,6 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
</article>
<?php/********************************/
/* CONSULTER LES RENDEZ-VOUS */
/*************************************/ ?>
<article data-title="Numéro de sécurité sociale">
<div>
<input type='radio' name='filter_c' id='tousRDV' checked><label for='tousRDV'>Toutes les consultations</label><br>
<input type='radio' name='filter_c' id='pastRDV'><label for='pastRDV'>Consultations passées</label><br>
<input type='radio' name='filter_c' id='fturRDV'><label for='fturRDV'>Consultations à venir</label><br>
<input type='submit' value='Rechercher'>
<input type='text' id='inSecu' placeholder='1 99 19 99 999 999 99'><span class='invalid'>Clé de contrôle invalide.</span>
</div>
</article>
</section>
</div>

View File

@ -14,6 +14,7 @@ if(!Authentification::checkUser(0)){
<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'/>

View File

@ -5,8 +5,19 @@ if(!Authentification::checkUser(0)){
die();
};
// formattage $_GET['type']
$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
function customCompression($input, $compression){
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
}
/* 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!';
// on récupère la liste des médecins si donnée
$medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode( customCompression($_GET['medecins'], false) , true) : [];
?>
@ -19,6 +30,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
<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/blue-green.theme.css'/>
@ -26,17 +38,17 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
<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/input-checker.js'></script>
<script type='text/javascript' src='js/lib/input-checker.js'></script>
</head>
<body>
<!-- BARRE DE NOTIFICATIONS -->
<div id='NOTIFBAR'>
<div id='NOTIFBAR' class='<?php echo ($managerStatus!=null) ? 'active '.$managerStatus : $managerStatus; ?>'>
<div></div>
<div>
<h3>Oups!</h3>
<p>Certains champs sont incorrects. Veuillez réessayer.</p>
<input type='button' value='Fermer'>
<h3><?php echo $managerTitle; ?></h3>
<p><?php echo $managerMessage; ?></p>
<a href='?medecins=<?php echo customCompression(json_encode($medecinsSearch), true); ?>'><input type='button' value='Fermer'></a>
</div>
</div>
@ -62,18 +74,56 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
<!-- FIL D'ARIANE -->
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Medecins.php'>Gestion des médecins</a></a> </div>
<?php if( $answerType != null ){
echo '<span>';
switch($answerType){
case 'creation': echo 'Médecin créé.'; break;
case 'error': echo 'Une erreur est survenue.'; break;
default: echo 'rien à déclarer ? Non!'; break;
}
echo '</span>';
<?php/********************************/
/* CONSULTER LES MÉDECIN */
/*************************************/ ?>
<article data-title="Rechercher un médecin">
<form method='POST' action='managers/'>
<br><h4>Recherche par nom et/ou prénom:</h4>
<input type='text' id='srPrenom' name='prenom' placeholder='Prénom' value=''><br>
<input type='text' id='srNom' name='nom' placeholder='NOM' value=''><br>
<br>
}
/*************************************/
<input type='hidden' name='command' value='Medecin:search'>
<input type='submit' id='sbCherche' value='Lancer la recherche'>
</form><br>
<h3>Résultats:</h3><br>
<table id='searchResultMedecin'>
<?php
// pour chaque médecin
foreach($medecinsSearch as $MED){ if( isset($MED['Id']) && isset($MED['Civilite']) && isset($MED['Prenom']) && isset($MED['Nom']) ){
echo '<tr>';
echo '<td>'.(($MED['Civilite']=='M')?'Monsieur':'Madame').'</td>';
echo '<td>'.$MED['Prenom'].'</td>';
echo '<td>'.strtoupper($MED['Nom']).'</td>';
// début modification
echo "<td><form class='updMedecin' action='managers/' method='POST'>";
echo "<input type='hidden' name='command' value='Medecin:update'>";
echo "<input type='hidden' name='id_medecin' value='".$MED['Id']."'>";
echo "<input type='submit' value=''>";
echo '</form></td>';
// fin modification
// début suppression
echo "<td><form class='delMedecin' action='managers/' method='POST'>";
echo "<input type='hidden' name='command' value='Medecin:delete'>";
echo "<input type='hidden' name='id_medecin' value='".$MED['Id']."'>";
echo "<input type='submit' value=''>";
echo '</form></td>';
// fin suppression
echo '</tr>';
}}
?>
</table>
</article>
<?php/**********************************/
/* AJOUTER UN MÉDECIN */
/*************************************/ ?>
<article data-title="Ajouter un médecin">

View File

@ -5,9 +5,19 @@ if(!Authentification::checkUser(0)){
die();
};
// formattage $_GET['type']
$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
function customCompression($input, $compression){
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
}
/* 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!';
// on récupère la liste des médecins si donnée
$patientsSearch = ( isset($_GET['patients']) ) ? json_decode( customCompression($_GET['patients'], false) , true) : [];
?>
<!DOCTYPE html>
@ -19,6 +29,7 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
<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/purple.theme.css'/>
@ -26,17 +37,17 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
<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/input-checker.js'></script>
<script type='text/javascript' src='js/lib/input-checker.js'></script>
</head>
<body>
<!-- BARRE DE NOTIFICATIONS -->
<div id='NOTIFBAR'>
<div id='NOTIFBAR' class='<?php echo ($managerStatus!=null) ? 'active '.$managerStatus : $managerStatus; ?>'>
<div></div>
<div>
<h3>Oups!</h3>
<p>Certains champs sont incorrects. Veuillez réessayer.</p>
<input type='button' value='Fermer'>
<h3><?php echo $managerTitle; ?></h3>
<p><?php echo $managerMessage; ?></p>
<a href='?patients=<?php echo customCompression( json_encode($patientsSearch), true ); ?>'><input type='button' value='Fermer'></a>
</div>
</div>
@ -55,25 +66,69 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
</nav>
<!-- CONTAINER DE LA PAGE -->
<section id='CONTAINER'>
<!-- FIL D'ARIANE -->
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Patients.php'>Gestion des Patients</a></a> </div>
<?php if( $answerType != null ){
echo '<span>';
switch($answerType){
case 'creation': echo 'Patient créé.'; break;
case 'error': echo 'Une erreur est survenue.'; break;
default: echo 'rien à déclarer ? Non!'; break;
}
echo '</span>';
}
/*************************************/
<?php/********************************/
/* CONSULTER LES PATIENTS */
/*************************************/ ?>
<article data-title="Rechercher un patient">
<form method='POST' action='managers/'>
<br><h4>Recherche par nom et/ou prénom:</h4>
<input type='text' id='srPrenom' name='prenom' placeholder='Prénom' value=''><br>
<input type='text' id='srNom' name='nom' placeholder='NOM' value=''><br>
<br>
<input type='hidden' name='command' value='Patient:search'>
<input type='submit' id='sbCherche' value='Lancer la recherche'>
</form><br>
<h3>Résultats:</h3><br>
<table id='searchResultPatient'><tbody>
<?php
// pour chaque médecin
foreach($patientsSearch as $PAT){ if( isset($PAT['Id']) && isset($PAT['Civilite']) && isset($PAT['Prenom']) && isset($PAT['Nom']) && isset($PAT['DateNaissance']) && isset($PAT['NumSecuriteSociale'])){
echo '<tr>';
// début modification
echo "<td colspan=5><form class='updPatient' action='managers/' method='POST'>";
echo "<input type='hidden' name='Id' value='". $PAT['Id'] ."'>";
echo "<input type='text' name='Civilite' value='". (($PAT['Civilite']=='M')?'Monsieur':'Madame') ."'>";
echo "<input type='text' name='Prenom' value='". $PAT['Prenom'] ."'>";
echo "<input type='text' name='Nom' value='". strtoupper($PAT['Nom']) ."'>";
echo "<input type='text' name='DateNaissance' value='". $PAT['DateNaissance'] ."'>";
echo "<input type='text' name='NumSecuriteSociale' value='". $PAT['NumSecuriteSociale'] ."'>";
echo "<input type='hidden' name='command' value='Patient:update'>";
echo "<input type='hidden' name='id_patient' value='". $PAT['Id'] ."'>";
echo "<input type='submit' value=''>";
echo '</form></td>';
// fin modification
// début suppression
echo "<td><form class='delPatient' action='managers/' method='POST'>";
echo "<input type='hidden' name='command' value='Patient:delete'>";
echo "<input type='hidden' name='id_patient' value='".$PAT['Id']."'>";
echo "<input type='submit' value=''>";
echo '</form></td>';
// fin suppression
echo '</tr>';
}}
?>
</tbody></table>
</article>
<?php/********************************/
/* AJOUTER UN PATIENT */
/*************************************/ ?>
<article data-title="Ajouter un patient">

23
css/font.css Executable file
View File

@ -0,0 +1,23 @@
/***************************/
/**********Open Sans********/
/***************************/
@font-face{ /* REGULAR */
font-family: 'Open Sans';
src: url('./font/Open Sans/8.ttf');
}
@font-face{ /* BOLD */
font-family: 'Open Sans';
src: url('./font/Open Sans/9.ttf');
font-weight: bold;
}
@font-face{ /* ITALIC */
font-family: 'Open Sans';
src: url('./font/Open Sans/7.ttf');
font-style: italic;
}

BIN
css/font/Open Sans/1.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/10.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/2.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/3.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/4.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/5.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/6.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/7.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/8.ttf Executable file

Binary file not shown.

BIN
css/font/Open Sans/9.ttf Executable file

Binary file not shown.

View File

@ -434,6 +434,7 @@ body{
/* border */
border: 1px solid #f09108;
}
#CONTAINER > article[data-title]:before{
@ -732,3 +733,78 @@ input[type=radio]:checked + label:before{
/* TABLEAU DE RESULTAT DE RECHERCHE */
#CONTAINER > article table{
/* position */
width: 100%;
/* border */
border-spacing: 0;
}
#CONTAINER > article table > tbody,
#CONTAINER > article table > tbody > tr{
/* position */
width: 100%;
}
#CONTAINER > article table td{
/* position */
max-width: calc( 100% / 6% );
/* border */
border-bottom: 1px solid #cacaca;
}
#CONTAINER > article table#searchResultMedecin td{
/* position */
max-width: calc( 100% / 5% );
/* border */
border-bottom: 1px solid #cacaca;
}
/* Suppression champ de recherche (patient/médecin/consultation) */
#CONTAINER > article .delPatient input[type=submit],
#CONTAINER > article .delMedecin input[type=submit]{
/* position */
padding: .5em 1em;
/* border */
border: 0;
/* background */
background-image: url(../src/svg/invalid.svg);
background-position: center center;
}
/* Modification champ de recherche (patient/médecin/consultation) */
#CONTAINER > article .updPatient input[type=text],
#CONTAINER > article .updMedecin input[type=text]{
width: 6em;
padding: .1em;
margin: 0 .2em;
border: 0;
}
#CONTAINER > article .updPatient input[type=submit],
#CONTAINER > article .updMedecin input[type=submit]{
/* position */
padding: .5em 1em;
/* border */
border: 0;
/* background */
background-image: url(../src/svg/edit.svg);
background-position: center center;
}

View File

@ -29,6 +29,7 @@ if(Authentification::checkUser(0)){
<meta name='author' value='{xdrm} & SeekDaSky'/>
<link rel='stylesheet' href='css/font.css'/>
<link rel='stylesheet' href='css/login-material.css'/>
</head>
<body>

View File

@ -1,5 +1,6 @@
var notifBar = document.getElementById('NOTIFBAR');
notifBar.children[1].children[2].addEventListener('click', function(e){
notifBar.children[1].children[2].addEventListener('click', function(e){
e.preventDefault();
remClass(notifBar, 'active');
}, false);
@ -41,35 +42,28 @@ if( newRDVPatient != null && newRDVMedecin != null ){
/* VERIFICATION DES CHAMPS */
/* [1] VERIFICATION DES CHAMPS DE LA CREATION
======================================================*/
var inCk = new inputChecker();
var inDate = document.getElementById('inDate');
var inHeure = document.getElementById('inHeure');
var inSecu = document.getElementById('inSecu');
var sbCreer = document.getElementById('sbCreer');
// format de date simplifié
var dateFormat = new formatChecker(null,
'Ji/Mi/2iii', { 'J': '[0-3]', 'M': '[0-1]' }
'Ji/Mi/iiii', { 'J': '[0-3]', 'M': '[0-1]' }
);
// format de temps simplifié
var timeFormat = new formatChecker(null,
'Hi:Mi', { 'H': '[0-2]', 'M': '[0-6]' }
);
// format numéro SECU simplifié
var secuFormat = new formatChecker(null,
'S ii Mi ii iii iii ii', { 'S': '[0-1]', 'M': '[0-1]' }
);
var now = new Date();
inCk.append( inDate, dateFormat, '01/01/2015' );
inCk.append( inHeure, timeFormat, '23:59' );
inCk.append( inSecu, secuFormat, inSecu.placeholder );
inDate.addEventListener('keyup', function(e){
if( inCk.check(inDate) ) addClass(inDate, 'validated'); // on active la classe si correct
@ -98,48 +92,6 @@ inDuree.addEventListener('keyup', function(e){
remClass(inDuree, 'validated'); // on désactive la classe
}, false);
function checkSecuControlKey(pNumSecu){
var NIR = pNumSecu.slice(0,-2).replace(/ /g, '');
var key = pNumSecu.slice(-2);
return 97-(NIR%97) == key;
}
inSecu.addEventListener('keyup', function(e){
if( inCk.check(inSecu) ){
if( checkSecuControlKey(inSecu.value) ){ // si la clé est correcte
addClass(inSecu, 'validated'); // on dis que le champ est valide
remClass(inSecu, 'invalid'); // on dis qu'il n'est pas invalide
}else{
remClass(inSecu, 'validated'); // on dis que le champ n'est pas valide
addClass(inSecu, 'invalid'); // on dis qu'il est invalide
}
}else{ // si incorrect
remClass(inSecu, 'validated'); // on désactive la classe
remClass(inSecu, 'invalid'); // on dis qu'il n'est pas invalide
inCk.correct(inSecu, false); // on corrige partiellement
if( inCk.check(inSecu) ){
if( checkSecuControlKey(inSecu.value) ){ // si la clé est correcte
addClass(inSecu, 'validated'); // on dis que le champ est valide
remClass(inSecu, 'invalid'); // on dis qu'il n'est pas invalide
}else{
remClass(inSecu, 'validated'); // on dis que le champ n'est pas valide
addClass(inSecu, 'invalid'); // on dis qu'il est invalide
}
}
}
}, false);
// inDate.value = 'x3 F3/a8';
// inHeure.value = 'x3 F3/a8';
inSecu.value = '1 96 01 31 555 861';
@ -166,11 +118,62 @@ sbCreer.addEventListener('click', function(e){
var inputCheckerValid = inCk.check(inDate) && inCk.check(inHeure);
var selectNoDefault = newRDVPatient.value != '*' && newRDVMedecin.value != '*';
console.log( inputCheckerValid );
console.log( checker );
console.log( selectNoDefault );
if( inputCheckerValid && checker && selectNoDefault ) // si tout es ok uniquement, on submit()
sbCreer.parentNode.submit();
}, false);
if( inputCheckerValid && checker && selectNoDefault ){ // si tout es ok uniquement, on submit()
var request = {
id_patient: newRDVPatient.value,
id_medecin: newRDVMedecin.value,
date: inDate.value,
heure: inHeure.value,
duree: inDuree.value
};
API.send('RDV: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);
/* [2] Verification des champs de la consultation
======================================================*/
var inCk2 = new inputChecker();
var csMonth = document.getElementById('csMonth');
var csPatient = document.getElementById('csPatient');
var csMedecin = document.getElementById('csMedecin');
// format de mois simplifié
var monthFormat = new formatChecker(null, 'Mi/iiii', { 'M': '[0-1]' } );
inCk2.append( csMonth, monthFormat, csMonth.placeholder );
csMonth.addEventListener('keyup', function(e){
if( inCk2.check(csMonth) ) addClass(csMonth, 'validated'); // on active la classe si correct
else{ // si incorrect
remClass(csMonth, 'validated'); // on désactive la classe
inCk2.correct(csMonth, false); // on corrige partiellement
if( inCk2.check(csMonth) ) addClass(csMonth, 'validated'); // mise à jour de la classe après correction
}
}, false);
/* [3] Affinage du calendrier
======================================================*/

View File

@ -53,7 +53,7 @@ APIClass.prototype = {
if( ptrAPI.xhr[i].readyState == 4 ){ // si la requête est terminée
/* DEBUG : affiche la réponse BRUTE de API.php */
console.log('managers/ => '+ptrAPI.xhr[i].responseText);
// console.log('managers/ => '+ptrAPI.xhr[i].responseText);
console.log( JSON.parse(ptrAPI.xhr[i].responseText) );
/* si success de requête */
@ -77,7 +77,7 @@ APIClass.prototype = {
this.xhr[i].open('POST', '/managers/', true);
// on définit le HEADER
this.xhr[i].setRequestHeader('X-Requested-With', 'XMLHttpRequest');
this.xhr[i].setRequestHeader('X-REQUESTED-WITH', 'XMLHttpRequest');
this.xhr[i].send( form );
}

View File

@ -26,6 +26,40 @@ function remClass(el, pClass){
// var completeAccentList = "àAAÀAAÁÂÒÓÔÕÖØòÒÓÔÕ-ÖØòó_ôõöøÈÉÊËèéêëÇçÒÓÔÕÖØòÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ";
var accentList = 'àÀÈÉÊËèéêëçîïúû';
/* Met à jour l'état visuel d'un <input> si sa valeur correspond aux initères
*
* @pInputElement<HTMLInputElement> l'élément <input> en question
* @pMinLength<int> la taille minimum autorisée
* @pMaxLength<int> la taille maximum autorisée
* @optAlpha<String> [OPT] TRUE si uniquement alphanumérique
*/
function checkVARCHAR(pInputElement, pMinLength, pMaxLength, optAlpha){
var optAlpha = (arguments.length > 3) ? optAlpha : false;
optAlpha = (typeof optAlpha == 'boolean') ? optAlpha : false;
var varcharRegExp;
if( optAlpha ) varcharRegExp = new RegExp('^(['+accentList+'a-z]{'+pMinLength+','+pMaxLength+'})$', 'i'); // only alpha characters
else varcharRegExp = new RegExp('^(['+accentList+'\\w -]{'+ pMinLength+','+pMaxLength+'})$', 'i'); // any word character
if( pInputElement.value.match(varcharRegExp) != null || pInputElement.value == '' ){ // si champ correct
addClass(pInputElement, 'validated');
if( pInputElement.required ) remClass(pInputElement, 'invalid');
}else{
remClass(pInputElement, 'validated');
if( pInputElement.required ) addClass(pInputElement, 'invalid');
}
}
var notifState = false; // VRAI si affiché, sinon FAUX
function notif(pType, pTitle, pMessage){
/* [0] Variables globales
@ -49,7 +83,7 @@ function notif(pType, pTitle, pMessage){
var pTitle = (arguments.length>1) ? pTitle : null;
var pMessage = (arguments.length>2) ? pMessage : null;
var index = ['error', 'success', 'info'].indexOf(pType)
var index = ['error', 'success', 'info'].indexOf(pType);
if( index == -1 ) return false; // si pType incorrect, on quitte

View File

@ -1,5 +1,6 @@
var notifBar = document.getElementById('NOTIFBAR');
notifBar.children[1].children[2].addEventListener('click', function(e){
notifBar.children[1].children[2].addEventListener('click', function(e){
e.preventDefault();
remClass(notifBar, 'active');
}, false);
@ -85,4 +86,98 @@ sbCreer.addEventListener('click', function(e){
}else{ // sinon on affiche l'erreur
notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.');
}
}, false);
}, false);
/* RECHERCHE DE MEDECINS */
var srPrenom = document.getElementById('srPrenom');
var srNom = document.getElementById('srNom');
var sbCherche = document.getElementById('sbCherche');
//////////////////////////////
// PRENOM & NOM (VARCHAR 45)//
//////////////////////////////
srPrenom.addEventListener('keyup', function(e){ checkVARCHAR(e.target, 1, 45, true); }, false);
srNom.addEventListener('keyup', function(e){ checkVARCHAR(e.target, 1, 45, true); }, false);
//////////////
// SUBMIT() //
//////////////
sbCherche.addEventListener('click', function(e){
e.preventDefault(); // on annule le submit()
var correctNom = srNom.className.indexOf('validated') > -1 && srNom.value.length > 0;
var correctPrenom = srPrenom.className.indexOf('validated') > -1 && srPrenom.value.length > 0;
if( correctPrenom || correctNom ){ // si tout es ok uniquement, on submit()
var request = {
prenom: (correctPrenom) ? srPrenom.value : null,
nom: (correctNom) ? srNom.value : null
};
API.send('Medecin:search', request, function(e){
if( e.status != 'success' )
notif(e.status, e.title, e.message);
if( e.hasOwnProperty('medecins') )
displayFoundMedecins(e.medecins);
else
displayFoundMedecins([]);
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);
////////////////////////////////////////////
// AFFICHAGE DES MEDECINS DE LA RECHERCHE //
////////////////////////////////////////////
function displayFoundMedecins(foundMedecins){
var container = document.getElementById('searchResultMedecin');
var content = '<table>';
for( var i = 0 ; i < foundMedecins.length ; i++ ){
content += '<tr>';
content += '<td>'+ ((foundMedecins[i].Civilite=='M')?'Monsieur':'Madame') + '</td>';
content += '<td>'+ foundMedecins[i].Prenom + '</td>';
content += '<td>'+ foundMedecins[i].Nom.toUpperCase() + '</td>';
// début modification
content += "<td><form class='updMedecin' action='managers/' method='POST'>";
content += "<input type='hidden' name='command' value='Medecin:update'>";
content += "<input type='hidden' name='id_medecin' value='"+foundMedecins[i].Id+"'>";
content += "<input type='submit' value=''>";
content += '</form></td>';
// fin modification
// début suppression
content += "<td><form class='delMedecin' action='managers/' method='POST'>";
content += "<input type='hidden' name='command' value='Medecin:delete'>";
content += "<input type='hidden' name='id_medecin' value='"+foundMedecins[i].Id+"'>";
content += "<input type='submit' value=''>";
content += '</form></td>';
// fin suppression
content += '</tr>';
}
content += '</table>';
// on vide le container
container.innerHTML = content;
}

View File

@ -1,5 +1,6 @@
var notifBar = document.getElementById('NOTIFBAR');
notifBar.children[1].children[2].addEventListener('click', function(e){
notifBar.children[1].children[2].addEventListener('click', function(e){
e.preventDefault();
remClass(notifBar, 'active');
}, false);
@ -30,34 +31,6 @@ inCk.append( inSecu, secuFormat, '1 99 19 99 999 999 99'); // on ajoute le
// var completeAccentList = "àAAÀAAÁÂÒÓÔÕÖØòÒÓÔÕ-ÖØòó_ôõöøÈÉÊËèéêëÇçÒÓÔÕÖØòÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ";
var accentList = 'àÀÈÉÊËèéêëçîïúû';
/* Met à jour l'état visuel d'un <input> si sa valeur correspond aux initères
*
* @pInputElement<HTMLInputElement> l'élément <input> en question
* @pMinLength<int> la taille minimum autorisée
* @pMaxLength<int> la taille maximum autorisée
* @optAlpha<String> [OPT] TRUE si uniquement alphanumérique
*/
function checkVARCHAR(pInputElement, pMinLength, pMaxLength, optAlpha){
var optAlpha = (arguments.length > 3) ? optAlpha : false;
optAlpha = (typeof optAlpha == 'boolean') ? optAlpha : false;
var varcharRegExp;
if( optAlpha ) varcharRegExp = new RegExp('^(['+accentList+'a-z]{'+pMinLength+','+pMaxLength+'})$', 'i'); // only alpha characters
else varcharRegExp = new RegExp('^(['+accentList+'\\w -]{'+ pMinLength+','+pMaxLength+'})$', 'i'); // any word character
if( pInputElement.value.match(varcharRegExp) != null || pInputElement.value == '' ){ // si champ correct
addClass(pInputElement, 'validated');
if( pInputElement.required ) remClass(pInputElement, 'invalid');
}else{
remClass(pInputElement, 'validated');
if( pInputElement.required ) addClass(pInputElement, 'invalid');
}
}
//////////////////////////////
// PRENOM & NOM (VARCHAR 45)//
@ -188,4 +161,104 @@ sbCreer.addEventListener('click', function(e){
}else{ // sinon on affiche l'erreur
notif('error', 'Oups!', 'Certains champs sont requis ou incorrects.');
}
}, false);
}, false);
/* RECHERCHE DE MEDECINS */
var srPrenom = document.getElementById('srPrenom');
var srNom = document.getElementById('srNom');
var sbCherche = document.getElementById('sbCherche');
//////////////////////////////
// PRENOM & NOM (VARCHAR 45)//
//////////////////////////////
srPrenom.addEventListener('keyup', function(e){ checkVARCHAR(e.target, 1, 45, true); }, false);
srNom.addEventListener('keyup', function(e){ checkVARCHAR(e.target, 1, 45, true); }, false);
//////////////
// SUBMIT() //
//////////////
sbCherche.addEventListener('click', function(e){
e.preventDefault(); // on annule le submit()
var correctNom = srNom.className.indexOf('validated') > -1 && srNom.value.length > 0;
var correctPrenom = srPrenom.className.indexOf('validated') > -1 && srPrenom.value.length > 0;
if( correctPrenom || correctNom ){ // si tout es ok uniquement, on submit()
var request = {
prenom: (correctPrenom) ? srPrenom.value : null,
nom: (correctNom) ? srNom.value : null
};
API.send('Patient:search', request, function(e){
if( e.status != 'success' )
notif(e.status, e.title, e.message);
if( e.hasOwnProperty('patients') )
displayFoundPatients(e.patients);
else
displayFoundPatients([]);
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);
////////////////////////////////////////////
// AFFICHAGE DES MEDECINS DE LA RECHERCHE //
////////////////////////////////////////////
function displayFoundPatients(foundPatients){
var container = document.getElementById('searchResultPatient');
var content = '';
for( var i = 0 ; i < foundPatients.length ; i++ ){
content += '<tr>';
// début modification
content += "<td colspan=6><form class='updPatient' action='managers/' method='POST'>";
content += "<input type='hidden' name='Id' value='"+ foundPatients[i].Id +"'>";
content += "<input type='text' name='Civilite' value='"+ ((foundPatients[i].Civilite=='M')?'Monsieur':'Madame') + "'>";
content += "<input type='text' name='Prenom' value='"+ foundPatients[i].Prenom + "'>";
content += "<input type='text' name='Nom' value='"+ foundPatients[i].Nom.toUpperCase() + "'>";
content += "<input type='text' name='DateNaissance' value='"+ foundPatients[i].DateNaissance + "'>";
content += "<input type='text' name='NumSecuriteSociale' value='"+ foundPatients[i].NumSecuriteSociale + "'>";
content += "<input type='hidden' name='command' value='Patient:update'>";
content += "<input type='hidden' name='id_patient' value='"+foundPatients[i].Id+"'>";
content += "<input type='submit' value=''>";
content += '</form></td>';
// fin modification
// début suppression
content += "<td><form class='delPatient' action='managers/' method='POST'>";
content += "<input type='hidden' name='command' value='Patient:delete'>";
content += "<input type='hidden' name='id_patient' value='"+foundPatients[i].Id+"'>";
content += "<input type='submit' value=''>";
content += '</form></td>';
// fin suppression
content += '</tr>';
}
// on vide le container
container.innerHTML = content;
}

View File

@ -1,5 +1,8 @@
<?php
function customCompression($input, $compression){
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
}
/**
* Created by PhpStorm.
* User: seekdasky
@ -9,56 +12,98 @@
class Medecin
{
public function add($params){
/* CREATION REUSSIE */
if(MedecinRepo::add($params['civilite'],strtolower($params['prenom']),strtolower($params['nom'])) !==FALSE){
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
$_status = 'success';
$_title = 'Création effectuée!';
$_message = 'Le médecin <strong>'.$params['prenom'].' '.$params['nom'].'</strong> a bien été créé.';
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']."/Medecins.php?type=creation");
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
/* ERREUR DE CREATION */
}else{
$_status = 'error';
$_title = 'Erreur de création!';
$_message = 'Certains champs étaient incorrects. Réessayez!';
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'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
}
public function search($params){
/* RECHERCHE REUSSIE */
if( ($medList=MedecinRepo::search(strtolower($params['nom']), strtolower($params['prenom']))) !== FALSE ){
$_status = 'success';
$_title = 'Recherche effectuée!';
$_message = '<strong>'.count($medList).'</strong> médecin(s) trouvé(s)!';
$_medecins = $medList;
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, 'medecins' => $_medecins ]));
else{
$response = new Response();
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&medecins='.customCompression(json_encode($_medecins), true));
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Création effectuée!',
'message' => 'Le médecin '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
]));
}
}else{
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
$_status = 'error';
$_title = 'Erreur lors de la recherche!';
$_message = 'Certains champs étaient incorrects. Réessayez!';
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']."/Medecins.php?type=error");
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de création!'
]));
}
}
}
public function delete($params){
if(MedecinRepo::delete($params['id_medecin']) !==FALSE){
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
if( MedecinRepo::delete($params['id_medecin']) !== FALSE ){
$_status = 'success';
$_title = 'Médecin supprimé!';
$_message = 'Le médecin a bien été supprimé de la base de données! ';
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']."/Medecins.php?type=supression");
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Médecin supprimé!',
'message' => ''
]));
}
}else{
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
$_status = 'error';
$_title = 'Erreur de suppression!';
$_message = 'Erreur lors de la suppression. Réessayez!';
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']."/Medecins.php?type=error");
$response->setHeader('Location','http://'.$_SERVER['HTTP_HOST'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur lors de la supression!'
]));
}
}
}

View File

@ -1,4 +1,8 @@
<?php
function customCompression($input, $compression){
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
}
/**
* Created by PhpStorm.
@ -9,45 +13,80 @@
class Patient
{
public function add($params){
if(StaticRepo::checkParam($params['date_naissance'],'Date')){
$params['num_secu'] = str_replace(' ','',$params['num_secu']);
if( StaticRepo::checkParam($params['date_naissance'], 'Date') ){
$params['num_secu'] = str_replace(' ', '', $params['num_secu']);
$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'],
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){
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
$_status = 'success';
$_title = 'Création effectuée!';
$_message = 'Le patient <strong>'.$params['prenom'].' '.$params['nom'].'</strong> a bien été créé.';
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']."/Patients.php?type=creation");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Création effectuée!',
'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
]));
}
}else{
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
$_status = 'error';
$_title = 'Erreur de création!';
$_message = 'Certains champs étaient incorrects. Réessayez!';
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']."/Patients.php?type=error");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de création!'
]));
}
}
}else{
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
$_status = 'error';
$_title = 'Erreur de création!';
$_message = 'Le format de la date est incorrect. Réessayez!';
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']."/Patients.php?type=error");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
}
public function search($params){
/* RECHERCHE REUSSIE */
if( ($patList=PatientRepo::search(strtolower($params['nom']), strtolower($params['prenom']))) !== FALSE ){
$_status = 'success';
$_title = 'Recherche effectuée!';
$_message = '<strong>'.count($patList).'</strong> patient(s) trouvé(s)!';
$_patients = $patList;
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, 'patients' => $_patients ]));
else{
$response = new Response();
// $response->write("patients=".$compressed_json);
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message.'&patients='.customCompression( json_encode($_patients), true));
$response->send();
}
}else{
$_status = 'error';
$_title = 'Erreur lors de la recherche!';
$_message = 'Certains champs étaient incorrects. Réessayez!';
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'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de paramètre',
'message' => 'Date incorrecte'
]));
}
}
}
@ -58,67 +97,73 @@ 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){
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
$_status = 'success';
$_title = 'Modification effectuée!';
$_message = 'Le patient <strong>'.$params['prenom'].' '.$params['nom'].'</strong> a bien été modifié.';
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']."/Patients.php?type=maj");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Modification effectuée!',
'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été modifié.'
]));
}
}else{
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
$_status = 'error';
$_title = 'Erreur de modification!';
$_message = 'Certains champs étaient incorrects. Réessayez!';
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']."/Patients.php?type=error");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de création!'
]));
}
}
}else{
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
$_status = 'error';
$_title = 'Erreur de modification!';
$_message = 'Le format de la date est incorrect. Réessayez!';
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']."/Patients.php?type=error");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de paramètre',
'message' => 'Date incorrecte'
]));
}
}
}
public function delete($params){
if(PatientRepo::delete($params['id_patient']) !==FALSE){
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
if( PatientRepo::delete($params['id_patient']) !== FALSE ){
$_status = 'success';
$_title = 'Patient supprimé!';
$_message = 'Le patient a bien été supprimé de la base de données!';
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']."/Patients.php?type=supression");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Supression effectuée!',
'message' => 'Le patient a bien été supprimé.'
]));
}
}else{
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
$_status = 'error';
$_title = 'Erreur de suppression!';
$_message = 'Erreur lors de la suppression. Réessayez!';
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']."/Patients.php?type=error");
$response->setHeader('Location', 'http://'.$_SERVER['HTTP_HOST'].'/Patients.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}else{
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur lors de la supression!'
]));
}
}
}

View File

@ -9,70 +9,70 @@
class RDV
{
public function add($params){
if(StaticRepo::checkParam($params['date_naissance'],'Date')) {
if(StaticRepo::checkParam($params['date'],'Date')) {
$params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']);
if (RDVRepo::add($params['date']->format('Y-m-d') . ' ' . $params['heure'] . ':00', $params['duree'], $params['id_patient'], $params['id_medecin']) !== 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=creation");
$response->send();
}else{
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Création effectuée!',
'message' => 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].' a bien été créée.'
]));
}else{
$response = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=creation");
$response->send();
}
}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{
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de création!'
]));
}else{
$response->send();
$response = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
}
}
}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{
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
Response::quickResponse(200, json_encode([
'status' => 'error',
'title' => 'Erreur de paramètre',
'message' => 'Date incorrecte'
]));
}else{
$response = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
$response->send();
}
}
}
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 = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=supression");
$response->send();
}else{
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{
$response = new Response();
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=supression");
$response->send();
}
}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{
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();
}
}
}

View File

@ -3,6 +3,9 @@
"add":{"method": "add",
"role": 0,
"strict": false},
"search":{"method":"search",
"role":0,
"strict":false},
"delete":{"method": "delete",
"role": 0,
"strict": false},
@ -26,6 +29,9 @@
"add":{"method":"add",
"role":0,
"strict":false},
"search":{"method":"search",
"role":0,
"strict":false},
"delete":{"method": "delete",
"role": 0,
"strict": false}

View File

@ -63,13 +63,13 @@ class StaticRepo{
}else{
// on supprime les doublons des entrées (indice numérique)
foreach($fetchData as $i=>$val){ // pour toutes les entrées
foreach($fetchData as $i=>$val){ // pour toutes les entrées
if( !mb_detect_encoding($val, 'UTF-8') )
$fetchData[$i] = utf8_encode($val);
if( is_int($i) ) // si l'indice est un entier
unset( $fetchData[$i] ); // on le supprime
if( is_int($i) ) // si l'indice est un entier
unset( $fetchData[$i] ); // on le supprime
}
}
@ -120,36 +120,40 @@ class StaticRepo{
switch($dbtype){
// [1] 'M' / 'F'
case 'Civilite':
$checker = $checker && is_string($variable) && in_array($variable, ['M','F']);
$checker = $checker && !is_null($variable) && is_string($variable) && in_array($variable, ['M','F']);
break;
// [2] Chaine de caractère (longueur variable)
case 'String':
$checker = $checker && is_string($variable) && strlen($variable) <= $len;
$checker = $checker && !is_null($variable) && is_string($variable) && strlen($variable) > 0 && strlen($variable) <= $len;
break;
case 'Integer':
$checker = $checker && is_int($variable) && $variable<pow(2, 32);
$checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 32);
break;
case 'Numeric':
$checker = $checker && !is_null($variable) && is_numeric($variable);
break;
case 'SmallInteger':
$checker = $checker && is_int($variable) && $variable<pow(2, 16);
$checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 16);
break;
case 'TinyInteger':
$checker = $checker && is_int($variable) && $variable<pow(2, 8);
$checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 8);
break;
case 'BigInteger':
$checker = $checker && is_int($variable) && $variable<pow(2, 64);
$checker = $checker && !is_null($variable) && is_int($variable) && $variable<pow(2, 64);
break;
case 'Date':
$checker = $checker && is_string($variable) && ( preg_match('/\d{2}\/\d{2}\/\d{4}/', $variable) || preg_match('/\d{4}-\d{2}-\d{2}/', $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_string($variable) && preg_match('/(\d+):(\d+)/is',$variable);
$checker = $checker && !is_null($variable) && is_string($variable) && preg_match('/(\d+):(\d+)/is',$variable);
break;
// [N] Type inconnu

View File

@ -11,7 +11,7 @@ class MedecinRepo
public static function getById($id){
if(!StaticRepo::checkParam($id,'Integer')){return false;}
if(!StaticRepo::checkParam($id, 'Numeric')) return false;
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id');
$req->execute(['id' => $id]);
@ -21,41 +21,52 @@ class MedecinRepo
public static function add($civilite,$prenom,$nom){
if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;}
if(!StaticRepo::checkParam($civilite,'Civilite') && !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')) return false;
$req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
$result = $req->execute(['civilite' => $civilite,
'nom' => $nom,
'prenom' => $prenom]);
'prenom' => $prenom
]);
//PDO renvoie un ID sous forme de char, on transtype
$id = StaticRepo::getConnexion()->lastInsertId();
settype($id,'integer');
if($result){return $id;}
else{return false;}
settype($id, 'integer');
if($result) return $id;
else return false;
}
public static function delete($idMedecin){
if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;}
if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false;
$req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id');
return $req->execute(['id' => $idMedecin]);
}
public static function search($nom,$prenom){
public static function search($nom, $prenom){
if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;}
if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false;
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
$req->execute(['nom' => $nom,
'prenom' => $prenom]);
// on définit les valeurs (peuvent être nulles)
$optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%';
$optNom = ( $nom != 'null' && StaticRepo::checkParam($nom, 'String45') ) ? '%'.$nom.'%' : '%';
return StaticRepo::delNumeric($req->fetchAll());
$req = StaticRepo::getConnexion()->query("SELECT Id, Civilite, Prenom, Nom
FROM Medecin
WHERE Nom LIKE '".$optNom."'
AND Prenom LIKE '".$optPrenom."'
ORDER BY Nom, Prenom ASC");
return StaticRepo::delNumeric( $req->fetchAll() );
}
public static function getPatients($idMedecin){
if(!StaticRepo::checkParam($idMedecin,'Integer')){return false;}
if(!StaticRepo::checkParam($idMedecin,'Numeric')) return false;
$req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin
WHERE Medecin.Id = :id

View File

@ -28,11 +28,11 @@ class PatientRepo
$correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String');
$correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date');
$correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50');
$correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') );
$correctTypes = $correctTypes && ( $medecinTraitant == 'null' || StaticRepo::checkParam($medecinTraitant, 'Numeric'));
if( !$correctTypes ) return false;
$dateNaissance = strtotime($dateNaissance);
$dateNaissance = Date('o-m-d',$dateNaissance);
$dateNaissance = Date('o-m-d', $dateNaissance);
$req = StaticRepo::getConnexion()->prepare("INSERT INTO Patient
VALUES(DEFAULT,
@ -112,10 +112,12 @@ class PatientRepo
public static function delete($idPatient){
if(!StaticRepo::checkParam($idPatient,'Integer')){ return false;}
// si format erroné, retourne FALSE
if( !StaticRepo::checkParam($idPatient, 'Numeric') ) return false;
$req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id');
return $req->execute(['id' => $idPatient]);
return $req->execute([':id' => $idPatient]);
}
@ -128,16 +130,26 @@ class PatientRepo
}
public static function search($nom,$prenom){
if(!StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45')){return false;}
public static function search($nom, $prenom){
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
$req->execute(['nom' => $nom, 'prenom' => $prenom]);
return StaticRepo::delNumeric($req->fetchAll());
if( !StaticRepo::checkParam($prenom,'String45') && !StaticRepo::checkParam($nom,'String45') ) return false;
// on définit les valeurs (peuvent être nulles)
$optPrenom = ( $prenom != 'null' && StaticRepo::checkParam($prenom,'String45') ) ? '%'.$prenom.'%' : '%';
$optNom = ( $nom != 'null' && StaticRepo::checkParam($nom, 'String45') ) ? '%'.$nom.'%' : '%';
$req = StaticRepo::getConnexion()->query("SELECT Id, Civilite, Nom, Prenom, DATE_FORMAT(DateNaissance, '%d/%m/%Y') as DateNaissance, NumSecuriteSociale
FROM Patient
WHERE Nom LIKE '".$optNom."'
AND Prenom LIKE '".$optPrenom."'
ORDER BY Nom, Prenom ASC");
return StaticRepo::delNumeric( $req->fetchAll() );
}
public static function getAll(){
$req = StaticRepo::getConnexion()->query('SELECT * FROM Patient ORDER BY nom, prenom ASC');

0
src/calendrier.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

0
src/calendrier_code.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

1
src/svg/edit.svg Executable file
View File

@ -0,0 +1 @@
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg enable-background="new 0 0 128 128" height="128px" id="Layer_1" version="1.1" viewBox="0 0 128 128" width="128px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M123.315,16L112.003,4.686C108.878,1.563,104.78,0,100.687,0s-8.188,1.563-11.313,4.686l-68.69,68.689 C17.563,76.5,8.004,88.586,8,92.68L0,128l35.313-8c0,0,16.188-9.563,19.313-12.688l68.69-68.687 C129.562,32.375,129.562,22.243,123.315,16z M10.605,117.398l5.195-22.953c0.074-0.328,0.129-0.664,0.16-0.992 c0.016-0.047,0.059-0.117,0.078-0.164l18.09,18.094c-0.605,0.367-1.215,0.734-1.813,1.094L10.605,117.398z M48.984,101.641 c-0.906,0.859-4.039,2.977-7.867,5.414L20.391,86.328c2.125-2.914,4.492-5.844,5.949-7.297l51.722-51.718l22.625,22.625 L48.984,101.641z M117.659,32.969l-11.316,11.313L83.718,21.657l11.316-11.313C96.542,8.829,98.55,8,100.687,8 s4.148,0.836,5.66,2.344l11.313,11.313c1.512,1.508,2.34,3.516,2.34,5.656C119.999,29.446,119.167,31.461,117.659,32.969z" fill="#546E7A"/></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -6,12 +6,10 @@
* Time: 11:40
*/
require_once('autoloader.php');
$rdv=new RDV();
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
@ -19,3 +17,81 @@ echo $rdv->getSVG(['mois' => '2015-11']);
?>
</body>
</html>
// Response::quickResponse(200,'lol');
$json = [
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
],
[
"nom" => "Alex",
"prenom" => "Alex",
]
];
$compressed = compress( json_encode($json) );
$uncompressed = uncompress( $compressed );
echo $compressed.'<br><br>';
echo $uncompressed.'<br><br>';
function customCompression($input, compression){
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
}
function uncompress($input){
}