/
reporte_viajes.php
166 lines (155 loc) · 6.34 KB
/
reporte_viajes.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
<?php
if (!isset($_COOKIE['nombre_usuario'])) {
header('Location: index.php');
}
$titulo_pagina = 'Reporte Viajes';
$titulo_sistema = 'Mamut Peru';
require_once('recursos/componentes/header.php');
require_once('nucleo/include/MasterConexion.php');
?>
<div class='control-group'>
<label>Fecha Inicio</label>
<input class='form-control' placeholder='Fecha Inicio' id='fecha_inicio' name='fecha_inicio' value="<?php if(isset($_GET["fi"])){echo $_GET["fi"];}?>"/>
</div>
<div class='control-group'>
<label>Fecha Fin</label>
<input class='form-control' placeholder='Fecha Fin' id='fecha_fin' name='fecha_fin' value="<?php if(isset($_GET["ff"])){echo $_GET["ff"];}?>"/>
</div>
<div class='control-group'>
<label>Tipo Unidad</label>
<select class='form-control' id='tipo_unidad' name='tipo_unidad'>
<option value="0" <?php if(isset($_GET["tu"])){ if($_GET["tu"] === "0"){echo " selected";}}?>>Todas</option>
<?php
require_once 'nucleo/tipo_unidad.php';
$objtipo_unidad = new tipo_unidad();
$ltu = $objtipo_unidad->listDB();
if(is_array($ltu)){
foreach ($ltu as $tu){
echo '<option value="'.$tu["id"].'"';
if(isset($_GET["tu"])){
if($_GET["tu"] === $tu["id"]){
echo " selected";
}
}
echo'>'.$tu["nombre"].'</option>';
}
}
?>
</select>
</div>
<div class='control-group'>
<label>Trayecto</label>
<select class='form-control' id='trayecto' name='trayecto'>
<?php
require_once 'nucleo/trayecto.php';
$objtrayecto = new trayecto();
$ltr = $objtrayecto->listDB();
if(is_array($ltr)){
foreach ($ltr as $tr){
echo '<option value="'.$tr["id"].'"';
if(isset($_GET["tr"])){
if($_GET["tr"] === $tr["id"]){
echo " selected";
}
}
echo'>'.$tr["nombre"].'</option>';
}
}
?>
</select>
</div>
<div class='control-group'>
<label>Facturado</label>
<select class='form-control' id='facturado' name='facturado' >
<option value='0'<?php if(isset($_GET["fac"])){ if($_GET["fac"] === "0"){echo " selected";}}?>>No</option>
<option value='1'<?php if(isset($_GET["fac"])){ if($_GET["fac"] === "1"){echo " selected";}}?>>Si</option>
</select>
</div>
<div class='control-group'>
<label>Numero Facturacion</label>
<input class='form-control' placeholder='Numero Facturacion' id='numero_facturacion' name='numero_facturacion' value="<?php if(isset($_GET["nfac"])){echo $_GET["nfac"];}?>"/>
</div>
<div class='control-group'>
<p></p>
<button type='button' class='btn btn-danger' onclick='filtrar()'>Filtrar</button>
</div>
</form>
<hr/>
<?php
include_once('nucleo/registro.php');
include_once('nucleo/conductor.php');
include_once('nucleo/grupo_conductor.php');
?>
<div class='contenedor-tabla'>
<table id='tb' class='display' cellspacing='0' width='100%'>
<thead>
<tr>
<th>Codigo</th>
<th>Nombre</th>
<th>Grupo</th>
<?php
if(isset($_GET["fi"])){
if($_GET["fi"] !== "" && $_GET["ff"] !== ""){
$fecha1 = $_GET["fi"];
$fecha2 = $_GET["ff"];
for($i=$fecha1;$i<=$fecha2;$i = date("Y-m-d", strtotime($i ."+ 1 days"))){
echo "<th>".$i."</th>";
}
}
}
?>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
$sql_where = "";
if(isset($_GET["tu"])){
if($_GET["tu"] !== "0"){
$sql_where .= " AND u.id_tipo_unidad = '".$_GET["tu"]."'";
}
}
if(isset($_GET["tr"])){
$sql_where .= " AND r.id_trayecto = '".$_GET["tr"]."'";
}
if(isset($_GET["fac"])){
$sql_where .= " AND r.facturado = '".$_GET["fac"]."'";
}
if(isset($_GET["nfac"])){
if($_GET["nfac"] !== ""){
$sql_where .= " AND r.numero_facturacion = '".$_GET["nfac"]."'";
}
}
$objconductor = new conductor();
$cons = $objconductor->listDB();
if(is_array($cons)){
foreach($cons as $co){
$total = 0;
echo "<tr>";
echo "<td>".$co["codigo"]."</td>";
echo "<td>".$co["nombres"]." ".$co["apellidos"]."</td>";
$objgc = new grupo_conductor();
$objgc->setId($co["id_grupo_conductor"]);
$objgc->getDB();
echo "<td>".$objgc->getNombre()."</td>";
if(isset($_GET["fi"])){
if($_GET["fi"] !== "" && $_GET["ff"] !== ""){
$fecha1 = $_GET["fi"];
$fecha2 = $_GET["ff"];
for($i=$fecha1;$i<=$fecha2;$i = date("Y-m-d", strtotime($i ."+ 1 days"))){
$objreg = new registro();
$conteo = $objreg->consulta_arreglo("Select count(id) as cnt from registro WHERE id_conductor = '".$co["id"]."' AND fecha = '".$i."'");
echo "<td>".intval($conteo["cnt"])."</td>";
$total = $total + intval($conteo["cnt"]);
}
}
}
echo "<td>".$total."</td>";
echo "</tr>";
}
}
?>
<?php
$nombre_tabla = 'reporte_viajes';
require_once('recursos/componentes/footer.php');
?>