public function add($params)
 {
     /* CREATION REUSSIE */
     if (MedecinRepo::add($params['civilite'], strtolower($params['prenom']), strtolower($params['nom'])) !== FALSE) {
         $_status = 'success';
         $_title = 'Création effectuée!';
         $_message = 'Le médecin <strong>' . $params['prenom'] . ' ' . $params['nom'] . '</strong> 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();
         }
         /* ERREUR DE CREATION */
     } 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();
         }
     }
 }
Exemple #2
0
<?php

/**
 * Created by PhpStorm.
 * User: seekdasky
 * Date: 03/12/15
 * Time: 11:52
 */
require_once 'autoloader.php';
$jsonP = json_decode(file_get_contents('Docs/PatientExemple.json'), true);
$jsonM = json_decode(file_get_contents('Docs/MedecinExemple.json'), true);
$jsonR = json_decode(file_get_contents('Docs/RDVExemple.json'), true);
var_dump(StaticRepo::testConnexion());
$repo = new PatientRepo();
$repoM = new MedecinRepo();
foreach ($jsonM as $patient) {
    $repoM->add($patient['Civilite'], $patient['Prenom'], $patient['Nom']);
}
foreach ($jsonP as $patient) {
    $repo->add($patient['Civilite'], $patient['Prenom'], $patient['Nom'], $patient['Adresse'], NULL, $patient['Ville'], $patient['CodePostal'], $patient['DateNaissance'], $patient['LieuNaissance'], $patient['NumSecuriteSociale'], $patient['MedecinTraitant']);
}
foreach ($jsonR as $rdv) {
    RDVRepo::add($rdv['DateRDV'], $rdv['Duree'], $rdv['Patient_Id'], $rdv['Medecin_Id']);
}