-
Notifications
You must be signed in to change notification settings - Fork 0
/
adm_reporte_envios.php
328 lines (310 loc) · 12.2 KB
/
adm_reporte_envios.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
<?php include("inc_session.php"); ?>
<?php include("inc_seguridad.php"); ?>
<?php include("inc_conectarse.php"); ?>
<?php $_SESSION["modulo"] = "reportes"; ?>
<?php include("inc_functions.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<?php include("inc_metadata.php"); ?>
<body>
<!-- wrap starts here -->
<?php include("inc_header.php"); ?>
<div id="wrap">
<?php include("inc_menu.php"); ?>
<!-- content-wrap starts here -->
<div id="content-wrap">
<?php include("inc_sidebar.php"); ?>
<div id="main">
<h1>Reporte de Envíos</h1>
<table>
<tr>
<td colspan="6">
<form name="frmSP" action="adm_reporte_envios.php" method="post"
enctype="multipart/form-data" onSubmit="return validate_busqueda_envio_form(this);">
<?php if(isset($_REQUEST["txtBusqueda"]) && $_REQUEST["txtBusqueda"]!="") { ?>
<input type="button" class="button" value="LIMPIAR BUSQUEDA"
onclick="javascript:document.location.href = 'adm_guias.php';" />
<?php } else { ?>
<strong>FECHA INICIO</strong>
<select name="cmbDiaI">
<option value=""></option>
<?php
$i=1;
while ($i <= 31) {
?>
<option value="<?php echo $i; ?>" <?php if($_REQUEST["cmbDiaI"]==$i) { ?> selected <?php } ?>>
<?php echo $i; ?>
</option>
<?php
$i++;
}
?>
</select>
<select name="cmbMesI">
<option value=""></option>
<?php
$i=1;
while ($i <= 12) {
?>
<option value="<?php echo $i; ?>" <?php if($_REQUEST["cmbMesI"]==$i) { ?> selected <?php } ?>>
<?php echo $i; ?>
</option>
<?php
$i++;
}
?>
</select>
<select name="cmbAnoI">
<option value=""></option>
<?php
$i = date("Y");
while ($i >= date("Y")-3) {
?>
<option value="<?php echo $i; ?>" <?php if($_REQUEST["cmbAnoI"]==$i) { ?> selected <?php } ?>>
<?php echo $i; ?>
</option>
<?php
$i--;
}
?>
</select>
<strong>FECHA FIN</strong>
<select name="cmbDiaF">
<option value=""></option>
<?php
$i=1;
while ($i <= 31) {
?>
<option value="<?php echo $i; ?>" <?php if($_REQUEST["cmbDiaF"]==$i) { ?> selected <?php } ?>>
<?php echo $i; ?>
</option>
<?php
$i++;
}
?>
</select>
<select name="cmbMesF">
<option value=""></option>
<?php
$i=1;
while ($i <= 12) {
?>
<option value="<?php echo $i; ?>" <?php if($_REQUEST["cmbMesF"]==$i) { ?> selected <?php } ?>>
<?php echo $i; ?>
</option>
<?php
$i++;
}
?>
</select>
<select name="cmbAnoF">
<option value=""></option>
<?php
$i = date("Y");
while ($i >= date("Y")-3) {
?>
<option value="<?php echo $i; ?>" <?php if($_REQUEST["cmbAnoF"]==$i) { ?> selected <?php } ?>>
<?php echo $i; ?>
</option>
<?php
$i--;
}
?>
</select>
<br/>
<br/>
<?php include("inc_lists.php"); ?>
<strong>REGION</strong>
<select name="cmbRegion" onChange="cargarEstados2(frmSP,0)">
<option value="">SELECCIONE...</option>
<?php
$result = obtenerRegiones($link);
while($row=mysql_fetch_object($result)) {
?>
<option value="<?php echo($row->id); ?>"
<?php if($_POST["cmbRegion"]==$row->id) { ?> selected <?php } ?>>
<?php echo($row->nombre); ?>
</option>
<?php
}
?>
</select>
<strong>ESTADO</strong>
<select name="cmbEstado" disabled=true" onChange="cargarDestinos(frmSP,0)">
</select>
<?php if($_POST["cmbRegion"]!="") {?>
<script type="text/javascript" language="JavaScript">
cargarEstados2(frmSP,<?php echo $_POST["cmbEstado"]; ?>);
</script>
<?php }?>
<strong>DESTINO</strong>
<select name="cmbDestino" disabled=true" >
</select>
<?php if($_POST["cmbEstado"]!="") {?>
<script type="text/javascript" language="JavaScript">
cargarDestinos(frmSP,<?php echo $_POST["cmbDestino"]; ?>);
</script>
<?php }?>
<br />
<br />
<strong>PROVEEDOR</strong>
<select name="cmbProveedor">
<option value="">SELECCIONE...</option>
<?php
$result = obtenerProveedores($link);
while($row=mysql_fetch_object($result)) {
?>
<option value="<?php echo($row->id); ?>"
<?php if($_REQUEST["cmbProveedor"]==$row->id) { ?> selected <?php } ?>>
<?php echo($row->nombre); ?>
</option>
<?php
}
?>
</select>
<br />
<br />
<strong>CLIENTE</strong>
<select name="cmbCliente">
<option value="">SELECCIONE...</option>
<?php
$result = obtenerClientes($link);
while($row=mysql_fetch_object($result)) {
?>
<option value="<?php echo($row->id); ?>"
<?php if($_REQUEST["cmbCliente"]==$row->id) { ?> selected <?php } ?>>
<?php echo($row->nombre); ?>
</option>
<?php
}
?>
</select>
<br />
<br />
<strong>CHOFER</strong>
<select name="cmbChofer">
<option value="">SELECCIONE...</option>
<?php
$result = obtenerChoferes($link);
while($row=mysql_fetch_object($result)) {
?>
<option value="<?php echo($row->id); ?>"
<?php if($_REQUEST["cmbChofer"]==$row->id) { ?> selected <?php } ?>>
<?php echo($row->nombre); ?>
</option>
<?php
}
?>
</select>
<br />
<br />
<input name="action" type="hidden" value="Buscar" />
<input type="submit" class="button" value="GENERAR REPORTE" />
<?php } ?>
</form>
</td>
</tr>
</table>
<?php
if($_POST["action"]!="") {
?>
<table style="padding-left:10px; font-size:11px" width="830px">
<tr>
<td colspan="11"><hr></td>
</tr>
<tr>
<td width="60" align="center"><strong>BULTOS</strong></td>
<td width="80" align="center"><strong>VALOR MERCANCIA</strong></td>
<td width="80" align="center"><strong>FLETE VALOR</strong></td>
<td width="80" align="center"><strong>FLETE PESO</strong></td>
<td width="80" align="center"><strong>FLETE VIAJE</strong></td>
</tr>
<tr>
<td class="text" colspan="11"><hr></td>
</tr>
<?php
// Determino el numero de paginas
$query = "SELECT SUM(e.bultos) as bultos,
SUM(e.mercancia) as mercancia,
SUM(e.mercancia*(e.flete/100)) as flete_valor,
SUM(e.peso) as peso,
SUM(e.peso*e.bskg) as flete_peso,
SUM(e.viaje) as viaje
FROM ts_envio e ";
if($_REQUEST["cmbChofer"]!="") {
$query .= " JOIN ts_guia g ON e.id_guia = g.id AND g.id_chofer=".$_REQUEST["cmbChofer"];
}
if($_REQUEST["cmbDestino"]=="") {
if($_REQUEST["cmbEstado"]!="") {
$query .= " JOIN ts_destino d ON e.id_destino = d.id AND d.id_estado=".$_REQUEST["cmbEstado"];
}
elseif($_REQUEST["cmbRegion"]!="") {
$query .= " JOIN ts_destino d ON e.id_destino = d.id AND d.id_region=".$_REQUEST["cmbRegion"];
}
}
$query .= " WHERE e.ind_activo = 1 ";
$fechaI = $_REQUEST["cmbAnoI"]."-".$_REQUEST["cmbMesI"]."-".$_REQUEST["cmbDiaI"];
$fechaF = $_REQUEST["cmbAnoF"]."-".$_REQUEST["cmbMesF"]."-".$_REQUEST["cmbDiaF"];
if($fechaI!="--") {
$query .= " AND e.fecha_creacion between '".$fechaI."' and '".$fechaF."' ";
}
if($_REQUEST["cmbProveedor"]!="") {
$query .= " AND e.id_proveedor=".$_REQUEST["cmbProveedor"];
}
if($_REQUEST["cmbCliente"]!="") {
$query .= " AND e.id_cliente=".$_REQUEST["cmbCliente"];
}
if($_REQUEST["cmbDestino"]!="") {
$query .= " AND e.id_destino=".$_REQUEST["cmbDestino"];
}
$result = obtenerResultset($link,$query);
while ($row = obtenerRegistro($result)) {
$inactiva = false;
if($row->ind_activo==0) {
$inactiva = true;
}
if($row->numero_guia=="") {
$row->numero_guia = $row->id;
}
?>
<tr style="color: #000">
<td <?php if($inactiva) {?> style="color:#999;" <?php } ?> align="center">
<strong><?php echo $row->bultos; ?></strong>
</td>
<td <?php if($inactiva) {?> style="color:#999;" <?php } ?> align="center">
<strong><?php echo number_format($row->mercancia,2,",","."); ?></strong>
</td>
<td <?php if($inactiva) {?> style="color:#999;" <?php } ?> align="center">
<strong><?php echo number_format($row->flete_valor,2,",","."); ?></strong>
</td>
<td <?php if($inactiva) {?> style="color:#999;" <?php } ?> align="center">
<strong><?php echo number_format($row->flete_peso,2,",","."); ?></strong>
</td>
<td <?php if($inactiva) {?> style="color:#999;" <?php } ?> align="center">
<strong><?php echo number_format($row->viaje,2,",","."); ?></strong>
</td>
<?php
}
?>
</td>
</tr>
<tr>
<td class="text" colspan="11"><hr></td>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
</table>
<?php } ?>
</div>
<!-- content-wrap ends here -->
</div>
<!-- wrap ends here -->
</div>
<?php include("inc_footer.php"); ?>
</body>
</html>
<?php include("inc_desconectarse.php"); ?>