2015-12-10 09:47:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: seekdasky
|
|
|
|
* Date: 10/12/15
|
|
|
|
* Time: 09:52
|
|
|
|
*/
|
|
|
|
class RDV
|
|
|
|
{
|
|
|
|
public function add($params){
|
2015-12-17 08:53:09 +00:00
|
|
|
if(StaticRepo::checkParam($params['date'],'Date')) {
|
2015-12-15 08:24:20 +00:00
|
|
|
$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) {
|
2015-12-17 08:53:09 +00:00
|
|
|
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
2015-12-15 08:24:20 +00:00
|
|
|
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.'
|
|
|
|
]));
|
2015-12-17 08:53:09 +00:00
|
|
|
}else{
|
2015-12-15 08:24:20 +00:00
|
|
|
$response = new Response();
|
2015-12-17 08:53:09 +00:00
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=creation");
|
2015-12-15 08:24:20 +00:00
|
|
|
$response->send();
|
2015-12-17 08:53:09 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
2015-12-15 08:24:20 +00:00
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'error',
|
|
|
|
'title' => 'Erreur de création!'
|
|
|
|
]));
|
2015-12-17 08:53:09 +00:00
|
|
|
}else{
|
|
|
|
$response->send();
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
2015-12-15 08:24:20 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}else{
|
2015-12-17 08:53:09 +00:00
|
|
|
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
2015-12-15 08:24:20 +00:00
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'error',
|
|
|
|
'title' => 'Erreur de paramètre',
|
|
|
|
'message' => 'Date incorrecte'
|
|
|
|
]));
|
2015-12-17 08:53:09 +00:00
|
|
|
}else{
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
|
|
|
$response->send();
|
2015-12-15 08:24:20 +00:00
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete($params){
|
|
|
|
if(RDVRepo::delete($params['id_consultation']) !==FALSE){
|
2015-12-17 08:53:09 +00:00
|
|
|
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
2015-12-15 08:24:20 +00:00
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'success',
|
|
|
|
'title' => 'Supression effectuée!',
|
|
|
|
'message' => 'La consultation a bien été supprimée.'
|
|
|
|
]));
|
2015-12-17 08:53:09 +00:00
|
|
|
}else{
|
2015-12-15 08:24:20 +00:00
|
|
|
$response = new Response();
|
2015-12-17 08:53:09 +00:00
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=supression");
|
2015-12-15 08:24:20 +00:00
|
|
|
$response->send();
|
2015-12-17 08:53:09 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){
|
2015-12-15 08:24:20 +00:00
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'error',
|
|
|
|
'title' => 'Erreur lors de la supression!'
|
|
|
|
]));
|
2015-12-17 08:53:09 +00:00
|
|
|
}else{
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultations.php?type=error");
|
|
|
|
$response->send();
|
2015-12-15 08:24:20 +00:00
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update($params){
|
2015-12-15 08:24:20 +00:00
|
|
|
if(StaticRepo::checkParam($params['date_naissance'],'Date')) {
|
|
|
|
$params['date'] = DateTime::createFromFormat('d/m/Y', $params['date']);
|
|
|
|
if (RDVRepo::updateDateTime($params['id_consultation'], $params['date']->format('Y-m-d') . ' ' . $params['heure'] . ':00') !== 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=maj");
|
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'success',
|
|
|
|
'title' => 'Modification effectuée!',
|
|
|
|
'message' => 'La consultation du '.$params['date']->format('d/m/Y').' à '.$params['heure'].'a bien été mis àjour.'
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
}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{
|
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'error',
|
|
|
|
'title' => 'Erreur de mise a jour!'
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
}
|
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']."/Consultations.php?type=error");
|
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
Response::quickResponse(200, json_encode([
|
|
|
|
'status' => 'error',
|
|
|
|
'title' => 'Erreur de paramètre',
|
|
|
|
'message' => 'Date incorrecte'
|
|
|
|
]));
|
|
|
|
}
|
2015-12-10 09:47:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|