Exemplo n.º 1
0
 if (($action == 'edit' || $action == 'delete') && isset($serviceInfo)) {
     $sqlData['id'] = $serviceInfo['id'];
     // Id du service
 }
 // Traitement du POST
 if ($action == 'edit' || $action == 'add') {
     foreach ($_POST as $key => $value) {
         if ($key == 'nom') {
             if ($value != '' && ($action == 'add' || $value != $serviceInfo[$key])) {
                 $sqlData[$key] = htmLawed($value);
             }
         }
         if ($key == 'chef' && is_numeric($value) && count(checkUser($value, array())) == 0 && ($action == 'add' || $value != $serviceInfo[$key])) {
             $sqlData[$key] = $value;
         }
         if ($key == 'hopital' && is_numeric($value) && count(checkHopital($value, array())) == 0 && ($action == 'add' || $value != $serviceInfo[$key])) {
             $sqlData[$key] = $value;
         }
         if ($key == 'specialite' && is_numeric($value) && count(checkSpecialite($value, array())) == 0 && ($action == 'add' || $value != $serviceInfo[$key])) {
             $sqlData[$key] = $value;
         }
         if ($key == 'certificat') {
             $sqlAffectationData = array();
             $currentCertificat = array();
             if (isset($serviceInfo)) {
                 $listeCertificats = array();
                 foreach ($serviceInfo['certificat'] as $certificatId => $certificatValue) {
                     $listeCertificats[$certificatValue['idAffectation']] = $certificatId;
                 }
             }
             /*
Exemplo n.º 2
0
if ($action == 'list') {
    if (isset($_GET['order'])) {
        $order = $_GET['order'];
    } else {
        $order = 'nom';
    }
    if (isset($_GET['desc'])) {
        $desc = true;
    } else {
        $desc = false;
    }
    $listeHopitaux = getHospitalList($order, $desc);
} else {
    if ($action == 'view' || $action == 'delete' || $action == 'edit') {
        // On récupère les données sur l'hopital
        if (count(checkHopital($_GET['id'], array())) == 0) {
            $hopitalData = getHospitalInfo($_GET['id']);
        } else {
            header('Location: ' . ROOT . CURRENT_FILE . '?page=' . $_GET['page']);
        }
    }
}
/**
		2. Traitement des formulaires
	**/
if (isset($_POST) && count($_POST)) {
    /*
    	Préparation des données : on crée un array contenant toutes les données, ce dernier sera ensuite parcouru pour créer la requête SQL qui sera préparée
    */
    if ($action == 'edit' || $action == 'delete') {
        $sqlData['id'] = $hopitalData['id'];
Exemplo n.º 3
0
/**
 * getHospitalInfo - Retourne les informations relatives à la spécialité
 *
 * @category stageFunction
 * @param int $id Identifiant de l'hopital
 * @return array Array contenant les informations relatives à l'hopital
 *
 * @Author Ali Bellamine
 *
 * Contenu de l'array retourné :<br>
 *	['id'] => (int) Identifiant de l'hopital<br>
 *	['nom'] => (string) Nom de l'hopital<br>
 *	['alias'] => (string) Alias du nom de l'hopital<br>
 *	['adresse']['rue'] => (string) Adresse de l'hopital (rue)<br>
 *	['adresse']['cp'] => (string) Adresse de l'hopital (code postal)<br>
 *	['adresse']['ville'] => (string) Adresse de l'hopital (ville)<br>
 *	['nb'] => (int) Nombre de services associés à l'hopital<br>
 *	['services'][id du service]['id'] => (int) Identifiant des services associés à l'hopital
 *
 */
function getHospitalInfo($id)
{
    /*
    	Initialisation des variables
    */
    global $db;
    // Permet l'accès à la BDD
    $erreur = array();
    $service = array();
    /*
    	On vérifie l'existance du service
    */
    $erreur = checkHopital($id, $erreur);
    if (count($erreur) == 0) {
        // Récupérations des données de l'hopital
        $sql = 'SELECT h.id id, h.nom hopitalNom, h.alias hopitalAlias, h.rue hopitalRue, h.cp hopitalCP, h.ville hopitalVille, (SELECT count(*) FROM service WHERE hopital = h.id LIMIT 1) nb
					  FROM hopital h
					  WHERE h.id = ?
					  LIMIT 1';
        $res = $db->prepare($sql);
        $res->execute(array($id));
        $hopital = array();
        // On construit l'array contenant les données de l'hopital
        if ($res_f = $res->fetch()) {
            $hopital['id'] = $res_f['id'];
            $hopital['nom'] = $res_f['hopitalNom'];
            $hopital['alias'] = $res_f['hopitalAlias'];
            $hopital['nb'] = $res_f['nb'];
            $hopital['adresse']['rue'] = $res_f['hopitalRue'];
            $hopital['adresse']['cp'] = $res_f['hopitalCP'];
            $hopital['adresse']['ville'] = $res_f['hopitalVille'];
        }
        // Liste des services enregistrés dans l'hopital
        $sql = 'SELECT s.id id
						FROM service s
						INNER JOIN specialite sp
						ON s.specialite = sp.id
						WHERE s.hopital = ?
						ORDER BY sp.nom  ASC, s.nom ASC';
        $res = $db->prepare($sql);
        $res->execute(array($id));
        while ($res_f = $res->fetch()) {
            $hopital['services'][$res_f['id']]['id'] = $res_f['id'];
        }
        return $hopital;
    } else {
        return false;
    }
}
Exemplo n.º 4
0
             $whereSqlFilter .= ' AND ';
         }
         if ($whereSqlContent == '') {
             $whereSqlContent .= 'WHERE ';
         } else {
             $whereSqlContent .= ' AND ';
         }
         $whereSqlFilter .= ' (SELECT count(*) FROM servicecertificat WHERE idService = e.service AND idCertificat =:certificat) != 0 ';
         $whereSqlContent .= ' (SELECT count(*) FROM servicecertificat WHERE idService = e.service AND idCertificat = :certificat) != 0 ';
     }
 }
 /*
 	Hopitaux
 */
 if (isset($_GET['FILTER']['hopital']) && is_numeric($_GET['FILTER']['hopital'])) {
     $erreur = checkHopital($_GET['FILTER']['hopital'], $erreur);
     if (count($erreur) == 0) {
         $preparedValue['hopital'] = $_GET['FILTER']['hopital'];
         if ($whereSqlFilter == '') {
             $whereSqlFilter .= 'WHERE ';
         } else {
             $whereSqlFilter .= ' AND ';
         }
         if ($whereSqlContent == '') {
             $whereSqlContent .= 'WHERE ';
         } else {
             $whereSqlContent .= ' AND ';
         }
         $whereSqlFilter .= ' s.hopital = :hopital ';
         $whereSqlContent .= ' s.hopital = :hopital ';
     }