first commit
This commit is contained in:
188
front/payroll.period.add.php
Normal file
188
front/payroll.period.add.php
Normal file
@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
|
||||
use Glpi\Event;
|
||||
|
||||
include ('../inc/includes.php');
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
if (Session::getCurrentInterface() == "helpdesk") {
|
||||
Html::helpHeader("Période de paie", '', $_SESSION["glpiname"]);
|
||||
} else {
|
||||
Html::header("Période de paie", '', "", "");
|
||||
}
|
||||
$currentYear = date('Y');
|
||||
$startYear = $currentYear - 1; // Start 5 years before the current year
|
||||
$endYear = $currentYear + 1; // End 5 years after the current year
|
||||
|
||||
|
||||
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' 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"]."/ajax/payroll.period.php' enctype='multipart/form-data'>
|
||||
<div class='spaced' id='tabsbody'>
|
||||
<table class='tab_cadre_fixe' id='mainformtable'>
|
||||
<tbody>
|
||||
<tr class='headerRow'>
|
||||
<th colspan='4' class='center'>Période de paie</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width='20%'>L'année : <span style='color:red'>*</span></td>
|
||||
<td width='30%'>
|
||||
<select style='width:95%;' id='year' name='year' required>
|
||||
<option value='' disabled selected>-- Sélectionnez une année --</option>";
|
||||
for ($year = $startYear; $year <= $endYear; $year++) {
|
||||
echo "<option value='$year'>$year</option>";
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
</td>
|
||||
<td width='20%'>Mois : <span style='color:red'>*</span></td>
|
||||
<td width='30%'>
|
||||
<select style='width:95%;' id='month' name='month' required>
|
||||
<option value='' disabled selected>-- Sélectionnez un mois --</option>
|
||||
<option value='01'>Janvier</option>
|
||||
<option value='02'>Février</option>
|
||||
<option value='03'>Mars</option>
|
||||
<option value='04'>Avril</option>
|
||||
<option value='05'>Mai</option>
|
||||
<option value='06'>Juin</option>
|
||||
<option value='07'>Juillet</option>
|
||||
<option value='08'>Août</option>
|
||||
<option value='09'>Septembre</option>
|
||||
<option value='10'>Octobre</option>
|
||||
<option value='11'>Novembre</option>
|
||||
<option value='12'>Décembre</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date début : <span style='color:red'>*</span></td>
|
||||
<td>
|
||||
<input style='width:95%;' id='start_date' type='date' name='start_date' value='' required>
|
||||
</td>
|
||||
<td>Date fin : <span style='color:red'>*</span></td>
|
||||
<td>
|
||||
<input style='width:95%;' id='end_date' type='date' name='end_date' value='' required>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class='center' style='margin-top: 20px;'>
|
||||
<button name='save' class='vsubmit' style='padding: 10px;'>Enregistrer</button>
|
||||
<a href='".$CFG_GLPI["root_doc"]."/front/payroll.period.list.php' class='vsubmit' style='margin-left: 15px; background-color: #eba696; padding: 10px; text-decoration: none;'>Annuler</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>";
|
||||
|
||||
if (Session::getCurrentInterface() == "helpdesk") {
|
||||
Html::helpFooter();
|
||||
} else {
|
||||
Html::footer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$link=$CFG_GLPI["root_doc"]."/front/ticket.php";
|
||||
$root = $CFG_GLPI["root_doc"];
|
||||
$user = Session::getCurrentInterface();
|
||||
?>
|
||||
|
||||
|
||||
<script>
|
||||
var root = <?php echo json_encode($root); ?>;
|
||||
var user = <?php echo json_encode($user); ?>;
|
||||
|
||||
function supprimer(e){
|
||||
$(e).parents("tr").remove();
|
||||
}
|
||||
|
||||
$("button[name='save']").click(function( event ) {
|
||||
if($("#form")[0].checkValidity()) {
|
||||
event.preventDefault();
|
||||
$("button[name='save']").attr("disabled", "disabled");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: root + "/ajax/payroll.period.php?action=add",
|
||||
data: $('#form').serialize()
|
||||
})
|
||||
.done(function(response) {
|
||||
try {
|
||||
var res = JSON.parse(response);
|
||||
|
||||
if (res.status === "success") {
|
||||
window.location = root + "/front/payroll.period.list.php";
|
||||
} else {
|
||||
showErrorMessage(res.message || "An error occurred while adding the payroll period.");
|
||||
// Enable the save button
|
||||
$("button[name='save']").removeAttr("disabled");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error parsing JSON response: ", e);
|
||||
// Enable the save button if JSON parsing fails
|
||||
$("button[name='save']").removeAttr("disabled");
|
||||
}
|
||||
})
|
||||
.fail(function(response) {
|
||||
console.log("Request failed: ", response);
|
||||
$("button[name='save']").removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Function to display error messages
|
||||
function showErrorMessage(message) {
|
||||
var errorMessageElement = $('<div class="error-message">' + message + '</div>');
|
||||
|
||||
// Append the error message to the body or a designated container
|
||||
$("body").append(errorMessageElement);
|
||||
|
||||
// Optionally, style it for visibility
|
||||
errorMessageElement.css({
|
||||
"background-color": "#f8d7da",
|
||||
"color": "#721c24",
|
||||
"border": "1px solid #f5c6cb",
|
||||
"padding": "10px",
|
||||
"border-radius": "5px",
|
||||
"margin": "10px 0"
|
||||
});
|
||||
|
||||
// Optionally, fade out and remove the error message after a few seconds
|
||||
setTimeout(function() {
|
||||
errorMessageElement.fadeOut(500, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
var userlink;
|
||||
if(user == "helpdesk"){
|
||||
userlink ='<li class="breadcrumb_item"><a href="'+root+'/front/helpdesk.public.php" title="Accueil">Accueil</a></li>';
|
||||
}else{
|
||||
userlink = '<li class="breadcrumb_item"><a href="'+root+'/front/central.php" title="Accueil">Accueil</a></li>';
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#c_ssmenu2").html('<ul>'+
|
||||
userlink+
|
||||
'<li class="breadcrumb_item"><a href="" title="">Administration</a></li>'+
|
||||
'<li class="breadcrumb_item"><a href="'+root+'/front/payroll.period.list.php" class="here" title="Période"><i class="far fa-sticky-note"></i> Périodes</a></li>'+
|
||||
'<span class="sr-only">Ajouter</span></a>'+
|
||||
'</li>'+
|
||||
'</ul>');
|
||||
});
|
||||
|
||||
</script>
|
||||
<!-- script pour liste déroulante -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.js-example-basic-single').select2();
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user