|
@@ -13,10 +13,28 @@ if ($user->acceso === null && !$user->admin){
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
-$fs_dias_festivos = $db->query("SELECT d.diasfestivos_id, d.diasfestivos_dia , p.periodo_id , p.periodo_nombre, extract(dow from diasfestivos_dia) AS dia_id from diasfestivos d
|
|
|
-join periodo p on p.periodo_id = any (d.periodos_id)
|
|
|
-order by d.diasfestivos_dia DESC");
|
|
|
|
|
|
+$periodo_rs = $db->querySingle('SELECT periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE periodo_id = :periodo_id', [':periodo_id' => $user->periodo_id]);
|
|
|
+
|
|
|
+
|
|
|
+if(isset($_POST["fecha_ini"]) && $_POST["fecha_ini"]!=""){
|
|
|
+ $fecha_ini_obj = DateTime::createFromFormat('d/m/Y', $_POST["fecha_ini"]);
|
|
|
+}else{
|
|
|
+ $fecha_ini_obj = DateTime::createFromFormat('Y-m-d', $periodo_rs["periodo_fecha_inicio"]);
|
|
|
+}
|
|
|
+if(isset($_POST["fecha_fin"]) && $_POST["fecha_fin"]!=""){
|
|
|
+ $fecha_fin_obj = DateTime::createFromFormat('d/m/Y', $_POST["fecha_fin"]);
|
|
|
+}else{
|
|
|
+ $fecha_fin_obj = DateTime::createFromFormat('Y-m-d', $periodo_rs["periodo_fecha_fin"]);
|
|
|
+}
|
|
|
+
|
|
|
+$fecha_ini = $fecha_ini_obj->format('d/m/Y');
|
|
|
+$fecha_fin = $fecha_fin_obj->format('d/m/Y');
|
|
|
+unset($periodo_rs);
|
|
|
+
|
|
|
+$fs_dias_festivos = $db->query("SELECT d.diasfestivos_id, d.diasfestivos_dia , p.periodo_id , p.periodo_nombre, extract(dow from diasfestivos_dia) AS dia_id from diasfestivos d
|
|
|
+join periodo p on p.periodo_id = any (d.periodos_id) where diasfestivos_dia between :ini and :fin
|
|
|
+order by d.diasfestivos_dia DESC", [":ini"=> $fecha_ini_obj->format('Y-m-d'), ":fin"=>$fecha_fin_obj->format('Y-m-d')]);
|
|
|
|
|
|
|
|
|
$dias_arr = array();
|
|
@@ -31,8 +49,11 @@ foreach ($fs_dias_festivos as $dia){
|
|
|
}
|
|
|
|
|
|
$dias_nombres=array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado");
|
|
|
-
|
|
|
$write = true;
|
|
|
+
|
|
|
+$fs_periodos = $db->query("SELECT periodo_id, periodo_nombre, periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE CURRENT_DATE < periodo_fecha_fin order by id_periodo_sgu");
|
|
|
+
|
|
|
+
|
|
|
?>
|
|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
@@ -79,7 +100,7 @@ $write = true;
|
|
|
</div>
|
|
|
<?php } ?>
|
|
|
<div id="message"></div>
|
|
|
- <form action="dias_festivos.php" method="post" class="">
|
|
|
+ <form action="días_festivos.php" method="post" class="">
|
|
|
<div class="form-box">
|
|
|
<div class="form-group row">
|
|
|
<label for="filter_fecha_ini" class="col-4 col-form-label">Fecha inicial</label>
|
|
@@ -188,7 +209,7 @@ $write = true;
|
|
|
<input id="diaFestivo" name="diaFestivo" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="">
|
|
|
</div>
|
|
|
<div class="col-1 diaFestivoRango">
|
|
|
- <span class="ing-menos"></span>
|
|
|
+ <span class="ing-menos pt-2"></span>
|
|
|
</div>
|
|
|
<div class="col-4 diaFestivoRango" id="diaFestivoRango">
|
|
|
<input id="diaFestivoFin" name="diaFestivoFin" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="">
|
|
@@ -198,14 +219,19 @@ $write = true;
|
|
|
|
|
|
<div class="form-group row" id="periodos">
|
|
|
<label for="periodos" class="col-3 col-form-label">Periodos</label>
|
|
|
- <div class="col-7">
|
|
|
- <select multiple="multiple" size="4" class="form-control">
|
|
|
-
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- <div class="col-2">
|
|
|
- <button class="btn btn-outline-primary"><span class="ing-mas"></span></button>
|
|
|
+ <div class="col-9" style="overflow-y:auto; overflow-x:none; max-height:220px; font-size:80%">
|
|
|
+ <?php
|
|
|
+ foreach($fs_periodos as $per){
|
|
|
+ ?>
|
|
|
+ <div class="form-check form-check-inline" data-fechaini = "<?php echo $per["periodo_fecha_inicio"];?>" data-fechafin = "<?php echo $per["periodo_fecha_fin"];?>">
|
|
|
+ <input class="form-check-input radio-lg " type="checkbox" id="check<?php echo $per["periodo_id"]?>" name="periodo[]" value="<?php echo $per["periodo_id"]?>">
|
|
|
+ <label for="check<?php echo $per["periodo_id"]?>" class="col-form-label"><?php echo $per["periodo_nombre"]?></label>
|
|
|
+ </div>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
</div>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<div class="form-group row">
|
|
@@ -225,7 +251,7 @@ $write = true;
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="modal fade" id="modal_confirm" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
|
|
|
+ <div class="modal fade" id="modal_confirm" tabindex="-1" role="dialog" aria-labelledby="modal_confirm" aria-hidden="true">
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
|
<div class="modal-content">
|
|
|
<div class="modal-body">
|
|
@@ -254,6 +280,13 @@ $write = true;
|
|
|
require_once 'js/messages.php';
|
|
|
?>
|
|
|
<script>
|
|
|
+ $(document).on( "click", ".btn-reset", function(event){
|
|
|
+ var forma = $(this).parents("form");
|
|
|
+ forma.find("input[type=text]").val("");
|
|
|
+ forma.submit();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
$(document).ready(function(){
|
|
|
$('.diaFestivoRango').hide();
|
|
|
});
|
|
@@ -299,19 +332,39 @@ $write = true;
|
|
|
triggerMessage("No se encontraron días festivos", "Error");
|
|
|
<?php } ?>
|
|
|
|
|
|
+ function actualizaPeriodos(fechaOriginal){
|
|
|
+ var partesFecha = fechaOriginal.split('/');
|
|
|
+ var fechaFestivo = partesFecha[2]+"-"+partesFecha[1]+"-"+partesFecha[0];
|
|
|
+
|
|
|
+ $.each($('#periodos .form-check'), function(){
|
|
|
+ if(fechaFestivo>= $(this).data("fechaini") && fechaFestivo<= $(this).data("fechafin")){
|
|
|
+ $(this).show();
|
|
|
+ }else{
|
|
|
+ $(this).find("input").prop("checked", false);
|
|
|
+ $(this).hide();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //Cambio de fecha valida periodos activos para esa fecha
|
|
|
+ $('#modal .date-picker').change(function(){
|
|
|
+ actualizaPeriodos($(this).val());
|
|
|
+ });
|
|
|
$('#modal').on('show.bs.modal', function (event){
|
|
|
var button = $(event.relatedTarget);
|
|
|
var tipo = button.data('tipo');
|
|
|
var modal = $(this);
|
|
|
+ $("#formaModal .text-danger").removeClass("text-danger");
|
|
|
+ $("#diaFestivoFin").removeClass("is-invalid");
|
|
|
if(tipo==1){//agregar
|
|
|
$('#modalLabel').html("Agregar Día Festivo");
|
|
|
$('#submitBtn').data('tipo', 1);
|
|
|
$('#diaFestivo').datepicker("setDate", today);
|
|
|
$('#diaFestivoFin').datepicker("setDate", today);
|
|
|
- setDatalistFirst("#periodo");
|
|
|
$('#rangoDiv').show();
|
|
|
$('#dia').removeClass('col-9');
|
|
|
$('#dia').addClass('col-4');
|
|
|
+ actualizaPeriodos($("#diaFestivo").val());
|
|
|
}
|
|
|
else{
|
|
|
$('#modalLabel').html("Editar Día Festivo");
|
|
@@ -329,11 +382,7 @@ $write = true;
|
|
|
success:function(result){
|
|
|
console.log(result);
|
|
|
$('#id').val(result['diasfestivos_id']);
|
|
|
- if(!result['periodo_id']){
|
|
|
- setDatalist('#periodo', 0);
|
|
|
- }else{
|
|
|
- setDatalist('#periodo', result['periodo_id']);
|
|
|
- }
|
|
|
+
|
|
|
var date = new Date(result['diasfestivos_dia']);
|
|
|
date.setDate(date.getDate() + 1);
|
|
|
$('#diaFestivo').datepicker("setDate", date);
|
|
@@ -345,6 +394,8 @@ $write = true;
|
|
|
|
|
|
function valida_campos(){
|
|
|
var error=false;
|
|
|
+ $("#modal .text-danger").removeClass("text-danger");
|
|
|
+ $("#diaFestivoFin").removeClass("is-invalid");
|
|
|
if($("#diaFestivo").val()==""){
|
|
|
$("#diaFestivo").addClass("is-invalid");
|
|
|
error=true;
|
|
@@ -360,6 +411,10 @@ $write = true;
|
|
|
$('#diaFestivoFin').addClass("is-invalid");
|
|
|
error=true;
|
|
|
}
|
|
|
+ if($("#modal .form-check-input:checked").length<=0){
|
|
|
+ $("#modal .form-check-input").siblings().addClass("text-danger");
|
|
|
+ error=true;
|
|
|
+ }
|
|
|
if(error){
|
|
|
return false;
|
|
|
}else{
|