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;
@ -268,24 +241,17 @@
Adresse durant le Congé :&lt;/strong&gt;&lt;/td&gt;&lt;td style="width: 60.624%; height: 17px;"&gt; '.$_POST['dc_adresse'].'&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;'; Adresse durant le Congé :&lt;/strong&gt;&lt;/td&gt;&lt;td style="width: 60.624%; height: 17px;"&gt; '.$_POST['dc_adresse'].'&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;';
break; break;
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'].'';
break; $requisition_date = $_POST['aa_date_absenter'];
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,17 +324,19 @@
<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'];
break; $requisition_date = $_POST['ae_date_reprendre'];
break;
case 5://DEMANDE DE RECRUTEMENT case 5://DEMANDE DE RECRUTEMENT
$name = "DEMANDE DE RECRUTEMENT"; $name = "DEMANDE DE RECRUTEMENT";
$table ='matricule : '.$_POST['matricule'].'<br>fonction : '.$_POST['fonction'].'<br>structure : '.$_POST['structure'].'<br><br>description : '.$_POST['description']; $table ='matricule : '.$_POST['matricule'].'<br>fonction : '.$_POST['fonction'].'<br>structure : '.$_POST['structure'].'<br><br>description : '.$_POST['description'];
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
@ -579,9 +481,9 @@
$isWorkOrder = true; $isWorkOrder = true;
break; break;
case 10: case 10:
$isBLAC = true; $isBLAC = true;
@ -609,9 +511,9 @@
} }
break; break;
case 11: case 11:
$name = "Demande de congé statutaire"; $name = "Demande de congé statutaire";
@ -631,39 +533,39 @@
Intérimaire :&lt;/strong&gt;&lt;/td&gt;&lt;td style="width: 60.624%; height: 17px;"&gt; '.$_POST['dcs_interimaire'].'&lt;/td&gt;&lt;/tr&gt;&lt;tr style="height: 17px;"&gt;&lt;td style="width: 39.376%; height: 17px;"&gt;&lt;strong&gt;'; Intérimaire :&lt;/strong&gt;&lt;/td&gt;&lt;td style="width: 60.624%; height: 17px;"&gt; '.$_POST['dcs_interimaire'].'&lt;/td&gt;&lt;/tr&gt;&lt;tr style="height: 17px;"&gt;&lt;td style="width: 39.376%; height: 17px;"&gt;&lt;strong&gt;';
break; break;
case 12: case 12:
$isBCPROD = true; $isBCPROD = true;
$name = "Production : Bon De Commande"; $name = "Production : Bon De Commande";
$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>'.'
<br>N° de Piece : BC PROD'.str_pad($last_generated_Sequence_bc , 6, '0', STR_PAD_LEFT).'/'.(date("y")).'<br>Hangar : '.$_POST['acbc_reference'].'<br><br>'; <br>N° de Piece : BC PROD'.str_pad($last_generated_Sequence_bc , 6, '0', STR_PAD_LEFT).'/'.(date("y")).'<br>Hangar : '.$_POST['acbc_reference'].'<br><br>';
$nbr = count($_POST["designation"]); $nbr = count($_POST["designation"]);
for($i=0;$i < $nbr ;$i++){ for($i=0;$i < $nbr ;$i++){
$table = $table.' '.$_POST['type'][$i].': <br>&nbsp;&nbsp;&nbsp; Désignation : '. $table = $table.' '.$_POST['type'][$i].': <br>&nbsp;&nbsp;&nbsp; Désignation : '.
$_POST['designation'][$i].'<br>&nbsp;&nbsp;&nbsp; N° Lot : '. $_POST['designation'][$i].'<br>&nbsp;&nbsp;&nbsp; N° Lot : '.
$_POST['lot'][$i].'<br>&nbsp;&nbsp;&nbsp; Quantité Livrée : '. $_POST['lot'][$i].'<br>&nbsp;&nbsp;&nbsp; Quantité Livrée : '.
$_POST['quantite'][$i].' <br>&nbsp;&nbsp;&nbsp; Observations : '. $_POST['quantite'][$i].' <br>&nbsp;&nbsp;&nbsp; Observations : '.
$_POST['obs'][$i].' <br>&nbsp;&nbsp;&nbsp;'. $_POST['obs'][$i].' <br>&nbsp;&nbsp;&nbsp;'.
'<br>'; '<br>';
} }
break; break;
case 13: case 13:
$isBLMP = true; $isBLMP = true;
@ -691,8 +593,9 @@
} }
break; break;
case 14:
case 14:
// Get the submitted data // Get the submitted data
$ap_date = $_POST['ap_date']; $ap_date = $_POST['ap_date'];
$ap_start_time = $_POST['ap_start_time']; $ap_start_time = $_POST['ap_start_time'];
@ -777,7 +680,9 @@
$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'];
break;
$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(); $tickets_id = $DB->insert_id();

View File

@ -514,27 +514,37 @@
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`,
`requesttypes_id`, `urgency`, `impact`, `locations_id`,
`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();
}
$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();
}
@ -690,7 +700,7 @@
function get_detail_ticket($id_ticket){ function get_detail_ticket($id_ticket){
@ -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,
@ -1096,7 +1106,7 @@
// closing hr tickets after 2 days // closing hr tickets after 2 days
function close_hr_tickets(){ function close_hr_tickets(){
global $DB; global $DB;
$stmt = $DB->prepare("update glpi_tickets set status = 6 , closedate = now() where id in ( SELECT $stmt = $DB->prepare("update glpi_tickets set status = 6 , closedate = now() where id in ( SELECT