-
Notifications
You must be signed in to change notification settings - Fork 0
/
adm_generar_factura_cliente.php
346 lines (326 loc) · 17.9 KB
/
adm_generar_factura_cliente.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
<?php include("inc_session.php"); ?>
<?php include("inc_seguridad.php"); ?>
<?php include("inc_conectarse.php"); ?>
<?php $_SESSION["modulo"] = "facturas"; ?>
<?php include("inc_functions.php"); ?>
<?php
if(isset($_POST["chkEnvio"])) {
$envios = $_POST["chkEnvio"];
if($envios=="") {
$envios = $_SESSION["envios"];
}
$_SESSION["envios"] = $envios;
$factura->proveedor = "";
$factura->factura = "";
$factura->total_bultos;
$factura->total_mercancia = 0;
$factura->total_peso = 0;
$factura->flete = 0;
$factura->bskg = 0;
$factura->total_viaje = 0;
$factura->seguro = obtenerSeguro($link);
$ult_proveedor = "";
foreach($envios as $id_envio) {
// Obtengo el envio
$query = "SELECT * FROM ts_envio WHERE id=".$id_envio;
$result = mysql_query($query, $link);
$row = mysql_fetch_object($result);
if($factura->cliente=="") {
$cliente = obtenerCliente($link, $row->id_cliente);
}
if($id_cliente=="") {
$id_cliente = $row->id_cliente;
}
if($row->id_proveedor!=$ult_proveedor) {
$factura->proveedor .= obtenerProveedorStr($link, $row->id_proveedor).",";
$string = preg_replace("/([,.?!])/"," \\1",$factura->proveedor);
$parts = explode(" ",$string);
$unique = array_unique($parts);
$unique = implode(" ",$unique);
$factura->proveedor = preg_replace("/\s([,.?!])/","\\1",$unique);
}
$ult_proveedor = $row->id_proveedor;
$factura->factura .= $row->factura.", ";
$factura->total_bultos += $row->bultos;
$factura->total_mercancia += $row->mercancia;
$factura->total_peso += $row->peso;
$factura->total_flete_mercancia += $row->mercancia*($row->flete/100);
$factura->total_flete_peso += $row->peso*$row->bskg;
$factura->total_viaje += $row->viaje;
if($factura->flete==0) $factura->flete = $row->flete;
if($factura->bskg==0) $factura->bskg = $row->bskg;
if($remesa=="") { $remesa = $row->remesa; }
if($factura->tipo_cobro=="") $factura->tipo_cobro = $row->tipo_cobro;
}
$factura->proveedor = substr($factura->proveedor,0,-1);
$factura->factura = substr($factura->factura,0,-2);
$factura->total_flete = $factura->total_flete_mercancia + $factura->total_flete_peso + $factura->total_viaje;
$factura->iva = obtenerIVA($link);
$factura->total_iva = ($factura->iva/100)*$factura->total_flete;
$factura->seguro = obtenerSeguro($link);
$factura->total_seguro;
}
if(isset($_GET["id"])) {
$remesa = $_GET["remesa"];
$id_cliente = $_GET["id"];
$cliente = obtenerCliente($link, $id_cliente);
$envios = obtenerEnviosClienteRemesa($link, $cliente->id, $remesa);
$factura->proveedor = "";
$factura->factura = "";
$factura->total_bultos;
$factura->total_mercancia = 0;
$factura->total_peso = 0;
$factura->flete = 0;
$factura->bskg = 0;
$factura->total_viaje = 0;
$factura->seguro = obtenerSeguro($link);
while($row = obtenerRegistro($envios)) {
$factura->proveedor .= obtenerProveedorStr($link, $row->id_proveedor).", ";
$factura->factura .= $row->factura.", ";
$factura->total_bultos += $row->bultos;
$factura->total_mercancia += $row->mercancia;
$factura->total_peso += $row->peso;
$factura->total_flete_mercancia += $row->mercancia*($row->flete/100);
$factura->total_flete_peso += $row->peso*$row->bskg;
$factura->total_viaje += $row->viaje;
if($factura->flete==0) $factura->flete = $row->flete;
if($factura->bskg==0) $factura->bskg = $row->bskg;
if($factura->tipo_cobro=="") $factura->tipo_cobro = $row->tipo_cobro;
}
$factura->proveedor = substr($factura->proveedor,0,-2);
$factura->factura = substr($factura->factura,0,-2);
$factura->total_flete = $factura->total_flete_mercancia + $factura->total_flete_peso + $factura->total_viaje;
$factura->iva = obtenerIVA($link);
$factura->total_iva = ($factura->iva/100)*$factura->total_flete;
$factura->seguro = obtenerSeguro($link);
$factura->total_seguro;
}
?>
<!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>Generar Factura</h1>
<form name="frmSP" action="adm_facturas.php" method="post" enctype="multipart/form-data"
onSubmit="return validate_factura_form(this);"
style="background-color:#FFF; border:none; margin:0px; padding: 0px;">
<table width="800px">
<tr>
<td colspan="6">
<table valign="top" border=0 style="padding-left:10px">
<tr>
<td width="100px" >
<img src="images/logo_small.jpg" width="100px" height="25%" />
</td>
<td valign="middle" style="padding:5px 5px 10px 10px" width="360px">
<strong style="font-size:20px">INVERSIONES SPAY, C.A.</strong>
<br />
Av. Victoria entre calle Chile con Internacional, <br />
Urb. Las Acacias, Edif. Bologna, PB, Local 1, Caracas. <br />
Teléfonos: (58-0212) 633.31.89 - Fax: (58-212) 632.8383 <br />
E-mail: transportespay@gmail.com
</td>
<td align="right" valign="top" width="220px">
<br /><br />
<strong style="padding-right:5px">FECHA</strong>
<input name="txtFecha" type="text" size="8" style="text-transform:uppercase"
value="<?php echo date("d/m/Y"); ?>" disabled />
<br /><br />
<strong style="padding-right:5px">RIF</strong>
<input name="txtRIF" type="text" size="12" style="text-transform:uppercase; text-align:right"
value="<?php echo $cliente->rif; ?>" disabled />
<br /><br />
<strong style="padding-right:5px">FACTURA N°</strong>
<input name="txtFactura" type="text" size="8" style="text-align:right"
value="<?php
if($remesa!="") {
echo str_pad($remesa, 9, "0", STR_PAD_LEFT);
}
?>" />
<br /><br />
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php include("inc_lists.php"); ?>
<p>
<strong style="padding-right:5px">NOMBRE O RAZON SOCIAL</strong>
<input name="txtNombre" type="text" size="76" style="text-transform:uppercase"
value="<?php echo $cliente->nombre; ?>" disabled />
<br /><br />
<strong style="padding-right:5px">DIRECCION FISCAL</strong>
<input name="txtDireccion" type="text" size="85" style="text-transform:uppercase"
value="<?php echo $cliente->direccion; ?>" disabled />
<br /><br />
<strong style="padding-right:5px">CIUDAD</strong>
<input name="txtCiudad" type="text" size="31" style="text-transform:uppercase"
value="<?php echo $cliente->ciudad; ?>" disabled />
<strong style="padding-right:5px">TELEFONOS</strong>
<input name="txtTelefono" type="text" size="42" style="text-transform:uppercase"
value="<?php echo $cliente->telefono; ?>" disabled />
<br /><br />
<strong style="padding-right:5px">PROVEEDOR</strong>
<input name="txtProveedor" type="text" size="91" style="text-transform:uppercase"
value="<?php echo $factura->proveedor; ?>" disabled />
<br /><br />
<strong style="padding-right:5px">N° FACTURA O GUIA</strong>
<input name="txtProveedor" type="text" size="62" style="text-transform:uppercase"
value="<?php echo $factura->factura; ?>" disabled />
<strong style="padding-right:5px">BULTOS</strong>
<input name="txtTelefono" type="text" size="1" style="text-align:right"
value="<?php echo $factura->total_bultos; ?>" disabled />
<br /><br />
<strong style="padding-right:5px">VALOR MERCANCIA Bs.</strong>
<input name="txtMercancia" type="text" size="15" style="text-align:right; font-weight:bold"
value="<?php echo number_format($factura->total_mercancia,2,",","."); ?>" disabled />
<strong style="padding-right:8px">POR Bs.</strong>
<input name="txtFlete" type="text" size="13" style="text-align:right"
value="<?php
if($factura->flete!=0) {
echo number_format($factura->flete,2,",",".")." %";
}
?>" onChange="fleteMercancia(frmSP)" <?php if($factura->tipo_cobro!="V") { ?> disabled <?php } ?> />
<strong style="padding-right:5px"></strong>
<input name="txtTotalFleteMercancia" type="text" size="16" style="text-align:right; border:2px solid #666; font-weight:bold;"
value="<?php
if($factura->total_flete_mercancia!=0 || $factura->total_viaje!=0) {
echo number_format($factura->total_flete,2,",",".");
}
/*
if($factura->total_viaje!=0) {
echo number_format($factura->total_viaje,2,",",".");
}
*/
?>" disabled />
<br />
<strong style="padding-right:5px">POR KILO Bs.</strong>
<input name="txtProveedor" type="text" size="29" style="text-align:right;"
value="<?php
if($factura->total_peso!=0) {
echo number_format($factura->total_peso,2,",","."). " Kg";
}
?>" disabled />
<strong style="padding-right:5px">POR Bs.</strong>
<input name="txtProveedor" type="text" size="13" style="text-align:right"
value="<?php
if($factura->bskg!=0) {
echo number_format($factura->bskg,2,",",".")." Bs/Kg";
}
?>" disabled />
<strong style="padding-right:5px"></strong>
<input name="txtTotalFletePeso" type="text" size="16" style="text-align:right; border:2px solid #666; font-weight:bold;"
value="<?php
if($factura->total_flete_peso!=0) {
echo number_format($factura->total_flete_peso,2,",",".");
}
?>" disabled />
<br />
<strong style="padding-right:5px">I.V.A.</strong>
<input name="txtIVA" type="text" size="37" style="text-align:right;"
value="<?php echo number_format(obtenerIVA($link),2,",",".")." %"; ?>" disabled />
<strong style="padding-right:7px">POR Bs.</strong>
<input name="txtFleteIVA" type="text" size="13" style="text-align:right"
value="<?php echo number_format($factura->total_flete,2,",","."); ?>" disabled />
<strong style="padding-right:5px"></strong>
<input name="txtTotalFleteIVA" type="text" size="16" style="text-align:right; border:2px solid #666; font-weight:bold;"
value="<?php
echo number_format($factura->total_flete*($factura->iva/100),2,",",".");
?>" disabled />
<br />
<strong style="padding-right:1px">SEGURO DE MERCANCIA Bs.</strong>
<input name="txtSeguro" type="text" size="13" style="text-align:right;"
value="<?php
if($cliente->seguro=="N" || $cliente->seguro=="") {
echo number_format(obtenerSeguro($link),2,",",".")." %";
}
?>" onChange="seguroMercancia(frmSP)" <?php if($cliente->seguro=="S") { ?> disabled <?php } ?> />
<strong style="padding-right:9px">POR Bs.</strong>
<input name="txtValorMercancia" type="text" size="13" style="text-align:right;"
value="<?php
if($cliente->seguro=="N" || $cliente->seguro=="") {
echo number_format($factura->total_mercancia,2,",",".");
}
?>" disabled />
<input name="txtTotalFleteSeguro" type="text" size="16" style="text-align:right; border:2px solid #666; font-weight:bold;"
value="<?php
if($cliente->seguro=="N" || $cliente->seguro=="") {
echo number_format($factura->total_mercancia*($factura->seguro/100),2,",",".");
}
?>" disabled />
<br />
<br />
<strong style="padding-right:5px">¿COBRAR SEGURO?</strong>
<input type="radio" name="cmbSeguro" value="S" <?php if($cliente->seguro=="N" || $cliente->seguro=="") { ?> checked <?php } ?>
onChange="validaSeguro(frmSP)" />
<strong>SI</strong>
<input type="radio" name="cmbSeguro" value="N" <?php if($cliente->seguro=="S") { ?> checked <?php } ?>
onChange="validaSeguro(frmSP)" />
<strong>NO</strong>
<strong style="padding-left:149px; padding-right:10px">TOTAL A PAGAR Bs</strong>
<input name="txtTotalPagar" type="text" size="16" style="text-align:right; border:2px solid #666; font-weight:bold;"
value="<?php
$valor = $factura->total_flete_mercancia;
$valor += $factura->total_flete_peso;
$valor += $factura->total_flete*($factura->iva/100);
$valor += $factura->total_viaje;
if($cliente->seguro=="N" || $cliente->seguro=="") {
$valor += $factura->total_mercancia*($factura->seguro/100);
}
echo number_format($valor,2,",",".");
?>" disabled />
<br />
<?php include("inc_mensajes.php"); ?>
</p>
<hr />
<p>
<input name="action" type="hidden" value="GenerarFacturaCliente" />
<input name="id_cliente" type="hidden" value="<?php echo $id_cliente; ?>" />
<input name="remesa" type="hidden" value="<?php echo $remesa; ?>" />
<input name="envios" type="hidden" value="<?php echo $envios_str; ?>" />
<input name="seguro_aux" type="hidden" value="<?php echo obtenerSeguro($link); ?>" />
<input name="mercancia" type="hidden" value="<?php echo $factura->total_mercancia; ?>" />
<input name="flete_mercancia" type="hidden" value="<?php echo $factura->total_flete_mercancia; ?>" />
<input name="total_viaje" type="hidden" value="<?php echo $factura->total_viaje; ?>" />
<input name="flete_peso" type="hidden" value="<?php echo $factura->total_flete_peso; ?>" />
<input name="iva" type="hidden" value="<?php echo $factura->total_flete*($factura->iva/100); ?>" />
<input name="tipo_cobro" type="hidden" value="<?php echo $factura->tipo_cobro; ?>" />
<input class="button" value="GENERAR FACTURA" type="submit" />
<input class="button" value="CANCELAR" type="reset" />
</p>
</form>
<br />
</div>
<!-- content-wrap ends here -->
</div>
<!-- wrap ends here -->
</div>
<?php include("inc_footer.php"); ?>
</body>
</html>
<?php include("inc_desconectarse.php"); ?>