Files
MYSOPHAL/ajax/drh.score.employees.php
2025-08-07 13:15:31 +01:00

53 lines
1.2 KiB
PHP

<?php
if (!defined('GLPI_ROOT')) {
define('GLPI_ROOT', dirname(__DIR__));
}
include_once GLPI_ROOT . '/inc/based_config.php';
// Init Timer to compute time of display
$TIMER_DEBUG = new Timer();
$TIMER_DEBUG->start();
/// TODO try to remove them if possible
include_once (GLPI_ROOT . "/inc/db.function.php");
// Standard includes
include_once (GLPI_ROOT . "/inc/config.php");
//disbled errors =>pour le variable res (Ajax)
ini_set('display_errors', 0);
Session::checkLoginUser();
global $DB;
function getUsersScores($year){
global $DB;
$query = "SELECT *
FROM `resultat_eval_scores`
WHERE type_id = ? ";
$stmt = $DB->prepare($query);
$stmt->bind_param("i" , $year);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$res = array();
while($row = $result->fetch_assoc()){
$res[$row['user_id']] = array($row['score'],$row['id_rfe']);
}
return $res;
}
return [];
}
if(isset($_POST)){
switch ($_GET['action']) {
case "get_utilisateur_scores":
$scores = getUsersScores($_GET['year']);
echo json_encode($scores);
break;
}
}