'success', 'title' => 'Création effectuée!', 'message' => 'Le médecin '.$params['prenom'].' '.$params['nom'].' a bien été créé.' ])); }else{ $response = new Response(); $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=creation"); $response->send(); } }else{ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ Response::quickResponse(200, json_encode([ 'status' => 'error', 'title' => 'Erreur de création!' ])); }else{ $response = new Response(); $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error"); $response->send(); } } } public function search($params){ if( ($medList=MedecinRepo::search(strtolower($params['nom']), strtolower($params['prenom']))) !== FALSE ){ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ Response::quickResponse(200, json_encode([ 'status' => 'success', 'medecins' => $medList ])); }else{ $response = new Response(); $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=creation"); $response->send(); } }else{ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ Response::quickResponse(200, json_encode([ 'status' => 'error', 'title' => 'Oups!', 'message' => 'Aucun médecin trouvé.' ])); }else{ $response = new Response(); $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error"); $response->send(); } } } public function delete($params){ if(MedecinRepo::delete($params['id_medecin']) !==FALSE){ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ Response::quickResponse(200, json_encode([ 'status' => 'success', 'title' => 'Médecin supprimé!', 'message' => '' ])); }else{ $response = new Response(); $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=supression"); $response->send(); } }else{ if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ){ Response::quickResponse(200, json_encode([ 'status' => 'error', 'title' => 'Erreur lors de la supression!' ])); }else{ $response = new Response(); $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error"); $response->send(); } } } }