<th><?php echo LANG_ADMIN_AFFECTATIONS_DATE_DEBUT; ?> </th> <th><?php echo LANG_ADMIN_AFFECTATIONS_DATE_FIN; ?> </th> <th></th> </tr> <?php // Récupération de la liste des étudiants affectés au service $sql = 'SELECT userId idEtudiant, ae.id affectationId FROM affectationexterne ae INNER JOIN user u ON u.id = ae.userId WHERE ae.service = :service AND ae.dateDebut <= :now AND ae.dateFin >= :now ORDER BY u.promotion ASC, nom ASC, prenom ASC'; $res = $db->prepare($sql); $res->execute(array('service' => $serviceInfo['id'], 'now' => TimestampToDatetime(time()))); if ($res_f = $res->fetch()) { $userData = getUserData($res_f['idEtudiant']); ?> <tr style = "text-align: center;"> <td><?php echo $userData['prenom']; ?> </td> <td><?php echo $userData['nom']; ?> </td> <td><?php echo $userData['promotion']['nom']; ?>
/** * getCertificatInfo - Retourne les informations relatives au certificat * * @category stageFunction * @param int $id Identifiant du certificat * @return array Array contenant les informations relatives au certificat * * @Author Ali Bellamine * * Contenu de l'array retourné :<br> * ['id'] => (int) Identifiant du certificat<br> * ['nom'] => (string) Nom du certificat<br> * ['promotion']['id'] => (int) Id de la promotion associée au certificat<br> * ['promotion']['nom'] => (string) Nom de la promotion associée au certificat<br> * ['services'][id du service]['id'] => (int) Id des services associés au certificat<br> * ['etudiants'][id de l'étudiant]['id'] => (int) Id des étudiants associés au certificat<br> * ['nb']['services'] => (int) Nombre de services associés au certificat<br> * ['nb']['etudiants'] => (int) Nombre d'étudiants associés au certificat * */ function getCertificatInfo($id) { /* Initialisation des variables */ global $db; // Permet l'accès à la BDD $erreur = array(); $specialite = array(); /* On vérifie l'existance du certificat */ $erreur = checkCertificat($id, $erreur); if (count($erreur) == 0) { // Récupérations des données $sql = 'SELECT c.id id, c.nom nom, p.nom promo, p.id promotionId, (SELECT count(*) FROM servicecertificat WHERE idCertificat = c.id LIMIT 1) nbServices FROM certificat c INNER JOIN promotion p ON p.id = c.promotion WHERE c.id = ? LIMIT 1'; $res = $db->prepare($sql); $res->execute(array($id)); $certificat = array(); // On construit l'array contenant les données if ($res_f = $res->fetch()) { $certificat['id'] = $res_f['id']; $certificat['nom'] = $res_f['nom']; $certificat['promotion']['nom'] = $res_f['promo']; $certificat['promotion']['id'] = $res_f['promotionId']; $certificat['nb']['services'] = $res_f['nbServices']; } // Liste des services enregistrés dans le certificat $sql = 'SELECT s.id id FROM servicecertificat sc INNER JOIN service s ON s.id = sc.idService INNER JOIN hopital h ON h.id = s.hopital WHERE sc.idCertificat = ? ORDER BY h.nom ASC, s.nom ASC'; $res = $db->prepare($sql); $res->execute(array($id)); while ($res_f = $res->fetch()) { $certificat['services'][$res_f['id']]['id'] = $res_f['id']; } // Liste des étudiants enregistrés dans le certificat $certificat['etudiants'] = array(); $sql = 'SELECT u.id id FROM servicecertificat sc INNER JOIN affectationexterne ae ON ae.service = sc.idService INNER JOIN user u ON u.id = ae.userId WHERE sc.idCertificat = :certificat AND ae.dateDebut <= :now AND ae.dateFin >= :now ORDER BY u.nom ASC, u.prenom ASC'; $res = $db->prepare($sql); $res->execute(array('certificat' => $id, 'now' => TimestampToDatetime(time()))); while ($res_f = $res->fetch()) { $certificat['etudiants'][$res_f['id']]['id'] = $res_f['id']; } $certificat['nb']['etudiants'] = count($certificat['etudiants']); return $certificat; } else { return false; } }
/** * eval_ccpc_setSettings - Enregistre les réglages de l'évaluation sélectionnée * * @category : eval_ccpc_functions * @param array $settings array Array contenant les données d'évaluation à enregistrer, correspond à la même structure que l'array retourné par eval_ccpc_setSettings * @return boolean TRUE si l'opération s'est déroulé avec succès * * @Author Ali Bellamine * */ function eval_ccpc_setSettings($settings) { initTable(); // S'assure de l'existence de la table dans la BDD global $db; if (isset($settings['id']) && count(checkEvaluation($settings['id'], array())) == 0) { // On vérifie les données à enregistrer if (isset($settings['dateDebut']) && isset($settings['dateFin']) && is_numeric($settings['dateFin']) && is_numeric($settings['dateDebut']) && $settings['dateDebut'] <= $settings['dateFin']) { // On prépare l'array $settings['dateDebut'] = TimestampToDatetime($settings['dateDebut']); $settings['dateFin'] = TimestampToDatetime($settings['dateFin']); // On vérifie si l'évaluation existe déjà dans la base settings $sql = 'SELECT count(*) FROM eval_ccpc_settings WHERE id_evaluation = ? LIMIT 1'; $res = $db->prepare($sql); $res->execute(array($settings['id'])); $res_f = $res->fetch(); if ($res_f[0] == 0) { $sql = 'INSERT INTO eval_ccpc_settings (id_evaluation, dateDebut, dateFin) VALUES (:id, :dateDebut, :dateFin)'; } else { $sql = 'UPDATE eval_ccpc_settings SET dateDebut = :dateDebut, dateFin = :dateFin WHERE id_evaluation = :id'; } $res2 = $db->prepare($sql); if ($res2->execute($settings)) { return TRUE; } else { return FALSE; } } else { return FALSE; } } else { return FALSE; } }
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'])) { $erreur[13] = TRUE; $validDate = FALSE; } } if ($validDate) { $sqlData[$key] = TimestampToDatetime($convertedDate); } } } } } } /* On enregistre les données dans la BDD */ $sqlInsert = FALSE; // Enregistre la bonne réussite des requêtes /** Pour les ajouts **/ if (isset($sqlData)) {
/** * validateEvaluation - Valide l'évaluation en cours, l'enregistre comme remplis et redirige l'utilisateur vers la liste des évaluations * * @category : evaluationFunction * @return boolean FALSE si echec lors de l'execution de la fonction * * @Author Ali Bellamine * * /!\ Cette fonction ne fonctionne que depuis une page de module d'évaluation /!\ */ function validateEvaluation() { global $evaluationData; // informations concernant l'évaluation qui a été remplie global $db; /* On enregistre l'évaluation */ if (isset($evaluationData) && isset($_SESSION['id'])) { /* Détermination de la date : on enregistre la date du premier jour de la semaine et non pas la date actuelle, afin de garantir l'anonymat */ $jour_actuel = date('d'); // On récupère le numéro du jour $numero_jour = date('w'); // On récupère le numéro du jour de la semaine (0 = dimanche) $date_lundi = $jour_actuel - $numero_jour + 1; // On fait le calcul $timestamp = mktime(0, 0, 0, date('m'), $date_lundi, date('Y')); /* Array contenant les données à envoyer dans la BDD */ $queryArray = array('registerId' => $evaluationData['register']['id'], 'date' => TimestampToDatetime($timestamp)); $sql = 'UPDATE evaluationregister SET date = :date, evaluationStatut = 1 WHERE id = :registerId'; $res = $db->prepare($sql); if ($res->execute($queryArray)) { header('Location: ' . ROOT . 'content/evaluation/index.php?msg=LANG_SUCCESS_EVALUATION_FORM'); } else { return false; } } else { return false; } }
} $orderSQL = ' ORDER BY u.nom, u.prenom'; } else { if ($typeUser == 'enseignant') { $sql = 'SELECT u.nom nom, u.prenom prenom, u.id id FROM user u WHERE u.rang > 1 '; /* On crée le $whereSQL */ $whereSQL = ''; if (isset($_POST['filtres'])) { if (isset($_POST['filtres']['promotion'])) { foreach ($_POST['filtres']['promotion'] as $promotionId => $promotionValue) { if (count(checkPromotion($promotionId, array())) == 0) { $whereSQL .= ' AND (SELECT count(*) FROM user INNER JOIN affectationexterne ON user.id = affectationexterne.userId INNER JOIN service ON service.id = affectationexterne.service WHERE user.promotion = ' . $promotionId . ' AND service.chef = u.id AND affectationexterne.dateDebut <= "' . TimestampToDatetime(time()) . '" AND affectationexterne.dateFin >= "' . TimestampToDatetime(time()) . '" LIMIT 1) = 1 '; } } } if (isset($_POST['filtres']['certificat']) && count($_POST['filtres']['certificat']) > 0) { $whereSQL .= ' AND ('; $addOR = FALSE; foreach ($_POST['filtres']['certificat'] as $certificatId => $certificatValue) { if (count(checkCertificat($certificatId, array())) == 0) { if ($addOR) { $whereSQL .= ' OR '; } else { $addOR = TRUE; } $whereSQL .= ' (SELECT count(*) FROM service INNER JOIN servicecertificat ON servicecertificat.idService = service.id WHERE service.chef = u.id AND servicecertificat.idCertificat = ' . $certificatId . ' LIMIT 1) = 1'; }
/** * eval_ccpc_applyFilter - Test l'ensemble des requêtes pour un service, et enregistre les filtres qui s'y appliquent dans la base de donnée * * @category : eval_ccpc_functions * @param int $id Identifiant du service * @param int $promotion Identifiant de la promotion pour laquelle les données seront restreinte si le filtre presente une restriction de promotion * @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 * @return boolean TRUE si l'opération s'est déroulée avec succès, FALSE sinon * * @Author Ali Bellamine * */ function eval_ccpc_applyFilter($id, $promotion, $dateDebut, $dateFin) { /** Prépare les variables **/ // Base de donnée global $db; // Objet XML du formulaire d'évaluation if (is_file(PLUGIN_PATH . 'formulaire.xml')) { $form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml'); } // Liste des filtres $filtres = eval_ccpc_getFilterList(); // Données d'évaluation // Pour la promotion $dataPromo = getEvaluationCCPCFullData($id, $promotion, $dateDebut, $dateFin, FALSE); // Sans la promotion (toutes les promotions) $dataAllPromo = getEvaluationCCPCFullData($id, FALSE, $dateDebut, $dateFin, FALSE); if (!isset($form)) { return FALSE; } /** Effectue les test **/ foreach ($filtres as $filtre) { $res = FALSE; if ($filtre['promotion'] == 0) { $res = eval_ccpc_exploreQuery($filtre['query'], $form, $dataAllPromo); } else { $res = eval_ccpc_exploreQuery($filtre['query'], $form, $dataPromo); } // Si le filtre est vérifié if ($res == 'success') { /* On enregistre le succès dans la BDD si il n'est pas déjà présent */ $sqlData = array('service' => $id, 'filtre' => $filtre['id'], 'dateDebut' => TimestampToDatetime($dateDebut), 'dateFin' => TimestampToDatetime($dateFin)); // On vérifie si il est déjà présent if ($filtre['promotion'] == 0) { $sql = 'SELECT count(*) FROM eval_ccpc_filtres_detected WHERE id_service = :service AND id_filtre = :filtre AND debutStage = :dateDebut AND finStage = :dateFin LIMIT 1'; } else { $sql = 'SELECT count(*) FROM eval_ccpc_filtres_detected WHERE id_service = :service AND id_filtre = :filtre AND debutStage = :dateDebut AND finStage = :dateFin AND promotion = :promotion LIMIT 1'; $sqlData['promotion'] = $promotion; } $res = $db->prepare($sql); $res->execute($sqlData); if ($res_f = $res->fetch()) { if ($res_f[0] == 0) { // On insert dans la base de donnée $sqlData['promotion'] = $promotion; // Dans tous les cas on enregistre la promotion $sql = 'INSERT INTO eval_ccpc_filtres_detected (id_service, id_filtre, debutStage, finStage, promotion) VALUES (:service, :filtre, :dateDebut, :dateFin, :promotion)'; $res = $db->prepare($sql); $res->execute($sqlData); } } } else { // On le supprime de la BDD si il est présent $sqlData = array('service' => $id, 'filtre' => $filtre['id'], 'dateDebut' => TimestampToDatetime($dateDebut), 'dateFin' => TimestampToDatetime($dateFin)); if ($filtre['promotion'] == 0) { $sql = 'DELETE FROM eval_ccpc_filtres_detected WHERE id_service = :service AND id_filtre = :filtre AND debutStage = :dateDebut AND finStage = :dateFin LIMIT 1'; } else { $sql = 'DELETE FROM eval_ccpc_filtres_detected WHERE id_service = :service AND id_filtre = :filtre AND debutStage = :dateDebut AND finStage = :dateFin AND promotion = :promotion LIMIT 1'; $sqlData['promotion'] = $promotion; } $res = $db->prepare($sql); $res->execute($sqlData); } } }
$action = FALSE; if (isset($_POST['action']) && in_array($_POST['action'], $allowedAction)) { $action = $_POST['action']; } // Action : registerBug : enregistre le bug dans le BDD if ($action == 'registerBug') { // On met les données dans un array $bugArray = array(); $bugArray['bugServerData'] = serialize($_SERVER); $bugArray['bugSessionVariable'] = serialize($_SESSION); if (isset($_POST['description']) && $_POST['description'] != '') { $bugArray['bugDescription'] = htmLawed($_POST['description']); } else { $bugArray['bugDescription'] = ''; } $bugArray['bugDate'] = TimestampToDatetime(time()); /* On enregistre dans la BDD */ $sql = 'INSERT INTO bug ('; $firstLoop = TRUE; foreach ($bugArray as $key => $value) { if ($firstLoop) { $firstLoop = FALSE; } else { $sql .= ', '; } $sql .= $key; } $sql .= ') VALUES ('; $firstLoop = TRUE;
/** * generatePDF - Génère un fichier PDF à partir des données d'évaluation d'un service * * @category : eval_ccpc_functions * @param array $data Données d'évaluation récupérées à partir de la fonction {@link getEvaluationCCPCFullData()} * @param boolean $comment TRUE si on incut les commentaire, FALSE si on ne les inclut pas * @param boolean $commentMSG TRUE si on incut un message concernant la CSG, FALSE si on ne l'inclut pas * @return array Array contenant les informations du fichier généré * * @Author Ali Bellamine * * Contenu de l'array retourné :<br> * ['pdfPath'] => (string) Chemin local vers le fichier généré<br> * ['pdfURI'] => (string) URI pointant vers le fichier généré * */ function generatePDF($data, $comment = FALSE, $commentMSG = FALSE) { // Accès à la BDD global $db; // Array contenant les résultats $output = array(); // On vérifie l'existence des données if (isset($data) && count($data) > 0) { /* Mise en cache */ // Calcul du md5 $hashdata = $data; $hashdata['optionsPDF'] = array('comment' => $comment, 'commentMSG' => $commentMSG); $hash = md5(json_encode($hashdata)); $pdfPath = PLUGIN_PATH . 'cache/' . $hash . '.pdf'; $pdfPathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.pdf'; if (is_file($pdfPath)) { $output['pdfPath'] = $pdfPath; $output['pdfURI'] = $pdfPathURI; return $output; } else { // On charge la librairie require_once PLUGIN_PATH . 'core/fpdf17/fpdf.php'; // On charge le fichier XML if (is_file(PLUGIN_PATH . 'formulaire.xml')) { $form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml'); } // Promotion if (count($data['service']['promotion']) > 1) { $promotion = false; } else { foreach ($data['service']['promotion'] as $promotionData) { $promotion = $promotionData['id']; } } try { ob_end_clean(); } catch (Exception $e) { } // On crée le PDF $A4Height = 842; $A4Width = 595; $titleSize = 15; $textSize = 11; $pdf = new FPDF('L', 'pt', 'A4'); $pdf->SetTopMargin(10); $pdf->SetLeftMargin(15); $pdf->SetAutoPageBreak(TRUE, 10); /** Page contenant le résumé des données d'évaluation **/ $pdf->AddPage(); $pdf->SetFont('Arial', 'B', $titleSize); // On affiche le titre $pdf->SetFillColor(70, 70, 242); $pdf->SetTextColor(255, 255, 255); $pdf->SetX(floor(0.1 * $A4Height)); $pdf->Cell(floor(0.8 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_TITLE), 'LRTB', 0, 'C', TRUE); // Première ligne $pdf->Ln(2 * $titleSize); $pdf->SetFont('Arial', '', $textSize); // On affiche les informations concernant le service // Récupération des données $textToDisplay = LANG_FORM_CCPC_FILTER_SERVICE_TITLE . ' : ' . $data['service']['FullName'] . PHP_EOL . LANG_FORM_CCPC_PDF_STAGEPERIODE . ' : ' . date('d/m/Y', $data['service']['date']['min']) . ' - ' . date('d/m/Y', $data['service']['date']['max']); // Nombre d'étudiants par promotion $nbEtudiantsService = array(); $sql = 'SELECT p.nom promotion, COUNT( ae.userId ) nombre FROM `affectationexterne` ae INNER JOIN user u ON u.id = ae.userId INNER JOIN promotion p ON p.id = u.promotion WHERE `dateDebut` >= "' . TimestampToDatetime($data['service']['date']['min']) . '" AND `dateFin` <= "' . TimestampToDatetime($data['service']['date']['max']) . '" AND service = ' . $data['service']['id'] . ' GROUP BY u.promotion'; $res = $db->query($sql); while ($res_f = $res->fetch()) { $nbEtudiantsService[$res_f['promotion']] = $res_f['nombre']; } $firstLoop = true; if (count($nbEtudiantsService) > 0) { $textToDisplay .= PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTPROMOTION . ' : '; foreach ($nbEtudiantsService as $promotionNom => $promotionNombre) { if (!$firstLoop) { $textToDisplay .= ', '; } else { $firstLoop = FALSE; } $textToDisplay .= $promotionNom . ' (' . $promotionNombre . ')'; } } $textToDisplay .= PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTNB . ' : ' . $data['service']['nbEvaluation'] . PHP_EOL . LANG_FORM_CCPC_PDF_EVALUATIONNB . ' : ' . $data['nb']; $textToDisplay = utf8_decode($textToDisplay); // Affichage $pdf->SetFillColor(231, 231, 231); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(floor(0.35 * $A4Height), $textSize + 5, $textToDisplay, 'LRTB', 'L', TRUE); // On affiche les graphiques : mainGraphPDF // Récupération des données // Liste des graphiques à afficher $input = $form->xpath('categorie/input[@mainPDFGraph="1"]'); $nbGraph = count($input); // Nombre de graphiques à intégrer // On génère $tempData, contenant les données utilisées pour génération du png foreach ($input as $select) { if ($select['type'] == 'select') { $categorie = $select->xpath('..')[0]; // Catégorie du graphique $tempData = array(); $tempData['settings'] = array('width' => 450, 'height' => 230); foreach ($select->option as $option) { if (isset($data[(string) $categorie['nom']][(string) $select['nomBDD']]['nb'][(string) $option['value']])) { $value = $data[(string) $categorie['nom']][(string) $select['nomBDD']]['nb'][(string) $option['value']]; if (is_numeric($value)) { $tempData['data'][constant((string) $option['text'])] = $value; } else { $tempData['data'][constant((string) $option['text'])] = 0; } } else { $tempData['data'][constant((string) $option['text'])] = 0; } } // On inclut l'image $pdf->Image(eval_ccpc_genGraphPie($tempData), 0.4 * $A4Height, 3 * $titleSize, floor(0.4 * $A4Height), 0, 'PNG'); break; } } // On affiche l'icone des filtres : maximum 4 $filtres = eval_ccpc_checkFilterExistence($data['service']['id'], $data['service']['date']['min'], $data['service']['date']['max'], $promotion); $numberOfIcons = 0; // Compte le nombre d'icones ajoutées $leftCornerX = 0.8 * $A4Height - 5; $leftCornerY = 3 * $titleSize - 5; if (is_array($filtres)) { foreach ($filtres as $filtre) { if (isset($filtre['icone']) && strlen($filtre['icone']) > 1 && $numberOfIcons < 4) { $pdf->Image($filtre['icone'], $leftCornerX, $leftCornerY, floor(0.1 * $A4Height), 0, 'PNG'); $numberOfIcons++; if ($numberOfIcons == 1) { $leftCornerX = 0.9 * $A4Height - 3; } else { if ($numberOfIcons == 2) { $leftCornerX = 0.8 * $A4Height - 5; $leftCornerY += 0.1 * $A4Height + 1; } else { if ($numberOfIcons == 3) { $leftCornerX = 0.9 * $A4Height - 3; } } } break; } } } if ($numberOfIcons == 0) { // On ajoute l'icone neutre si aucune icone n'est présente $pdf->Image(PLUGIN_PATH . '/css/img/neutral.png', $leftCornerX, $leftCornerY, floor(0.1 * $A4Height), 0, 'PNG'); } // Deuxième ligne $pdf->Ln(8 * $titleSize); // On affiche le radar sur 1 an de données $fullYearData = getEvaluationCCPCFullData($data['service']['id'], $promotion, $data['service']['date']['max'] - 31536000, $data['service']['date']['max'], FALSE); // Récupération des données // Titre $pdf->Cell(floor(0.4 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_STAGEPERIODE_FULLYEAR . ' (' . date('d/m/Y', $fullYearData['service']['date']['min']) . ' ' . LANG_FORM_CCPC_PDF_STAGEPERIODE_END . ' ' . date('d/m/Y', $fullYearData['service']['date']['max']) . ')'), 0, 0, 'C', FALSE); // On affiche l'image // Liste des valeurs à afficher $input = $form->xpath('categorie/input[@radarPDFGraph="1"]'); // Préparation des données $tempData = array(); $tempData['settings'] = array('height' => 380, 'width' => 680, 'max' => 10); foreach ($input as $theinput) { // Récupération du parent $categorie = $theinput->xpath('..')[0]; // Catégorie du graphique if (isset($data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'])) { $tempData['data'][constant($theinput['label'] . '_SHORT')] = $fullYearData[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'] + 5; } } // Affichage de l'image $pdf->Image(eval_ccpc_genGraphRadar($tempData), 10, $pdf->getY() + 40, floor(0.4 * $A4Height), 0, 'PNG'); // On affiche le radar sur la période du stage // On décale du 0.05*largeur $pdf->Cell(floor(0.05 * $A4Height)); // On crée un rectangle contenant les données $pdf->Rect($pdf->getX(), $pdf->getY() - 10, 0.5 * $A4Height, 0.3 * $A4Height, 'F'); // Titre $pdf->Cell(floor(0.5 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_STAGEPERIODE_START . ' ' . date('d/m/Y', $data['service']['date']['min']) . ' ' . LANG_FORM_CCPC_PDF_STAGEPERIODE_END . ' ' . date('d/m/Y', $data['service']['date']['max'])), 0, 0, 'C', FALSE); // On ajoute l'image // Liste des valeurs à afficher $input = $form->xpath('categorie/input[@radarPDFGraph="1"]'); // Préparation des données $tempData = array(); $tempData['settings'] = array('height' => 380, 'width' => 650, 'max' => 10); foreach ($input as $theinput) { // Récupération du parent $categorie = $theinput->xpath('..')[0]; // Catégorie du graphique if (isset($data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'])) { $tempData['data'][constant($theinput['label'] . '_SHORT')] = $data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'] + 5; } } // Affichage de l'image $pdf->Image(eval_ccpc_genGraphRadar($tempData), $pdf->getX() - 0.45 * $A4Height, $pdf->getY() + 40, floor(0.4 * $A4Height), 0, 'PNG'); // Affiche du logo $pdf->Image(ROOT . 'theme/img/logo.png', 10, $A4Width - 100, 0, 50, 'PNG'); // Pied de Page $pdf->SetX(0.5 * $A4Height); $pdf->SetY($A4Width - 40); $textSize = 10; $pdf->SetFont('Arial', 'I', $textSize); // Ligne de demarcation $pdf->Line(15, $pdf->getY(), $A4Height - 15, $pdf->getY()); // Accès aux résultats $pdf->SetX(0.5 * $A4Height); $pdf->Cell(0.5 * $A4Height - 15, $textSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_FOOTER_FULLRESULT . ' ' . getPageUrl('evalView', array('evaluationType' => 1, 'service' => $data['service']['id']))), 0, 1, 'R', 0); // Coordonées CSG if ($commentMSG) { $pdf->SetFont('Arial', 'B', $textSize); $pdf->SetX(15); $pdf->Cell($A4Height - 15, $textSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_FOOTER_STRUCTURENAME . ' - ' . CONTACT_STAGE_MAIL), 0, 0, 'C', 0); } /** Commentaires **/ // Ajout des commentaires, points positifs et points négatifs : 'pdfComment' if ($comment) { $pdf->addPage('P', 'A4'); // Titre $pdf->SetFont('Arial', 'B', $titleSize); $pdf->SetFillColor(70, 70, 242); $pdf->SetTextColor(255, 255, 255); $pdf->SetX(floor(0.1 * $A4Width)); $pdf->Cell(floor(0.8 * $A4Width), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_COMMENT_TITLE), 'LRTB', 1, 'C', TRUE); $pdf->SetTextColor(0, 0, 0); $pdf->SetFillColor(245, 245, 245); // Les commentaires $input = $form->xpath('categorie/input[@pdfComment="1"]'); foreach ($input as $theinput) { $categorie = $theinput->xpath('..')[0]; if ($theinput['type'] == 'text') { // Création de l'array contenant les données à afficher sous forme [timestamp fin][timestamp début][timestamp commantaire][idMessage][] => message $tempData = array(); foreach ($theinput->text as $value) { if (isset($data[(string) $categorie['nom']][(string) $value['nomBDD']])) { foreach ($data[(string) $categorie['nom']][(string) $value['nomBDD']] as $idEval => $textValue) { if (isset($data['donnees'][$idEval]['infos'])) { $tempData[$data['donnees'][$idEval]['infos']['dateFin']][$data['donnees'][$idEval]['infos']['dateDebut']][$data['donnees'][$idEval]['infos']['date']][$idEval][] = $textValue; } } } } $textArea = ''; $firstLoop = TRUE; // On affiche les commentaires krsort($tempData); foreach ($tempData as $dateFin => $tempvalue) { krsort($tempvalue); foreach ($tempvalue as $dateDebut => $value2) { krsort($value2); foreach ($value2 as $date => $value3) { foreach ($value3 as $commentId => $comments) { foreach ($comments as $comment) { if ($comment != '') { if (!$firstLoop) { $textArea .= PHP_EOL . PHP_EOL; } else { $firstLoop = FALSE; } // Saut de ligne $textArea .= $comment . ' - ' . date('d/m/Y', $date) . ' #' . $commentId; } } } } } } if ($textArea != '') { // On affiche les textes dans le PDF $pdf->Ln(20); $pdf->SetX(20); $pdf->setFont('Arial', '', $titleSize); $pdf->Cell(0, $titleSize + 5, utf8_decode(constant($theinput['label'] . '_SHORT')), 0, 1, 'L', FALSE); $pdf->setFont('Arial', '', $textSize); $pdf->SetX(20); $pdf->MultiCell($A4Width - 40, $textSize + 5, utf8_decode($textArea), 'LTRB', 'L', TRUE); } } else { if ($theinput['type'] == 'textarea') { // Création de l'array contenant les données à afficher sous forme [timestamp fin][timestamp début][timestamp commantaire][idCommentaire] => commentaire $tempData = array(); foreach ($data[(string) $categorie['nom']][(string) $theinput['nomBDD']] as $commentId => $commentData) { if (isset($data['donnees'][$commentId]['infos'])) { $tempData[$data['donnees'][$commentId]['infos']['dateFin']][$data['donnees'][$commentId]['infos']['dateDebut']][$data['donnees'][$commentId]['infos']['date']][$commentId] = $commentData; } } $textArea = ''; $firstLoop = TRUE; // On affiche les commentaires krsort($tempData); foreach ($tempData as $dateFin => $tempvalue) { krsort($tempvalue); foreach ($tempvalue as $dateDebut => $value2) { krsort($value2); foreach ($value2 as $date => $value3) { foreach ($value3 as $commentId => $comment) { if ($comment != '') { if (!$firstLoop) { $textArea .= PHP_EOL . PHP_EOL; } else { $firstLoop = FALSE; } // Saut de ligne $textArea .= $comment . ' - ' . date('d/m/Y', $date) . ' #' . $commentId; } } } } } if ($textArea != '') { // On affiche les textes dans le PDF $pdf->Ln(20); $pdf->SetX(20); $pdf->setFont('Arial', '', $titleSize); $pdf->Cell(0 * $A4Width, $titleSize + 5, utf8_decode(constant($theinput['label'] . '_SHORT')), 0, 1, 'L', FALSE); $pdf->setFont('Arial', '', $textSize); $pdf->SetX(20); $pdf->MultiCell($A4Width - 40, $textSize + 5, utf8_decode($textArea), 'LTRB', 'L', TRUE); } } } } } // On retourne le fichier PDF $pdf->Output($pdfPath, 'F'); $output['pdfPath'] = $pdfPath; $output['pdfURI'] = $pdfPathURI; return $output; } exit; } else { return FALSE; } }
/** * getEvaluationCCPCFullData - Récupère l'intégralité des données d'évaluation de stage * * @category : eval_ccpc_functions * @param int $id Identifiant du service pour lequel on récupère les données * @param int|boolean $promotion Identifiant de la promotion pour laquelle on récupère les données, FALSE si elles sont récupérés indifférement de la promotion * @param string $dateMin Borne inférieure de la période pour laquelle on récupère les données d'évaluation, sous forme de Timestamp * @param string $dateMax Borne supérieure de la période pour laquelle on récupère les données d'évaluation, sous forme de Timestamp * @param boolean $modere si TRUE on affiche les commentaires modérés, si FALSE on ne les affiche pas * @return array Array contenant les résultats d'évaluation pour un service durant une période donnée et pour une promotion donnée * * @Author Ali Bellamine * * Contenu de l'array retourné :<br> * Contient l'intégralité des données retournés par {@link getEvaluationCCPCPartialData()}<br> * ['donnees'][identifiant de l'évaluation][categorie de la question][nom du champs dans la BDD] => (int) Valeur de la réponse à la question, toutes les données y apparaissent<br> * [Catégorie des données][Nom du champs dans la BDD]['nb'][valeur] => (int) Nombre d'occurence de chaque valeur<br> * [Catégorie des données][Nom du champs dans la BDD]['nbTotal'] => (int) Nombre total de réponses pour le champs donné<br> * [Catégorie des données][Nom du champs dans la BDD][] => (string) Pour champs texte uniquement, contient toutes les réponses données dans le champs * */ function getEvaluationCCPCFullData($id, $promotion, $dateMin, $dateMax, $modere = FALSE) { global $db; // On récupère des données de la page d'accueil $evaluationData = getEvaluationCCPCPartialData($id, $promotion, $dateMin, $dateMax); if (!isset($evaluationData) || $evaluationData == FALSE) { return FALSE; } /** Récupération des toutes les évaluations de type différent de select concernant le service dans la base de donnée **/ $listEvaluationItems = array(); $listTextItems = array(); // Liste des champs à ne pas dénombrer $listChamp = array(); if (is_file(PLUGIN_PATH . 'formulaire.xml')) { if ($form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml')) { foreach ($form->categorie as $categorie) { $listChamp[(string) $categorie['nom']] = array(); foreach ($categorie->input as $input) { if ($input['type'] == 'select') { $listChamp[(string) $categorie['nom']][] = (string) $input['nomBDD']; } if ($input['type'] == 'radio' || $input['type'] == 'textarea') { $listChamp[(string) $categorie['nom']][] = (string) $input['nomBDD']; $listEvaluationItems[(string) $input['nomBDD']]['type'] = (string) $categorie['nom']; if ($input['type'] == 'radio') { $listEvaluationItems[(string) $input['nomBDD']]['value'] = array(); foreach ($input->radio as $radio) { $listEvaluationItems[(string) $input['nomBDD']]['value'][] = (string) $radio['value']; } } if ($input['type'] == 'textarea') { $listTextItems[(string) $input['nomBDD']] = (string) $categorie['nom']; } } else { if ($input['type'] == 'checkbox') { foreach ($input->checkbox as $checkbox) { $listChamp[(string) $categorie['nom']][] = (string) $checkbox['nomBDD']; $listEvaluationItems[(string) $checkbox['nomBDD']]['type'] = (string) $categorie['nom']; $listEvaluationItems[(string) $checkbox['nomBDD']]['value'] = array(0, 1); } } else { if ($input['type'] == 'text') { foreach ($input->text as $text) { $listChamp[(string) $categorie['nom']][] = (string) $text['nomBDD']; $listTextItems[(string) $text['nomBDD']] = (string) $categorie['nom']; $listEvaluationItems[(string) $text['nomBDD']]['type'] = (string) $categorie['nom']; } } } } } } } } /** On récupère les données non récupérés dans getEvaluationCCPCPartialData **/ $sqlData = array('id' => $id); $sql = 'SELECT e.id evaluationId, e.moderation moderation'; foreach ($listEvaluationItems as $key => $value) { $sql .= ', e.' . $key . ' ' . $key . ' '; } $sql .= 'FROM eval_ccpc_resultats e WHERE e.service = :id '; if ($dateMin != 0 && $dateMax != 0) { $sql .= 'AND e.debutStage >= :dateMin AND e.finStage <= :dateMax '; $sqlData['dateMin'] = TimestampToDatetime($dateMin); $sqlData['dateMax'] = TimestampToDatetime($dateMax); } if (isset($promotion) && is_numeric($promotion) && count(checkPromotion($promotion, array())) == 0) { $sql .= 'AND e.promotion = :promotion '; $sqlData['promotion'] = $promotion; } // Si il s'agit d'un étudiant, on affiche que les évaluations vielles de + de 30 jours if ($_SESSION['rang'] <= 1) { if (defined('CONFIG_EVAL_CCPC_DELAIDISPOEVAL') && is_numeric(constant('CONFIG_EVAL_CCPC_DELAIDISPOEVAL')) && constant('CONFIG_EVAL_CCPC_DELAIDISPOEVAL') >= 0) { $nbJourAllowedDate = CONFIG_EVAL_CCPC_DELAIDISPOEVAL; } else { $nbJourAllowedDate = 30; } $allowedDate = TimestampToDatetime(time() - $nbJourAllowedDate * 24 * 3600); $sql .= ' AND e.date <= "' . $allowedDate . '" '; } $res = $db->prepare($sql); $res->execute($sqlData); while ($res_f = $res->fetch()) { // On récupére la liste des champs textes modérés if (isset($res_f['moderation']) && unserialize($res_f['moderation'])) { $moderationArray = unserialize($res_f['moderation']); } else { $moderationArray = array(); } // On remplit l'array de résultats foreach ($res_f as $key => $value) { // On enregistre l'évaluation if (isset($listEvaluationItems[$key]) && $value != '') { $evaluationData['donnees'][$res_f['evaluationId']][$listEvaluationItems[$key]['type']][$key] = $value; } // On stocke à part les évaluation de type text if (isset($listTextItems[$key])) { if ($value != '') { // On enregistre le fait que ça soit modéré if (isset($moderationArray[$key])) { $evaluationData['donnees'][$res_f['evaluationId']]['Moderation'][$key] = TRUE; } if (!isset($moderationArray[$key]) || $modere) { $evaluationData[$listTextItems[$key]][$key][$res_f['evaluationId']] = $value; } else { $evaluationData[$listTextItems[$key]][$key][$res_f['evaluationId']] = LANG_FORM_CCPC_QUESTION_TEXT_MODERATE; } } } } } /** On compte les réponses et on enregistre combien il y a de chaque réponse **/ foreach ($evaluationData['donnees'] as $id => $valeur) { foreach ($listChamp as $champType => $champValeur) { foreach ($champValeur as $champ) { if (!isset($listTextItems[$champ]) && isset($valeur[$champType][$champ])) { /* On compte l'item */ if (!isset($evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]]) || !is_numeric($evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]])) { $evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]] = 1; } else { $evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]]++; } /* On calcul le total */ if (!isset($evaluationData[$champType][$champ]['nbTotal']) || !is_numeric($evaluationData[$champType][$champ]['nbTotal'])) { $evaluationData[$champType][$champ]['nbTotal'] = 1; } else { $evaluationData[$champType][$champ]['nbTotal']++; } } } } } /** On corrige met 0 aux valeurs non cochés pour les questions où les réponses possibles sont exhaustives **/ foreach ($listEvaluationItems as $listFixQuestionName => $listFixQuestionValue) { if (isset($listFixQuestionValue['value'])) { foreach ($listFixQuestionValue['value'] as $listFixQuestionPossibilite) { if (!isset($evaluationData[$listFixQuestionValue['type']][$listFixQuestionName]['nb'][$listFixQuestionPossibilite])) { $evaluationData[$listFixQuestionValue['type']][$listFixQuestionName]['nb'][$listFixQuestionPossibilite] = 0; } } } } return $evaluationData; }
} else { $whereSqlContent .= ' AND '; } $whereSqlFilter .= ' e.hide = 0'; $whereSqlContent .= ' e.hide = 0'; } /* Ne pas afficher les evaluations vielles de plus d'un mois aux étudiants */ if ($_SESSION['rang'] <= 1) { if (defined('CONFIG_EVAL_CCPC_DELAIDISPOEVAL') && is_numeric(constant('CONFIG_EVAL_CCPC_DELAIDISPOEVAL')) && constant('CONFIG_EVAL_CCPC_DELAIDISPOEVAL') >= 0) { $nbJourAllowedDate = CONFIG_EVAL_CCPC_DELAIDISPOEVAL; } else { $nbJourAllowedDate = 30; } $allowedDate = TimestampToDatetime(time() - $nbJourAllowedDate * 24 * 3600); if ($whereSqlFilter == '') { $whereSqlFilter .= 'WHERE '; } else { $whereSqlFilter .= ' AND '; } if ($whereSqlContent == '') { $whereSqlContent .= 'WHERE '; } else { $whereSqlContent .= ' AND '; } $whereSqlFilter .= ' e.date <= "' . $allowedDate . '"'; $whereSqlContent .= ' e.date <= "' . $allowedDate . '"'; } /* Ne pas afficher les évaluations des autres services aux chef de service
$DateMin = time() - 365 * 24 * 3600; // On lance la recherche pour chaque service foreach ($listeServices as $service) { $listePromotion = array(); $listeDate = array(); // On détermine la liste des promotions représentées dans le service $sql = 'SELECT DISTINCT promotion FROM `eval_ccpc_resultats` WHERE service = ?'; $res = $db->prepare($sql); $res->execute(array($service['id'])); while ($res_f = $res->fetch()) { $listePromotion[] = $res_f[0]; } // On détermine les couples de dates à tester $sql = 'SELECT DISTINCT debutStage, finStage FROM `eval_ccpc_resultats` WHERE service = ? AND debutStage >= ? AND finStage <= ?'; $res = $db->prepare($sql); $res->execute(array($service['id'], TimestampToDatetime($DateMin), TimestampToDatetime($DateMax))); while ($res_f = $res->fetch()) { $listeDate[] = array('DateMin' => DatetimeToTimestamp($res_f['debutStage']), 'DateMax' => DatetimeToTimestamp($res_f['finStage'])); } // On peux lancer le scan du service foreach ($listeDate as $IntervalleDates) { foreach ($listePromotion as $promotionId) { eval_ccpc_applyFilter($service['id'], $promotionId, $IntervalleDates['DateMin'], $IntervalleDates['DateMax']); } } } $tempGET = $_GET; unset($tempGET['action']); header('Location: ' . ROOT . CURRENT_FILE . '?' . http_build_query($tempGET)); } // Ajout et edition des filtres