126 lines
5.9 KiB
PHP
Executable File
126 lines
5.9 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: seekdasky
|
|
* Date: 10/12/15
|
|
* Time: 09:52
|
|
*/
|
|
class RDV
|
|
{
|
|
public function add($params){
|
|
if(StaticRepo::checkParam($params['date_naissance'],'Date')) {
|
|
$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) {
|
|
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=creation");
|
|
$response->send();
|
|
}else{
|
|
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.'
|
|
]));
|
|
}
|
|
}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 création!'
|
|
]));
|
|
}
|
|
}
|
|
}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 paramètre',
|
|
'message' => 'Date incorrecte'
|
|
]));
|
|
}
|
|
}
|
|
}
|
|
|
|
public function delete($params){
|
|
if(RDVRepo::delete($params['id_consultation']) !==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=supression");
|
|
$response->send();
|
|
}else{
|
|
Response::quickResponse(200, json_encode([
|
|
'status' => 'success',
|
|
'title' => 'Supression effectuée!',
|
|
'message' => 'La consultation a bien été supprimée.'
|
|
]));
|
|
}
|
|
}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 lors de la supression!'
|
|
]));
|
|
}
|
|
}
|
|
}
|
|
|
|
public function update($params){
|
|
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!'
|
|
]));
|
|
}
|
|
}
|
|
}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 paramètre',
|
|
'message' => 'Date incorrecte'
|
|
]));
|
|
}
|
|
}
|
|
}
|
|
|
|
public function getSVG($params){
|
|
|
|
}
|
|
|
|
} |