feat: add api to fetch hr tickets
This commit is contained in:
@ -1141,3 +1141,51 @@
|
||||
return $result->modify('+48 hours');
|
||||
}
|
||||
}
|
||||
|
||||
function get_hr_tickets($from_date = null, $itilcategories_id = null) {
|
||||
global $DB;
|
||||
|
||||
if (!$from_date || !$itilcategories_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
t.id,
|
||||
t.name,
|
||||
t.date_creation,
|
||||
u.registration_number,
|
||||
t.itilcategories_id,
|
||||
v.status as 'validation_status',
|
||||
u2.registration_number as 'validate_by_user',
|
||||
v.validation_date,
|
||||
t.content
|
||||
FROM glpi_tickets t
|
||||
LEFT JOIN glpi_users u ON u.id = t.users_id_recipient
|
||||
LEFT JOIN glpi_ticketvalidations v ON v.tickets_id = t.id
|
||||
LEFT JOIN glpi_users u2 ON u2.id = v.users_id_validate
|
||||
WHERE
|
||||
DATE(t.date_creation) >= ?
|
||||
AND t.itilcategories_id = ?
|
||||
ORDER BY t.date_creation
|
||||
";
|
||||
|
||||
$stmt = $DB->prepare($sql);
|
||||
|
||||
// Bind parameters
|
||||
$stmt->bind_param('si', $from_date, $itilcategories_id);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$res = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
// Unescape the content column
|
||||
if (isset($row['content'])) {
|
||||
$row['content'] = html_entity_decode($row['content'], ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
$res[] = $row;
|
||||
}
|
||||
|
||||
return $res ?: null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user