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
|
<?
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Autores: Pedro Obregón Mejías
Rubén D. Mancera Morán
Versión: 1.0
Fecha Liberación del código: 13/07/2004
Galopín para gnuLinEx 2004 -- Extremadura
*/
?>
<html>
<head>
<title>Galopin v1.0</title>
<link href="estilo.css" rel="stylesheet" type="text/css">
<script>
var miPopup
function abreVentana(){
miPopup = window.open("buscarcliente.php","miwin","width=600,height=400,scrollbars=yes")
miPopup.focus()
}
</script>
</head>
<? include ("conectar.php");
include ("convertirfechas2.php");?>
<body>
<img src="images/nuevas/administracionfacturas.jpg" alt="Administración de Facturas"><br>
<br>
<form name="formul" method="post" action="facturas.php">
<? if ($ini==1) {
$error=0;
include ("controlfecha1.php"); }
if ($error==1) {
print $errores; } ?>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
<tr>
<td width="33%" class="primeralineaizquierda">Código de cliente</td>
<td colspan="2">
<? if ($ini==0) { ?>
<input name="codigo" type="text" id="codigo" size="10" maxlength="10">
<? } else { ?>
<input name="codigo" type="text" id="nombre" size="10" maxlength="10" value="<? echo $codigo; ?>">
<? } ?>
<a href="#"><img src="images/lupa.jpg" alt="Buscar Cliente" width="17" height="17" border="0" onclick="abreVentana()"></a></td>
<td width="1%"></td>
</tr>
<tr>
<td class="primeralineaizquierda">Código de factura:</td>
<td colspan="3">
<? if ($ini==0) { ?>
<input name="factura" type="text" id="factura" size="8" maxlength="8">
<? } else { ?>
<input name="factura" type="text" id="factura" size="8" maxlength="8" value="<? echo $factura; ?>">
<? } ?>
</td></tr>
<tr>
<td class="primeralineaizquierda">Fecha de la factura:</td>
<td colspan="3">Desde
<? if ($ini==0) { ?>
<input name="fecha1" type="text" id="fecha1" size="10" maxlength="10">
<? } else { ?>
<input name="fecha1" type="text" id="fecha1" size="10" maxlength="10" value="<? echo $fecha1; ?>">
<? } ?>
hasta
<? if ($ini==0) { ?>
<input name="fecha2" type="text" id="fecha2" size="10" maxlength="10">
<? } else { ?>
<input name="fecha2" type="text" id="fecha2" size="10" maxlength="10" value="<? echo $fecha2; ?>">
<? } ?>
</td></tr>
<tr>
<td class="primeralineaizquierda">Estado de la Factura:</td>
<td colspan="3">
<? if ($ini==0) { ?>
<select name="estado">
<option value="">Todas</option>
<option value="1">No pagada</option>
<option value="2">En Proceso</option>
<option value="3">Pagada</option>
</select>
<? } else { ?>
<select name="estado">
<option value="" <? if ($estado=="") print ("selected");?>>Todas</option>
<option value="1" <? if ($estado=="1") print ("selected");?>>No pagada</option>
<option value="2" <? if ($estado=="2") print ("selected");?>>En proceso</option>
<option value="3" <? if ($estado=="3") print ("selected");?>>Pagada</option>
</select>
<? } ?>
</td></tr>
<tr>
<td class="primeralineaizquierda">Fecha de cobro:</td>
<td colspan="3">Desde
<? if ($ini==0) { ?>
<input name="fecha11" type="text" id="fecha11" size="10" maxlength="10">
<? } else { ?>
<input name="fecha11" type="text" id="fecha11" size="10" maxlength="10" value="<? echo $fecha11; ?>">
<? } ?>
hasta
<? if ($ini==0) { ?>
<input name="fecha22" type="text" id="fecha22" size="10" maxlength="10">
<? } else { ?>
<input name="fecha22" type="text" id="fecha22" size="10" maxlength="10" value="<? echo $fecha22; ?>">
<? } ?>
</td></tr>
<tr>
<td class="primeralineaizquierda"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Ordenar
resultados por:</font></td>
<? if ($ini==0) { ?>
<td width="25%"><select name="campo" size="1">
<option selected value="codfactura">Cod. Factura</option>
<option value="fecha">Fecha</option>
<option value="fechacobro">Fecha de Cobro</option>
<option value="nombre">Cliente</option>
</select></td>
<td width="42%"><input name="ordenacion" type="radio" value="desc" checked>Descendente
<input name="ordenacion" type="radio" value="asc">Ascendente</td>
<? }
if ($ini==1) {
if ($campo=="codfactura") { ?>
<td width="25%"><select name="campo" size="1"><option selected value="codfactura">Cod. Factura</option>
<option value="fecha">Fecha</option>
<option value="fechacobro">Fecha de Cobro</option>
<option value="nombre">Cliente</option></select></td>
<? } else {
if ($campo=="fecha") { ?>
<td width="25%"><select name="campo" size="1"><option value="codfactura">Cod. Factura</option>
<option selected value="fecha">Fecha</option>
<option value="fechacobro">Fecha de Cobro</option>
<option value="nombre">Cliente</option></select></td>
<? } else {
if ($campo=="fechacobro") { ?>
<td width="25%"><select name="campo" size="1"><option value="codfactura">Cod. Factura</option>
<option value="fecha">Fecha</option>
<option selected value="fechacobro">Fecha de Cobro</option>
<option value="nombre">Cliente</option></select></td>
<? } else { ?>
<td width="25%"><select name="campo" size="1"><option value="codfactura">Cod. Factura</option>
<option value="fecha">Fecha</option>
<option value="fechacobro">Fecha de Cobro</option>
<option selected value="nombre">Cliente</option></select></td>
<? } } } ?>
<? if ($ordenacion=="desc") { ?>
<td width="42%"><input name="ordenacion" type="radio" value="desc" checked>Descendente
<input name="ordenacion" type="radio" value="asc">Ascendente</td>
<? } else { ?>
<td width="42%"><input name="ordenacion" type="radio" value="desc">Descendente
<input name="ordenacion" type="radio" value="asc" checked>Ascendente</td>
<? } ?>
<? } ?>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"><div align="center">
<input type="submit" name="Submit" value="Buscar facturas">
<input type="hidden" name="ini" value="1">
</div></td>
</tr>
</table>
</form>
<center>
<form action="insertar_nueva_factura.php" method="post">
<input type="submit" value="Insertar nueva factura">
</form>
</center>
<p>
<? if ($ini==1) {
$consulta = "Select facturas.*,nombre from facturas,clientes";
$consulta2 = "where facturas.codcliente=clientes.codcliente and codfactura<>'0'";
if ($estado<>"") $consulta2 = $consulta2 . " and estado=$estado";
include ("convertirfechas.php");
$fecha11=conversion($fecha11);
$fecha22=conversion($fecha22);
if (($fecha11<>"") and ($fecha22<>""))
{
$consulta2= $consulta2 . " and fechacobro >= '$fecha11' and fechacobro <= '$fecha22'";
};
include ("cascadafacturas.php");
$consulta = $consulta . " " . "order by ".$campo." ".$ordenacion." ";
$resultado = mysql_query($consulta, $conexion);
$filas=mysql_num_rows($resultado);
if (empty($numi)) { $numi=0; }
print "<center><font size=2 face='Verdana, Arial, Helvetica, sans-serif'>Número de facturas " . $filas . "</font></center>";
$consulta=$consulta." limit $numi,40";
$resultado = mysql_query($consulta, $conexion);
$enlaces=$filas;
if ($estado==1) $estadofacturas=" no pagadas";
if ($estado==2) $estadofacturas=" en proceso de pago";
if ($estado==3) $estadofacturas=" pagadas";
?>
</p>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
<tr>
<td width="8%" class="primeralinea">Cod. Factura</td>
<td width="32%" class="primeralinea">Cliente</td>
<td width="5%" class="primeralinea">Estado</td>
<td width="7%" class="primeralinea">Fecha</td>
<td width="17%" class="primeralinea">Importe<br/>(con IVA)</td>
<td width="12%" class="primeralinea">Ver Factura</td>
<td width="12%" class="primeralinea">Modificar Factura</td>
</tr>
<? $precioacumulado=0; ?>
<? while ($lafila=mysql_fetch_array($resultado)) { ?>
<tr>
<?
$fech=$lafila["fecha"];
$fech=reconversion($fech);
$fechacobro=$lafila["fechacobro"];
$fechacobro=reconversion($fechacobro);
$codcli=$lafila["codcliente"];
$consulta1 = "select nombre from clientes where codcliente = '$codcli'";
$resultado1 = mysql_query($consulta1, $conexion);
$lafila1=mysql_fetch_array($resultado1); ?>
<!--
<?
print_r($lafila);
$muliva=$lafila['iva']/100+1;
$resulprecio = mysql_query("select SUM(importe)*".$muliva." as total from factulinea WHERE codfactura='".$lafila["codfactura"]."'");
$filaprecio=mysql_fetch_array($resulprecio);
$precio=number_format($filaprecio['total'],2,",",".");
$precioacumulado+=round($filaprecio['total'],2);
echo " // muliva=$muliva precio=$precio precioacumulado=$precioacumulado //";
?>-->
<td class="segundalinea"><font color="#FF0000"><b> <? echo $lafila["codfactura"]; ?></b></font></td>
<td class="segundalineaizquierda"><font color="#FF0000">[<? echo $lafila["codcliente"]; ?>] <? echo $lafila1["nombre"]; ?></font></td>
<td class="segundalinea"><?
if ($lafila["estado"]==1) echo " <b>no pagada</b>";
elseif ($lafila["estado"]==2) echo " en proceso de pago";
elseif ($lafila["estado"]==3) echo " <s>pagada</s>";
?></td>
<td class="segundalinea"><? echo $fech; ?></td>
<!--<td class="segundalinea"><? echo $fechacobro; ?></td>-->
<td class="segundalinea"><b><? echo $precio; ?> €</b> IVA <? echo $lafila['iva']?>%</td>
<td class="segundalinea">
<form name="form2" method="post" action="vista_factura.php">
<input type="submit" name="Submit2" value="Ver factura">
</td>
<input type="hidden" name="codfactura" value="<? echo $lafila["codfactura"]; ?>">
<input type="hidden" name="codalba" value="<? echo $lafila["codfactura"]; ?>">
<input type="hidden" name="codcli" value="<? echo $codcli; ?>">
<input type="hidden" name="ini" value="0">
</form>
<td class="segundalinea">
<form name="form3" method="post" action="modificar_factura.php">
<input type="submit" name="Submit3" value="Modificar factura">
</td>
<input type="hidden" name="codfactura" value="<? echo $lafila["codfactura"]; ?>">
<input type="hidden" name="codalba" value="<? echo $lafila["codfactura"]; ?>">
<input type="hidden" name="codcli" value="<? echo $codcli; ?>">
<input type="hidden" name="ini" value="0">
</form>
</tr>
<? } ?>
<tr>
<td width="8%" class="primeralinea"></td>
<td width="32%" class="primeralinea">Total Acumulado</td>
<td width="5%" class="primeralinea"></td>
<td width="7%" class="primeralinea"></td>
<td width="17%" class="primeralinea"><? echo number_format($precioacumulado,2,",",".");?> €</td>
<td width="12%" class="primeralinea"></td>
<td width="12%" class="primeralinea"></td>
</tr>
</table>
<? }
if ($enlaces>40) {
$i=0;
$j=1;
print "<center><font size=2 face='Verdana, Arial, Helvetica, sans-serif'>Páginas: ";
while ($i<$enlaces) { ?>
<a href="facturas.php?fecha11=<? echo reconversion($fecha11); ?>&fecha22=<? echo reconversion($fecha22); ?>&fecha1=<? echo reconversion($fecha1); ?>&fecha2=<? echo reconversion($fecha2); ?>&estado=<? echo $estado; ?>&campo=<? echo $campo; ?>&ordenacion=<? echo $ordenacion; ?>&codigo=<? echo $codigo; ?>&ini=1&numi=<? echo $i; ?>"><? echo $j; ?></a>
<? $j++;
$i=$i+40; }
}
?>
<br>
<br>
<? @mysql_free_result($resultado);
@mysql_free_result($resultado1); ?>
</body>
</html>
|