-
Notifications
You must be signed in to change notification settings - Fork 0
/
asistencia.php
293 lines (266 loc) · 10.2 KB
/
asistencia.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php require_once("includes/conexion.php");
PermitirAcceso(301);
$sw=0;
$IDPeriodo=0;
//Listado de periodos de la congregacion
$SQL_Periodos=Seleccionar('uvw_tbl_PeriodosInformes','*',"NumCong='".$_SESSION['NumCong']."'",'AnioPeriodo DESC, MesPeriodo DESC');
if(isset($_GET['Periodo'])&&$_GET['Periodo']!=""){
$IDPeriodo=base64_decode($_GET['Periodo']);
$sw=1;
}
if(isset($_POST['P'])&&($_POST['P']!="")){//Insertar registro
try{
$Count=count($_POST['ReunionSemana']);
$i=0;
while($i<$Count){
if($_POST['Metodo'][$i]!="0"){
$ParamInsert=array(
"'".$_POST['IDAsistencia'][$i]."'",
"'".base64_decode($_POST['Periodo'])."'",
"'".$_POST['Semana'][$i]."'",
"'".$_POST['ReunionSemana'][$i]."'",
"'".$_POST['ReunionFinSemana'][$i]."'",
"'".$_SESSION['NumCong']."'",
"'".$_SESSION['CodUser']."'"
);
$SQL_Insert=EjecutarSP('usp_tbl_Asistencia',$ParamInsert,$_POST['P']);
if(!$SQL_Insert){
throw new Exception('Ha ocurrido un error al insertar la asistencia');
}
}
$i=$i+1;
}
sqlsrv_close($conexion);
header('Location:asistencia.php?Periodo='.$_POST['Periodo'].'&a='.base64_encode("OK_AsistAdd"));
}catch (Exception $e){
echo 'Excepcion capturada: ', $e->getMessage(), "\n";
}
}
?>
<!DOCTYPE html>
<html><!-- InstanceBegin template="/Templates/PlantillaPrincipal.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<?php include("includes/cabecera.php"); ?>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Asistencia a las reuniones | <?php echo NOMBRE_PORTAL;?></title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<?php
if(isset($_GET['a'])&&($_GET['a']==base64_encode("OK_AsistAdd"))){
echo "<script>
$(document).ready(function() {
Swal.fire({
title: '¡Listo!',
text: 'La asistencia ha sido agregada exitosamente.',
icon: 'success'
});
});
</script>";
}
?>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="wrapper">
<?php include("includes/menu.php"); ?>
<div id="page-wrapper" class="gray-bg">
<?php include("includes/menu_superior.php"); ?>
<!-- InstanceBeginEditable name="Contenido" -->
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-sm-8">
<h2>Asistencia a las reuniones</h2>
<ol class="breadcrumb">
<li>
<a href="index1.php">Inicio</a>
</li>
<li>
<a href="#">Ingresar informes</a>
</li>
<li class="active">
<strong>Asistencia a las reuniones</strong>
</li>
</ol>
</div>
</div>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-lg-12">
<div class="ibox-content">
<?php include("includes/spinner.php"); ?>
<form action="asistencia.php" method="get" id="formBuscar" class="form-horizontal">
<div class="form-group">
<label class="col-xs-12"><h3 class="bg-success p-xs b-r-sm"><i class="fa fa-filter"></i> Datos para filtrar</h3></label>
</div>
<div class="form-group">
<label class="col-lg-1 control-label">Periodo (Mes) <span class="text-danger">*</span></label>
<div class="col-lg-3">
<select name="Periodo" class="form-control select2" id="Periodo" required>
<option value="">Seleccione...</option>
<?php while($row_Periodos=sqlsrv_fetch_array($SQL_Periodos)){?>
<option value="<?php echo base64_encode($row_Periodos['IDPeriodo']);?>" <?php if((isset($_GET['Periodo']))&&(strcmp($row_Periodos['IDPeriodo'],base64_decode($_GET['Periodo']))==0)){ echo "selected=\"selected\"";}?>><?php echo $row_Periodos['NombreMes']."/".$row_Periodos['AnioPeriodo'];?></option>
<?php }?>
</select>
</div>
<div class="col-lg-1">
<button type="submit" form="formBuscar" class="btn btn-outline btn-success pull-right"><i class="fa fa-search"></i> Consultar</button>
</div>
</div>
</form>
</div>
</div>
</div>
<br>
<?php //echo $Cons;?>
<?php if($sw==1){?>
<div class="row">
<div class="col-lg-12">
<div class="ibox-content col-lg-12">
<?php include("includes/spinner.php"); ?>
<div class="col-lg-9">
<form action="asistencia.php" method="post" class="form-horizontal" enctype="multipart/form-data" id="frmAsistencia">
<?php for($i=1;$i<=5;$i++){
$SQL=Seleccionar('uvw_tbl_Asistencia','*',"NumCong='".$_SESSION['NumCong']."' and IDPeriodo='".$IDPeriodo."' and Semana='".$i."'");
$row=sqlsrv_fetch_array($SQL);?>
<div class="form-group">
<div class="col-lg-8 border-bottom">
<label class="control-label text-danger h4">Semana <?php echo $i;?></label>
</div>
</div>
<div class="form-group">
<div class="col-lg-3">
<label class="control-label">Reunión de entre semana</label>
<input name="ReunionSemana[]" type="text" onKeyPress="return justNumbers(event,this.value);" onChange="CambiarMetodo('<?php echo $i;?>');" required="required" class="form-control" id="ReunionSemana<?php echo $i;?>" maxlength="5" value="<?php echo $row['AsistSemana'];?>" autocomplete="off">
</div>
<div class="col-lg-3">
<label class="control-label">Reunión del fin de semana</label>
<input name="ReunionFinSemana[]" type="text" onKeyPress="return justNumbers(event,this.value);" onChange="CambiarMetodo('<?php echo $i;?>');" class="form-control" id="ReunionFinSemana<?php echo $i;?>" maxlength="5" value="<?php echo $row['AsistFinSemana'];?>" autocomplete="off">
</div>
<input type="hidden" id="Metodo<?php echo $i;?>" name="Metodo[]" value="0" />
<input type="hidden" id="Semana<?php echo $i;?>" name="Semana[]" value="<?php echo $i;?>" />
<input type="hidden" id="IDAsistencia<?php echo $i;?>" name="IDAsistencia[]" value="<?php echo $row['IDAsistencia'];?>" />
</div>
<?php }?>
<div class="form-group m-t-lg">
<div class="col-lg-12">
<button class="btn btn-primary" form="frmAsistencia" type="submit" id="Ingresar"><i class="fa fa-check"></i> Ingresar asistencia</button>
<input type="hidden" id="P" name="P" value="302" />
<input type="hidden" id="Periodo" name="Periodo" value="<?php echo base64_encode($IDPeriodo);?>" />
</div>
</div>
</form>
</div>
<?php
$ParamTotal=array(
"'".$_SESSION['NumCong']."'",
"'".$IDPeriodo."'"
);
$SQL_Total=EjecutarSP('usp_CalcularTotalesAsistencia',$ParamTotal);
$row_Total=sqlsrv_fetch_array($SQL_Total);
?>
<div class="col-lg-3">
<div class="col-lg-12">
<div class="ibox border-left-right border-top-bottom">
<div class="ibox-title bg-primary">
<h2 class="font-bold">Total entre semana</h2>
</div>
<div class="ibox-content">
<h1 class="no-margins"><span class="font-bold text-navy"><?php echo $row_Total['TotalSemana'];?></span></h1>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="ibox border-left-right border-top-bottom">
<div class="ibox-title bg-primary">
<h2 class="font-bold">Promedio entre semana</h2>
</div>
<div class="ibox-content">
<h1 class="no-margins"><span class="font-bold text-navy"><?php echo $row_Total['PromSemana'];?></span></h1>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="ibox border-left-right border-top-bottom">
<div class="ibox-title bg-success">
<h2 class="font-bold">Total fin de semana</h2>
</div>
<div class="ibox-content">
<h1 class="no-margins"><span class="font-bold text-success"><?php echo $row_Total['TotalFinSemana'];?></span></h1>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="ibox border-left-right border-top-bottom">
<div class="ibox-title bg-success">
<h2 class="font-bold">Promedio fin de semana</h2>
</div>
<div class="ibox-content">
<h1 class="no-margins"><span class="font-bold text-success"><?php echo $row_Total['PromFinSemana'];?></span></h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php }?>
</div>
<!-- InstanceEndEditable -->
<?php include("includes/footer.php"); ?>
</div>
</div>
<?php include("includes/pie.php"); ?>
<!-- InstanceBeginEditable name="EditRegion4" -->
<script>
$(document).ready(function(){
$("#formBuscar").validate({
submitHandler: function(form){
$('.ibox-content').toggleClass('sk-loading');
form.submit();
}
});
$("#frmAsistencia").validate({
submitHandler: function(form){
Swal.fire({
title: "¿Está seguro que desea guardar los datos?",
icon: "question",
showCancelButton: true,
confirmButtonText: "Si, confirmo",
cancelButtonText: "No"
}).then((result) => {
if (result.isConfirmed) {
$('.ibox-content').toggleClass('sk-loading',true);
form.submit();
}
});
}
});
$(".alkin").on('click', function(){
$('.ibox-content').toggleClass('sk-loading');
});
$('#FechaInicial').datepicker({
todayBtn: "linked",
keyboardNavigation: false,
forceParse: false,
calendarWeeks: true,
autoclose: true,
format: 'yyyy-mm-dd'
});
$('#FechaFinal').datepicker({
todayBtn: "linked",
keyboardNavigation: false,
forceParse: false,
calendarWeeks: true,
autoclose: true,
format: 'yyyy-mm-dd'
});
$(".select2").select2();
$("span.pie").peity("pie");
});
function CambiarMetodo(id){
document.getElementById("Metodo"+id).value='1';
}
</script>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd --></html>
<?php sqlsrv_close($conexion);?>