Vérification pre-submit pour toutes les pages (créations)
This commit is contained in:
parent
a07a23e856
commit
58cb185407
|
@ -3,7 +3,12 @@ require('autoloader.php');
|
|||
if(!Authentification::checkUser(0)){
|
||||
header("Location: http://".$_SERVER['HTTP_HOST']."/index.php");
|
||||
die();
|
||||
};?>
|
||||
};
|
||||
|
||||
// formattage $_GET['type']
|
||||
$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -44,8 +49,19 @@ if(!Authentification::checkUser(0)){
|
|||
|
||||
<!-- FIL D'ARIANE -->
|
||||
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Consultations.php'>Consultations</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/********************************/
|
||||
}
|
||||
/*************************************/
|
||||
/* SAISIR UN RENDEZ-VOUS */
|
||||
/*************************************/ ?>
|
||||
<article data-title="Saisir un rendez-vous">
|
||||
|
@ -68,13 +84,13 @@ if(!Authentification::checkUser(0)){
|
|||
</select><span class='associated'>Médecin traitant du patient.</span>
|
||||
</div><br>
|
||||
|
||||
<input type='text' id='inDate' name='date' placeholder='jj/mm/aaaa'><span class='info'>Date de la consultation</span><br>
|
||||
<input type='text' id='inHeure' name='heure' placeholder='HH:MM'><span class='info'>Heure de la consultation</span><br>
|
||||
<input type='text' id='inDuree' name='duree' placeholder='minutes'><span class='info'>Durée de la consultation</span><br>
|
||||
<input type='text' id='inDate' name='date' placeholder='jj/mm/aaaa' required><span class='info'>Date de la consultation</span><br>
|
||||
<input type='text' id='inHeure' name='heure' placeholder='HH:MM' required><span class='info'>Heure de la consultation</span><br>
|
||||
<input type='text' id='inDuree' name='duree' placeholder='minutes' required><span class='info'>Durée de la consultation</span><br>
|
||||
<br>
|
||||
|
||||
<input type='hidden' name='command' value='Consultation:add'>
|
||||
<input type='submit' value='Enregistrer la consultation'>
|
||||
<input type='hidden' name='command' value='RDV:add'>
|
||||
<input type='submit' id='sbCreer' value='Enregistrer la consultation'>
|
||||
</form>
|
||||
|
||||
</article>
|
||||
|
@ -87,7 +103,7 @@ if(!Authentification::checkUser(0)){
|
|||
/*************************************/ ?>
|
||||
<article data-title="Numéro de sécurité sociale">
|
||||
<div>
|
||||
<input type='radio' name='filter_c' id='tousRDV'><label for='tousRDV'>Toutes les consultations</label><br>
|
||||
<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'>
|
||||
|
|
26
Medecins.php
26
Medecins.php
|
@ -3,7 +3,12 @@ require('autoloader.php');
|
|||
if(!Authentification::checkUser(0)){
|
||||
header("Location: http://".$_SERVER['HTTP_HOST']."/index.php");
|
||||
die();
|
||||
};?>
|
||||
};
|
||||
|
||||
// formattage $_GET['type']
|
||||
$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -45,22 +50,33 @@ if(!Authentification::checkUser(0)){
|
|||
|
||||
<!-- 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/********************************/
|
||||
}
|
||||
/*************************************/
|
||||
/* AJOUTER UN MÉDECIN */
|
||||
/*************************************/ ?>
|
||||
<article data-title="Ajouter un médecin">
|
||||
<form method='POST' action='managers/'>
|
||||
<br><h4>Ajout d'un nouveau médecin</h4>
|
||||
<input type='text' id='crPrenom' name='prenom' placeholder='Prénom' value=''><br>
|
||||
<input type='text' id='crNom' name='nom' placeholder='NOM' value=''><br>
|
||||
<input type='text' id='crPrenom' name='prenom' placeholder='Prénom' value='' required><br>
|
||||
<input type='text' id='crNom' name='nom' placeholder='NOM' value='' required><br>
|
||||
|
||||
<input type='radio' name='civilite' value='M' id='civ1' checked><label for='civ1'>Homme</label><br>
|
||||
<input type='radio' name='civilite' value='F' id='civ2'><label for='civ2'>Femme</label><br>
|
||||
<br>
|
||||
|
||||
<input type='hidden' name='command' value='Medecin:add'>
|
||||
<input type='submit' value='Créer le médecin'>
|
||||
<input type='submit' id='sbCreer' value='Créer le médecin'>
|
||||
</form>
|
||||
|
||||
</article>
|
||||
|
|
|
@ -7,6 +7,7 @@ if(!Authentification::checkUser(0)){
|
|||
|
||||
// formattage $_GET['type']
|
||||
$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
@ -48,15 +49,14 @@ $answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
|||
<section id='CONTAINER'>
|
||||
|
||||
<!-- FIL D'ARIANE -->
|
||||
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Medecins.php'>Gestion des médecins</a></a> </div>
|
||||
<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>';
|
||||
|
|
|
@ -456,6 +456,7 @@ body{
|
|||
-o-transition: all .2s ease-in-out;
|
||||
}
|
||||
|
||||
#CONTAINER > article input:hover + .info,
|
||||
#CONTAINER > article input:focus + .info{
|
||||
color: #afafaf;
|
||||
border-color: #afafaf;
|
||||
|
@ -557,17 +558,11 @@ input[type=radio] + label:before{
|
|||
|
||||
/* @active + label */
|
||||
input[type=radio]:active + label:before{
|
||||
transform: scale(.8);
|
||||
-moz-transform: scale(.8);
|
||||
-webkit-transform: scale(.8);
|
||||
-ms-transform: scale(.8);
|
||||
-o-transform: scale(.8);
|
||||
|
||||
transform: rotate(360deg);
|
||||
-moz-transform: rotate(360deg);
|
||||
-webkit-transform: rotate(360deg);
|
||||
-ms-transform: rotate(360deg);
|
||||
-o-transform: rotate(360deg);
|
||||
transform: rotate(360deg) scale(.9);
|
||||
-moz-transform: rotate(360deg) scale(.9);
|
||||
-webkit-transform: rotate(360deg) scale(.9);
|
||||
-ms-transform: rotate(360deg) scale(.9);
|
||||
-o-transform: rotate(360deg) scale(.9);
|
||||
}
|
||||
|
||||
|
||||
|
@ -577,11 +572,11 @@ input[type=radio]:checked + label:before{
|
|||
background-size: 50% auto;
|
||||
|
||||
/* animation */
|
||||
transform: rotate(360deg);
|
||||
-moz-transform: rotate(360deg);
|
||||
-webkit-transform: rotate(360deg);
|
||||
-ms-transform: rotate(360deg);
|
||||
-o-transform: rotate(360deg);
|
||||
transform: rotate(360deg) scale(1.2);
|
||||
-moz-transform: rotate(360deg) scale(1.2);
|
||||
-webkit-transform: rotate(360deg) scale(1.2);
|
||||
-ms-transform: rotate(360deg) scale(1.2);
|
||||
-o-transform: rotate(360deg) scale(1.2);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ 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,
|
||||
|
@ -131,4 +131,39 @@ inSecu.addEventListener('keyup', function(e){
|
|||
|
||||
// inDate.value = 'x3 F3/a8';
|
||||
// inHeure.value = 'x3 F3/a8';
|
||||
inSecu.value = '1 96 01 31 555 861';
|
||||
inSecu.value = '1 96 01 31 555 861';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
// VERIFICATION DU SUBMIT() //
|
||||
//////////////////////////////
|
||||
sbCreer.addEventListener('click', function(e){
|
||||
e.preventDefault(); // on annule le submit()
|
||||
|
||||
var formElements = sbCreer.parentNode.children;
|
||||
var checker = true;
|
||||
|
||||
// pour chaque <input type='text'> du formulaire (fils direct uniquement)
|
||||
for( var i = 0 ; i < formElements.length ; i++ ){ if( formElements[i] instanceof HTMLInputElement && formElements[i].type == 'text' ){
|
||||
// si le champ est requis (required)
|
||||
if( formElements[i].required )
|
||||
checker = checker && formElements[i].className.indexOf('validated') > -1; // TRUE => validé (niveau interface)
|
||||
// si le champ n'est pas requis et pas vide, on le vide
|
||||
else if( formElements[i].value != '' && formElements[i].className.indexOf('validated') < 0 ) // si incorrect et pas vide
|
||||
formElements[i].value = ''; // on vide
|
||||
}}
|
||||
|
||||
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);
|
|
@ -1,6 +1,6 @@
|
|||
var crPrenom = document.getElementById('crPrenom');
|
||||
var crNom = document.getElementById('crNom');
|
||||
|
||||
var crNom = document.getElementById('crNom');
|
||||
var sbCreer = document.getElementById('sbCreer');
|
||||
|
||||
|
||||
/* VERIFICATION DES SAISIES */
|
||||
|
@ -37,4 +37,26 @@ crNom.addEventListener('keyup', function(e){
|
|||
else
|
||||
remClass(crNom, 'invalid');
|
||||
}
|
||||
}, false);
|
||||
|
||||
|
||||
|
||||
sbCreer.addEventListener('click', function(e){
|
||||
e.preventDefault(); // on annule le submit()
|
||||
|
||||
var formElements = sbCreer.parentNode.children;
|
||||
var checker = true;
|
||||
|
||||
// pour chaque <input type='text'> du formulaire (fils direct uniquement)
|
||||
for( var i = 0 ; i < formElements.length ; i++ ){ if( formElements[i] instanceof HTMLInputElement && formElements[i].type == 'text' ){
|
||||
// si le champ est requis (required)
|
||||
if( formElements[i].required )
|
||||
checker = checker && formElements[i].className.indexOf('validated') > -1; // TRUE => validé (niveau interface)
|
||||
// si le champ n'est pas requis et pas vide, on le vide
|
||||
else if( formElements[i].value != '' && formElements[i].className.indexOf('validated') < 0 ) // si incorrect et pas vide
|
||||
formElements[i].value = ''; // on vide
|
||||
}}
|
||||
|
||||
if( checker ) // si tout es ok uniquement, on submit()
|
||||
sbCreer.parentNode.submit();
|
||||
}, false);
|
|
@ -20,6 +20,9 @@ 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
|
||||
|
@ -33,8 +36,8 @@ function checkVARCHAR(pInputElement, pMinLength, pMaxLength, optAlpha){
|
|||
|
||||
var varcharRegExp;
|
||||
|
||||
if( optAlpha ) varcharRegExp = new RegExp('^([a-z]{'+pMinLength+','+pMaxLength+'})$', 'i'); // only alpha characters
|
||||
else varcharRegExp = new RegExp('^([\\w -]{'+ pMinLength+','+pMaxLength+'})$', 'i'); // any word character
|
||||
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');
|
||||
|
@ -142,7 +145,7 @@ sbCreer.addEventListener('click', function(e){
|
|||
if( formElements[i].required )
|
||||
checker = checker && formElements[i].className.indexOf('validated') > -1; // TRUE => validé (niveau interface)
|
||||
// si le champ n'est pas requis et pas vide, on le vide
|
||||
else if( formElements[i].value != '' && formElements[i].className.indexOf('validated') < 0) // si incorrect et pas vide
|
||||
else if( formElements[i].value != '' && formElements[i].className.indexOf('validated') < 0 ) // si incorrect et pas vide
|
||||
formElements[i].value = ''; // on vide
|
||||
}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue