示例#1
0
文件: fnStage.php 项目: Galinijay/PAS
/**
 * getServiceInfo - Retourne les informations relatives au service
 *
 * @category stageFunction
 * @param int $id Identifiant du service
 * @return array Array contenant les informations relatives au service
 *
 * @Author Ali Bellamine
 *
 * Contenu de l'array retourné :<br>
 *	['id'] => (int) Identifiant du service<br>
 *	['nom'] => (string) Nom du service<br>
 *	['hopital']['alias'] => (string) Alias du nom de l'hopital dont dépend le service<br>
 *	['hopital']['nom'] => (string) Nom de l'hopital dont dépend le service<br>
 *	['specialite']['id'] (optionnel) => (int) Identifiant de la spécialité dont dépend le service<br>
 *	['specialite']['nom'] => (string) Nom de la spécialité dont dépend le service<br>
 *	['chef']['id'] (optionnel) => (int) Identifiant du chef du service<br>
 *	['chef']['nom'] => (string)  Nom du chef du service<br>
 *	['chef']['prenom'] => (string) Prénom du chef du service<br>
 *	['certificat'][identifiant du certificat]['id'] => (int) Identifiant d'un certificat associé au service<br>
 *	['certificat'][identifiant du certificat]['idAffectation'] => (int) Identifiant du lien dans la base de donnée entre le service et le certificat<br>
 *	['certificat'][identifiant du certificat]['nom'] => (string) Nom d'un certificat associé au service<br>
 *	['FullName'] => (string) Nom complet du service
 *
 */
function getServiceInfo($id)
{
    /*
    	Initialisation des variables
    */
    global $db;
    // Permet l'accès à la BDD
    $erreur = array();
    $service = array();
    /*
    	On vérifie l'existance du service
    */
    $erreur = checkService($id, $erreur);
    if (count($erreur) == 0) {
        // Récupérations des données du service
        $sql = 'SELECT s.id serviceId, s.nom serviceNom, h.nom hopitalNom, h.id hopitalId, h.alias hopitalAlias, sp.id specialiteId, sp.nom specialiteNom, u.nom chefNom, u.prenom chefPrenom, u.id chefId
					  FROM service s
					  INNER JOIN hopital h on h.id = s.hopital
					  LEFT JOIN specialite sp on sp.id = s.specialite
					  LEFT JOIN user u ON u.id = s.chef
					  WHERE s.id = ?
					  LIMIT 1';
        $res = $db->prepare($sql);
        $res->execute(array($id));
        // On construit l'array contenant les données du service
        if ($res_f = $res->fetch()) {
            $service['id'] = $res_f['serviceId'];
            $service['nom'] = $res_f['serviceNom'];
            $service['hopital']['id'] = $res_f['hopitalId'];
            $service['hopital']['nom'] = $res_f['hopitalNom'];
            $service['hopital']['alias'] = $res_f['hopitalAlias'];
            if (isset($res_f['specialiteNom'])) {
                $service['specialite']['id'] = $res_f['specialiteId'];
                $service['specialite']['nom'] = $res_f['specialiteNom'];
            } else {
                $service['specialite']['nom'] = '';
            }
            if (isset($res_f['chefNom'])) {
                $service['chef']['id'] = $res_f['chefId'];
                $service['chef']['nom'] = $res_f['chefNom'];
                $service['chef']['prenom'] = $res_f['chefPrenom'];
            } else {
                $service['hopital']['chef']['nom'] = '';
                $service['hopital']['chef']['prenom'] = '';
            }
            /*
            	On récupère la liste des certificats du service
            */
            $service['certificat'] = array();
            $sql = 'SELECT c.id certificatId, c.nom certificatNom, s.id idAffectation
							FROM servicecertificat s
							INNER JOIN certificat c ON c.id = s.idCertificat
							WHERE s.idService = ?';
            $res2 = $db->prepare($sql);
            $res2->execute(array($res_f['serviceId']));
            while ($res2_f = $res2->fetch()) {
                $service['certificat'][$res2_f['certificatId']]['id'] = $res2_f['certificatId'];
                $service['certificat'][$res2_f['certificatId']]['idAffectation'] = $res2_f['idAffectation'];
                $service['certificat'][$res2_f['certificatId']]['nom'] = $res2_f['certificatNom'];
            }
            // String pour la génération du FullName
            $fullNameCertificat = '';
            if (isset($service['certificat']) && count($service['certificat']) != 0) {
                foreach ($service['certificat'] as $certificat) {
                    $fullNameCertificat .= '[' . $certificat['nom'] . ']';
                }
            }
            $firstTerm = TRUE;
            $service['FullName'] = '';
            /* On inclut les données une à une dans le champs texte */
            if (isset($fullNameCertificat) && $fullNameCertificat != '') {
                if (!$firstTerm) {
                    $service['FullName'] .= ' - ';
                } else {
                    $firstTerm = FALSE;
                }
                $service['FullName'] .= $fullNameCertificat;
            }
            if (isset($service['specialite']['nom']) && $service['specialite']['nom'] != '') {
                if (!$firstTerm) {
                    $service['FullName'] .= ' - ';
                } else {
                    $firstTerm = FALSE;
                }
                $service['FullName'] .= $service['specialite']['nom'];
            }
            if (isset($service['hopital']['alias']) && $service['hopital']['alias'] != '') {
                if (!$firstTerm) {
                    $service['FullName'] .= ' - ';
                } else {
                    $firstTerm = FALSE;
                }
                $service['FullName'] .= $service['hopital']['alias'];
            }
            if (isset($service['nom']) && $service['nom'] != '') {
                if (!$firstTerm) {
                    $service['FullName'] .= ' - ';
                } else {
                    $firstTerm = FALSE;
                }
                $service['FullName'] .= $service['nom'];
            }
            $service['FullName'] .= ' - ' . LANG_ADMIN_SERVICES_NOM_SERVICEOF . ' ' . $service['chef']['nom'];
        }
        return $service;
    } else {
        return false;
    }
}
示例#2
0
文件: service.php 项目: Galinijay/PAS
$allowedAction = array('add', 'view', 'edit', 'delete');
if (isset($_POST['action']) && in_array($_POST['action'], $allowedAction)) {
    $action = $_GET['action'];
} else {
    if (isset($_GET['action']) && in_array($_GET['action'], $allowedAction)) {
        $action = $_GET['action'];
    } else {
        header('Location: ' . $pageServices);
    }
}
/**
		Récupération des informations sur le service
	**/
