5 Commits

5 changed files with 271 additions and 207 deletions

View File

@ -91,6 +91,8 @@
$isBLMP = false; $isBLMP = false;
$requisition_date = "";
$last_generated_Sequence_bl = last_generated_Sequence('bon de livraison ac')+1 ; $last_generated_Sequence_bl = last_generated_Sequence('bon de livraison ac')+1 ;
@ -111,54 +113,27 @@
case 0: //BULLETIN DE SORTIE case 0: //BULLETIN DE SORTIE
// Get the submitted date // Get the submitted date
$bs_date_sortir = $_POST['bs_date_sortir']; $bs_date_sortir = $_POST['bs_date_sortir'];
// Get the current date in 'Y-m-d' format // Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d'); $current_date = date('Y-m-d');
if ($bs_date_sortir < $current_date) { if ($bs_date_sortir < $current_date) {
$_SESSION["bs_date_sortir"] = $bs_date_sortir; $_SESSION["bs_date_sortir"] = $bs_date_sortir;
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR); Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([ echo json_encode([
'is_valid' => false, 'is_valid' => false,
'modele' => $_SESSION['modele'] 'modele' => $_SESSION['modele']
]); ]);
return ; return ;
} }
unset($_SESSION["bs_date_sortir"]); unset($_SESSION["bs_date_sortir"]);
$name = "Bulletin de sortie"; $name = "Bulletin de sortie";
$table='&lt;table style="height: 136px; width: 100%; border-collapse: collapse;" border="1" cellpadding="5"&gt;&lt;tbody&gt;&lt;tr style="height: 17px;"&gt;&lt;td style="width: 49.1195%; height: 17px;"&gt;&lt;strong&gt; $table='&lt;table style="height: 136px; width: 100%; border-collapse: collapse;" border="1" cellpadding="5"&gt;&lt;tbody&gt;&lt;tr style="height: 17px;"&gt;&lt;td style="width: 49.1195%; height: 17px;"&gt;&lt;strong&gt;
@ -175,9 +150,7 @@
Pour affaire Personnelle :&lt;/strong&gt;&lt;/td&gt;&lt;td style="width: 50.8805%; height: 17px;"&gt;'.$_POST['bs_affaire_personnelle'].'&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;'; Pour affaire Personnelle :&lt;/strong&gt;&lt;/td&gt;&lt;td style="width: 50.8805%; height: 17px;"&gt;'.$_POST['bs_affaire_personnelle'].'&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;';
$requisition_date = $_POST['bs_date_sortir'];
break; break;
@ -272,20 +245,13 @@
case 3://Autorisation d'absence case 3://Autorisation d'absence
// Get the submitted date // Get the submitted date
$aa_date_absenter = $_POST['aa_date_absenter']; $aa_date_absenter = $_POST['aa_date_absenter'];
// Get the current date in 'Y-m-d' format // Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d'); $current_date = date('Y-m-d');
if ($aa_date_absenter < $current_date) { if ($aa_date_absenter < $current_date) {
@ -312,66 +278,42 @@
} }
unset($_SESSION["aa_date_absenter"]); unset($_SESSION["aa_date_absenter"]);
$name = "Autorisation d'absence"; $name = "Autorisation d'absence";
$table ='Matricule : '.$_POST['matricule'].'<br>Fonction : '.$_POST['fonction'].'<br> Structure : '.$_POST['structure'].' $table ='Matricule : '.$_POST['matricule'].'<br>Fonction : '.$_POST['fonction'].'<br> Structure : '.$_POST['structure'].'
<br> Est autorisé (e) à s&apos;absenter la journée du : '.$_POST['aa_date_absenter'].'<br> Commentaire : '.$_POST['aa_commentaire'].''; <br> Est autorisé (e) à s&apos;absenter la journée du : '.$_POST['aa_date_absenter'].'<br> Commentaire : '.$_POST['aa_commentaire'].'';
$requisition_date = $_POST['aa_date_absenter'];
break; break;
case 4://AUTORISATION D'ENTREE case 4://AUTORISATION D'ENTREE
// Get the submitted date // Get the submitted date
$ae_date_reprendre = $_POST['ae_date_reprendre']; $ae_date_reprendre = $_POST['ae_date_reprendre'];
// Get the current date in 'Y-m-d' format // Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d'); $current_date = date('Y-m-d');
if ($ae_date_reprendre < $current_date) { if ($ae_date_reprendre < $current_date) {
$_SESSION["ae_date_reprendre"] = $ae_date_reprendre; $_SESSION["ae_date_reprendre"] = $ae_date_reprendre;
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR); Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([ echo json_encode([
'is_valid' => false, 'is_valid' => false,
'modele' => $_SESSION['modele'] 'modele' => $_SESSION['modele']
]); ]);
return ; return ;
} }
unset($_SESSION["ae_date_reprendre"]); unset($_SESSION["ae_date_reprendre"]);
@ -382,6 +324,8 @@
<br>Est autorisé (e) de reprendre à : '.$_POST['ae_date_reprendre'].'<br> Commentaire : '.$_POST['ae_commentaire']; <br>Est autorisé (e) de reprendre à : '.$_POST['ae_date_reprendre'].'<br> Commentaire : '.$_POST['ae_commentaire'];
$requisition_date = $_POST['ae_date_reprendre'];
break; break;
@ -401,22 +345,12 @@
// Get the submitted date // Get the submitted date
$date_req = $_POST['date_req']; $date_req = $_POST['date_req'];
// Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d'); $current_date = date('Y-m-d');
if ($date_req < $current_date) {
// Calculate the date two days ago from today
$two_days_ago = date('Y-m-d', strtotime('-2 days', strtotime($current_date)));
if ($date_req < $two_days_ago) {
@ -430,28 +364,18 @@
$_SESSION["lieu_de_travail"] = $_POST['lieu_de_travail']; $_SESSION["lieu_de_travail"] = $_POST['lieu_de_travail'];
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR); Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([ echo json_encode([
'is_valid' => false, 'is_valid' => false,
'modele' => $_SESSION['modele'] 'modele' => $_SESSION['modele']
]); ]);
return ; return ;
} }
unset($_SESSION["date_req"]); unset($_SESSION["date_req"]);
unset($_SESSION["mot_req"]); unset($_SESSION["mot_req"]);
@ -464,10 +388,6 @@
$name = "HEURES SUPPLEMENTAIRES"; $name = "HEURES SUPPLEMENTAIRES";
$table ='matricule : '.$_POST['matricule'].'<br>fonction : '.$_POST['fonction'].'<br>structure : '.$_POST['structure'].'<br> $table ='matricule : '.$_POST['matricule'].'<br>fonction : '.$_POST['fonction'].'<br>structure : '.$_POST['structure'].'<br>
@ -476,10 +396,10 @@
<br>Heure de fin : '.$_POST['heure_f'].'<br>Lieu de travail : '.$_POST['lieu_de_travail']; <br>Heure de fin : '.$_POST['heure_f'].'<br>Lieu de travail : '.$_POST['lieu_de_travail'];
$requisition_date = $_POST['date_req'];
break; break;
case 7://DEMANDE ORDRE DE MISSION case 7://DEMANDE ORDRE DE MISSION
$name = "DEMANDE ORDRE DE MISSION"; $name = "DEMANDE ORDRE DE MISSION";
@ -496,32 +416,21 @@
case 8://CONGE DE RECUPERATION case 8://CONGE DE RECUPERATION
$cr_date_debut = $_POST['cr_date_debut']; $cr_date_debut = $_POST['cr_date_debut'];
$cr_date_fin = $_POST['cr_date_fin']; $cr_date_fin = $_POST['cr_date_fin'];
$current_date = date('Y-m-d'); $current_date = date('Y-m-d');
if ($cr_date_debut < $current_date || $cr_date_fin < $cr_date_debut) { if ($cr_date_debut < $current_date || $cr_date_fin < $cr_date_debut) {
$_SESSION["cr_date_debut"] = $cr_date_debut; $_SESSION["cr_date_debut"] = $cr_date_debut;
$_SESSION["cr_date_fin"] = $cr_date_fin; $_SESSION["cr_date_fin"] = $cr_date_fin;
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR); Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([ echo json_encode([
'is_valid' => false, 'is_valid' => false,
@ -529,21 +438,12 @@
'modele' => $_SESSION['modele'] 'modele' => $_SESSION['modele']
]); ]);
return ; return ;
} }
unset($_SESSION["cr_date_debut"]); unset($_SESSION["cr_date_debut"]);
unset($_SESSION["cr_date_fin"]); unset($_SESSION["cr_date_fin"]);
$name = "CONGE DE RECUPERATION"; $name = "CONGE DE RECUPERATION";
@ -559,6 +459,8 @@
if(isset($_POST['cr_date_5']) && $_POST['cr_date_5'] != '') $table = $table.",".$_POST['cr_date_5']; if(isset($_POST['cr_date_5']) && $_POST['cr_date_5'] != '') $table = $table.",".$_POST['cr_date_5'];
if(isset($_POST['cr_date_6']) && $_POST['cr_date_6'] != '') $table = $table.",".$_POST['cr_date_6']; if(isset($_POST['cr_date_6']) && $_POST['cr_date_6'] != '') $table = $table.",".$_POST['cr_date_6'];
$requisition_date = $_POST['cr_date_debut'];
break; break;
case 9://Work Order case 9://Work Order
@ -692,6 +594,7 @@
} }
break; break;
case 14: case 14:
// Get the submitted data // Get the submitted data
$ap_date = $_POST['ap_date']; $ap_date = $_POST['ap_date'];
@ -777,6 +680,8 @@
$name = "Autorisation de paie"; $name = "Autorisation de paie";
$table ='Matricule : '.$_POST['matricule'].'<br>Fonction : '.$_POST['fonction'].'<br>Structure : '.$_POST['structure'].' $table ='Matricule : '.$_POST['matricule'].'<br>Fonction : '.$_POST['fonction'].'<br>Structure : '.$_POST['structure'].'
<br>Est autorise le : '.$_POST['ap_date'].'<br> Du : '.$_POST['ap_start_time'].'<br> a : '.$_POST['ap_end_time']; <br>Est autorise le : '.$_POST['ap_date'].'<br> Du : '.$_POST['ap_start_time'].'<br> a : '.$_POST['ap_end_time'];
$requisition_date = $_POST['ap_date'];
break; break;
} }
@ -807,7 +712,7 @@
add_ticket($id_categorie[$name],$name,$table,$_SESSION["glpiID"]); add_ticket($id_categorie[$name],$name,$table,$_SESSION["glpiID"], $requisition_date);
$tickets_id = $DB->insert_id(); $tickets_id = $DB->insert_id();

