2015-12-10 09:47:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: seekdasky
|
|
|
|
* Date: 10/12/15
|
|
|
|
* Time: 10:02
|
|
|
|
*/
|
|
|
|
class Medecin
|
|
|
|
{
|
|
|
|
public function add($params){
|
|
|
|
if(MedecinRepo::add($params['civilite'],strtolower($params['prenom']),strtolower($params['nom'])) !==FALSE){
|
2015-12-15 08:24:20 +00:00
|
|
|
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=creation");
|
|
|
|
$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éé.'
|
|
|
|
]));
|
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}else{
|
2015-12-15 08:24:20 +00:00
|
|
|
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error");
|
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'error',
|
|
|
|
'title' => 'Erreur de création!'
|
|
|
|
]));
|
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete($params){
|
|
|
|
if(MedecinRepo::delete($params['id_medecin']) !==FALSE){
|
2015-12-15 08:24:20 +00:00
|
|
|
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=supression");
|
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'success',
|
|
|
|
'title' => 'Médecin supprimé!',
|
|
|
|
'message' => ''
|
|
|
|
]));
|
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}else{
|
2015-12-15 08:24:20 +00:00
|
|
|
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error");
|
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'error',
|
|
|
|
'title' => 'Erreur lors de la supression!'
|
|
|
|
]));
|
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|