<?php
 include ("emenux.php"); 
 require "funciones.php";
 require ("conecta.php");
 $_SESSION['con']=$con;
 $sw=$_POST['hdsw'];
 $swest=$_POST['hdswest'];
 $rut=$_POST['rut'];
 $numero=$_POST['numero'];
 $cp=$_POST['hdcodpag'];
 $nombre=$_POST['nombre'];
 $fecha=editafechag($_POST['fecha']);
 $subtotal=$_POST['st1'];
 $d1=$_POST['hdd1'];
 $d2=$_POST['hdd2'];
 $d3=$_POST['hdd3'];
 $neto=$_POST['hdneto'];
 $iva=$_POST['hdiva'];
 $total=$_POST['hdtotal']; 
 $numprov=$_POST['numprov'];
 calculaped($numero,$con);
 //****************graba encabezado****************
 //***********************************************
 
 if ($sw=="grabae"){    
   $sqlge="replace into adae01  (numero,fecha,rut,nombre,cpago,num_prov,estado,d1,d2,d3,neto,iva,total) values ('$numero','$fecha','$rut','$nombre','$cp','$numprov','0','$d1','$d2','$d3','$neto','$iva','$total');"; 
   $resge=mysql_query($sqlge,$con) or die(mysql_error());   
   $sw="buscanumero";
 }//fin grabaencabezado
 
 //*********fin graba encabezado
 //***********************************************
 
 
 //***************elimina registro*****************
 //***********************************************
 if ($sw=="eliminaped"){
  $sqlest="select estado from adae01 where numero = '$numero' and estado='0';";
  $resest=mysql_query($sqlest,$con) or die(mysql_error());   
  if (mysql_num_rows($resest)<>0){//si #
   $sqlel="DELETE from adai01 where llave like '$numero%';";
   $resel=mysql_query($sqlel,$con) or die(mysql_error());
   $sqlee="DELETE from adae01 where numero = '$numero';";
   $resee=mysql_query($sqlee,$con) or die(mysql_error());
   }//fin si#
 $numero="";
 $rut="";
 $numprov="";  
 $sw="buscanumero";   
 }//fin eliminar 
 //*************************fin eliminar**********
 //*****************edita detalle del pedido
  if ($sw=="acciona"){
  $cod=$_POST['hdcod'];
  $pre=$_POST['hdpre'];
  $cant=$_POST['hdcant'];
  $subtotal=$cant * $pre;
  if ($cant==0){// /
   $sqla="delete from adai01 where cod_interno='$cod' ;";
   $resa=mysql_query($sqla,$con) or die(mysql_error());      
   }else{
    $sqlm="update adai01 set cantidad='$cant',precio='$pre',stotal='$subtotal' where llave like '$numero%' and cod_interno='$cod';";
	$resm=mysql_query($sqlm,$con) or die(mysql_error());
	calculaped($numero,$con);
  }// /
  $sw="buscanumero";
 }// fin acciona 
 
 
 
 
 //********************************************
 //********************************agrega nuevo
 if ($sw=="agregarnuevo"){
  $cant=$_POST['cant'];
  $interno=$_POST['interno'];
  $codprov=$_POST['codprov'];
  $glosa=$_POST['glosa'];
  $precio=$_POST['precio'];
  $st=$_POST['st'];
  $numero=sprintf("%07d",$numero);
  $sqla="select * from adai01 where llave like '$numero%' and cod_interno<>'$interno';";
  $resa=mysql_query($sqla,$con) or die(mysql_error());
  $regs=mysql_num_rows($resa);
  while ($filaresa=mysql_fetch_row($resa)){
   $sec=substr($filaresa[0],7,3);
  }
  $sig=sprintf("%03d",$sec+1);
  $llave=$numero . $sig;
  $sqlg="insert into adai01 (LLAVE,CANTIDAD,COD_INTERNO,COD_PROV,GLOSA,PRECIO,STOTAL)
  values ('$llave','$cant','$interno','$codprov','$glosa','$precio','$st') ;";
  $resg=mysql_query($sqlg,$con) or die(mysql_error());
  if (strlen($codprov)>2){$proc=ingcodprov($interno,$rut,$codprov,$con);}
  $sw="buscanumero";
  $interno="";
  $glosa="";
 }//fin agregar nuevo 
 //********************************************
 //********************************************
 
 //********************************************
 //***************************busca codigo interno
 
 if ($sw=='interno'){
  $internoi=$_POST['interno'];
  $sqli="select * from m07001 where cod_interno='$internoi';";
  $resi=mysql_query($sqli,$con) or die(mysql_error());
  while ($filai=mysql_fetch_row($resi)){
    $glosai=$filai[3];
	$internoi=$filai[0];
   }//wend
   $sw="agregar";
 }
 
 //********************************************
 
 
 
 
 //********************************************
 //*******************************busqueda de numero 
 if ($sw=="buscanumero" or $sw=="agregar"){
  calculaped($numero,$con);
  $numero=sprintf("%07d",$numero);
  if (($numero*1)>0){//si ##
   $sqlbn="select * from adae01 where numero='$numero';";
   $resbn=mysql_query($sqlbn,$con);
   if (mysql_num_rows($resbn)>0){//si *
    while ($filabn=mysql_fetch_row($resbn)){
     $rut=$filabn[2];
   	 $cp=$filabn[4];
 	 $nombre=$filabn[3];
	 $fecha=$filabn[1];
	 $subtotal=$filabn[7];
	 $d1=$filabn[8];
     $d2=$filabn[9];
     $d3=$filabn[10];
     $neto=$filabn[11];
     $iva=$filabn[12];
     $total=$filabn[13]; 
	 $swest=$filabn[6];
	 $numprov=$filabn[5];
    } //fin while
    calculaped($numero,$con);
   }else{    
	 $rut="";
	 $nombre="";
	 $numprov="";
	 $cp="";
	 $sw="nuevo";
	 $fecha=date("Ymd");
	 $sqln="insert into adae01  (numero) values ('$numero');";
	 $resn=mysql_query($sqln,$con) or die(mysql_error());
   }//fin si *
  }else{
   //ver mayor y asignar siguiente folio
    $sqlmax="select max(numero) from adae01;";
	$resmax=mysql_query($sqlmax,$con);
	while ($filamax=mysql_fetch_row($resmax)){
	 $maximo=$filamax[0];	 
	} 
	$maximo++;
	$numero=sprintf("%07d",$maximo);
   //***********************************
  }//fin si ##  
 }//fin buscanumero
 //************************************************
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<?php
 $sqlp="select rut,nombre from m01001 order by nombre;";
 $resp=mysql_query($sqlp,$con);
 echo "<script language='JavaScript'>" ;
 echo  "var seleccionado = '';"; 
 echo  " var aEdit = new Array("; 
 $regs=mysql_num_rows($resp);
 $contp=0;
 while ($filap=mysql_fetch_row($resp)){
   $contp++;
   $rutp=$filap[0];
   $nombrep=$filap[1];
          echo      "\"" . $rutp . "," . $nombrep . "\""; 
          if ($regs != $contp){echo ",";} 
          
				}//fin while
            echo   ")"; 
 echo "</script>"; 
