]> git.llucax.com Git - mecon/intranet.git/blob - sistema/www/servicios/bandas/banda_agente.php
-Bugs
[mecon/intranet.git] / sistema / www / servicios / bandas / banda_agente.php
1 <?
2 require_once '../../../local_lib/HTML_DietMarco.php';
3 require_once 'MECON/HTML/Image.php';
4 require_once 'MECON/HTML/Link.php';
5 require_once 'MECON/Dependencia.php';
6 require_once 'MECON/NovedadesDia.php';
7 require_once 'BandasNovedades/AgenteBanda.php';
8 require_once 'HTML/Table.php';
9 require_once 'DB.php';
10
11 if(!isset($_SESSION['documento']))
12 {
13         header('Location: ../../servicios.php');
14 }
15
16 //CREO LA CONEXION A LA BASE DE DATOS
17 $dbh = DB::connect("mysql://intranet:intranet@bal747f/bandas",true);
18 if (DB::isError($dbh)) {
19     die ($DB->getMessage());
20 }
21
22 //Seteo las variables generales
23 $nrodoc = $_SESSION['documento'];
24 setlocale (LC_ALL, 'es_AR');
25 $fecha = $_POST['fecha'];
26
27 $fecha_spliteada = split('-',$fecha);
28 $mes = strftime("%B", mktime(0,0,0,$fecha_spliteada[1],1,$fecha_spliteada[0]));
29
30 $agente =& new BandasNovedades_AgenteBanda($nrodoc,new date($fecha),$dbh);
31 if(!$agente->buscarAgente($nrodoc))
32 {
33         echo "El agente no está en las bases de RRHH";
34         die;
35 }
36
37 /* Instancio DietMarco que sirve para mostrar la pagina dentro del marco de Intranet*/
38 $m = new HTML_DietMarco('servicios','Bandas Horarias');
39 $m->addTitle('Bandas Horarias');
40 $m->addStyleSheet('../../css/servicios_bandas.css');
41
42 /* Instancio un objeto Table para el cuerpo de la pagina*/
43 $tabla_cuerpo = new HTML_Table(array('width'=>'760','border'=>'0','cellspacing'=>'0','cellpadding'=>'0'));
44
45 /* Encabezado propio de la pagina */
46 $imagen = new MECON_HTML_Image('../../images/servicios_imprimir1.gif',
47                                                  '',
48                                                 array('width'=>'24','height'=>'24','alt'=>'imprimir'));
49 $row_cuerpo = array('Datos Personales',
50                                         'P&aacute;gina de Impresi&oacute;n ',
51                                         $imagen->toHtml());
52 $tabla_cuerpo->addRow($row_cuerpo,array('height'=>'24'));
53 $imagen = new MECON_HTML_Image('/MECON/images/blanco.gif',
54                                                 '',
55                                                 array('width'=>'586','height'=>'1','alt'=>'blanco','align'=>'top'));
56 $imagen2 = new MECON_HTML_Image('/MECON/images/blanco.gif',
57                                                 '',
58                                                 array('width'=>'150','height'=>'1','alt'=>'blanco','align'=>'top'));
59 $imagen3 = new MECON_HTML_Image('/MECON/images/blanco.gif',
60                                                 '',
61                                                 array('width'=>'24','height'=>'1','alt'=>'blanco','align'=>'top'));
62
63 $row_cuerpo = array($imagen->toHtml(),$imagen2->toHtml(),$imagen3->toHtml());
64
65 $tabla_cuerpo->addRow($row_cuerpo,array('bgcolor'=>'#FF9900',
66                                                                         'height'=>'1'));
67 $tabla_cuerpo->addRow($row_cuerpo,array('bgcolor'=>'#FFFFFF',
68                                                                         'height'=>'10'));
69
70 $tabla_cuerpo->updateCellAttributes(0,
71                                                                         0,
72                                                                         array('width'=>'586','class'=>'titulo_tres'));
73 $tabla_cuerpo->updateCellAttributes(0,
74                                                                         1,
75                                                                         array('width'=>'150','class'=>'imprimir_bandas'));
76 $tabla_cuerpo->updateCellAttributes(0,
77                                                                         2,
78                                                                         array('width'=>'24','class'=>'imprimir_bandas'));
79 $tabla_cuerpo->updateCellAttributes(1,
80                                                                         0,
81                                                                         array('height'=>'1'));
82 $tabla_cuerpo->updateCellAttributes(1,
83                                                                         1,
84                                                                         array('height'=>'1'));
85 $tabla_cuerpo->updateCellAttributes(1,
86                                                                         2,
87                                                                         array('height'=>'1'));
88
89 $m->addBodyContent($tabla_cuerpo);
90
91 /* Fin del encabezado propio de la pagina*/
92 /* 
93 Aca empieza las tablas con la informacion personal del agente y
94 con las referencias de cada color de las celdas
95 */
96
97 /* Armo la tabla de la información personal */
98
99 $tabla_info_personal_adentro = new HTML_Table(array('width'=>'360',
100                                                                                         'border'=>'0',
101                                                                                         'valign'=>'top',
102                                                                                         'cellspacing'=>'2',
103                                                                                         'cellpadding'=>'0'));
104 $row = array('Datos personales');
105 $imagen = new MECON_HTML_Image('../../images/servicios_bandas_borde_tabla.gif','');
106
107 $tabla_info_personal_adentro->addRow($row, array('colspan'=>'2', 'class'=>'titulo_form', 'align'=>'left'));
108
109 $row = array('Agente',$agente->getNombre());
110 $tabla_info_personal_adentro->addRow($row);
111
112 $row = array('N° de documento',$agente->agente);
113 $tabla_info_personal_adentro->addRow($row);
114
115 $dep =& new MECON_Dependencia($agente->getDependencia());
116 $row = array('Dependencia',$dep->getNombre());
117 $tabla_info_personal_adentro->addRow($row);
118
119 $row = array('Código',$agente->getDependencia());
120 $tabla_info_personal_adentro->addRow($row);
121
122 $hora_desde =& new MECON_Tiempo_Hora($agente->datos['hora_desde']);
123 $hora_hasta =& new MECON_Tiempo_Hora($agente->datos['hora_hasta']);
124 $row = array('Horario oficial',$hora_desde->get().' - '.$hora_hasta->get());
125 $tabla_info_personal_adentro->addRow($row);
126
127 $tipo_ag = $agente->getTipo();
128 if(preg_match('/^BEC/',$tipo_ag))
129 {
130         $tipo_ag = 'PASANTE';
131 }elseif(preg_match('/^CON/',$tipo_ag))
132 {
133         $tipo_ag = 'CONTRATADO';
134 }elseif(preg_match('/^ADS/',$tipo_ag))
135 {
136         $tipo_ag = 'ADSCRIPTO';
137 }elseif(preg_match('/^TRA/',$tipo_ag))
138 {
139         $tipo_ag = 'PLANTA TRANSITORIA';
140 }else
141 {
142         $tipo_ag = 'PLANTA PERMANENTE';
143 }
144
145 $row = array('Categoría',$tipo_ag);
146 $tabla_info_personal_adentro->addRow($row);
147
148 for($fila=1; $fila <= 6; $fila++)
149 {
150         $tabla_info_personal_adentro->updateCellAttributes($fila,0,array('class'=>'titulo_columna', 
151                                                                                                                                         'width'=>'120',
152                                                                                                                                         'background'=>$imagen->getSrc()));
153 }
154
155 $tabla_info_personal_adentro->updateColAttributes(1,array('class'=>'txt_fila', 
156                                                                                                         'bgcolor'=>'#FFFFFF',
157                                                                                                         'width'=>'180'));
158
159 $tabla_info_personal = new HTML_Table(array('width'=>'360',
160                                                                                         'border'=>'0',
161                                                                                         'cellspacing'=>'0',
162                                                                                         'cellpadding'=>'0',
163                                                                                         'bgcolor'=>'#003366'));
164 $tabla_info_personal->addRow(array($tabla_info_personal_adentro));
165
166 /* Armo la tabla de referencias */
167 $tabla_referencias_adentro = new HTML_Table(array('width'=>'360',
168                                                                                         'border'=>'0',
169                                                                                         'valign'=>'top',
170                                                                                         'cellspacing'=>'2',
171                                                                                         'cellpadding'=>'0'));
172 $row = array('Referencias');
173 $tabla_referencias_adentro->addRow($row, array('colspan'=>'2', 'class'=>'titulo_form', 'align'=>'left'));
174
175 $row = array('&nbsp;','Promedio diario');
176 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'#FFFFFF'));
177 $row = array('&nbsp;','Sábados/Domingos/Feriados');
178 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'lightblue'));
179 $row = array('&nbsp;','Lic. extraordinaria');
180 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'#009999'));
181 $row = array('&nbsp;','Otras inasistencias');
182 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'#CC66CC'));
183 $row = array('&nbsp;','Inasistencias');
184 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'#FF9900'));
185 $row = array('&nbsp;','Lic. enfermedad');
186 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'#00CC33'));
187 $row = array('&nbsp;','Lic. anual ordinaria');
188 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'#3366FF'));
189 $row = array('&nbsp;','Ausentes sin informar');
190 $tabla_referencias_adentro->addRow($row,array('bgcolor'=>'#FF0000'));
191
192 $tabla_referencias_adentro->updateColAttributes(0,array('width'=>'20',
193                                                                                                                 'class'=>'titulo_columna'));
194
195
196 $tabla_referencias_adentro->updateColAttributes(1,array('bgcolor'=>'#FFFFFF',
197                                                                                                                 'width'=>'340',
198                                                                                                                 'class'=>'txt_fila'));
199
200 $tabla_referencias = new HTML_Table(array('width'=>'360',
201                                                                                         'border'=>'0',
202                                                                                         'cellspacing'=>'0',
203                                                                                         'cellpadding'=>'0',
204                                                                                         'bgcolor'=>'#003366'));
205 $tabla_referencias->addRow(array($tabla_referencias_adentro));
206
207
208 /* Agrego las tablas de referencia al cuerpo */
209 $t = new HTML_Table(array('width'=>'760',
210                                                         'border'=>'0',
211                                                         'cellspacing'=>'0',
212                                                         'cellpadding'=>'0'));
213 $row = array();
214 $imagen = new MECON_HTML_Image('/MECON/images/blanco.gif',
215                                                 '',
216                                                 array('width'=>'360','height'=>'1','alt'=>'blanco'));
217 array_push($row,$imagen);
218 array_push($row,'');
219 $imagen = new MECON_HTML_Image('/MECON/images/blanco.gif',
220                                                 '',
221                                                 array('width'=>'40','height'=>'1','alt'=>'blanco'));
222 array_push($row,$imagen);
223 $imagen = new MECON_HTML_Image('/MECON/images/blanco.gif',
224                                                 '',
225                                                 array('width'=>'360','height'=>'1','alt'=>'blanco'));
226 array_push($row,$imagen);
227
228 $t->addRow($row);
229 $t->updateCellAttributes(0,0,array('colspan'=>'2'));
230
231 $row = array($tabla_info_personal,'','&nbsp;',$tabla_referencias);
232 $t->addRow($row,array('valign'=>'top'));
233 $t->updateCellAttributes(1,0,array('colspan'=>'2'));
234
235 /* Esta fila contiene las referencias */
236 $row_cuerpo = array($t);
237
238 $m->addBodyContent($t);
239
240 $m->addBodyContent('<BR>');
241
242 /* Armo la tabla de información */
243 $tabla_info_adentro = new HTML_Table(array('width'=>'760',
244                                                                                         'border'=>'0',
245                                                                                         'valign'=>'top',
246                                                                                         'cellspacing'=>'2',
247                                                                                         'cellpadding'=>'0'));
248 $row = array('Mes: '.$mes.' - Año: '.$fecha_spliteada[0]);
249 $tabla_info_adentro->addRow($row, array('colspan'=>'10', 'class'=>'titulo_form', 'align'=>'left'));
250
251
252 $horas=$agente->getHoras();
253 for($i=1;$i<4;$i++)
254 {
255         $aux=($i-1)*10;
256         $row=array(1+$aux,2+$aux,3+$aux,4+$aux,5+$aux,6+$aux,7+$aux,8+$aux,9+$aux,10+$aux);
257
258         $tabla_info_adentro->addRow($row,array('width'=>'76',
259                                                                                         'background'=>'../../images/servicios_bandas_borde_tabla.gif',
260                                                                                         'class'=>'titulo_columna'));
261         
262         $row=array();
263         $celda_ASN=array();
264         $celda_NOV=array();
265         $celda_FER=array();
266         for($j=1;$j<11;$j++)
267         {
268                 if(isset($horas[$j+$aux]['tiempo']))
269                 {
270                         array_push($row,$horas[$j+$aux]['tiempo']);
271                         if($horas[$j+$aux]['tiempo']=='0:00')
272                         {
273                                 if($horas[$j+$aux]['ASN']==1 || $horas[$j+$aux]['inconsistencia']==1)
274                                 {
275                                         array_push($celda_ASN,$j-1);
276                                         
277                                 }
278                                 if($horas[$j+$aux]['ASN']==0 && $horas[$j+$aux]['tipo']=='laborable')
279                                 {
280                                         array_push($celda_NOV,array($j-1,$horas[$j+$aux]['fecha']));
281                                         $row[$j-1]="<a href=\"\" onClick=\"window.open('./nov_dia.php?nrodoc=".$nrodoc."&fecha=".$horas[$j+$aux]['fecha']."','novedad','width=250,height=100');return(false);\">".$row[$j-1]."</a>";
282                                 }
283                         }
284                         ($horas[$j+$aux]['ASN']==0 && $horas[$j+$aux]['tipo']=='no laborable')?array_push($celda_FER,$j-1):0;
285                 }else
286                 {
287                         array_push($row,'&nbsp');
288                 }
289         }
290         $tabla_info_adentro->addRow($row,array('bgcolor'=>'#FFFFFF', 'class'=>'txt_fila'));
291         $tabla_info_adentro->addRow(array('&nbsp;'),array('colspan'=>'10',
292                                                                                                                 'bgcolor'=>'#FFFFFF',
293                                                                                                                 'class'=>'txt_fila'));
294         foreach ($celda_ASN as $c)
295         {
296                 $tabla_info_adentro->updateCellAttributes(($i-1)*3+2,$c,array('bgcolor'=>'red'));
297         }
298
299         foreach ($celda_NOV as $c)
300         {
301                 $novedad =& new MECON_NovedadesDia($nrodoc,new date($c[1]));
302                 if(preg_match('/^13/',$novedad->novedades[0]->codigo))
303                 {
304                         $color='#009999';
305                 }elseif(preg_match('/^15||^2606\/83$||^Adp$||^Com$||^Coms$||^FES\/REL$||^Fran$||^Grem$/',$novedad->novedades[0]->codigo))
306                 {
307                         $color='#CC66CC';
308                 }elseif(preg_match('/^14||^Asa$||^Pap$||^Sus$/',$novedad->novedades[0]->codigo))
309                 {
310                         $color='#FF9900';
311                 }elseif(preg_match('/^10||^Pat$/',$novedad->novedades[0]->codigo))
312                 {
313                         $color='#00CC33';
314                 }elseif(preg_match('/^9/',$novedad->novedades[0]->codigo))
315                 {
316                         $color='#3366FF';
317                 }
318
319                 $tabla_info_adentro->updateCellAttributes(($i-1)*3+2,$c[0],array('bgcolor'=>$color));
320         }
321         
322         foreach ($celda_FER as $c)
323         {
324                 $tabla_info_adentro->updateCellAttributes(($i-1)*3+2,$c,array('bgcolor'=>'lightblue'));
325         }
326
327 }
328
329 if(isset($horas[31]['tiempo']))
330 {
331         $row = array(31,'Días Trabajados','','','Días Laborables Trabajados','','','Promedio','','');
332         
333         $tabla_info_adentro->addRow($row,array('class'=>'titulo_columna',
334                                                                                         'background'=>'../../images/servicios_bandas_borde_tabla.gif'));
335         $row = array($horas[31]['tiempo'],
336                                 $agente->getDiasTrabajados(),'','',
337                                 $agente->getDiasLaborablesTrabajados(),'','',
338                                 $agente->getPromedioMensual(),'','');
339
340         if($horas[31]['tiempo']=='0:00' && $horas[31]['ASN']==0 && $horas[31]['tipo']=='laborable')
341         {
342                 $row[0]="<a href=\"\" onClick=\"window.open('./nov_dia.php?nrodoc=".
343                                         $nrodoc."&fecha=".$horas[31]['fecha'].
344                                         "','novedad','width=\"250\" height=\"100\"');return(false);\">
345                                         ".$horas[31]['tiempo']."</a>";
346         }
347         $tabla_info_adentro->addRow($row,array('class'=>'txt_fila',
348                                                                                         'bgcolor'=>'#FFFFFF'));
349
350         if($horas[31]['tiempo']=='0:00')
351         {
352                 if($horas[31]['ASN']==1)
353                 {
354                         $tabla_info_adentro->updateCellAttributes(11,0,array('bgcolor'=>'red'));
355                 }
356                 if($horas[31]['ASN']==0 && $horas[31]['tipo']=='laborable')
357                 {
358                         preg_replace('/(..)$/','31',$fecha);
359                         $novedad =& new MECON_NovedadesDia($nrodoc,new date($fecha));
360                         if(preg_match('/^13/',$novedad->novedades[0]->codigo))
361                         {
362                                 $color='#009999';
363                         }elseif(preg_match('/^15||^2606\/83$||^Adp$||^Com$||^Coms$||^FES\/REL$||^Fran$||^Grem$/',$novedad->novedades[0]->codigo))
364                         {
365                                 $color='#CC66CC';
366                         }elseif(preg_match('/^14||^Asa$||^Pap$||^Sus$/',$novedad->novedades[0]->codigo))
367                         {
368                                 $color='#FF9900';
369                         }elseif(preg_match('/^10||^Pat$/',$novedad->novedades[0]->codigo))
370                         {
371                                 $color='#00CC33';
372                         }elseif(preg_match('/^9/',$novedad->novedades[0]->codigo))
373                         {
374                                 $color='#3366FF';
375                         }
376                         $tabla_info_adentro->updateCellAttributes(11,0,array('bgcolor'=>$color));
377                 }
378         }
379         if($horas[31]['ASN']==0 && $horas[31]['tipo']=='no laborable')
380         {
381                 $tabla_info_adentro->updateCellAttributes(11,0,array('bgcolor'=>'lightblue'));
382         }
383         
384         $tabla_info_adentro->updateCellAttributes(10,1,array('colspan'=>'3'));
385         $tabla_info_adentro->updateCellAttributes(10,4,array('colspan'=>'3'));
386         $tabla_info_adentro->updateCellAttributes(10,7,array('colspan'=>'3'));
387
388         $tabla_info_adentro->updateCellAttributes(11,1,array('colspan'=>'3'));
389         $tabla_info_adentro->updateCellAttributes(11,4,array('colspan'=>'3'));
390         $tabla_info_adentro->updateCellAttributes(11,7,array('colspan'=>'3'));
391
392 }else
393 {
394         $row = array('Días Trabajados','','','','Días Laborables Trabajados','','','Promedio','','');
395         $tabla_info_adentro->addRow($row,array('class'=>'titulo_columna',
396                                                                                         'background'=>'../../images/servicios_bandas_borde_tabla.gif'));
397         $tabla_info_adentro->updateCellAttributes(10,0,array('colspan'=>'4'));
398         $tabla_info_adentro->updateCellAttributes(10,4,array('colspan'=>'3'));
399         $tabla_info_adentro->updateCellAttributes(10,7,array('colspan'=>'3'));
400         
401         $row = array($agente->getDiasTrabajados(),'','','',
402                                 $agente->getDiasLaborablesTrabajados(),'','',
403                                 $agente->getPromedioMensual(),'','');
404
405         $tabla_info_adentro->addRow($row,array('class'=>'txt_fila',
406                                                                                         'bgcolor'=>'#FFFFFF'));
407         $tabla_info_adentro->updateCellAttributes(11,0,array('colspan'=>'4'));
408         $tabla_info_adentro->updateCellAttributes(11,4,array('colspan'=>'3'));
409         $tabla_info_adentro->updateCellAttributes(11,7,array('colspan'=>'3'));
410
411 }
412
413
414 $tabla_info = new HTML_Table(array('width'=>'760',
415                                                                         'border'=>'0',
416                                                                         'cellspacing'=>'0',
417                                                                         'cellpadding'=>'0',
418                                                                         'bgcolor'=>'#003366'));
419
420 $tabla_info->addRow(array($tabla_info_adentro));
421 $m->addBodyContent($tabla_info);
422
423 $m->addBodyContent('<BR>');
424
425 /* Comienzo a mostrar los links con las notas, accesos y salidas autorizadas*/
426 $tabla_notas = new HTML_Table(array('width'=>'760',
427                                                                         'border'=>'0',
428                                                                         'cellspacing'=>'0',
429                                                                         'cellpadding'=>'0',
430                                                                         'bgcolor'=>'#003366'));
431
432 $imagen_notas = new MECON_HTML_Image('../../images/servicios_notas.gif',
433                                                          '',
434                                                         array('width'=>'24','height'=>'24','valign'=>'top'));
435
436 $imagen_anterior = new MECON_HTML_Image('../../images/servicios_bandas_anterior.gif',
437                                                                 '',
438                                                                 array('width'=>'16','height'=>'10','valign'=>'top'));
439                                                                 
440 $imagen_visto = new MECON_HTML_Image('../../images/servicios_visto.gif',
441                                                                 '',
442                                                                 array('width'=>'16','height'=>'10','valign'=>'top'));
443 $link_volver = new MECON_HTML_LINK('./','volver');
444
445 $row = array($imagen_notas,'Nota: Fecha de último cruce con las novedades',$imagen_anterior->toHtml().' '.$link_volver->toHtml(),$imagen_visto->toHtml().' accesos',$imagen_visto->toHtml().' salidas autorizadas');
446                         
447 $tabla_notas->addRow($row,array('class'=>'imprimir_bandas',
448                                                                                 'bgcolor'=>'#FFFFFF'));
449
450 $tabla_notas->updateCellAttributes(0,0,array('width'=>'24','height'=>'24','class'=>'aclarar'));
451 $tabla_notas->updateCellAttributes(0,1,array('width'=>'370','height'=>'30','class'=>'aclarar'));
452 $tabla_notas->updateCellAttributes(0,2,array('width'=>'130','class'=>'imprimir_bandas'));
453 $tabla_notas->updateCellAttributes(0,3,array('width'=>'130','class'=>'imprimir_bandas'));
454 $tabla_notas->updateCellAttributes(0,4,array('width'=>'130','class'=>'imprimir_bandas'));
455
456 $m->addBodyContent($tabla_notas);
457 $m->display();
458 ?>
459