summaryrefslogtreecommitdiffstatsabout
path: root/ges_stock.php
blob: 7b41d0af67e60ef7b7a5b73fd52595b81002c749 (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
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
<?
    /*  
  
    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">
</head>

<body>
<img src="images/nuevas/administracionpreciosprov.jpg" alt="Administraci&oacute;n de Precios / Proveedor"><br>
<br>

  <?
   include ("conectar.php");
   
   //Borra la tabla temporal por si acaso no se ha borrado anteriormente
   $consulta = "delete from tempartpro";
   $query = mysql_query($consulta);
   
   
  ?>
     <blockquote>
     <b>Buscador de Artículos:</b><br>
	 </blockquote>
<table align="center">
   <tr>
    <td width="100%" bgcolor="#0066FF" align="left">
    <form action="ges_stock.php">
	  <input type="hidden" name="ini" value="true">
	 <br> 
	<table border="0" cellpadding="0" cellspacing="0" bordercolor="#0066FF" align="center">
	  <tr>
	   <td width="30%" class="primeralineaizquierda">
	     Código:
	   </td>
	   <td width="70%">
	     <input type="text" name="codigo" size="6" maxlength="6">
	   </td>
	  </tr>
	  <tr> 
	    <td width="30%" class="primeralineaizquierda">
		  Descripci&oacute;n:
		</td>
		<td width="70%">
		 <input type="text" name="articulo" size="30">
		</td>
	  </tr>
	  <tr>
	    <td width="30%" class="primeralineaizquierda">
		   <?
	        //buscamos los proveedores
	        $consulta="select * from proveedores order by nombre";
	        $query = mysql_query($consulta);
	       ?>
		   Proveedor:
		</td>
		<td width="70%">
		<select name="proveedor" >
	     <option value=""></option>
	     <?
		   while ($row=mysql_fetch_row($query))
		      {
		 ?>
		        <option value="<?=$row[0]?>"><?=$row[1]?></option>
		 <?
			  }
	     ?>
	   </select>
		</td>
	  </tr>
	</table> 
       <br>
	   <center>
	   <input type="submit" value="Buscar artículos">
	   </center>
	</form>	 </td>
  </tr>
</table>
  

<?
  if (($ini<>"") and (($codigo<>"") or ($proveedor<>"")))
  {
	 
	 //Realizo la consulta con elecciones de usuario
	 
	 $consulta="Select distinct idproveedor,idarticulo,precio from articulos,artpro,proveedores";
	 
	 //obtenemos familia, subfamilia y codigo de articulo
	 $familia = substr($codigo,0,2);
     $subfamilia = substr($codigo,2,2);
     $codigoarticulo = substr($codigo,4,2);
	 
	 if (($codigo<>"") or ($articulo<>"") or ($proveedor<>""))
	 {
	 $consulta = $consulta . " where artpro.idarticulo=articulos.id";
	 };
	 
	 if ($codigo<>"")
	 { 
	 $consulta = $consulta . " and codfamilia='$familia' and codsubfamilia='$subfamilia' and codigo='$codigoarticulo'";
	 };
	 if ($articulo<>"")
	 { 
	 $consulta = $consulta . " and descripcion like '%".$articulo."%'";
	 };	 
	 
	 if ($proveedor<>"")
	 { 
	  $consulta = $consulta . " and artpro.idproveedor=$proveedor and proveedores.codproveedor=artpro.idproveedor";
	 };
	 
	 $consulta = $consulta . " order by nombre,codigo";
	 
	 
	 $resultado = mysql_query($consulta);
     $filas=mysql_num_rows($resultado);
	 $total=$filas;
	 if (empty($numi)) { $numi=0; }
	 print "<br><center><font color=ff0000 face='Verdana, Arial, Helvetica, sans-serif'>Número de art/prov: " . $filas . "</font></center>";
	 $consulta=$consulta." limit $numi,10";
	 $query = mysql_query($consulta);
	 $enlaces=$filas;

	 //
	 // Si total es distinto de cero es que ha encontrado registros en la búsqueda
	 //
	 
	 if ($total<>0)
	 {
?>	 
  <b><blockquote>Resultados de la búsqueda:</blockquote></b>
   <table width="80%" border="1" align="center" bordercolor="#0066FF" cellspacing="1" cellpadding="1">	
   <tr>
     <td width="70%" align="center" class="primeralinea">
	  <b>Artículo --> Proveedor</b>
	 </td>
	 <td width="30%" class="primeralinea">
	   <b>Opciones</b>
	 </td>
	 </tr>
    
<?   
	 while ($row = mysql_fetch_row($query))
        {
?>
           <tr>
		     <td width="80%" class="segundalineaizquierda">
			    <?
				  $consulta2="select * from articulos where id=$row[1]";
				  $query2=mysql_query($consulta2);
				  $row2=mysql_fetch_row($query2); 
				  
				  $consulta3="select * from proveedores where codproveedor=$row[0]";
				  $query3=mysql_query($consulta3);
				  $row3=mysql_fetch_row($query3);
				  
				  $preciopro=sprintf("%01.2f",$row[2]);
	              $preciopro= number_format($preciopro,2,",",".");
				  
				?>
			    <b><?=$row2[1]?><?=$row2[2]?><?=$row2[3]?>-<?=$row2[4]?></b> ---> <?=$row3[1]?> === <font color="ff0000"><b><?=$preciopro?> </font>Euros</b>
			 </td>
			 <td width="20%" class="segundalinea">
			    <form action="modificar_stock.php" method="post">
				  <input type="submit" value="Modificar Precio"> 
		     </td>
				  <input type="hidden" name="idproveedor" value="<?=$row[0]?>">
				  <input type="hidden" name="idarticulo" value="<?=$row[1]?>">
				  <input type="hidden" name="proveedor" value="<?=$row3[1]?>">
				  <input type="hidden" name="articulo" value="<?=$row2[3]?>">
				</form>
			
		   </tr>
<? 
        }
?>
</table>		
<?
  if ($enlaces>10) 
  {
    $i=0;
    $j=1; 
    print "<center><font size=2 face='Verdana, Arial, Helvetica, sans-serif'>Páginas: ";
    while ($i<$enlaces) 
	    { 
		  ?>
           <a href="ges_stock.php?idproveedor=<?=$codigo?>$articulo=<?=$articulo?>&proveedor=<?=$proveedor?>&ini=true&numi=<? echo $i; ?>"><? echo $j; ?></a>
          <? $j++; 
          $i=$i+10; 
		}
   }
 } 
	 else
	 {
	  print("No hay ninguna coincidencia en la Base de Datos.");
	 }
  }
  else
	{
	  print("<center><br><br><font color=ff0000 size=-2>Error: Debe introducir al menos el código o el proveedor en la búsqueda.</font></center>");
	} 
?>

	 <br><br>

</body>
</html>