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; $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

@ -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;
@ -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,