prepare($query); $stmt->bind_param("i", $id_fiche_evaluation); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { $rows[] = $row; } return $rows[0]; } return array(); } function getResultatLignesFicheEvaluation($id_resultat_fiche_evaluation){ if(isInjection($id_resultat_fiche_evaluation)) { echo "Not Allowed"; return array(); } global $DB; $query = "SELECT * from resultat_ligne_fiche_evaluation rlfe LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation WHERE rlfe.id_resultat_fiche_evaluation = ? group by lfe.id_fiche_evaluation"; $stmt = $DB->prepare($query); $stmt->bind_param("i", $id_resultat_fiche_evaluation); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { $rows[] = $row; } } $annuel = getFicheEvaluationEdit($rows[0]['id_fiche_evaluation']); $query = "SELECT * from resultat_ligne_fiche_evaluation rlfe LEFT JOIN ligne_fiche_evaluation lfe ON lfe.id_ligne_fiche_evaluation = rlfe.id_ligne_fiche_evaluation WHERE rlfe.id_resultat_fiche_evaluation = ? order by lfe.ordre"; $stmt = $DB->prepare($query); $stmt->bind_param("i", $id_resultat_fiche_evaluation); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { $rowssb = array(); if($annuel) { $query = "SELECT date, eval FROM resultat_ligne_fiche_eval_annuel where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("ii", $row['id_resultat_fiche_evaluation'],$row['id_ligne_fiche_evaluation']); $stmt->execute(); $resultsb = $stmt->get_result(); while($rowsb = $resultsb->fetch_assoc()) { $rowssb[] = $rowsb; } } if(!empty($rowssb)) $rows[] = $row+$rowssb[0]; else $rows[] = $row; } } //print_r($rows); return $rows; } function getUserId($idUser){ global $DB; $subUsers = array(); $query = "SELECT id , CONCAT(realname,' ', firstname) as fullname, registration_number as matricule from glpi_users where id=? "; $stmt = $DB->prepare($query); $stmt->bind_param("i", $idUser); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { $subUsers[] = $row; } return $subUsers[0]; } return $subUsers; } function isUserSupervisor($userId, $currentUserId) { global $DB; $query = "SELECT id , CONCAT(realname,' ', firstname) as fullname, users_id_supervisor from glpi_users where id=? "; $stmt = $DB->prepare($query); $stmt->bind_param("i", $userId); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { if($row['users_id_supervisor'] == $currentUserId) return true; } } return false; } function updateResultatLigneFicheEvaluationNoRepons($idResultatLigneFicheEvaluation, $observation) { global $DB; $query = "UPDATE resultat_ligne_fiche_evaluation SET observation = ? where id_resultat_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("si",$observation,$idResultatLigneFicheEvaluation); $stmt->execute(); } function updateResultatLigneFicheEvaluation($idResultatLigneFicheEvaluation, $reponse, $observation) { global $DB; $query = "UPDATE resultat_ligne_fiche_evaluation SET reponse = ? , observation = ? where id_resultat_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("ssi",$reponse,$observation,$idResultatLigneFicheEvaluation); $stmt->execute(); } function updateResultatLigneFicheEvalAnnueld($idResultatLigneFicheEvaluation, $date) { global $DB; $query = "SELECT * from resultat_ligne_fiche_evaluation where id_resultat_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("i", $idResultatLigneFicheEvaluation); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { $rows[] = $row; } $id1 = $rows[0]['id_resultat_fiche_evaluation']; $id2 = $rows[0]['id_ligne_fiche_evaluation']; if(evalAnnExists($id1,$id2)){ $query = "UPDATE resultat_ligne_fiche_eval_annuel SET date = ? where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("sii",$date,$id1,$id2); }else{ $query = "INSERT INTO resultat_ligne_fiche_eval_annuel (`id_ligne_fiche_evaluation`, `id_resultat_fiche_evaluation`, `date`, `eval`) VALUES (?,?,?, '0')"; $stmt = $DB->prepare($query); $stmt->bind_param("iis", $id2,$id1,$date); } $stmt->execute(); } } function evalAnnExists($id1,$id2){ global $DB; $query = "SELECT * from resultat_ligne_fiche_eval_annuel where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("ii", $id1,$id2); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { return true; }else{ return false; } } function updateResultatLigneFicheEvalAnnuel($idResultatLigneFicheEvaluation, $eval) { global $DB; $query = "SELECT * from resultat_ligne_fiche_evaluation where id_resultat_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("i", $idResultatLigneFicheEvaluation); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { $rows[] = $row; } $id1 = $rows[0]['id_resultat_fiche_evaluation']; $id2 = $rows[0]['id_ligne_fiche_evaluation']; $query = "UPDATE resultat_ligne_fiche_eval_annuel SET eval = ? where id_resultat_fiche_evaluation = ? and id_ligne_fiche_evaluation = ?"; $stmt = $DB->prepare($query); $stmt->bind_param("sii", $eval,$id1,$id2); $stmt->execute(); } } function evalTrack($idResultatFeval, $user) { global $DB; $query = "INSERT INTO `evaluation_tracking`(`id_resultat_feval`, `user`, `comment`) VALUES (?, ?, 'suivi')"; //echo $query; $stmt = $DB->prepare($query); $stmt->bind_param("ii", $idResultatFeval,$user); $stmt->execute(); }