View File

@ -2347,7 +2347,7 @@ function modeles($modele ,$dc_nbr_jour, $type ){
<input type='date' min='".date('Y-m-d',(strtotime ( '-2 day' , strtotime (date('Y-m-d')) ) ))."' name='date_req' value='".(isset($_SESSION["date_req"]) != null ? $_SESSION["date_req"] : '' )."' autocomplete='off' required> <input type='date' min='".date('Y-m-d',(strtotime (date('Y-m-d')) ))."' name='date_req' value='".(isset($_SESSION["date_req"]) != null ? $_SESSION["date_req"] : '' )."' autocomplete='off' required>

84
front/ticket.api.php Normal file
View File

@ -0,0 +1,84 @@
<?php
require_once '../functionsophalglpi.php';
include('../inc/includes.php');
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: X-API-Key, Content-Type');
const ALLOWED_ITIL_CATEGORIES = [12, 15, 16, 36, 38, 72];
// === SECURITY (simple token auth) ===
$headers = getallheaders();
$apiKey = $headers['X-API-Key'] ?? '';
$validKey = getenv('HR_API_KEY'); // store securely in system env or .env
if ($apiKey !== $validKey) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized'], JSON_PRETTY_PRINT);
exit;
}
// === Validate & normalize dates ===
function check_param($from_date = null, $itilcategories_id = null) {
// Validate dates
if ($from_date && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $from_date)) {
http_response_code(400);
echo json_encode(['error' => 'Invalid start_date format (YYYY-MM-DD)'], JSON_PRETTY_PRINT);
exit;
}
// Validate category if provided
if ($itilcategories_id !== null) {
// It must be numeric
if (!ctype_digit((string)$itilcategories_id)) {
http_response_code(400);
echo json_encode(['error' => 'Invalid category id (must be numeric)'], JSON_PRETTY_PRINT);
exit;
}
// It must be one of the allowed values
if (!in_array((int)$itilcategories_id, ALLOWED_ITIL_CATEGORIES, true)) {
http_response_code(400);
echo json_encode([
'error' => 'Invalid category id',
], JSON_PRETTY_PRINT);
exit;
}
}
return [$from_date, $itilcategories_id];
}
// ====== ONLY ONE ROUTE: /tickets ======
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$path = basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
if ($path !== 'tickets') {
http_response_code(404);
echo json_encode(['error' => 'Route not found'], JSON_PRETTY_PRINT);
exit;
}
// Read GET URL params
$from_date = $_GET['from_date'] ?? null;
$itilcategories_id = $_GET['itilcategories_id'] ?? null;
[$from_date, $itilcategories_id] = check_param(
$from_date,
$itilcategories_id
);
// Fetch GLPI data
$tickets = get_hr_tickets($from_date, $itilcategories_id);
echo json_encode($tickets, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
}
// Default
http_response_code(404);
echo json_encode(['error' => 'Invalid request'], JSON_PRETTY_PRINT);

