Add requisition date field in HR ticket

This commit is contained in:
Kheireddine Mehdi
2025-11-10 11:54:33 +01:00
parent 5c733eac6b
commit e95c3630bd
2 changed files with 79 additions and 164 deletions

View File

@ -91,6 +91,8 @@
$isBLMP = false;
$requisition_date = "";
$last_generated_Sequence_bl = last_generated_Sequence('bon de livraison ac')+1 ;
@ -111,54 +113,27 @@
case 0: //BULLETIN DE SORTIE
// Get the submitted date
$bs_date_sortir = $_POST['bs_date_sortir'];
// Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d');
if ($bs_date_sortir < $current_date) {
$_SESSION["bs_date_sortir"] = $bs_date_sortir;
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([
'is_valid' => false,
'modele' => $_SESSION['modele']
]);
return ;
}
unset($_SESSION["bs_date_sortir"]);
$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;
@ -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;';
$requisition_date = $_POST['bs_date_sortir'];
break;
@ -272,20 +245,13 @@
case 3://Autorisation d'absence
// Get the submitted date
$aa_date_absenter = $_POST['aa_date_absenter'];
// Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d');
if ($aa_date_absenter < $current_date) {
@ -312,66 +278,42 @@
}
unset($_SESSION["aa_date_absenter"]);
$name = "Autorisation d'absence";
$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'].'';
$requisition_date = $_POST['aa_date_absenter'];
break;
case 4://AUTORISATION D'ENTREE
// Get the submitted date
$ae_date_reprendre = $_POST['ae_date_reprendre'];
// Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d');
if ($ae_date_reprendre < $current_date) {
$_SESSION["ae_date_reprendre"] = $ae_date_reprendre;
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([
'is_valid' => false,
'modele' => $_SESSION['modele']
]);
return ;
}
unset($_SESSION["ae_date_reprendre"]);
@ -382,6 +324,8 @@
<br>Est autorisé (e) de reprendre à : '.$_POST['ae_date_reprendre'].'<br> Commentaire : '.$_POST['ae_commentaire'];
$requisition_date = $_POST['ae_date_reprendre'];
break;
@ -401,22 +345,12 @@
// Get the submitted date
$date_req = $_POST['date_req'];
// Get the current date in 'Y-m-d' format
$current_date = date('Y-m-d');
// 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) {
if ($date_req < $current_date) {
@ -430,28 +364,18 @@
$_SESSION["lieu_de_travail"] = $_POST['lieu_de_travail'];
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([
'is_valid' => false,
'modele' => $_SESSION['modele']
]);
return ;
}
unset($_SESSION["date_req"]);
unset($_SESSION["mot_req"]);
@ -464,10 +388,6 @@
$name = "HEURES SUPPLEMENTAIRES";
$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'];
$requisition_date = $_POST['date_req'];
break;
case 7://DEMANDE ORDRE DE MISSION
$name = "DEMANDE ORDRE DE MISSION";
@ -496,32 +416,21 @@
case 8://CONGE DE RECUPERATION
$cr_date_debut = $_POST['cr_date_debut'];
$cr_date_fin = $_POST['cr_date_fin'];
$current_date = date('Y-m-d');
if ($cr_date_debut < $current_date || $cr_date_fin < $cr_date_debut) {
$_SESSION["cr_date_debut"] = $cr_date_debut;
$_SESSION["cr_date_fin"] = $cr_date_fin;
Session::addMessageAfterRedirect(__('VOUS N\'ETES PAS PERMIS'),false, ERROR);
echo json_encode([
'is_valid' => false,
@ -529,21 +438,12 @@
'modele' => $_SESSION['modele']
]);
return ;
}
unset($_SESSION["cr_date_debut"]);
unset($_SESSION["cr_date_fin"]);
$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_6']) && $_POST['cr_date_6'] != '') $table = $table.",".$_POST['cr_date_6'];
$requisition_date = $_POST['cr_date_debut'];
break;
case 9://Work Order
@ -692,6 +594,7 @@
}
break;
case 14:
// Get the submitted data
$ap_date = $_POST['ap_date'];
@ -777,6 +680,8 @@
$name = "Autorisation de paie";
$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'];
$requisition_date = $_POST['ap_date'];
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();

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;
$stmt = $DB->prepare("INSERT INTO `glpi_tickets` (`date`, `type`, `itilcategories_id`, `entities_id`, `status`,
if ($requisition_date) {
// With 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())");
`priority`, `name`, `content`, `id`, `users_id_lastupdater`,
`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(), ?)
");
$stmt->bind_param("issiis", $id_categorie, $name, $table, $glpiID, $glpiID, $requisition_date);
} 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->execute();
}
function isValidConge($tickets_id){
global $DB;
@ -959,7 +969,7 @@
WHEN t.status = 2 THEN 'En cours'
WHEN t.status = 3 THEN 'En cours'
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'
END AS status,
t.name as ticket_name,
@ -987,7 +997,7 @@
WHEN t.status = 2 THEN 'En cours'
WHEN t.status = 3 THEN 'En cours'
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'
END AS status,
t.name as ticket_name,