198 lines
6.1 KiB
PHP
198 lines
6.1 KiB
PHP
<?php
|
|
ob_Start();
|
|
|
|
use Glpi\Event;
|
|
|
|
include ('../inc/includes.php');
|
|
|
|
Session::checkLoginUser();
|
|
|
|
$allowed_groups = [38, 2];
|
|
|
|
if (empty(array_intersect($allowed_groups, $_SESSION['glpigroups']))) {
|
|
Html::redirect($CFG_GLPI["root_doc"] . "/front/central.php");
|
|
exit;
|
|
}
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpHeader("Gestion des employées", '', $_SESSION["glpiname"]);
|
|
} else {
|
|
Html::header("Gestion des employées", '', "", "");
|
|
}
|
|
|
|
function get_users() {
|
|
global $DB;
|
|
|
|
$query = "
|
|
SELECT
|
|
user1.id,
|
|
CONCAT(user1.realname, ' ', user1.firstname) as full_name ,
|
|
user1.registration_number,
|
|
user1.users_id_supervisor,
|
|
CONCAT(user2.realname, ' ', user2.firstname) as superior,
|
|
p.value as value,
|
|
p2.value as value2
|
|
FROM glpi_users user1
|
|
LEFT JOIN glpi_users user2 ON user1.users_id_supervisor = user2.id
|
|
LEFT JOIN picklist p on user1.id_fonction = p.id
|
|
LEFT JOIN picklist p2 on user1.id_structure = p2.id
|
|
WHERE user1.is_active = 1
|
|
AND user1.is_deleted = 0
|
|
AND user1.registration_number REGEXP '^[0-9]+$'
|
|
ORDER BY CAST(user1.registration_number AS UNSIGNED) ASC
|
|
";
|
|
|
|
// Execute the query
|
|
$result = $DB->query($query);
|
|
|
|
// Check if there are results and fetch them
|
|
if ($result && $result->num_rows > 0) {
|
|
$res = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$res[] = $row;
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
// Return null if no results
|
|
return null;
|
|
}
|
|
|
|
$res = get_users() ;
|
|
|
|
echo '
|
|
<div class="center">
|
|
<table border="0" class="tab_cadrehov" style="font-size: 12px;">
|
|
<thead>
|
|
<tr class="tab_bg_2" style="text-align: center; vertical-align: middle;">
|
|
<th></th>
|
|
<th>Employee</th>
|
|
<th>Matricule</th>
|
|
<th>Responsable</th>
|
|
<th>Poste</th>
|
|
<th>Structure</th>
|
|
<th></th>
|
|
</tr>
|
|
<tr class="tab_bg_2" style="text-align: center; vertical-align: middle;">
|
|
<th></th>
|
|
<th><input type="text" data-type="full_name" placeholder="Rechercher employé..." style="width: 50%;" oninput="filtre(this);"></th>
|
|
<th><input type="text" data-type="registration_number" placeholder="Rechercher matricule..." style="width: 50%;" oninput="filtre(this);"></th>
|
|
<th><input type="text" data-type="superior" placeholder="Rechercher supérieur..." style="width: 50%;" oninput="filtre(this);"></th>
|
|
<th><input type="text" data-type="value" placeholder="Rechercher poste..." style="width: 50%;" oninput="filtre(this);"></th>
|
|
<th><input type="text" data-type="value2" placeholder="Rechercher structure..." style="width: 50%;" oninput="filtre(this);"></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="data"></tbody>
|
|
<tfoot>
|
|
<tr class="tab_bg_2" style="text-align: center; vertical-align: middle;">
|
|
<th></th>
|
|
<th>Employee</th>
|
|
<th>Matricule</th>
|
|
<th>Responsable</th>
|
|
<th>Poste</th>
|
|
<th>Structure</th>
|
|
<th></th>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>';
|
|
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpFooter();
|
|
} else {
|
|
Html::footer();
|
|
}
|
|
|
|
$link=$CFG_GLPI["root_doc"]."/front/ticket.php";
|
|
$root = $CFG_GLPI["root_doc"];
|
|
$user = Session::getCurrentInterface();
|
|
?>
|
|
|
|
|
|
<script>
|
|
var root = <?php echo json_encode($root); ?>;
|
|
var res = <?php echo json_encode($res); ?>;
|
|
var user = <?php echo json_encode($user); ?>;
|
|
var userlink;
|
|
if(user == "helpdesk"){
|
|
userlink ='<li class="breadcrumb_item"><a href="'+root+'/front/helpdesk.public.php" title="Accueil">Accueil</a></li>';
|
|
}else{
|
|
userlink = '<li class="breadcrumb_item"><a href="'+root+'/front/central.php" title="Accueil">Accueil</a></li>';
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
|
|
$("#c_ssmenu2").html('<ul>'+
|
|
userlink+
|
|
'<li class="breadcrumb_item"><a href="" title="">Administration</a></li>'+
|
|
'<li class="breadcrumb_item"><a href="'+root+'/front/user.list.php" class="here" title="Gestion des employées"><i class="far fa-sticky-note"></i> Gestion des employées</a></li>'+
|
|
'<span class="sr-only">Ajouter</span></a>'+
|
|
'</li>'+
|
|
'</ul>');
|
|
|
|
});
|
|
|
|
function loadTable(data) {
|
|
if (data != null && data.length > 0) {
|
|
for (var i = 0; i < data.length; i++) {
|
|
var row = data[i];
|
|
|
|
var actions = '<a href="' + root + '/front/user.update.php?id=' + row['id'] + '" title="Modifier">' +
|
|
'<i class="fa fa-edit fa-lg" style="color: green; cursor: pointer;"></i>' +
|
|
'</a> ';
|
|
|
|
$('#data').append(
|
|
'<tr class="tab_bg_2" style="text-align: center; vertical-align: middle;">' +
|
|
'<td width="10" valign="top"></td>' +
|
|
'<td valign="top">' + row['full_name'] + '</td>' +
|
|
'<td valign="top">' + row['registration_number'] + '</td>' +
|
|
'<td valign="top">' + row['superior'] + '</td>' +
|
|
'<td valign="top">' + row['value'] + '</td>' +
|
|
'<td valign="top">' + row['value2'] + '</td>' +
|
|
'<td valign="top" style="text-align: center; vertical-align: middle;">' + actions + '</td>' +
|
|
'</tr>'
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
function filtre() {
|
|
let filters = {};
|
|
|
|
// Collect all filter inputs
|
|
$("thead input[data-type]").each(function () {
|
|
let type = $(this).data("type");
|
|
let valeur = $(this).val();
|
|
if (valeur !== "") {
|
|
filters[type] = valeur;
|
|
}
|
|
});
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: root + "/ajax/user.php?action=filtre",
|
|
data: { filters: filters },
|
|
dataType: "json"
|
|
})
|
|
.done(function (msg) {
|
|
$("#data").empty();
|
|
if (msg !== null) {
|
|
loadTable(msg);
|
|
}
|
|
})
|
|
.fail(function (msg) {
|
|
console.log(msg);
|
|
});
|
|
}
|
|
|
|
loadTable(res);
|
|
|
|
</script>
|
|
<!-- script pour liste déroulante -->
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('.js-example-basic-single').select2();
|
|
});
|
|
</script>
|