format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !== FALSE){ $_status = 'success'; $_title = 'Création effectuée!'; $_message = 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.'; 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 création!'; $_message = 'Certains champs étaient incorrects. 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(); } } }else{ $_status = 'error'; $_title = 'Erreur de création!'; $_message = 'Le format de la date 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(); } } } public function update($params){ if(StaticRepo::checkParam($params['date_naissance'],'Date')){ $params['num_secu'] = str_replace(' ','',$params['num_secu']); $params['date_naissance'] = DateTime::createFromFormat('d/m/Y', $params['date_naissance']); if(PatientRepo::update($params['id_patient'],$params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['cope_postal'], $params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){ $_status = 'success'; $_title = 'Modification effectuée!'; $_message = 'Le patient '.$params['prenom'].' '.$params['nom'].' 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 = 'Certains champs étaient incorrects. 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(); } } }else{ $_status = 'error'; $_title = 'Erreur de modification!'; $_message = 'Le format de la date 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(); } } } public function delete($params){ if(PatientRepo::delete($params['id_patient']) !==FALSE){ $_status = 'success'; $_title = 'Patient supprimé!'; $_message = 'Le patient a bien été supprimé de la base de données!'; 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 suppression!'; $_message = 'Erreur lors de la suppression. 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(); } } } }