Files
MYSOPHAL/front/drh.demandes.php
2025-08-07 13:15:31 +01:00

4790 lines
56 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use Glpi\Event;
include ('../inc/includes.php');
Session::checkLoginUser();
require_once '../functionsophalglpi.php';
$modele =addslashes($_GET['modele']);
$type = isset($_GET['type']) ? addslashes($_GET['type']) : '';
//Security - Get Variables
if(isset($modele) ){
if( filter_var($modele, FILTER_VALIDATE_INT)=== 0 || !filter_var($modele, FILTER_VALIDATE_INT)=== FALSE){
if( $modele > 14 or $modele < 0){Html::redirect($CFG_GLPI["root_doc"]."/front/ticket.php");}
}else{
Html::redirect($CFG_GLPI["root_doc"]."/front/ticket.php");
}
}else if (!isset($modele)){
Html::redirect($CFG_GLPI["root_doc"]."/front/ticket.php");
}
if( ($_SESSION['glpiactiveprofile']['name'] == "Self-Service" || $_SESSION['glpiactiveprofile']['name'] == "Utilisateur-standard") && $modele == 7){
Html::redirect($CFG_GLPI["root_doc"]."/front/ticket.php");
}
if (Session::getCurrentInterface() == "helpdesk") {
Html::helpHeader("DRH", '', $_SESSION["glpiname"]);
} else {
Html::header("DRH", '', "", "");
}
$title = array("Bulletin de sortie", "Requete Administrative", "Demande de conge" ,"Autorisation d'absence"
,"Autorisation d'entree" , "DEMANDE DE RECRUTEMENT" , "Heures supplémentaires" ,"Demande d'ordre de mission" ,"Congé de récupération"
, "Work Order Form", "AC : Bon De Livraison", "Demande de congé Statutaire","Production : Bon De Commande","MP : Bon De Livraison","Autorisation de paie");
$unites = array("U1", "U2", "U3", "U4", "U5", "U6");
$famtype = array("Matieres Premieres","Etuis","Notices","Aluminium","PVC","Cartons d'emballages","Vignettes"," Etiquettes carton"
,"Scotch","Etiquettes flacon","Injectable","Sirop","Collyre");
$famtypeMp = array("API","Excipient","Gelule","Désinfectant","Injectable");
$congeValues = array("1-Mon mariage","2-Naissance dun enfant","3-Mariage de lun des descendants (enfants)"
,"4-Décès dascendant (Mère, grande mère, Père, \ngrand père), descendant (Enfants), collatéral
\n(frère, sœur) du travailleur ou de son conjoint","5-Décès du conjoint","6-Circoncision dun enfant du travailleur"
,"7-Mariage dun collatéral du travailleur (frère, sœur)","8-Décès de lun des ascendants (neveu, nièce),\n
(enfants du fils /ou fille du travailleur),\n de la petite famille (oncle)"
,"9-Le retour des parents des lieux saint (petit et grand pèlerinage)");
// $list = getUserHierarchy($_SESSION["glpiID"]);
// print_r($list);
// To check if we are in active payroll period
function ActivePayrollPeriode(){
global $DB;
// Get the current date
$current_date = date("Y-m-d");
// Prepare the SQL query to get the latest payroll period
$query = $DB->prepare("SELECT start_date, end_date FROM payroll_period where is_deleted = FALSE ORDER BY year DESC, month DESC, id DESC LIMIT 1");
$query->execute();
$query->bind_result($start_date, $end_date);
$query->fetch();
$query->close();
// If there is no active payroll period, return false
if (!$start_date || !$end_date) {
return false;
}
// Convert the dates to the same format for comparison (Y-m-d)
$start_date = date("Y-m-d", strtotime($start_date));
$end_date = date("Y-m-d", strtotime($end_date));
// Check if the current date is within the start and end date range
if ($current_date >= $start_date && $current_date <= $end_date) {
return true; // Current date is within the active payroll period
}
return false; // Current date is outside the active payroll period
}
// limiter les autorisations(pas plus que 02 fois par mois).
function CountAutorisationByMonthAndYear($modele){
global $DB;
//modele => itilcategories_id
$modele_to_itilcategories_id= array(0=>12, 3=>15, 4=>16, 14=>72 );
$currentDate = new DateTime();
$year = $currentDate->format("Y");
$month = $currentDate->format("m");
$query = "SELECT count(*) as ligne FROM glpi_tickets , glpi_tickets_users
WHERE glpi_tickets.id = glpi_tickets_users.tickets_id
AND glpi_tickets.itilcategories_id = ".$modele_to_itilcategories_id[$modele]."
AND glpi_tickets_users.type = 1
AND EXTRACT(YEAR FROM glpi_tickets.date) = ".$year."
AND EXTRACT(MONTH FROM glpi_tickets.date) = ".$month."
AND glpi_tickets_users.users_id = ".$_SESSION["glpiID"]."
AND glpi_tickets.is_deleted = 0";
$result = $DB->query($query);
if ($result->num_rows > 0) {
$res = $result->fetch_assoc();
return $res['ligne'];
}
return null;
}
function CountPayAutorisation() {
global $DB;
// Get the latest payroll period
$query = $DB->prepare("SELECT start_date, end_date FROM payroll_period WHERE is_deleted = FALSE ORDER BY year DESC, month DESC, id DESC LIMIT 1");
$query->execute();
$query->bind_result($start_date, $end_date);
$query->fetch();
$query->close();
// Convert to Y-m-d format
$start_date = date("Y-m-d", strtotime($start_date));
$end_date = date("Y-m-d", strtotime($end_date));
// Secure query with prepared statements
$query = $DB->prepare("
SELECT COUNT(*) as ligne
FROM glpi_tickets
INNER JOIN glpi_tickets_users ON glpi_tickets.id = glpi_tickets_users.tickets_id
WHERE glpi_tickets.itilcategories_id = ?
AND glpi_tickets_users.type = 1
AND DATE(glpi_tickets.date) BETWEEN ? AND ?
AND glpi_tickets_users.users_id = ?
AND glpi_tickets.is_deleted = 0
");
// Bind parameters
$itil_category_id = 72;
$user_id = $_SESSION["glpiID"];
$query->bind_param("issi", $itil_category_id, $start_date, $end_date, $user_id);
$query->execute();
// Fetch the result
$result = $query->get_result();
$row = $result->fetch_assoc();
$query->close();
return $row ? $row['ligne'] : null;
}
function getfullnameResponsable($idResponsable){
global $DB;
$stmt = $DB->prepare("SELECT id , CONCAT(realname,' ', firstname) as fullname from glpi_users where id = ? ");
$stmt->bind_param("i",$idResponsable);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$Responsable = $result->fetch_array(MYSQLI_ASSOC);
}else{
$Responsable['fullname'] = null;
$Responsable['id'] = null;
}
return $Responsable;
}
function getInformationUser(){
global $DB;
$query = "SELECT registration_number as matricule , realname as nom , firstname as prenom , users_id_supervisor as idResponsable from glpi_users where id ='".$_SESSION["glpiID"]."' ";
$result = $DB->query($query);
if ($result->num_rows > 0) {
$InformationUser = $result->fetch_assoc();
// print_r( $InformationUser);
}
return $InformationUser;
}
function getFonction(){
global $DB;
$query = "SELECT picklist.value as fonction from glpi_users , picklist where glpi_users.id_fonction = picklist.id and glpi_users.id ='".$_SESSION["glpiID"]."' ";
$result = $DB->query($query);
if ($result->num_rows > 0) {
$fonction = $result->fetch_assoc();
}
if(!empty($fonction['fonction'])){
return $fonction['fonction'];
}else{
return $fonction = "";
}
}
function getStructure(){
global $DB;
$query = "SELECT picklist.value as structure from glpi_users , picklist
where glpi_users.id_structure = picklist.id and glpi_users.id ='".$_SESSION["glpiID"]."' ";
$result = $DB->query($query);
if ($result->num_rows > 0) {
$structure = $result->fetch_assoc();
}
if(!empty($structure['structure'])){
return $structure['structure'];
}else{
return $structure ="";
}
}
$InformationUser = getInformationUser();
$Responsable = getfullnameResponsable( $InformationUser['idResponsable'] );
$fonction = getFonction() ;
$structure = getStructure();
if(isset($Responsable['id'])){
$_SESSION['idResponsable'] = $Responsable['id'];
}else{
$_SESSION['idResponsable'] = null;
}
$_SESSION['modele'] = $modele ;
$_SESSION['InformationUser'] = $InformationUser;
echo "<style>
#messageBar {
opacity: 0.5;
background-color: white;
z-index: 100000;
position: fixed;
top: 0px;
width: 100%;
height: 100%;
}
.alert-danger {
color: #842029;
background-color: #f8d7da;
border-color: #f5c2c7;
}
.alert {
position: relative;
padding: 1rem 1rem;
margin-bottom: 1rem;
border: 1px solid transparent;
border-radius: 0.25rem;
}
.tab_cadre_fixe th{
background: #0d6efd;
color:white;
}
.ui-widget input{
display: block !important;
height: calc(0.1em + .5rem + 2px) !important;
padding: .375rem .75rem !important;
font-size: 0.75rem !important;
font-weight: 400 !important;
line-height: 1.5 !important;
color: #495057 !important;
background-color: #fff !important;
background-clip: padding-box !important;
border: 1px solid #ced4da !important;
border-radius: .25rem !important;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out !important;
font-weight:600 !important;
}
.tab_cadre_fixe td{
font-size:0.75rem;
}
.vsubmit{
display: inline-block;
width:80%;
font-weight: 600;
line-height: 1.5;
color: #212529;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
background-color: transparent;
border: 2px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
border-radius: .25rem;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
color: #0d6efd;
border-color: #0d6efd;
margin-top:20px;
}
.vsubmit:hover{
color: #fff;
background-color: #0d6efd;
border-color: #0d6efd;
}
.input-date{
display:none !important;
}
.input-date-shown{
display:inline-masonry !important;
}
.form-select {
display: block;
width: 100%;
padding: .375rem 2.25rem .375rem .75rem;
-moz-padding-start: calc(0.75rem - 3px);
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
background-color: #fff;
background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e\");
background-repeat: no-repeat;
background-position: right .75rem center;
background-size: 16px 12px;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-repeat: no-repeat;
}
</style>";
echo "<div id='messageBar' style='display: none;'>
<div style='text-align:center;position:fixed;top:50%;left:40%;'>
<img src='../file_upload/loading.gif'>
</div>
</div>";
echo "<div id='tabs1216654411' class='center vertical ui-tabs ui-corner-all ui-widget ui-widget-content ui-tabs-vertical ui-helper-clearfix ui-corner-left'>
<div id='ui-id-3' style=' margin-left: 0px; ' aria-live='polite' aria-labelledby='ui-id-2' role='tabpanel' class='ui-tabs-panel ui-corner-bottom ui-widget-content' aria-hidden='false'>
<br>
<form id='form' name='form' method='post' action='".$CFG_GLPI["root_doc"]."/front/drh.demandes.form.php' enctype='multipart/form-data'>
<input type='hidden' name='entities_id' value='0'>
<div class='spaced' id='tabsbody'>";
if($_GET['modele'] == 2){
$mat = getMatricule();
if(isset($mat) && !empty($mat)){
$res = callWebService($mat , 'get_reliquat_conge');
if( $res === false){
echo "<script>if (window.confirm('Serveur Introuvable , veuillez contacter votre administrateur système'))
{history.go(-1) ;}else{ history.go(-1) ;};</script>";
}else{
//supprimer UTF-8-BOM
for ($i = 0; $i <= 31; ++$i) {
$res = str_replace(chr($i), "", $res);
}
$res = str_replace(chr(127), "", $res);
if (0 === strpos(bin2hex($res), 'efbbbf')) {
$res = substr($res, 3);
}
//supprimer UTF-8-BOM
$res = json_decode( $res,true);
$sum = 0;
echo'<table class="tab_cadre_fixehov">
<tr>
<th style="text-align: center;">Exercice</th>
<th style="text-align: center;">Reliquat</th>
</tr>
<tbody>';
if($res != null){
for ($o = 0 ; $o < count($res) ;$o++) {
echo'
<tr class="tab_bg_1">
<td style="text-align: center;">'.$res[$o]['Exercice'].'</td>
<td style="text-align: center;">'.number_format($res[$o]['Reliquat'], 2, '.', '').'</td>
</tr>';
$sum =$sum + $res[$o]['Reliquat'];
}
}
echo' <tr class="headerRow">
<th class="">Reliquat De Congé : '.$sum.' jours</th>
<input type="hidden" name="max_jour" value="'.$sum.'">
<th class=""></th>
</tr>
</tbody>
</table>
<br>';
$dc_nbr_jour = $sum;
}
}
}
if($modele == 4){
if(CountAutorisationByMonthAndYear($modele) >= 2){
echo"<div class='alert alert-danger' role='alert'>
Vous ne disposez que deux <strong>".$title[$modele]."</strong> par mois
</div>";
}
}
if($modele == 0 || $modele == 3){
if(CountAutorisationByMonthAndYear(0) + CountAutorisationByMonthAndYear(3) >= 2){
echo"<div class='alert alert-danger' role='alert'>
Vous ne disposez que de deux <strong>".$title[0]." et ".$title[3]."</strong> en Total par mois
</div>";
}
}
if ($modele == 14) {
if (!ActivePayrollPeriode()) {
echo "<div class='alert alert-danger' role='alert'>
Vous n'êtes pas dans la période de paye.
</div>";
} else if (CountPayAutorisation() >=1){
echo"<div class='alert alert-danger' role='alert'>
Vous ne disposez que une seule <strong>".$title[$modele]."</strong> par mois
</div>";
}
}
$_SESSION['token'] = Session::getNewCSRFToken();
echo"<table class='tab_cadre_fixe' id='mainformtable'>
<tbody>
<tr class='headerRow'>
<th colspan='2' class=''>".$title[$modele]."</th>
<th colspan='2' class=''>".date("Y-m-d")."</th>
<input type='hidden' id='_glpi_csrf_token' name='_glpi_csrf_token' value='".$_SESSION['token']."'>
</tr>
<tr class=''>
<td width='20%'>Matricule : </td>
<td width='30%'>
<input id='matricule' type='text' name='matricule' value='".$InformationUser['matricule']."' required readonly>
</td>
<td width='20%'>Responsable hiérarchique : <span style='color:red'>*</span></td>
<td width='30%'>
<input style='width:80%;' id='responsable' type='text' name='responsable' value='".$Responsable['fullname']."' readonly>
</td>
</tr>
<tr class=''>
<td width='20%'>Nom : <span style='color:red'>*</span></td>
<td width='30%'>
<input style='width:80%;' id='nom' type='text' name='nom' value='".$InformationUser['nom']."' readonly>
</td>
<td width='20%'>Prénom : <span style='color:red'>*</span></td>
<td width='30%'>
<input style='width:80%;' id='prenom' type='text' name='prenom' value='".$InformationUser['prenom']."' readonly>
</td>
</tr>
<tr class=''>
<td width='20%'>Fonction : </td>
<td width='30%'>
<input style='width:80%;' id='fonction' type='text' name='fonction' value='".$fonction."' readonly>
</td>
<td width='20%'>Structure : </td>
<td width='30%'>
<input style='width:80%;' id='structure' type='text' name='structure' value='".$structure."' readonly>
</td>
</tr>";
if(!isset($dc_nbr_jour)) $dc_nbr_jour =0;
modeles($modele,$dc_nbr_jour,$type);
if($modele == 0 || $modele == 3){
if(CountAutorisationByMonthAndYear(0) + CountAutorisationByMonthAndYear(3) < 2){
echo"<tr class='tab_bg_2'>
<td class='center' colspan='4'>
<div class='center'>
<button name='add' class='vsubmit'><i class='fas fa-plus'></i>&nbsp;Ajouter </button>
</div>
</td>
</tr>";
}
}else if($modele == 4){
if(CountAutorisationByMonthAndYear($modele) < 2){
echo"<tr class='tab_bg_2'>
<td class='center' colspan='4'>
<div class='center'>
<button name='add' class='vsubmit'><i class='fas fa-plus'></i>&nbsp;Ajouter </button>
</div>
</td>
</tr>";
}
}else if ($modele == 14) {
if (ActivePayrollPeriode() && CountPayAutorisation() < 1) {
echo"<tr class='tab_bg_2'>
<td class='center' colspan='4'>
<div class='center'>
<button name='add' class='vsubmit'><i class='fas fa-plus'></i>&nbsp;Ajouter </button>
</div>
</td>
</tr>";
}
}else{
echo"<tr class='tab_bg_2'>
<td class='center' colspan='4'>
<div class='center'>
<button name='add' class='vsubmit'><i class='fas fa-plus'></i>&nbsp;Ajouter </button>
</div>
</td>
</tr>";
}
echo"</tbody>
</table>
</div>
</form>
</div>
</div>";
if (Session::getCurrentInterface() == "helpdesk") {
Html::helpFooter();
} else {
Html::footer();
}
function modeles($modele ,$dc_nbr_jour, $type ){
global $unites;
global $famtype;
global $famtypeMp;
global $congeValues;
if(isset($modele)){
echo "<script>console.log('modele : ', " . json_encode($modele) . ");</script>";
switch ($modele) {
case 0:
echo" <tr class=''>
<td width='20%'>Est autorisé (e) de sortir le : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='bs_date_sortir' value='".(isset($_SESSION["aa_date_absenter"]) != null ? $_SESSION["aa_date_absenter"] : '' )."' id='date' min=".date('Y-m-d', strtotime(date('Y-m-d')))." autocomplete='off' required>
</td>
<td width='20%'>A : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='text' name='bs_heure' value='' autocomplete='off' required>
Heures
</td>
</tr>
<tr>
<td width='20%'>Pour affaire Personnelle : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='bs_affaire_personnelle' value='' autocomplete='off'></td>
</tr>";
break;
case 1:
$val = array("Certificat de travial (accompagné d'un bulletin de paie et attestaion de travail N° de Tél)");
echo'<tr class="">
<td width="20%">Demande : <span style="color:red">*</span></td>
<td width="30%">
<table>
<tr>
<td><input type="radio" id="1" name="ra_demande" value="Attestation de travail" style="border: 1px solid red; display: block;"></td>
<td><label for="1">Attestation de travaill</label><br></td>
</tr>
</table>
</td>
</tr>
<tr class="">
<td width="20%"></td>
<td width="30%">
<table>
<tr>
<td><input type="radio" id="2" name="ra_demande" value="Attestation de salarié CNAS (CHIFAA)" style="border: 1px solid red; display: block;" ></td>
<td><label for="2">Attestation de salarié CNAS (CHIFAA)</label><br></td>
</tr>
<tr>
<td><input type="radio" id="3" name="ra_demande" value="Demande de congé signé par le responsable" style="border: 1px solid red; display: block;"></td>
<td><label for="3">Demande de congé signé par le responsable</label><br></td>
</tr>
<tr>
<td><input type="radio" id="4" name="ra_demande" value="'.$val[0].'" style="border: 1px solid red; display: block;"></td>
<td><label for="4">Certificat de travail (accompagné d"un bulletin de paie et attestaion de travail N° de Tél)</label><br></td>
</tr>
<tr>
<td><input type="radio" id="5" name="ra_demande" value="Demande d&#39;allocations familiales" style="border: 1px solid red; display: block;" required></td>
<td><label for="5">Demande d&#39;allocations familiales</label><br></td>
</tr>
<tr>
<td><input type="radio" id="6" name="ra_demande" value="Autres" style="border: 1px solid red; display: block;" required></td>
<td><label for="6">Autres</label><br></td>
</tr>
</table>
</td>
</tr>
<tr class="">
<td rowspan="4" class="middle"><label for="Autres">Préciser</label></td>
<td class="center middle" rowspan="4"><textarea cols="45" rows="6" id="Autres" name="ra_autres"></textarea></td>
</tr> ';
break;
case 2:
echo" <tr class=''>
<td width='20%'>Nombre de jours : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='number' min='7' max='{$dc_nbr_jour}' name='dc_nbr_jour' value='' autocomplete='off' required>
</td>
<td width='20%'>Exercice : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='text' name='dc_exercice' value='' autocomplete='off' required>
</td>
</tr>
<tr class=''>
<td width='20%'>Date de Départ : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='dc_date_depart' value='' min=".date('Y-m-d', strtotime(date('Y-m-d'). ' + 5 days'))." autocomplete='off' required>
</td>
<td width='20%'>Intérimaire : </td>
<td width='30%'>
<input type='text' name='dc_interimaire' value='' autocomplete='off'>
</td>
</tr>
<tr>
<td width='20%'>Adresse durant le Congé : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='dc_adresse' value=''></td>
</tr>"
;
break;
case 3:
echo" <tr class=''>
<td width='20%'>Est autorisé (e) à s'absenter la journée du : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='aa_date_absenter' value='".(isset($_SESSION["aa_date_absenter"]) != null ? $_SESSION["aa_date_absenter"] : '' )."' min=".date('Y-m-d', strtotime(date('Y-m-d')))." autocomplete='off' required>
</td>
</tr>
<tr>
<td width='20%'>commentaire : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='aa_commentaire' value='' autocomplete='off'></td>
</tr>" ;
break;
case 4:
echo" <tr class=''>
<td width='20%'>Est autorisé (e) de reprendre à : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='ae_date_reprendre' value='".(isset($_SESSION["ae_date_reprendre"]) != null ? $_SESSION["ae_date_reprendre"] : '' )."' min=".date('Y-m-d', strtotime(date('Y-m-d')))." autocomplete='off' required>
</td>
</tr>
<tr>
<td width='20%'>commentaire : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='ae_commentaire' value='' autocomplete='off'></td>
</tr>" ;
break;
case 5:
echo" <tr class='tab_bg_2'>
<td>Description</td>
<td colspan='3'>";
Html::textarea([
'name' => "description",
'enable_richtext' => true,
'required' => 1
]);
echo"</td></tr>";
break;
case 6:
echo" <tr class=''>
<td width='20%'>Date de réquisition : <span style='color:red'>*</span></td>
<td width='30%'>
<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>
</td>
<td width='20%'>Le motif de la réquisition : <span style='color:red'>*</span></td>
<td width='30%'>
<input style='width:80%;' type='text' name='mot_req' value='".(isset($_SESSION["mot_req"]) != null ? $_SESSION["mot_req"] : '' )."' autocomplete='off' required>
</td>
</tr>
<tr class=''>
<td width='20%'>Heure de début : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='text' name='heure_d' value='".(isset($_SESSION["heure_d"]) != null ? $_SESSION["heure_d"] : '' )."' autocomplete='off' required>
</td>
<td width='20%'>Heure de fin : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='text' name='heure_f' value='".(isset($_SESSION["heure_f"]) != null ? $_SESSION["heure_f"] : '' )."' autocomplete='off' required>
</td>
</tr>
<tr>
<td width='20%'>Lieu de travail (Heures supplémentaires) : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='lieu_de_travail' value='".(isset($_SESSION["lieu_de_travail"]) != null ? $_SESSION["lieu_de_travail"] : '' )."'></td>
</tr>"
;
break;
case 7:
echo" <tr class=''>
<td width='20%'>Date de départ : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' min='1' name='date_de_depart' value='' autocomplete='off' required>
</td>
<td width='20%'>Destination : <span style='color:red'>*</span></td>
<td width='30%'>
<input style='width:80%;' type='text' name='destination' value='' autocomplete='off' required>
</td>
</tr>
<tr class=''>
<td width='20%'>Date de retour : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='date_de_retour' value='' autocomplete='off' required>
</td>
<td width='20%'>Moyens de Transport : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='text' name='moy_transport' value='' autocomplete='off' required>
</td>
</tr>
<tr>
<td width='20%'>Objet de la mission : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='ob_mission' value=''></td>
</tr>"
;
break;
case 8:
echo "<tr class=''>
<td width='20%'>De : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='cr_date_debut' onChange='calcDiffDate();updateMaxDate();' value='' min=" . date('Y-m-d', strtotime(date('Y-m-d'))) . " autocomplete='off' required>
</td>
<td width='20%'>A : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='cr_date_fin' value='' onChange='calcDiffDate()' min=" . date('Y-m-d', strtotime(date('Y-m-d'))) . " autocomplete='off' required>
</td>
</tr>
<tr colspan='4'>
<td colspan='4'>
<div style='width:100%;display:block;margin:auto;height:2px;border-bottom:3px dotted blue;'></div>
</td>
</tr>
<tr class='tr-input-date input-date'>
<td>
<h3 style='color:#0d6efd'>Les jours à consommer</h3>
</td>
</tr>
<tr class='tr-input-date input-date'>
<td width='20%'>Date 1 : <span style='color:red'>*</span></td>
<td colspan='3'>
<input type='date' name='cr_date_1' class='form-control date_picker' max=" . date('Y-m-d', strtotime(date('Y-m-d'))) . " value='' autocomplete='off' required>
</td>
</tr>
<tr class='tr-input-date input-date'>
<td width='20%'>Date 2 : <span style='color:red'>*</span></td>
<td colspan='3'>
<input type='date' name='cr_date_2' class='form-control date_picker' max=" . date('Y-m-d', strtotime(date('Y-m-d'))) . " value='' autocomplete='off'>
</td>
</tr>
<tr class='tr-input-date input-date'>
<td width='20%'>Date 3 : <span style='color:red'>*</span></td>
<td colspan='3'>
<input type='date' name='cr_date_3' class='form-control date_picker' max=" . date('Y-m-d', strtotime(date('Y-m-d'))) . " value='' autocomplete='off'>
</td>
</tr>
<tr class='tr-input-date input-date'>
<td width='20%'>Date 4 : <span style='color:red'>*</span></td>
<td colspan='3'>
<input type='date' name='cr_date_4' class='form-control date_picker' max=" . date('Y-m-d', strtotime(date('Y-m-d'))) . " value='' autocomplete='off'>
</td>
</tr>
<tr class='tr-input-date input-date'>
<td width='20%'>Date 5 : <span style='color:red'>*</span></td>
<td colspan='3'>
<input type='date' name='cr_date_5' class='form-control date_picker' max=" . date('Y-m-d', strtotime(date('Y-m-d'))) . " value='' autocomplete='off'>
</td>
</tr>
";
break;
case 9:
if($type != "climatisation")
{
echo" <tr class=''>
<td width='20%'>Date : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='wo_date' value='' id='date' max=".date('Y-m-d', strtotime(date('Y-m-d')))." autocomplete='off' required>
</td>
<td width='20%'>Time: <span style='color:red'>*</span></td>
<td width='30%'>
<input type='time' name='wo_heure' value='' autocomplete='off' required>
</td>
</tr>
<tr>
<td width='20%'>Unit N°: <span style='color:red'>*</span></td>
<td width='30%'>
<select style='width:50%' id='wo_unitNum' name='wo_unitNum' required>";
foreach($unites as $row) {
echo '<option value="'.$row.'">'.$row.'</option>';
}
echo"</select></td>
<td width='20%'>From (Dept.): <span style='color:red'>*</span></td>
<td width='30%'><input type='text' maxlength='250' name='wo_fromdep' value='' autocomplete='off' required></td>
</tr>
<tr>
<td width='20%'>Location: <span style='color:red'>*</span></td>
<td width='30%'><input type='text' maxlength='250' name='wo_location' value='' autocomplete='off' required></td>
<td width='20%'>Operator Name: </td>
<td width='30%'><input type='text' maxlength='250' name='wo_opname' value='' autocomplete='off'></td>
</tr>";
echo'
<tr class="">
<td width="20%">Work Order Type:</td>
<td width="30%">
<table>
<tr>
<td><input type="radio" id="7" name="wo_type" onclick="handleWOTypeChanged(this);" value="General Maintenance" style="border: 1px solid red; display: block;" ></td>
<td><label for="7">General Maintenance</label><br></td>
</tr>
<tr>
<td><input type="radio" id="8" name="wo_type" onclick="handleWOTypeChanged(this);" value="Breakdown" style="border: 1px solid red; display: block;" checked></td>
<td><label for="8">Breakdown</label><br></td>
</tr>
</table>
</td>
</tr>';
echo"
<tr>
<td width='20%'>Equipment/machine utility Name : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='wo_equipment' value='' autocomplete='off'></td>
</tr>
<tr>
<td width='20%'>Code N° : </td>
<td colspan='3'><input type='text' style='width:84%' maxlength='250' name='wo_equipment_num' value='' autocomplete='off'></td>
</tr>";
echo'
<tr class="" id="wo_prob_type_holder">
<td width="20%">Problem Type:</td>
<td width="30%">
<table>
<tr>
<td><input type="radio" id="9" name="wo_prob_type" value="Mechanical" style="border: 1px solid red; display: block;" required></td>
<td><label for="9">Mechanical</label><br></td>
</tr>
<tr>
<td><input type="radio" id="10" name="wo_prob_type" value="Electrical" style="border: 1px solid red; display: block;"></td>
<td><label for="10">Electrical</label><br></td>
</tr>
<tr>
<td><input type="radio" id="11" name="wo_prob_type" value="Instrumentation" style="border: 1px solid red; display: block;"></td>
<td><label for="11">Instrumentation</label><br></td>
</tr>
</table>
</td>
</tr>';
echo"
<tr class='tab_bg_2'>
<td>Problem Description : <span style='color:red'>*</span></td>
<td colspan='3'>";
Html::textarea([
'name' => "wo_description",
'enable_richtext' => true,
'required' => 1
]);
echo"</td></tr>";
} else {
echo" <tr class=''>
<td width='20%'>Date : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='wo_date' value='' id='date' max=".date('Y-m-d', strtotime(date('Y-m-d')))." autocomplete='off' required>
</td>
<td width='20%'>Time: <span style='color:red'>*</span></td>
<td width='30%'>
<input type='time' name='wo_heure' value='' autocomplete='off' required>
</td>
</tr>
<tr>
<td width='20%'>From (Dept.): <span style='color:red'>*</span></td>
<td width='30%'><input type='text' maxlength='250' name='wo_fromdep' value='' autocomplete='off' required></td>
<td width='20%'>Location: <span style='color:red'>*</span></td>
<td width='30%'><input type='text' maxlength='250' name='wo_location' value='' autocomplete='off' required></td>
</tr>";
echo'
<input type="hidden" name="wo_prob_type" value="Climatisation">';
echo"
<tr class='tab_bg_2'>
<td>Problem Description : <span style='color:red'>*</span></td>
<td colspan='3'>";
Html::textarea([
'name' => "wo_description",
'enable_richtext' => true,
'required' => 1
]);
echo"</td></tr>";
}
break;
case 10:
die("<div style='color:red; font-weight:bold; margin-bottom: 10px'>Page indisponible, prière de passer vers ERP pour faire cette demande.</div>");
echo'
<tr class="">
<td width="20%">Référence : <span style="color:red">*</span></td>
<td width="30%">
<input style="width:80%;" id="acbc_reference" type="text" name="acbc_reference" value="" required>
</td>
<td width="20%"></td>
<td width="30%"></td>
</tr>
<table class="tab_cadre_fixehov" id="dynamique" style="padding-top: 20px;">
<thead>
<tr>
<th></th>
<th></th>
<th class="">Désignation <span style="color:red">*</span></th>
<th class="">N° Lot</th>
<th class="">Quantité Livrée <span style="color:red">*</span></th>
<th class="">Observations</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th class="">Désignation <span style="color:red">*</span></th>
<th class="">N° Lot</th>
<th class="">Quantité Livrée <span style="color:red">*</span></th>
<th class="">Observations</th>
</tr>
</tfoot>
<tbody id="result">
<tr class="tab_bg_2">
<td></td>
<td>
<select class="js-example-basic-single" name="type[]" required>';
foreach ($famtype as $t) {
echo '<option value="'.$t.'">'.$t.'</option>';
}
echo'
</select>
</td>
<td><input type="text" name="designation[]" required></td>
<td><input type="text" maxlength="250" name="lot[]" value=""></td>
<td><input type="number" name="quantite[]" min="0" step="any" required></td>
<td><input type="text" name="obs[]"></td>
</tr>
</tbody>
</table>
<table class="tab_cadre_fixe">
<tr class="tab_bg_2">
<td><i name="add_lign" id="add_lign" class="fas fa-plus"></i>&nbsp;Ajouter</td>
<td></td>
</tr>
</table>';
break;
case 11:
echo"
<tr class=''>
<td width='20%'>Raison <span style='color:red'>*</span></td>
<td width='30%'>
<input type='hidden' id='dcs_nbr_jour' name='dcs_nbr_jour' value='3'>
<select style='width:85%' id='dcs_raison' name='dcs_raison' onchange='congeValChanged(this)' required>";
foreach($congeValues as $row) {
echo '<option value="'.$row.'">'.explode("-",$row)[1].'</option>';
}
echo"
</select>
</td>
<td width='20%'></td>
<td width='30%'></td>
</tr>
<tr class=''>
<td width='20%'>Date de Départ : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='dcs_date_depart' value='' min=".date('Y-m-d', strtotime(date('Y-m-d')))." autocomplete='off' required>
</td>
<td width='20%'>Intérimaire : </td>
<td width='30%'>
<input type='text' name='dcs_interimaire' value='' autocomplete='off'>
</td>
</tr>";
break;
case 12:
die("<div style='color:red; font-weight:bold; margin-bottom: 10px'>Page indisponible, prière de passer vers ERP pour faire cette demande.</div>");
echo'
<tr class="">
<td width="20%">Hangar : <span style="color:red">*</span></td>
<td width="30%">
<input style="width:80%;" id="acbc_reference" type="text" name="acbc_reference" value="" required>
</td>
<td width="20%">Magasin : <span style="color:red">*</span></td>
<td width="30%">
<select class="js-example-basic-single" name="acbc_magasin" required>
<option value="AC">ARTICLES CONDITIONNEMENT</option>
<option value="MP">MATIERE PREMIERE</option>
<td>
</tr>
<table class="tab_cadre_fixehov" id="dynamique" style="padding-top: 20px;">
<thead>
<tr>
<th></th>
<th></th>
<th class="">Désignation <span style="color:red">*</span></th>
<th class="">N° Lot</th>
<th class="">Quantité Livrée <span style="color:red">*</span></th>
<th class="">Observations</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th class="">Désignation <span style="color:red">*</span></th>
<th class="">N° Lot</th>
<th class="">Quantité Livrée <span style="color:red">*</span></th>
<th class="">Observations</th>
</tr>
</tfoot>
<tbody id="result">
<tr class="tab_bg_2">
<td></td>
<td>
<select class="js-example-basic-single" name="type[]" required>';
foreach ($famtype as $t) {
echo '<option value="'.$t.'">'.$t.'</option>';
}
echo'
</select>
</td>
<td><input type="text" name="designation[]" required></td>
<td><input type="text" maxlength="250" name="lot[]" value=""></td>
<td><input type="number" name="quantite[]" min="0" step="any" required></td>
<td><input type="text" name="obs[]"></td>
</tr>
</tbody>
</table>
<table class="tab_cadre_fixe">
<tr class="tab_bg_2">
<td><i name="add_lign" id="add_lign" class="fas fa-plus"></i>&nbsp;Ajouter</td>
<td></td>
</tr>
</table>';
break;
case 13:
die("<div style='color:red; font-weight:bold; margin-bottom: 10px'>Page indisponible, prière de passer vers ERP pour faire cette demande.</div>");
echo'
<tr class="">
<td width="20%">Référence : <span style="color:red">*</span></td>
<td width="30%">
<input style="width:80%;" id="acbc_reference" type="text" name="acbc_reference" value="" required>
</td>
<td width="20%"></td>
<td width="30%"></td>
</tr>
<table class="tab_cadre_fixehov" id="dynamique" style="padding-top: 20px;">
<thead>
<tr>
<th></th>
<th></th>
<th class="">Désignation <span style="color:red">*</span></th>
<th class="">N° Lot</th>
<th class="">Quantité Livrée <span style="color:red">*</span></th>
<th class="">Observations</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th class="">Désignation <span style="color:red">*</span></th>
<th class="">N° Lot</th>
<th class="">Quantité Livrée <span style="color:red">*</span></th>
<th class="">Observations</th>
</tr>
</tfoot>
<tbody id="result">
<tr class="tab_bg_2">
<td></td>
<td>
<select class="js-example-basic-single" name="type[]" required>';
foreach ($famtypeMp as $t) {
echo '<option value="'.$t.'">'.$t.'</option>';
}
echo'
</select>
</td>
<td><input type="text" name="designation[]" required></td>
<td><input type="text" maxlength="250" name="lot[]" value="" required></td>
<td><input type="number" name="quantite[]" min="0" step="any" required></td>
<td><input type="text" name="obs[]"></td>
</tr>
</tbody>
</table>
<table class="tab_cadre_fixe">
<tr class="tab_bg_2">
<td><i name="add_lign" id="add_lign" class="fas fa-plus"></i>&nbsp;Ajouter</td>
<td></td>
</tr>
</table>';
break;
case 14:
echo"
<tr class=''>
<td width='20%'>Est autorisé (e) à s'absenter la journée du : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='date' name='ap_date' value='".(isset($_SESSION["ap_date"]) != null ? $_SESSION["ap_date"] : '' )."' min=".date('Y-m-d', strtotime(date('Y-m-d')))." autocomplete='off' required>
</td>
</tr>
<tr class=''>
<td width='20%'>Est autorisé (e) de : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='time' name='ap_start_time' value='".(isset($_SESSION["ap_start_time"]) != null ? $_SESSION["ap_start_time"] : '' )."' autocomplete='off' required>
</td>
<td width='20%'>Est autorisé (e) à : <span style='color:red'>*</span></td>
<td width='30%'>
<input type='time' name='ap_end_time' value='".(isset($_SESSION["ap_end_time"]) != null ? $_SESSION["ap_end_time"] : '' )."' autocomplete='off' required>
</td>
</tr>
</table>" ;
break;
}
}
}
$link=$CFG_GLPI["root_doc"]."/front/ticket.php";
$root = $CFG_GLPI["root_doc"];
?>
<script>
var root = <?php echo json_encode($root); ?>;
var modele = <?php echo json_encode($modele); ?>;
var famtype = ["Matieres Premieres","Etuis","Notices","Aluminium","PVC","Cartons d'emballages","Vignettes","Etiquettes carton"
,"Scotch","Etiquettes flacon","Injectable","Sirop","Collyre"];
$("button[name='add']").click(function( event ) {
if($("#form")[0].checkValidity()) {
event.preventDefault();
$("button[name='add']").attr("disabled","disabled");
$("#messageBar").css("display","block");
$.ajax({
type: "POST",
url: "drh.demandes.form.php",
data: $('#form').serialize()
})
.done(function( msg ) {
try {
if (msg) {
let result = JSON.parse(msg);
if (result.is_valid === false) {
window.location = root + "/front/drh.demandes.php?modele=" + result.modele;
} else {
window.location = root + "/front/ticket.php";
}
} else {
window.location = root + "/front/ticket.php";
}
} catch (error) {
console.error("Error parsing response: ", error);
}
})
.fail(function(msg) {
$("#messageBar").css("display","none");
$("button[name='add']").removeAttr("disabled");
});
}
});
function handleWOTypeChanged(e){
if (e.value == "Breakdown"){
document.getElementById('wo_prob_type_holder').style.display= 'block' ;
}else{
document.getElementById('wo_prob_type_holder').style.display= 'none' ;
document.getElementById('9').checked = false ;
document.getElementById('10').checked = false ;
document.getElementById('11').checked = false ;
}
}
function supprimer(e){
$(e).parents("tr").remove();
}
$(document).ready(function(){
$("#add_lign").click(function(){
var required = '';
if(modele == '13'){
required = 'required';
famtype = ["API","Excipient","Gelule","Désinfectant","Injectable"];
}
var optionsContent = ""
for(var i = 0; i< famtype.length;i++){
optionsContent = optionsContent + "<option value='"+famtype[i]+"'>"+famtype[i]+"</option>";
}
var markup = "<tr class='tab_bg_2'>"
+"<td><i class='fa fa-trash deleteRow cursorPointer' onclick='supprimer(this)' title='Supprimer' style='display: inline-block;' ></i></td>"
+"<td><select class='js-example-basic-single' name='type[]' required>"
+optionsContent
+"</select></td>"
+"<td><input type='text' name='designation[]' required></td>"
+"<td><input type='text' maxlength='250' name='lot[]' value='' "+required+"></td>"
+"<td><input type='number' name='quantite[]' min='0' step='any' required></td>"
+"<td><input type='text' name='obs[]'></td>"
+"</tr>";
$("#dynamique").append(markup);
});
document.querySelectorAll(".date_picker").forEach(input => {
input.addEventListener("change", function () {
let selectedDate = this.value;
let inputs = document.querySelectorAll(".date_picker");
// Check if any other input has the same date
let duplicate = [...inputs].some(el => el !== this && el.value === selectedDate);
if (duplicate) {
alert("<p style='text-align:center;'> هذا التاريخ مُحدد بالفعل. الرجاء اختيار تاريخ آخر. </br> This date is already selected. Please choose another date. </br> Cette date est déjà sélectionnée. Veuillez choisir une autre date. </p>");
this.value = ""; // Clear the duplicate selection
}
});
});
});
function congeValChanged(e){
if(parseInt(e.value.split("-")[0])>6){
$("#dcs_nbr_jour").val(1)
}else{
$("#dcs_nbr_jour").val(3)
}
}
function updateMaxDate() {
const startDateInput = (document.querySelector('[name="cr_date_debut"]')) ;
const endDateInput = (document.querySelector('[name="cr_date_fin"]')) ;
// Get the value of the start date input
const startDate = new Date(startDateInput.value);
console.log("startDate",startDate);
// If the start date is valid
if (startDate) {
// Add 5 days to the start date
startDate.setDate(startDate.getDate() + 4);
// Format the new max date in YYYY-MM-DD format (required by input[type="date"])
const maxDate = startDate.toISOString().split("T")[0];
// Set the max date of the end date input
endDateInput.setAttribute("max", maxDate);
}
}
function calcDiffDate(){
updateMaxDate();
let date1 = new Date(document.querySelector('[name="cr_date_debut"]').value) ;
let date2 = new Date(document.querySelector('[name="cr_date_fin"]').value) ;
if (date2 < date1) {
alert("<p style='text-align:center;'>تاريخ البدء قبل تاريخ الانتهاء</br>The start date must be before the end date</br> La date de début doit être antérieure à la date de fin. </p>");
document.querySelector('[name="cr_date_fin"]').value = ""
}
const differenceInDays = (date2 - date1) / (1000 * 60 * 60 * 24) + 1;
$("#cr_dates").val(differenceInDays);
var elements = document.querySelectorAll('.input-date');
if(!Number.isNaN(differenceInDays)){
switch (differenceInDays) {
case 1:
$('.tr-input-date:first').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(1)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(2)').addClass('input-date').removeClass('input-date-shown');
$('.tr-input-date:nth(3)').addClass('input-date').removeClass('input-date-shown');
$('.tr-input-date:nth(4)').addClass('input-date').removeClass('input-date-shown');
$('.tr-input-date:nth(5)').addClass('input-date').removeClass('input-date-shown');
$("[name='cr_date_1']").attr('required', true)
$("[name='cr_date_2']").attr('required', false)
$("[name='cr_date_3']").attr('required', false)
$("[name='cr_date_4']").attr('required', false)
$("[name='cr_date_5']").attr('required', false)
break;
case 2:
$('.tr-input-date:first').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(1)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(2)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(3)').addClass('input-date').removeClass('input-date-shown');
$('.tr-input-date:nth(4)').addClass('input-date').removeClass('input-date-shown');
$('.tr-input-date:nth(5)').addClass('input-date').removeClass('input-date-shown');
$("[name='cr_date_1']").attr('required', true)
$("[name='cr_date_2']").attr('required', true)
$("[name='cr_date_3']").attr('required', false)
$("[name='cr_date_4']").attr('required', false)
$("[name='cr_date_5']").attr('required', false)
break;
case 3:
$('.tr-input-date:first').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(1)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(2)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(3)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(4)').addClass('input-date').removeClass('input-date-shown');
$('.tr-input-date:nth(5)').addClass('input-date').removeClass('input-date-shown');
$("[name='cr_date_1']").attr('required', true)
$("[name='cr_date_2']").attr('required', true)
$("[name='cr_date_3']").attr('required', true)
$("[name='cr_date_4']").attr('required', false)
$("[name='cr_date_5']").attr('required', false)
break;
case 4:
$('.tr-input-date:first').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(1)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(2)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(3)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(4)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(5)').addClass('input-date').removeClass('input-date-shown');
$("[name='cr_date_1']").attr('required', true)
$("[name='cr_date_2']").attr('required', true)
$("[name='cr_date_3']").attr('required', true)
$("[name='cr_date_4']").attr('required', true)
$("[name='cr_date_5']").attr('required', false)
break;
default:
$('.tr-input-date:first').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(1)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(2)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(3)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(4)').addClass('input-date-shown').removeClass('input-date');
$('.tr-input-date:nth(5)').addClass('input-date-shown').removeClass('input-date');
$("[name='cr_date_1']").attr('required', true)
$("[name='cr_date_2']").attr('required', true)
$("[name='cr_date_3']").attr('required', true)
$("[name='cr_date_4']").attr('required', true)
$("[name='cr_date_5']").attr('required', true)
break;
}
}
}
</script>