Esempio n. 1
0
 public function search($params)
 {
     /* RECHERCHE REUSSIE */
     if (($patList = PatientRepo::search(strtolower($params['nom']), strtolower($params['prenom']))) !== FALSE) {
         $_status = 'success';
         $_title = 'Recherche effectuée!';
         $_message = '<strong>' . count($patList) . '</strong> patient(s) trouvé(s)!';
         $_patients = $patList;
         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, 'patients' => $_patients]));
         } else {
             $response = new Response();
             // $response->write("patients=".$compressed_json);
             $response->setHeader('Location', 'http://' . $_SERVER['HTTP_HOST'] . '/Patients.php?status=' . $_status . '&title=' . $_title . '&message=' . $_message . '&patients=' . customCompression(json_encode($_patients), true));
             $response->send();
         }
     } else {
         $_status = 'error';
         $_title = 'Erreur lors de la recherche!';
         $_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'] . '/Patients.php?status=' . $_status . '&title=' . $_title . '&message=' . $_message);
             $response->send();
         }
     }
 }