?>			   
<TITLE>Pedido Proveedor</TITLE>
<script language="javascript" src="fstandar.js"></script>
<script language="javascript">

function buscar(){
   open("popupc.php?nombre=" + document.form1.rut.value ); 
   
   }
function ponecpago(){
 document.form1.hdcodpag.value=document.form1.cmbcondpag.value;
 //window.alert(document.form1.hdcodpag.value);
 
 }  
function buscarut(){
 if (modulo11(document.form1.rut.value)==0){
  document.form1.rut.style.backgroundColor="#FFFFFF";
  document.form1.hdsw.value="buscar";
  document.form1.action="M0101001.php";
  document.form1.method="post";
  document.form1.submit();
 // window.alert("si");
  }else{
   window.alert("El rut ingresado es incorrecto" );
   document.form1.rut.style.backgroundColor="#FFFFCC";
   document.form1.rut.focus();  
  }//si 
 } 
function buscanumero(){ 
 if (event.keyCode==13 || event.keyCode==9){//si 0
 if (isNaN(document.form1.numero.value)){//si 1
  window.alert("dato ingresado no valido");
  document.form1.numero.focus();
 }else{
 document.form1.hdsw.value="buscanumero";
 document.form1.action="m0105001.php";
 document.form1.method="post"; 
 document.form1.submit();
 }//fin si1
 }//fin si 0
}//fin buscanumero
function agregar(){
 if (document.form1.hdswest.value != "1"){
  document.form1.hdsw.value="agregar";
  document.form1.action="M0105001.php";
  document.form1.method="post";
  document.form1.submit();
  }else{
   window.alert("Este pedido no se puede na' modificar oiga, \n ya que tiene recepciones actualizadas al inventario");
 }//fin si
}//fin agregar
function acciona(cant,pre,cod){
 if (event.keyCode==13){//#
  if (document.form1.hdswest.value==0){//si *
   //window.alert(cant + " " + pre + " " + cod);
   document.form1.hdcant.value=cant;
   document.form1.hdpre.value=pre;
   document.form1.hdcod.value=cod;
   document.form1.hdsw.value="acciona";
   document.form1.action="M0105001.php";
   document.form1.method="post";
   document.form1.submit();   
   }else{
    window.alert("Pedido no se puede modificar por que ya esta \n actualizado al inventario");
   }// *
 }//#
 
}//fin acciona
 