// Récupération de l'id du service
if (isset($_GET['id']) && $action != 'add') {
    if (count(checkService($_GET['id'], array())) == 0) {
        $serviceInfo = getServiceInfo($_GET['id']);
    } else {
        header('Location: ' . $pageServices);
    }
}
/***
		II. 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
    */
    // Ce qui est propre aux edit et delete
    if (($action == 'edit' || $action == 'delete') && isset($serviceInfo)) {
        $sqlData['id'] = $serviceInfo['id'];
示例#3
0
/**
 * checkAffectation - Vérifie la validité des données d'affectation d'un étudiant et leurs concordance avant de les ajouter dans la base de donnée
 *
 * @category : checkFunction
 * @param int $etudiant Identifiant de l'étudiant
 * @param int $service Identifiant du service
 * @param timestamp $dateDebut Date du début de l'affectation
 * @param timestamp $dateFin Date de fin de l'affectation
 * @param array $erreur Array contenant la liste des erreurs rencontrées avant execution de la fonction
 * @return array Array contenant la liste des erreurs rencontrées après execution de la fonction
 *
 * @Author Ali Bellamine
 */
function checkAffectationInsertData($etudiant, $service, $dateDebut, $dateFin, $erreur)
{
    $serviceCheck = FALSE;
    // On récupère les données sur l'étudiant si il existe
    if (count(checkUser($etudiant, array())) == 0) {
        $userData = getUserData($etudiant);
    } else {
        $erreur = checkUser($etudiant, $erreur);
    }
    // On récupère les infos sur le service
    if (count(checkService($service, array())) == 0) {
        $serviceCheck = TRUE;
    } else {
        $erreur = checkService($service, $erreur);
    }
    // Si le service et l'étudiant sont disponibles, on vérifie que l'étudiant n'est pas déjà inscrit dans le service
    if (isset($userData) && $serviceCheck) {
        if (isset($userData['service'][$service])) {
            $erreur[10] = TRUE;
        }
    }
    // On vérifie les dates
    if (isset($dateDebut) && (preg_match('#^([0-9]{2})([/-])([0-9]{2})\\2([0-9]{4})$#', $dateDebut, $m) == 1 && checkdate($m[3], $m[1], $m[4]))) {
        $dateDebutTimestamp = DatetimeToTimestamp($m[4] . '-' . $m[3] . '-' . $m[1]);
    } else {
        $erreur[11] = TRUE;
    }
    if (isset($dateFin) && (preg_match('#^([0-9]{2})([/-])([0-9]{2})\\2([0-9]{4})$#', $dateFin, $m) == 1 && checkdate($m[3], $m[1], $m[4]))) {
        $dateFinTimestamp = DatetimeToTimestamp($m[4] . '-' . $m[3] . '-' . $m[1]);
    } else {
        $erreur[12] = TRUE;
    }
    if (isset($dateDebutTimestamp) && isset($dateFinTimestamp) && $dateDebutTimestamp > $dateFinTimestamp) {
        $erreur[13] = TRUE;
    }
    return $erreur;
}
示例#4
0
 if ($action2 == 'add') {
     $sqlData['userId'] = $userData['id'];
     // Id de l'utilisateur
 } else {
     if ($action2 == 'edit' || $action2 == 'delete') {
         $sqlData['id'] = $affectationData['id'];
         // Id de l'affectation
     }
 }
 if ($action2 == 'edit' || $action2 == 'add') {
     foreach ($_POST as $key => $value) {
         if ($key == 'service') {
             if ($value != '' && count(checkService($value, array())) == 0) {
                 $sqlData[$key] = $value;
             } else {
                 $erreur = checkService($value, $erreur);
             }
         } else {
             if ($key == 'dateDebut' || $key == 'dateFin') {
                 // On convertit les dates si elle sont valides
                 $temp = explode('/', $value);
                 if (isset($value) && count($temp) > 3 && checkdate($temp[1], $temp[0], $temp[2])) {
                     $convertedDate = DatetimeToTimestamp(FrenchdateToDatetime($value));
                     // Date au format timestamp
                     $validDate = TRUE;
                     // Si dateDebut : on refuse le cas où la date est supérieure à la marge sup
                     if ($key == 'dateDebut' && (isset($_POST['dateFin']) && $convertedDate >= DatetimeToTimestamp(FrenchdateToDatetime($_POST['dateFin'])) || $action2 == 'edit' && $convertedDate >= $affectationData['service']['date']['fin'])) {
                         $erreur[13] = TRUE;
                         $validDate = FALSE;
                     } else {
                         if ($key == 'dateFin' && (isset($_POST['dateDebut']) && $convertedDate <= DatetimeToTimestamp(FrenchdateToDatetime($_POST['dateDebut'])) || $action2 == 'edit' && $convertedDate <= $affectationData['service']['date']['debut'])) {
示例#5
0
文件: fnAdmin.php 项目: alibell/PAS
/**
 * eval_ccpc_checkFilterExistence - Récupère les filtres appliqués à un service sur une période donnée
 *
 * @category : eval_ccpc_functions
 * @param int $service Identifiant du service
 * @param string $debutStage Borne inférieur de l'intervalle temporel considéré, sous forme de timestamp
 * @param string $finStage Borne supérieure de l'intervalle temporel considéré, sous forme de timestamp
 * @param int|boolean $promotion Promotion pour laquelle on s'intéresse aux filtres détectés, FALSE si pas de promotion particulière
 * @return array Array contenant la liste des filtres s'appliquant au service
 * 
 * @Author Ali Bellamine
 *
 * Contenu de l'array retourné :<br>
 *	[Identifiant du filtre][] => (array) Informations relatives au filtre, voir {@link eval_ccpc_getFilterDetails()}<br>
 *
 */
function eval_ccpc_checkFilterExistence($service, $debutStage, $finStage, $promotion = FALSE)
{
    if (isset($service) && count(checkService($service, array())) == 0 && isset($debutStage) && isset($finStage)) {
        global $db;
        $filtres = array();
        // Contient la liste des filtres
        $sqlData = array('service' => $service, 'debutStage' => TimestampToDatetime($debutStage), 'finStage' => TimestampToDatetime($finStage));
        // Array utilisé dans la requête préparée
        if (isset($promotion) && is_numeric($promotion) && count(checkPromotion($promotion, array())) == 0) {
            $sqlData['promotion'] = $promotion;
            $sql = 'SELECT id_filtre id FROM eval_ccpc_filtres_detected WHERE id_service = :service AND debutStage = :debutStage AND finStage = :finStage AND (promotion = :promotion OR promotion IS NULL)';
        } else {
            $sql = 'SELECT id_filtre filtre FROM eval_ccpc_filtres_detected WHERE id_service = :service AND debutStage = :debutStage AND finStage = :finStage';
        }
        echo $sql;
        $res = $db->prepare($sql);
        $res->execute($sqlData);
        while ($res_f = $res->fetch()) {
            $filtres[$res_f['id']] = eval_ccpc_getFilterDetails($res_f['id']);
        }
        print_r($filtres);
        exit;
        return $filtres;
    } else {
        return FALSE;
    }
}
示例#6
0
文件: profil.php 项目: Galinijay/PAS
                     if (isset($tempMailArray) && is_array($tempMailArray)) {
                         $sqlData[$key] = serialize($tempMailArray);
                     } else {
                         $erreur[19] = true;
                     }
                 } else {
                     if ($key == 'rang' && is_numeric($value) && ($action == 'edit' && $value != $userInfo['rang'] || $action == 'add') && $value <= $_SESSION['rang']) {
                         $sqlData[$key] = $value;
                     } else {
                         if ($key == 'promotion' && is_numeric($value) && $action == 'edit' && $value != $userInfo[$key] && count(checkPromotion($value, array())) == 0) {
                             $sqlData[$key] = $value;
                         } else {
                             if ($key == 'affectation' && $action == 'edit') {
                                 $sqlAffectationData = array();
                                 foreach ($_POST['affectation'] as $affectationId => $affectationValue) {
                                     if (is_numeric($affectationId) && $affectationValue != $userInfo['service'][$affectationId]['id'] && count(checkService($affectationValue, array())) == 0) {
                                         $sqlAffectationData[$affectationId] = array('id' => $affectationId, 'service' => $affectationValue);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
 			On lance les enregistrement dans la BDD
 		**/
 $sqlInsert = FALSE;
示例#7
0
/**
 * generateAllCSV - Génère un fichier CSV à partir d'une liste de services (plusieurs services en même temps)
 *
 * @category : eval_ccpc_functions
 * @param array $list Array contenant la liste des identifiants des services
 * @param string $dateMin Borne inférieure de l'intervalle temporel sur lequel on extrait les données
 * @param string $dateMax Borne supérieure de l'intervalle temporel sur lequel on extrait les données
 * @param int|boolean $promotion Promotion pour laquelle on extrait les données, FALSE si on extrait indifféremment de la promotion
 * @param boolean $moderate TRUE si on affiche les messages modérés, FALSE sinon
 * @return array Array contenant les informations du fichier généré
 *
 * @Author Ali Bellamine
 *
 * Contenu de l'array retourné :<br>
 * 	['csvPath'] => (string) Chemin local vers le fichier généré<br>
 * 	['csvURI'] => (string) URI pointant vers le fichier généré
 *
 */
function generateAllCSV($list, $dateMin, $dateMax, $promotion = FALSE, $moderate = FALSE)
{
    // Array contenant les résultats
    $output = array();
    // On vérifie l'existence des données
    if (isset($list) && count($list) > 0 && isset($dateMin) && isset($dateMax) && $dateMin <= $dateMax) {
        // Calcul du md5
        $hash = md5(json_encode($list));
        $csvPath = PLUGIN_PATH . 'cache/' . $hash . '.csv';
        $csvPathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.csv';
        if ($csv = fopen($csvPath, 'w')) {
            $firstLoop = TRUE;
            foreach ($list as $service) {
                // Si le service existe
                if (count(checkService($service, array())) == 0) {
                    // On affiche la liste des catégorie uniquement au premier tour de boucle
                    if ($firstLoop) {
                        $serviceCSV = generateCSV(getEvaluationCCPCFullData($service, $promotion, $dateMin, $dateMax, $moderate), TRUE);
                    } else {
                        $serviceCSV = generateCSV(getEvaluationCCPCFullData($service, $promotion, $dateMin, $dateMax, $moderate), FALSE);
                    }
                    // On lit le fichier CSV généré
                    if ($tempCSV = fopen($serviceCSV['csvPath'], 'r')) {
                        $tempCSVContent = fread($tempCSV, filesize($serviceCSV['csvPath']));
                    }
                    // On copie son contenue à la fin du fichier CSV final
                    fwrite($csv, $tempCSVContent);
                    unset($tempCSVContent);
                    $firstLoop = FALSE;
                }
            }
            fclose($csv);
            $output['csvPath'] = $csvPath;
            $output['csvURI'] = $csvPathURI;
            return $output;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
示例#8
0
文件: admin.php 项目: Galinijay/PAS
            header('Location: ' . ROOT . CURRENT_FILE . '?' . http_build_query($tempGet));
        }
    }
}
// Téléchargement des fiches PDF
if (isset($_GET['dateDebut']) && isset($_GET['dateFin']) && isset($_GET['serviceId']) && ($_GET['serviceId'] == 'all' && isset($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']]) || is_numeric($_GET['serviceId']) && isset($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']][$_GET['serviceId']]) && count($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']][$_GET['serviceId']]) > 0)) {
    if (isset($_GET['download']) && isset($allowedDownloadAction[$_GET['download']])) {
        $action = $allowedDownloadAction[$_GET['download']];
        $serviceId = $_GET['serviceId'];
        if (isset($filtreData['promotion']) && count(checkPromotion($filtreData['promotion'], array())) == 0) {
            $promotion = $filtreData['promotion'];
        } else {
            $promotion = FALSE;
        }
        // Pour un service sélectionné
        if (is_numeric($serviceId) && count(checkService($serviceId, array())) == 0) {
            // On crée le fichier
            if ($action['type'] == 'CSV') {
                downloadFILE(generateCSV(getEvaluationCCPCFullData($serviceId, $promotion, $_GET['dateDebut'], $_GET['dateFin'], $action['moderation']), TRUE)['csvPath'], getServiceInfo($serviceId)['FullName'] . '.csv');
            } else {
                if ($action['type'] == 'PDF') {
                    downloadFILE(generatePDF(getEvaluationCCPCFullData($serviceId, $promotion, $_GET['dateDebut'], $_GET['dateFin'], $action['moderation']), $action['comment'], TRUE)['pdfPath'], getServiceInfo($serviceId)['FullName'] . '.pdf');
                }
            }
        } else {
            if ($serviceId == 'all') {
                // On crée l'archive
                $zip = new ZipArchive();
                $zipPath = PLUGIN_PATH . 'cache/' . $filtreData['nom'] . '.zip';
                if ($zip->open($zipPath, ZipArchive::CREATE) === true) {
                    foreach ($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']] as $serviceDetected) {
示例#9
0
/**
* Will check each dremel server with each service and return a simple array
*
* @param $dremel - An array of the $dremel servers
* @param $servicesObjectsData -An Assoc. Array of static data about each service
* @param $servicesObjectsFn - An Assoc. Array of functions to check status
* @return An array of all the dremel servers with data on each
*/
function checkAllServersAndServices($dremel, $servicesObjectsData, $servicesObjectsFn)
{
    //
    $titles = checkService("titles", $servicesObjectsData, $servicesObjectsFn);
    $retArr = array();
    foreach ($dremel as $val) {
        $data = array();
        //TODO: Set the learningSuite Object environment
        foreach ($titles as $key => $vals) {
            $temp = simpleCheckService(strtolower($vals['title']), $servicesObjectsData, $servicesObjectsFn);
            $data[] = simpleCheckService(strtolower($vals['title']), $servicesObjectsData, $servicesObjectsFn);
            //$data[] =  simpleCheckService(strtolower($vals['title']),$servicesObjectsData,$servicesObjectsFn);
        }
        $retArr[$val] = $data;
    }
    return $retArr;
}