summaryrefslogtreecommitdiffstatsabout
path: root/articulosvendidos.php
blob: 55df78646692aa23ba776fcf87400815dc8517aa (plain)
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
<?
    /*  
  
    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("listado_articulos3.php","miwin","width=600,height=400,scrollbars=yes")
	miPopup.focus()
	}
</script>
</head>
<? include ("conectar.php");
include ("convertirfechas.php"); 
   include ("convertirfechas2.php");?>
<body>
<img src="images/nuevas/impresionartvendidos.jpg" alt="Impresión Art. Vendidos"><br>
<br>

<form name="formul" method="post" action="articulosvendidos.php">
  <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
    <tr> 
      <td width="33%" class="primeralineaizquierda">C&oacute;digo 
        de artículo:</td>
      <td width="67%"> 
	  <? if ($ini==0) { ?>
	    <input name="codigo" type="text" id="codigo" size="6" maxlength="6"> 
	  <? } else { ?>
	  <input name="codigo" type="text" id="nombre" size="6" maxlength="6" value="<? echo $codigo; ?>"> 
	  <? } ?>
	  <a href="#"><img src="images/lupa.jpg" alt="Buscar Artículos" width="17" height="17" border="0" onclick="abreVentana()"></a></td>
      </td>
    </tr>
	<tr> 
      <td class="primeralineaizquierda">Fecha de la 
        venta:</td>
      <td>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 colspan="2">&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center"> 
          <input type="submit" name="Submit" value="Buscar artículos">
		  <input type="hidden" name="ini" value="1">
      </div></td>
    </tr>
  </table>
</form>
<? if ($ini==1) { 
     if (!empty($codigo)) { ?>
		       <center>  
             <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr><td colspan="3" class="primeralinea">FACTURAS</td>
	        </tr>
	        <tr>
               <td width="48%" class="primeralinea">Cliente</td>
               <td width="23%" class="primeralinea">Cód Factura</td>
               <td width="29%" class="primeralinea">Cantidad de artículos</td>
             </tr><? 
	 		 if (empty($fecha1)) { $fecha1="01/01/1970"; }
	 		 if (empty($fecha2)) { $fecha2=date("d/m/Y"); }
			 $fecha1=conversion($fecha1);
	 		 $fecha2=conversion($fecha2);
             $familia = substr($codigo,0,2);
             $subfamilia = substr($codigo,2,2);
             $codigoarticulo = substr($codigo,4,2);
             $consulta2 = "select * from articulos where codfamilia='$familia' and codsubfamilia='$subfamilia' and codigo='$codigoarticulo'";
             $resultado2 = mysql_query($consulta2, $conexion);
             $filas2=mysql_num_rows($resultado2);
			 if ($filas2>0) {
                    $consulta = "Select clientes.nombre,facturas.codfactura,factulinea.cantidad from clientes,facturas,factulinea where
	                clientes.codcliente=facturas.codcliente and facturas.codfactura=factulinea.codfactura and factulinea.codfamilia='$familia' and 
					factulinea.codsubfamilia='$subfamilia' and factulinea.codigo='$codigoarticulo' and fecha >= '$fecha1' and fecha <= '$fecha2'";
					$resultado = mysql_query($consulta, $conexion);
                    while ($lafila=mysql_fetch_array($resultado)) { ?>
					     <tr>
                            <td class="segundalineaizquierda"><? echo $lafila["0"]; ?></td>
                            <td class="segundalinea"><? echo $lafila["1"]; ?></td>
                            <td class="segundalineaderecha"><? $tot1= number_format($lafila["2"],2,",","."); echo $tot1; ?></td>
                         </tr>
					<? }
			 } else {
			 }
   ?>
   </table>
   <br><br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr><td colspan="3" class="primeralinea">ALBARANES</td>
	   </tr>
	   <tr>
        <td width="48%" class="primeralinea">Cliente</div></td>
        <td width="23%" class="primeralinea">Cód Albarán</div></td>
        <td width="29%" class="primeralinea">Cantidad de artículos</div></td>
       </tr><?
			 if ($filas2>0) {
                    $consulta = "Select clientes.nombre,albaranes.codalbaran,albalinea.cantidad from clientes,albaranes,albalinea where
	                albaranes.codfactura=0 and clientes.codcliente=albaranes.codcliente and albaranes.codalbaran=albalinea.codalbaran and albalinea.codfamilia='$familia' and 
					albalinea.codsubfamilia='$subfamilia' and albalinea.codigo='$codigoarticulo' and fecha >= '$fecha1' and fecha <= '$fecha2'";
                    $resultado = mysql_query($consulta, $conexion);
                    while ($lafila=mysql_fetch_array($resultado)) { ?>
					     <tr>
                            <td class="segundalineaizquierda"><? echo $lafila["0"]; ?></td>
                            <td class="segundalinea"><? echo $lafila["1"]; ?></td>
                            <td class="segundalineaderecha"><? $tot1= number_format($lafila["2"],2,",","."); echo $tot1; ?></td>
                         </tr>
					<? }
			 } else {
			 }
		 ?>
   </table>
   <br><br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr><td colspan="3" class="primeralinea">PARTES</td>
	   </tr>
	   <tr>
        <td width="48%" class="primeralinea">Cliente</div></td>
        <td width="23%" class="primeralinea">Cód Parte</div></td>
        <td width="29%" class="primeralinea">Cantidad de artículos</div></td>
       </tr><?
			 if ($filas2>0) {
                    $consulta = "Select clientes.nombre,partes.codparte,partelinea.cantidad from clientes,partes,partelinea where
	                partes.codalbaran=0 and clientes.codcliente=partes.codcliente and partes.codparte=partelinea.codparte and partelinea.codfamilia='$familia' and 
					partelinea.codsubfamilia='$subfamilia' and partelinea.codigo='$codigoarticulo' and fecha >= '$fecha1' and fecha <= '$fecha2'";
                    $resultado = mysql_query($consulta, $conexion);
                    while ($lafila=mysql_fetch_array($resultado)) { ?>
					     <tr>
                            <td class="segundalineaizquierda"><? echo $lafila["0"]; ?></td>
                            <td class="segundalinea"><? echo $lafila["1"]; ?></td>
                            <td class="segundalineaderecha"><? $tot1= number_format($lafila["2"],2,",","."); echo $tot1; ?></td>
                         </tr>
					<? }
			 } else {
			 }
 		} else {
		}
	 }
   ?>
   </table>
   </center> 

<?  @mysql_free_result($resultado);
    @mysql_free_result($resultado1);  ?>
</body>
</html>