View File

@ -514,30 +514,40 @@
function add_ticket($id_categorie,$name,$table,$glpiID){ function add_ticket($id_categorie, $name, $table, $glpiID, $requisition_date = null) {
global $DB; global $DB;
if ($requisition_date) {
// With requisition_date
$stmt = $DB->prepare("INSERT INTO `glpi_tickets` (`date`, `type`, `itilcategories_id`, `entities_id`, `status`, $stmt = $DB->prepare("
INSERT INTO glpi_tickets
(`date`, `type`, `itilcategories_id`, `entities_id`, `status`,
`requesttypes_id`, `urgency`, `impact`, `locations_id`, `requesttypes_id`, `urgency`, `impact`, `locations_id`,
`priority`, `name`, `content`, `id`, `users_id_lastupdater`,
`priority`, `name`, `content`, `id`, `users_id_lastupdater`, `users_id_recipient`, `users_id_recipient`, `global_validation`, `date_creation`, `date_mod`, `requisition_date`)
VALUES (NOW(), '2', ?, '0', '1', '1', '3', '3', '0', '3', ?, ?, '0', ?, ?, '1', NOW(), NOW(), ?)
`global_validation`, `date_creation`, `date_mod`) ");
$stmt->bind_param("issiis", $id_categorie, $name, $table, $glpiID, $glpiID, $requisition_date);
VALUES (NOW(), '2', ?, '0', '1', '1', '3', '3', '0', '3',?, ?, '0', ?, ?, '1', NOW(), NOW())"); } else {
// Without requisition_date
$stmt = $DB->prepare("
INSERT INTO glpi_tickets
(`date`, `type`, `itilcategories_id`, `entities_id`, `status`,
`requesttypes_id`, `urgency`, `impact`, `locations_id`,
`priority`, `name`, `content`, `id`, `users_id_lastupdater`,
`users_id_recipient`, `global_validation`, `date_creation`, `date_mod`)
VALUES (NOW(), '2', ?, '0', '1', '1', '3', '3', '0', '3', ?, ?, '0', ?, ?, '1', NOW(), NOW())
");
$stmt->bind_param("issii", $id_categorie, $name, $table, $glpiID, $glpiID); $stmt->bind_param("issii", $id_categorie, $name, $table, $glpiID, $glpiID);
}
$stmt->execute(); $stmt->execute();
} }
function isValidConge($tickets_id){ function isValidConge($tickets_id){
global $DB; global $DB;
@ -704,7 +714,7 @@
from glpi_tickets from glpi_tickets
where id = ?' LIMIT 1"; where id = ? LIMIT 1";
$stmt = $DB->prepare($query); $stmt = $DB->prepare($query);
@ -959,7 +969,7 @@
WHEN t.status = 2 THEN 'En cours' WHEN t.status = 2 THEN 'En cours'
WHEN t.status = 3 THEN 'En cours' WHEN t.status = 3 THEN 'En cours'
WHEN t.status = 4 THEN 'En attente' WHEN t.status = 4 THEN 'En attente'
WHEN t.status = 5 THEN 'R<>solu' WHEN t.status = 5 THEN 'R<>solu'
WHEN t.status = 6 THEN 'Clos' WHEN t.status = 6 THEN 'Clos'
END AS status, END AS status,
t.name as ticket_name, t.name as ticket_name,
@ -987,7 +997,7 @@
WHEN t.status = 2 THEN 'En cours' WHEN t.status = 2 THEN 'En cours'
WHEN t.status = 3 THEN 'En cours' WHEN t.status = 3 THEN 'En cours'
WHEN t.status = 4 THEN 'En attente' WHEN t.status = 4 THEN 'En attente'
WHEN t.status = 5 THEN 'R<>solu' WHEN t.status = 5 THEN 'R<>solu'
WHEN t.status = 6 THEN 'Clos' WHEN t.status = 6 THEN 'Clos'
END AS status, END AS status,
t.name as ticket_name, t.name as ticket_name,
@ -1103,12 +1113,79 @@
id id
from glpi_tickets from glpi_tickets
where STATUS != 6 and itilcategories_id in (12,15,16,36,38,72) and (CASE where STATUS != 6 and itilcategories_id in (12,15,16,36,38,72) and (CASE
WHEN DAYOFWEEK(date_creation) IN (4) THEN TIMESTAMPDIFF(HOUR,date_creation,CONCAT(DATE(date_creation), ' 00:00:00') + INTERVAL 2 DAY) + TIMESTAMPDIFF(HOUR, CONCAT(DATE(date_creation), ' 00:00:00') + INTERVAL 4 DAY,now()) WHEN DAYOFWEEK(requisition_date) IN (4) THEN TIMESTAMPDIFF(HOUR,requisition_date,CONCAT(DATE(requisition_date), ' 00:00:00') + INTERVAL 2 DAY) + TIMESTAMPDIFF(HOUR, CONCAT(DATE(requisition_date), ' 00:00:00') + INTERVAL 4 DAY,now())
WHEN DAYOFWEEK(date_creation) IN (5) THEN TIMESTAMPDIFF(HOUR,date_creation,CONCAT(DATE(date_creation), ' 00:00:00') + INTERVAL 1 DAY) + TIMESTAMPDIFF(HOUR, CONCAT(DATE(date_creation), ' 00:00:00') + INTERVAL 3 DAY,now()) WHEN DAYOFWEEK(requisition_date) IN (5) THEN TIMESTAMPDIFF(HOUR,requisition_date,CONCAT(DATE(requisition_date), ' 00:00:00') + INTERVAL 1 DAY) + TIMESTAMPDIFF(HOUR, CONCAT(DATE(requisition_date), ' 00:00:00') + INTERVAL 3 DAY,now())
WHEN DAYOFWEEK(date_creation) IN (6) THEN TIMESTAMPDIFF(HOUR,CONCAT(DATE(date_creation), ' 00:00:00') + INTERVAL 2 DAY, now()) WHEN DAYOFWEEK(requisition_date) IN (6) THEN TIMESTAMPDIFF(HOUR,CONCAT(DATE(requisition_date), ' 00:00:00') + INTERVAL 2 DAY, now())
WHEN DAYOFWEEK(date_creation) IN (7) THEN TIMESTAMPDIFF(HOUR,CONCAT(DATE(date_creation), ' 00:00:00') + INTERVAL 1 DAY, now()) WHEN DAYOFWEEK(requisition_date) IN (7) THEN TIMESTAMPDIFF(HOUR,CONCAT(DATE(requisition_date), ' 00:00:00') + INTERVAL 1 DAY, now())
ELSE TIMESTAMPDIFF(HOUR,date_creation, now()) ELSE TIMESTAMPDIFF(HOUR,requisition_date, now())
END) > 48)"); END) > 24)");
return $stmt->execute(); return $stmt->execute();
} }
function getMaxTicketValidationDateTime(DateTime $requisition_date): DateTime {
$weekday = (int) $requisition_date->format('N'); // 1 (Mon) to 7 (Sun)
if ($weekday === 5) { // Friday
$sunday = clone $requisition_date;
$sunday->modify('+2 days')->setTime(0, 0);
return $sunday->modify('+48 hours');
} elseif ($weekday === 6) { // Saturday
$sunday = clone $requisition_date;
$sunday->modify('+1 day')->setTime(0, 0);
return $sunday->modify('+48 hours');
} elseif (in_array($weekday, [3, 4])) { // Wednesday or Thursday
$result = clone $requisition_date;
return $result->modify('+96 hours');
} else {
$result = clone $requisition_date;
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;
}

View File

@ -7385,21 +7385,40 @@ abstract class CommonITILObject extends CommonDBTM {
echo "</div>"; echo "</div>";
} }
//sophal block validation =>
//clôturer la modification du validation (autorisation absence,entree .......) 48h aprees l envoi
/*
if (strpos($item['type'], 'Validation') > 0 && if (strpos($item['type'], 'Validation') > 0 &&
(isset($item_i['can_answer']) && $item_i['can_answer'])) { (isset($item_i['can_answer']) && $item_i['can_answer'])) {
// sophal
// prevent validators to update validations after 48 hours from tickets creation ( excluding weekends )
$detail_ticket = get_detail_ticket($_GET['id']); $detail_ticket = get_detail_ticket($_GET['id']);
$itilcategories_ids = array(15, 16 , 12, 38 , 36); $itilcategories_ids = array(15, 16 , 12, 38 , 36, 72);
$date_fin = date('Y-m-d H:i:s',strtotime('+48 hour',strtotime($detail_ticket['date']))); $requisition_date = new DateTime($detail_ticket['requisition_date']);
$courant_date = date('Y-m-d H:i:s'); $max_date = getMaxTicketValidationDateTime($requisition_date);
$courant_date = new DateTime(); // current datetime
if (!(in_array($detail_ticket['itilcategories_id'], $itilcategories_ids))
|| $max_date >= $courant_date) {
$form_url = $item['type']::getFormURL();
echo "<form id='validationanswers_id_{$item_i['id']}' class='center' action='$form_url' method='post'>";
echo Html::hidden('id', ['value' => $item_i['id']]);
echo Html::hidden('users_id_validate', ['value' => $item_i['users_id_validate']]);
Html::textarea([
'name' => 'comment_validation',
'rows' => 5
]);
echo "<button type='submit' class='submit approve' name='approval_action' value='approve'>";
echo "<i class='far fa-thumbs-up'></i>&nbsp;&nbsp;".__('Approve')."</button>";
echo "<button type='submit' class='submit refuse very_small_space' name='approval_action' value='refuse'>";
echo "<i class='far fa-thumbs-down'></i>&nbsp;&nbsp;".__('Refuse')."</button>";
Html::closeForm();
} else {
if(in_array($detail_ticket['itilcategories_id'],$itilcategories_ids)){
if($date_fin <= $courant_date){
$item_i['can_answer'] = 0; $item_i['can_answer'] = 0;
$validateur_res = explode("=>", $item_i['content']);
echo '<style> echo '<style>
.alert { .alert {
position: relative; position: relative;
@ -7415,32 +7434,11 @@ abstract class CommonITILObject extends CommonDBTM {
} }
</style>'; </style>';
echo '<div class="alert alert-danger" role="alert"> echo '<div class="alert alert-danger" role="alert">
'.get_fullname_user($item_i['users_id_validate']).' => vous avez dépassé le délai<strong> de validation</strong> (48 hours) vous avez dépassé le délai<strong> de validation</strong> (48 hours)
</div>'; </div>';
} }
}
}
*/
//sophal
if (strpos($item['type'], 'Validation') > 0 &&
(isset($item_i['can_answer']) && $item_i['can_answer'])) {
$form_url = $item['type']::getFormURL();
echo "<form id='validationanswers_id_{$item_i['id']}' class='center' action='$form_url' method='post'>";
echo Html::hidden('id', ['value' => $item_i['id']]);
echo Html::hidden('users_id_validate', ['value' => $item_i['users_id_validate']]);
Html::textarea([
'name' => 'comment_validation',
'rows' => 5
]);
echo "<button type='submit' class='submit approve' name='approval_action' value='approve'>";
echo "<i class='far fa-thumbs-up'></i>&nbsp;&nbsp;".__('Approve')."</button>";
echo "<button type='submit' class='submit refuse very_small_space' name='approval_action' value='refuse'>";
echo "<i class='far fa-thumbs-down'></i>&nbsp;&nbsp;".__('Refuse')."</button>";
Html::closeForm();
} }
if ($item['type'] == 'Solution' && $item_i['status'] != CommonITILValidation::WAITING && $item_i['status'] != CommonITILValidation::NONE) { if ($item['type'] == 'Solution' && $item_i['status'] != CommonITILValidation::WAITING && $item_i['status'] != CommonITILValidation::NONE) {
echo "<div class='users_id_approval' id='users_id_approval_".$item_i['users_id_approval']."'>"; echo "<div class='users_id_approval' id='users_id_approval_".$item_i['users_id_approval']."'>";