-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexportar.php
More file actions
114 lines (102 loc) · 5.53 KB
/
exportar.php
File metadata and controls
114 lines (102 loc) · 5.53 KB
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
<?php
header("Content-Type: application/xls; charset=utf-16");
header("Content-Disposition: attachment; filename= reporte_tickets.xls");
include_once 'funciones/bd-conexion.php';
//Establecemos la zona horaria
date_default_timezone_set('America/Guatemala');
//Funcion que devuelve el tiempo transcurrido
function tiempo_transcurrido($segundos){
$arrayfecha = array(
' año' => $segundos / 31556926 % 12,
' mes' => $segundos / 604800 % 52,
' dia' => $segundos / 86400 % 7,
' hora' => $segundos / 3600 % 24,
' minutos' => $segundos / 60 % 60,
' segundos' => $segundos % 60
);
foreach($arrayfecha as $llave => $valor){
if($valor > 1)$tiempo[] =" ".$valor. $llave;
}
$ret[] = 'Trasncurridos';
return join('', $tiempo);
} //fin de la funcion
$stmt = $conn->prepare("SELECT `idticket`, `sn`, `nombrecontacto`, `fecharegistro`, `estado`, `clienteid`, clientes.empresa FROM `tickets` JOIN clientes ON tickets.clienteid = clientes.idcliente ORDER BY `clientes`.`empresa` DESC " );
$stmt->execute();
?>
<table id="registrados" border="1" cellpadding="1" cellspacing="1" class="table table-bordered table-striped">
<thead>
<tr>
<th class="border">CODIGO</th>
<th>NOMBRE CONTACTO</th>
<th>SN</th>
<th>ESTADO</th>
<th>EMPRESA</th>
<th>FECHA REGISTRO</th>
<th>FECHA ATENCION</th>
<th>TIEMPO TRANSCURRIDO</th>
</tr>
</thead>
<tbody>
<?php while ($ticket = $stmt->fetch()) { ?>
<tr>
<td><?php echo utf8_decode($ticket ['idticket']); ?></td>
<td><?php echo utf8_decode($ticket ['nombrecontacto']); ?></td>
<td><?php echo utf8_decode($ticket ['sn']); ?></td>
<td>
<?php
$estado = $ticket ['estado'];
$id = $ticket['idticket'];
switch ($estado) {
case 4:
$stmt2 = $conn->prepare("SELECT * FROM asignaciones WHERE ticketid = :ticketid " );
$stmt2->bindValue(":ticketid", $id, PDO::PARAM_STR);
$stmt2->execute();
$resultado2 = $stmt2->fetch();
$idasignacion = $resultado2['idasignacion'];
$stmt3 = $conn->prepare("SELECT * FROM finallizado WHERE asignacionid = :asignacionid " );
$stmt3->bindValue(":asignacionid", $idasignacion, PDO::PARAM_INT);
$stmt3->execute();
$resultado3 = $stmt3->fetch();
echo '<strong style="color: green;">finalizado</strong>';
break;
case 1:
echo '<strong style="color: rgb(202, 179, 51);">registrado</strong>';
break;
case 2:
echo '<strong style="color: blue;">asignado</strong>';
break;
case 3:
echo '<strong style="color: red;">incidencia</strong>';
break;
};
?>
</td>
<td><?php echo utf8_decode($ticket['empresa']); ?></td>
<td><?php echo utf8_decode($ticket ['fecharegistro']); ?></td>
<?php if($estado == 4){ ?>
<td><?php echo $resultado3['fechafinalizado']; ?></td>
<?php } else{
echo "<td> </td>";
} ?>
<!-- Calculamos el total de horas transcurridas -->
<?php if($estado == 4){ ?>
<td>
<?php
$start_time = strtotime($ticket ['fecharegistro']);
$end_time = strtotime($resultado3['fechafinalizado']);
echo tiempo_transcurrido($end_time - $start_time);
?>
</td>
<?php }else{ ?>
<td>
<?php
$start_time = strtotime($ticket ['fecharegistro']);
$end_time = strtotime(date('Y-m-d H:m:s'));
echo tiempo_transcurrido($end_time - $start_time);
?>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>