Merge branch 'master' of github.com:xdrm-brackets/projetphp

This commit is contained in:
Lucas Mascaro 2016-01-03 17:44:31 +01:00
commit 7d0a1be0f7
5 changed files with 61 additions and 3 deletions

View File

@ -135,7 +135,7 @@ $medecinOpt = (!is_numeric($medecinOpt)) ? null : $medecinOpt;
echo "<form action='managers/' method='POST'>";
echo "<input type='text' class='jour' name='jour' value='".date('d/m/Y', strtotime($RDV['DateRDV']))."'>";
echo "<input type='text' class='heure' name='heure' value='".date('H:i', strtotime($RDV['DateRDV']))."'>";
echo "<input type='text' class='duree' name='Duree' value='".date('i:s', strtotime($RDV['Duree']))."'>";
echo "<input type='text' class='duree' name='Duree' value='".date('H:i', strtotime($RDV['Duree']))."'>";
echo "<input type='text' readonly class='Medecin' value='Medecin: ".$RDV['M_Prenom']." ".$RDV['M_Nom']."'>";
echo "<input type='text' readonly class='Patient' value='Patient: ".$RDV['P_Prenom']." ".$RDV['P_Nom']."'>";

View File

@ -97,7 +97,7 @@ $medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode( customCompression(
// début modification
echo "<td colspan=4><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='Civilite' value='". (($PAT['Civilite']=='M')?'Monsieur':'Madame') ."' readonly>";
echo "<input type='text' name='Prenom' value='". $PAT['Prenom'] ."'>";
echo "<input type='text' name='Nom' value='". strtoupper($PAT['Nom']) ."'>";
echo "<input type='hidden' name='command' value='Medecin:update'>";

View File

@ -97,7 +97,7 @@ $patientsSearch = ( isset($_GET['patients']) ) ? json_decode( customCompression(
// 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='Civilite' value='". (($PAT['Civilite']=='M')?'Monsieur':'Madame') ."' readonly>";
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'] ."'>";

View File

@ -107,4 +107,55 @@ class Medecin
}
}
public function update($params){
if( StaticRepo::checkParam($params['Id'], 'Numeric') && StaticRepo::checkParam($params['Prenom'], 'String45') && StaticRepo::checkParam($params['Nom'], 'String45') ){
// si la modification réussit
if( MedecinRepo::update($params['Id'], $params['Nom'], $params['Prenom']) ){
$_status = 'success';
$_title = 'Médecin modifié!';
$_message = 'Le médecin <strong>'.$params['Prenom'].' '.strtoupper($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'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}else{
$_status = 'error';
$_title = 'Erreur de modification!';
$_message = 'La modification a échoué. 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();
}
}
// erreur de params
}else{
$_status = 'error';
$_title = 'Erreur de paramètres!';
$_message = 'Un des champs 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'].'/Medecins.php?status='.$_status.'&title='.$_title.'&message='.$_message);
$response->send();
}
}
}
}

View File

@ -86,4 +86,11 @@ class MedecinRepo
}
public static function update($id, $nom, $prenom){
$req = StaticRepo::getConnexion()->prepare("UPDATE Medecin SET Nom = :nom, Prenom = :prenom WHERE Id = :id");
return $req->execute([ ':nom' => strtoupper($nom), ':prenom' => $prenom, ':id' => $id ]);
}
}