function veinterno(){
 if(event.keyCode==113){
  open("popupart2.php?glosa=" + document.form1.interno.value + "&rut=" + document.form1.rut.value); 
 }
 if(event.keyCode==13){
   document.form1.hdsw.value="interno";
   document.form1.action="M0105001.php";
   document.form1.method="post";
   document.form1.submit();   
 }
}//fin función interno
function buscarut(){
 if (event.keyCode==13){
  for (var i = 0; i < aEdit.length; i++){
  var a =aEdit[i];
  //window.alert(a.substr(0,8));
  if (document.form1.rut.value==a.substr(0,9)){
    //document.form1.nombre.value=substr(aEdit[i]);
    //window.alert(a.substr(10));
	document.form1.nombre.value=a.substr(10);	
	document.form1.cmbcondpag.focus();
   }//si
  }//for
 }//fin eevnt.keycode 
}//fin funcion
function precios(){ 
 if (event.keyCode==13){//si*
  // aqui validar cantidad y precio
   document.form1.glosa.disabled=false; 
   document.form1.st.disabled=false;     
   document.form1.st.value=document.form1.precio.value * document.form1.cant.value;
   document.form1.hdsw.value="agregarnuevo";
   document.form1.action="m0105001.php";
   document.form1.method="post";
   document.form1.submit();
  // fin de validacion de cantidad y precio
 }//fin si *
}//fin función precio
function eliminaped(){
 if (window.confirm("Seguro desea eliminar")==true){
  document.form1.hdsw.value="eliminaped";
  document.form1.action="m0105001.php";
  document.form1.method="post";
  document.form1.submit();
  }//fin si
}
function ponecant(){
 if (event.keyCode==13){ //si 1
 if (!(isNaN(document.form1.cant.value)) && document.form1.cant.value > 0) {//si 2
  document.form1.interno.focus();
  } //fin si 2
 }//fin si 1
}
function grabae(){
  document.form1.nombre.disabled=false;
  document.form1.hdsw.value="grabae";
  document.form1.action="m0105001.php";
  document.form1.method="post";
  document.form1.submit();
}
function ponecodprov(){
 if (event.keyCode==13){
  document.form1.precio.focus();
  }
}
function termina(){
 window.open("finpedido.php?numero=" + document.form1.numero.value);
}
</script>
<link rel="stylesheet" href="styles.css">
<style type="text/css">
<!--
.Estilo3 {color: #FFFFFF}
-->
</style>
</HEAD>
<BODY <?php
 if ($sw=="agregar"){
  echo "onload='javascript:(document.form1.cant.focus())'";
  }
 if ($sw=="nuevo" || $sw=="eliminar"){
  echo "onload='javascript:(document.form1.rut.focus())'";
  } 
 if ($sw=="encontrado" ){
  echo "onload='javascript:(document.form1.rut.focus())'";
//  echo "onload='javascript:(document.form1.cmdgra.focus())'";
  }  
  ?>>
  <form id="form1" name="form1" method="post" action="M0105001.php">
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" align=center 
border=0>
  <TBODY>
  <TR>
    <TD vAlign=center align=middle height="100%">
      <TABLE height=400 cellSpacing=0 cellPadding=0 width=718 border=0>
        <TBODY>
        <TR>
          <TD width="718" height=22>
            <TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" 
              border=0><TBODY>
              <TR>
                <TD vAlign=top align=left width=24><A 
                  href="index.php"><IMG src="images/xc_left.gif" alt="Inicio" width=24 
                  height=22 
                  border=0></A></TD>
                <TD vAlign=top align=left width="100%"><IMG height=22 
                  src="images/xc_center.gif" width="100%" 
                border=0></TD>
              <TD vAlign=top align=right width=24><IMG height=22 
                  src="images/xc_right.gif" width=24 
              border=0></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD class=BottomTable vAlign=top 
          background=images/xc_stripes.gif height="100%">
            <TABLE class=IconsTable height=33 cellSpacing=0 cellPadding=0 
            width="100%" border=0>
              <TBODY>
              <TR>
                <TD height="32"><div align="right" class="larger">
                  <div align="right">
                  </div>
                </div></TD>
                </TR></TBODY></TABLE>
            <TABLE cellSpacing=0 cellPadding=0 width="715" 
              border=0>
              <TBODY>
              <TR>
                <TD width=23 height=18>&nbsp;</TD>
                <TD height=18 align=left vAlign=top><span class="MainMenuHead">Pedido de proveedor:
                    <label></label>
                </span>                  <label><br />
                <br />
                </label></TD>
                <TD width=20 height=18>&nbsp;</TD></TR>
              <TR>
                <TD width=23 height="100%">&nbsp;</TD>
                <TD height="100%" align=left vAlign=top class="contentcell">
                  <table width="660" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <th width="10%" class="Emphasize" scope="col"><div align="right">N&uacute;mero:</div></th>
                      <th width="8%" scope="col"><label>
                        <div align="left">
                          <input name="numero" type="text" id="numero" size="8" maxlength="7" value="<?php echo $numero ?>" onkeydown="buscanumero()" />
                          </div>
                      </label></th>
                      <th width="9%" class="Emphasize" scope="col"><div align="right">Rut:</div></th>
                      <th width="15%" scope="col"><label>
                              <input name="rut" type="text" id="rut" size="10" maxlength="9" value="<?php echo $rut ?>" onkeydown="buscarut();" />                                </label></th>
                      <th width="6%" scope="col"><div align="left"><img src="images/i.p.search.gif" alt="Buscar Rut" width="22" height="18" longdesc="Buscar Rut" onclick="buscar()" />&nbsp;&nbsp;</div></th>
                      <th width="7%" class="Emphasize" scope="col"><div align="right">Nombre:</div></th>
                      <th colspan="2" scope="col"><input name="hdsw" type="hidden" id="hdsw" value="agregar" />
                        <label>
                        <input name="hdswest" type="hidden" id="hdswest" value="<?php echo $swest ?>" />
                        <div align="left">
                                  <input name="nombre" type="text" id="nombre" size="50" maxlength="51" value="<?php echo $nombre ?>" disabled="disabled"/>
                                </div>
                      </label></th>
                    </tr>
                    <tr>
                      <th class="Emphasize" scope="row"><div align="right">Cond_pago:</div></th>
                      <td colspan="5">
                        <div align="left">
                          <label>
                           <?php
							  		$sqlcodpag="select * from m01002 order by 2;";
									$rescodpag=mysql_query($sqlcodpag,$con) ;				
							  ?>
								<select name="cmbcondpag" class="Emphasize" id="cmbcondpag" onchange="ponecpago()">
								<?php 
									while ($fila=mysql_fetch_row($rescodpag)){
									if ($fila[0]==$cp){
										echo "<option value=$fila[0] selected='selected'>$fila[1]</option>";
									}else{
										echo "<option value=$fila[0]>$fila[1]</option>";
										}
									}
								?>
								</select>
								<input name="hdcodpag" type="hidden" id="hdcodpag" value="<?php echo $cp ?>" />
                          </label>
                        </div>
                        <div align="right" class="Emphasize"></div>
                        <div align="left"></div></td>

                      <td width="25%" class="Emphasize"><div align="right">Fecha_pedido:</div></td>
                      <td width="20%" class="Emphasize"><input name="fecha" type="text" id="fecha" size="11" maxlength="10"  value="<?php if (strlen($fecha)==8)
					    echo editafecha($fecha);
					    ?>"/></td>
                    </tr>
                    <tr>
                      <th class="Emphasize" scope="row">Numero Prov :</th>
                      <td colspan="4"><label>
                        <input name="numprov" type="text" id="numprov" size="11" maxlength="12" value="<?php echo $numprov ?>" />
                        <input name="grabaenc" type="button" id="grabaenc" value="Graba Encab."  onclick="grabae()"/>
</label></td>
                      <td colspan="3" class="Emphasize"><table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#ECE9D8">
                        <tr>
                          <th class="m0l0oout" scope="col"><label>
                            <input name="Agregar" type="button" id="Agregar" value="Agregar Art&uacute;culo" onclick="agregar()" />
                          </label></th>
                          <th class="m0l0oout" scope="col"><label>
                          </label></th>
                          <th class="m0l0oout" scope="col"><label>
                            <input name="eliminar" type="button" id="eliminar" value="Eliminar Pedido"  onclick="eliminaped()" />
                          </label></th>
                          <th class="m0l0oout" scope="col"><label>
                            <input name="terminar" type="button" id="terminar" value="Terminar Pedido" onclick="termina()" />
                          </label></th>
                        </tr>
                      </table></td>
                    </tr>
                  </table>
                        </TD>
                <TD width=20 height="100%">&nbsp;</TD></TR>
              <TR>
                <TD width=23 height=8>&nbsp;</TD>
                <TD height=8 class="contentcell"><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#C4D2E2" class="Emphasize">
                  <tr>
                    <th width="7%" class="m0l0oout Estilo3" scope="col">Cant.</th>
                    <th width="13%" class="m0l0oout" scope="col"><p align="left" class="Estilo3">Cod_interno</p>                      </th>
                    <th width="15%" class="m0l0oout" scope="col"><div align="left" class="Estilo3">Cod_prove</div></th>
                    <th width="43%" class="m0l0oout" scope="col"><div align="center" class="Estilo3">Glosa</div></th>
                    <th width="11%" class="m0l0oout Estilo3" scope="col">Precio Unit. </th>
                    <th width="11%" class="m0l0oout" scope="col"><p class="Estilo3">Sub Total</p>                      </th>
                  </tr>
                  
                  <?php	
				   $indice=0;	
				   if (strlen($numero)>0){//si#		  
				   $sqld="select * from adai01 where llave like '$numero%' ;";
				   $resd=mysql_query($sqld,$con) or die(mysql_error());
				   while ($filad=mysql_fetch_row($resd)){
				    $indice++;
				    $cant=$filad[1];
					$interno=$filad[2];
					$original=$filad[3];
					$glosa=$filad[4];
					$precio=$filad[5];					
					$stot=$filad[6];
					$lcod="<input name='hd$indice' type='hidden' value='$interno' />";
					$lcant="<input type='text' name='t$indice' value='$cant' size='2' onkeydown='acciona(document.form1.t$indice.value,document.form1.p$indice.value,document.form1.hd$indice.value)'/>";
					$lpre="<input type='text' name='p$indice' value='$precio' size='4' onkeydown='acciona(document.form1.t$indice.value,document.form1.p$indice.value,document.form1.hd$indice.value)'/>";
					//$stot=number_format($stot,0,".",",");
					echo "<tr><td>" . $lcant . "</td><td>$interno" . $lcod . "</td><td>$original</td><td>$glosa</td><td>" . $lpre . "</td><td align='right'>" .number_format($stot,0,".",",") ."</td></tr>";					
				   }//fin while				   
				   }//fin si#
				   $interno="";
				   $glosa="";
				   ?>
				  <tr>
                    <th class="m0l0oout" scope="col"><div align="left">
                      <input name="cant" type="text" id="cant" size="3" maxlength="6" <?php if ($sw!="agregar"){echo "disabled"; } ?> onkeydown="ponecant();" />
                    </div></th>
                    <th class="m0l0oout" scope="col"><input name="interno" type="text" id="interno" size="10" maxlength="25"  <?php if ($sw!="agregar"){echo "disabled"; } ?>  onkeydown="veinterno()" value="<?php echo $internoi ?>" /></th>
                    <th class="m0l0oout" scope="col"><input name="codprov" type="text" id="codprov" size="20" maxlength="20" <?php if ($sw!="agregar"){echo "disabled"; } ?> onkeydown="ponecodprov()" /></th>
                    <th class="m0l0oout" scope="col"><input name="glosa" type="text" id="glosa" size="40" maxlength="20" value="<? echo $glosai ?>" disabled/></th>
                    <th class="m0l0oout Estilo3" scope="col"><div align="left">
                      <input name="precio" type="text" id="precio" size="5" maxlength="7" onkeydown="precios()"  <?php if ($sw!="agregar"){echo "disabled"; } ?> />
                    </div></th>
                    <th class="m0l0oout" scope="col"><input name="st" type="text" id="st" size="5" maxlength="7" disabled /></th>
                  </tr> 
                </table></TD>
                <TD width=20 
      height=8>&nbsp;</TD></TR>
              <TR>
                <TD height=8>&nbsp;</TD>
                <TD height=8 class="contentcell"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <th width="85%" scope="col"><div align="right" class="Emphasize">Sub Total: </div></th>
                    <th width="15%" scope="col"><div align="right"><?php echo number_format($subtotal,0,".",",") ?></div></th>
                  </tr>
                  <tr>
                    <th class="Emphasize" scope="row"><div align="right">
                      
                      D1:</div></th>
                    <td><div align="right"><b><?php echo number_format($d1,0,".",",") . "%" ?></b></div></td>
                  </tr>
                  <tr>
                    <th class="Emphasize" scope="row"><div align="right"> D2:</div></th>
                    <td><div align="right"><b><?php echo number_format($d2,0,".",",") . "%" ?></b></div></td>
                  </tr>
                  <tr>
                    <th class="Emphasize" scope="row"><div align="right">
                      <label>
                      <input name="hdcant" type="hidden" id="hdcant" />
                      <input name="hdcod" type="hidden" id="hdcod" />
                      <input name="hdpre" type="hidden" id="hdpre" />
                      </label>
                      D3:</div></th>
                    <td><div align="right"><b><?php echo number_format($d3,0,".",",") . "%" ?></b></div></td>
                  </tr>
                  <tr>
                    <th class="Emphasize" scope="row"><div align="right">
                      <input name="hdd1" type="hidden" id="hdd1" />
                      <input name="hdd2" type="hidden" id="hdd2" />
                      <input name="hdd3" type="hidden" id="hdd3" />
                      Neto:</div></th>
                    <td><div align="right"><b><?php echo number_format($neto,0,".",",")  ?></b></div></td>
                  </tr>
                  <tr>
                    <th class="Emphasize" scope="row"><div align="right">
                      <input name="hdneto" type="hidden" id="hdneto" />
                      <input name="hdiva" type="hidden" id="hdiva" />
                      <input name="hdtotal" type="hidden" id="hdtotal" />
                      IVA:</div></th>
                    <td><div align="right"><b><?php echo number_format($iva,0,".",",")  ?></b></div></td>
                  </tr>
                  <tr>
                    <th class="Emphasize" scope="row"><div align="right">Total:</div></th>
                    <td><div align="right"><b><?php echo number_format($total,0,".",",") ?></b></div></td>
                  </tr>
                </table> </TD>
                <TD 
      height=8>&nbsp;</TD>
              </TR>
              </TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY>
			  
<!-- /Footer -->
<script language="JavaScript" src="menu.js"></script>
<script language="JavaScript" src="menu_tpl.js"></script>
<script language="JavaScript">
	new menu (MENU_ITEMS, MENU_POS);
</script>
    </TABLE>
</form>
</BODY>
<?php
	mysql_close($con);
?>
</HTML>

