Merge branch 'master' of github.com:xdrm-brackets/projetphp
This commit is contained in:
commit
7d0a1be0f7
|
@ -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']."'>";
|
||||
|
||||
|
|
|
@ -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'>";
|
||||
|
|
|
@ -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'] ."'>";
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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 ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue