-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgestionarTarea.php
524 lines (430 loc) · 20 KB
/
gestionarTarea.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<?php
session_start();
header("Cache-control: private");
$_SESSION['detalle']="TRUE";
require_once "inc/theme.inc";
require "inc/funciones.inc";
require "inc/funcionesCambiarEstado.inc";
require "inc/funcionesModificar.inc";
//Conectar con el servidor de base de datos
$conn=conectar_bd();
$id = $_REQUEST['id'];
$mensaje = "";
// Si ya hemos introducido valores para gestionar la tarea
if($_SERVER['REQUEST_METHOD']=='POST') {
//Funcion cambio de estado de la tarea
if (isset($_POST['cambiarEstado'])){
$mensaje = cambiarEstado($conn, $id);
}
//Funcion modificar la tarea
if (isset($_REQUEST['modificar'])){
$mensaje = modificarTarea($conn, $id);
}
//Funcion subir archivo de la tarea
if (isset($_REQUEST['subirArchivo'])){
$mensaje = subirArchivo($conn, $id);
}
}
if ($id != '') {
$tsql = "SELECT *
FROM INV_TBTAREAS
LEFT JOIN INV_VIEW_DATOS_TODO ON INV_VIEW_DATOS_TODO.ID_TAREA = INV_TBTAREAS.ID
WHERE ID = '$id'";
$resultado = sqlsrv_query($conn, $tsql);
if( $resultado === false ) {
die( print_r( sqlsrv_errors(), true));
} else {
$registro = sqlsrv_fetch_array($resultado);
}
sqlsrv_free_stmt($resultado);
$tsql = "SELECT *
FROM INV_TBTAREAS
LEFT JOIN INV_VIEW_DATOS_TODO ON INV_VIEW_DATOS_TODO.ID_TAREA = INV_TBTAREAS.ID";
if ($registro['REF'] != '') {
if ($registro['INCIDENCIA'] != '') {
$tsql = $tsql." WHERE (REF = '".$registro['REF']."' OR INCIDENCIA = '".$registro['INCIDENCIA']."')
AND INV_TBTAREAS.ID <> '$id'
ORDER BY INV_TBTAREAS.FECHA_REGISTRO, INV_TBTAREAS.FECHA_INICIO, INV_TBTAREAS.FECHA_RESOL";
} else {
$tsql = $tsql." WHERE REF = '".$registro['REF']."'
AND INV_TBTAREAS.ID <> '$id'
ORDER BY INV_TBTAREAS.FECHA_REGISTRO, INV_TBTAREAS.FECHA_INICIO, INV_TBTAREAS.FECHA_RESOL";
}
} else {
if ($registro['INCIDENCIA'] != '') {
$tsql = $tsql." WHERE INCIDENCIA = '".$registro['INCIDENCIA']."'
AND INV_TBTAREAS.ID <> '$id'
ORDER BY INV_TBTAREAS.FECHA_REGISTRO, INV_TBTAREAS.FECHA_INICIO, INV_TBTAREAS.FECHA_RESOL";
} else {
$tsql = $tsql." WHERE INV_TBTAREAS.ID <> '$id'
ORDER BY INV_TBTAREAS.FECHA_REGISTRO, INV_TBTAREAS.FECHA_INICIO, INV_TBTAREAS.FECHA_RESOL";
}
}
$resultado = sqlsrv_query($conn, $tsql);
if( $resultado === false ) {
die( print_r( sqlsrv_errors(), true));
}
} else {
die( print_r('TAREA NO INFORMADA', true));
}
// print the page header
print_theme_header();
?>
<!-- start: Content -->
<div id="content" class="span12">
<ul class="breadcrumb">
<li>
<i class="icon-home"></i>
<a href="index.php">Home</a>
<i class="icon-angle-right"></i>
</li>
<li><a href="#">Gestionar</a></li>
</ul>
<!--FORMULARIO-->
<form method="post" action="gestionarTarea.php" role="form" enctype="multipart/form-data">
<fieldset>
<!--DETALLE TAREA-->
<div style="padding-left:5px;" class="row-fluid yellow">
<div class="control-group form-group span2">
<div class="controls">
<input class="hidden" name="ID_REGION" value="<?php echo $registro['ID_REGION'];?>">
<strong>REGION: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="REGION" value="<?php echo $registro['REGION'];?>">
</div>
</div>
<div class="control-group form-group span2">
<div class="controls">
<strong>PROVINCIA: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="PROVINCIA" value="<?php echo $registro['PROVINCIA'];?>">
</div>
</div>
<div class="control-group form-group span2">
<div class="controls">
<input class="hidden" name="COD_CABECERA" value="<?php echo $registro['cod_cabecera'];?>">
<strong>CABECERA: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="CABECERA" value="<?php echo $registro['CABECERA'];?>">
</div>
</div>
<div class="control-group form-group span2">
<div class="controls">
<strong>ARBOL: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="ARBOL" value="<?php echo $registro['ARBOL'];?>">
</div>
</div>
<div class="control-group form-group span2">
<div class="controls">
<strong>ID_ACTUACION: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="ID_ACTUACION" value="<?php echo $registro['ID_ACTUACION'];?>">
</div>
</div>
<div class="control-group form-group span2">
<div class="controls">
<strong>GESTOR: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="GESTOR" value="<?php echo $registro['GESTOR'];?>">
</div>
</div>
</div>
<div class="row-fluid">
<div class="span2" ontablet="span4" ondesktop="span2">
<div class="control-group form-group">
<div class="controls">
<strong>ID: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="id" value="<?php echo $id;?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>ID_GD: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="ID_GD" value="<?php echo $registro['ID_GD'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>REF: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="REF" value="<?php echo $registro['REF'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>INCIDENCIA: </strong><input type="text" class="form-control input" name="INCIDENCIA" value="<?php echo $registro['INCIDENCIA'];?>">
</div>
</div>
</div>
<div class="span2" ontablet="span4" ondesktop="span2">
<div class="control-group form-group">
<div class="controls">
<strong>PRIORIDAD: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="PRIORIDAD" value="<?php echo $registro['PRIORIDAD'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<input class="hidden" name="ID_ACTIVIDAD" value="<?php echo $registro['id_actividad'];?>">
<strong>ACTIVIDAD: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="ACTIVIDAD" value="<?php echo $registro['ACTIVIDAD'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<input class="hidden" name="ID_SUBACTIVIDAD" value="<?php echo $registro['id_Subactividad'];?>">
<strong>SUBACTIVIDAD: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="SUBACTIVIDAD" value="<?php echo $registro['SUBACTIVIDAD'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>ESTADO: <br /></strong>
<?php
//id del estado de la tarea
$tsql="select id_estado from inv_tbestados where estado='".$registro['ESTADO']."'";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false ){die ("Error al ejecutar consulta: ".$tsql);}
$id_estado_Tarea = sqlsrv_fetch_array($stmt);
//tabla y array de estados de estados
$tsql="select id_estado, estado from inv_tbestados order by id_estado";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false ){die ("Error al ejecutar consulta: ".$tsql);}
//array de estados
$array_estados = array();
while($row_estados = sqlsrv_fetch_array($stmt)){
$array_estados[$row_estados['id_estado']] = $row_estados['estado'];
}
//tabla de estados posibles desde el estado actual
$tsql="select DISTINCT id_estado_fin
from INV_tbMotor_estados
where id_estado_ini = '".$id_estado_Tarea['id_estado']."'";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false ){die ("Error al ejecutar consulta: ".$tsql);}
echo '<SELECT tabindex="2" id="ESTADO" name="ESTADO" >';
echo '<option class="form-control input" value="'.$id_estado_Tarea['id_estado'].'-'.$registro['ESTADO'].'" selected="selected" >'.$registro['ESTADO'].'</option>';
while($row = sqlsrv_fetch_array($stmt)){
echo '<option class="form-control input" value="'.$row['id_estado_fin'].'-'.$array_estados[$row['id_estado_fin']].'" >'.$array_estados[$row['id_estado_fin']].'</option>';
}
echo '</SELECT>';
?>
</div>
</div>
</div>
<div class="span2" ontablet="span4" ondesktop="span2">
<div class="control-group form-group">
<div class="controls">
<strong>FECHA_INICIO: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="FECHA_INICIO" value="<?php echo date_format($registro['FECHA_INICIO'], 'Y-m-d H:i:s'); ?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>FECHA_RESOL: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="FECHA_RESOL" value="<?php echo date_format($registro['FECHA_RESOL'], 'Y-m-d H:i:s'); ?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>FECHA_REGISTRO: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="FECHA_REGISTRO" value="<?php echo date_format($registro['FECHA_REGISTRO'], 'Y-m-d H:i:s'); ?>">
</div>
</div>
</div>
<div class="span2" ontablet="span4" ondesktop="span2">
<div class="control-group form-group">
<div class="controls">
<strong>USUORIGEN: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="USUORIGEN" value="<?php echo $registro['USUORIGEN'];?>">
<?php echo '<input readonly="true" type="text" class="form-control input uneditable-input hidden" name="ID_USUORIGEN" value="'.get_idFromNombre($registro['USUORIGEN']).'">';?>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>GRUPO: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="GRUPO" value="<?php echo $registro['GRUPO'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>GRUPO_ESCALADO: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="GRUPO_ESCALADO" value="<?php echo $registro['GRUPO_ESCALADO'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>TÉCNICO: </strong><?php echo '<input readonly="true" type="text" class="form-control input uneditable-input" name="TECNICO" value="'.(($registro['TECNICO'] == '')?get_nombre($_SESSION['usuario']):$registro['TECNICO']).'">';?>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<?php echo '<input readonly="true" type="text" class="form-control input uneditable-input hidden" name="ID_TECNICO" value="'.(($registro['TECNICO'] == '')?get_idUsu($_SESSION['usuario']):get_idFromNombre($registro['TECNICO'])).'">';?>
</div>
</div>
</div>
<div class="span2" ontablet="span4" ondesktop="span2">
<div class="control-group form-group">
<div class="controls">
<strong>TICKET_OCEANE: </strong><input type="text" class="form-control input" name="TICKET_OCEANE" value="<?php echo $registro['TICKET_OCEANE'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>TP: </strong><input type="text" class="form-control input" name="TP" value="<?php echo $registro['TP'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<strong>ID_MAPEO: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="ID_MAPEO" value="<?php echo $registro['ID_MAPEO'];?>">
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<input class="hidden" name="ID_EEMM" value="<?php echo $registro['ID_EEMM'];?>">
<strong>ID_TIPO_ENTRADA: </strong><input readonly="true" type="text" class="form-control input uneditable-input" name="ID_TIPO_ENTRADA" value="<?php echo $registro['ID_TIPO_ENTRADA'];?>">
</div>
</div>
</div>
<div class="span2" ontablet="span4" ondesktop="span2">
<div class="control-group form-group">
<div class="controls">
<strong>CTOS: </strong><br>
<?php
//CTOS DE LA ACTUACION
$tsql = "SELECT INV_CTOS.NUMERO, INV_CTOS.COD_CTO
FROM INV_TBTAREAS
INNER JOIN INV_CTOS ON INV_CTOS.id_Actuacion = INV_TBTAREAS.ID_ACTUACION
WHERE INV_TBTAREAS.ID = '$id'";
$ctosActuacion = sqlsrv_query($conn, $tsql);
if( $ctosActuacion === false ) {
die( print_r( sqlsrv_errors(), true));
}
//CTOS DE LA TAREA
$tsql = "SELECT INV_CTOS.NUMERO
FROM INV_TBTAREAS
INNER JOIN INV_TBTAREAS_CTO ON INV_TBTAREAS_CTO.ID = INV_TBTAREAS.id
INNER JOIN INV_CTOS ON INV_CTOS.COD_CTO = INV_TBTAREAS_CTO.COD_CTO
WHERE INV_TBTAREAS.ID = '$id'";
$ctosTarea = sqlsrv_query($conn, $tsql);
if( $resultado === false ) {
die( print_r( sqlsrv_errors(), true));
}
$arrayCtosTarea = array();
while(($row = sqlsrv_fetch_array($ctosTarea))) {
$arrayCtosTarea[] = $row['NUMERO'];
}
$rows = sqlsrv_has_rows($ctosActuacion );
if ($rows === true){
while ($cto = sqlsrv_fetch_array($ctosActuacion)){
echo "<INPUT TYPE='CHECKBOX' name='MARCAR[]' VALUE='" .$cto['COD_CTO'] . "'".((in_array($cto['NUMERO'], $arrayCtosTarea))?' checked':'')."> ".$cto['NUMERO']."<br> ";
}
}
?>
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="form-group span5">
<strong >COMENTARIOS: </strong>
<textarea rows="5" name="COMENTARIOS" class="form-control" name="COMENTARIOS"><?php echo $registro['COMENTARIOS'];?></textarea>
</div>
<div class="form-group span5">
<strong>COMENTARIOS2: </strong>
<textarea rows="5" name="COMENTARIOS2" class="form-control" name="COMENTARIOS2"><?php echo $registro['COMENTARIOS2'];?></textarea>
</div>
</div>
<div class="row-fluid">
<div class="form-group span1">
<?php
$tsqlArchivo="SELECT archivo from INV_TBARCHIVOS WHERE idTarea='".$id."'";
$stmtArchivo = sqlsrv_query( $conn, $tsqlArchivo);
while($rowArchivo = sqlsrv_fetch_array($stmtArchivo)){
$nombreArchivo= $rowArchivo["archivo"];
}
sqlsrv_free_stmt( $stmtArchivo);
if (isset($nombreArchivo)){
echo "<a class='btn btn-small' href='upload/".$nombreArchivo."'><i class='halflings-icon white paperclip'></i><span> Archivo Anexo</span></a>";
}
?>
</div>
<div class="form-group span2">
<div class="control-group form-group">
<div class="controls">
<input type="file" name="adjunto" id="adjunto" />
</div>
</div>
</div>
<div class="form-group span1">
<div class="control-group form-group">
<div class="controls">
<button onclick="return confirmarSubir();" type="submit" name="subirArchivo" value="subirArchivo" class="btn btn-info btn-small subirArchivo"><i class="halflings-icon white upload"></i> Subir Archivo</button>
</div>
</div>
</div>
<div class="form-group span1">
<div class="control-group form-group">
<div class="controls">
<button type="submit" name="cambiarEstado" value="cambiarEstado" class="btn btn-danger btn-small cambiarEstado" onclick="return confirmarAccion();"><i class="halflings-icon white play"></i> Cambiar Estado</button>
</div>
</div>
</div>
<div class="form-group span1">
<div class="control-group form-group">
<div class="controls">
<button type="submit" name="modificar" value="modificar" class="btn btn-danger btn-small modificar" onclick="return confirmarAccion();"><i class="halflings-icon white play"></i> Modificar</button>
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<?php echo $mensaje;?>
</div>
</div>
</fieldset>
<!--FIN DETALLE-->
<!--LISTADO DE TAREAS ASOCIADAS-->
<div class="row-fluid">
<div class="box span12">
<div class="box-header" data-original-title>
<h2><i class="halflings-icon user"></i><span class="break"></span>Listado Tareas Asociadas</h2>
</div>
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>ID_TAREA</th>
<th>REMEDY</th>
<th>REFERENCIA</th>
<th>OCEAN</th>
<th>ACTIVIDAD</th>
<th>SUBACTIVIDAD</th>
<th>SOLICITANTE</th>
<th>TÉCNICO</th>
<th>F.REGIS.</th>
<th>F.INIC.</th>
<th>F.RESOL.</th>
<th>ESTADO</th>
<th>P</th>
<th>TRANSACCIÓN</th>
</tr>
</thead>
<tbody>
<?php while ($lineaAsoc = sqlsrv_fetch_array($resultado)){ ?>
<td class="center"><?php echo $lineaAsoc['ID_TAREA']; ?></td>
<td class="center"><?php echo $lineaAsoc['REMEDY']; ?></td>
<td class="center"><?php echo $lineaAsoc['REF_TBTAREA']; ?></td>
<td class="center"><?php echo $lineaAsoc['OCEANE_TBTAREA']; ?></td>
<td class="center"><?php echo $lineaAsoc['ACTIVIDAD']; ?></td>
<td class="center"><?php echo $lineaAsoc['SUBACTIVIDAD']; ?></td>
<td class="center"><?php echo $lineaAsoc['USUORIGEN']; ?></td>
<td class="center"><?php echo $lineaAsoc['TECNICO']; ?></td>
<td class="center"><?php echo date_format($lineaAsoc['FECHA_REGISTRO'], 'Y-m-d H:i:s'); ?></td>
<td class="center"><?php echo date_format($lineaAsoc['FECHA_INICIO'], 'Y-m-d H:i:s'); ?></td>
<td class="center"><?php echo date_format($lineaAsoc['FECHA_RESOL'], 'Y-m-d H:i:s'); ?></td>
<td class="center"><?php echo $lineaAsoc['ESTADO']; ?></td>
<td class="center"><?php echo $lineaAsoc['PRIORIDAD']; ?></td>
<td class="center">
<a title="Gestionar" class="btn btn-danger btn-mini gestionar_tarea" href="<?php echo 'gestionarTarea.php?id='.$lineaAsoc['ID_TAREA']; ?>">
<i class="halflings-icon white edit"></i>
</a>
</td>
</tr>
<?php }
sqlsrv_free_stmt($resultado);
sqlsrv_close($conn);
?>
</tbody>
</table>
</div>
</div>
</div>
</form>
<!--FIN FILTROS-->
</div><!--/#content.span10-->
</div><!--/row-->
</div><!--/.fluid-container-->
<!-- Modal Editar Grupo-->
<div class="clearfix"></div>
<?php
print_theme_footer();
sqlsrv_free_stmt($registros);
?>