<?
session_start();
require("../conectar.php");
?>
<HTML>
<HEAD>
<TITLE>DATOS PROVEEDORES</TITLE>
</HEAD>
<?
echo<<<h

<script language="JavaScript" src="js/calen.js"></script>

<SCRIPT LANGUAGE="JavaScript">
<!--
function entimpio (f){
	f.municipio.length=0;
h;

$sql="SELECT * FROM entidades";
$rd=mysql_query($sql);
while ($ld=mysql_fetch_object ($rd)){
echo <<<h
if (f.estado.value == '$ld->id'){
h;
$sql="SELECT id, nombre FROM municipios WHERE id_entidad='$ld->id'";
$rdd=mysql_query($sql);
$i=0;
while ($ldd=mysql_fetch_object ($rdd)){
$i++;
echo <<<h
f.municipio.options[$i]=new Option("$ldd->nombre","$ldd->id");
h;
}
echo "}";
}

echo <<<h
}
//-->
</SCRIPT>
h;
?>
<SCRIPT LANGUAGE="JavaScript">
<!--

function validar(f){
	
if (f.rfc.value==''){
		alert("Debes Ingresar el RFC");
		f.rfc.focus();
		return false;
	}

if (f.calle.value==''){
		alert("Debes Ingresar la calle");
		f.calle.focus();
		return false;
	}

if (f.noext.value==''){
		alert("Debes Ingresar el numero Exterior");
		f.noext.focus();
		return false;
	}

}
//-->
</SCRIPT>

<?
if ($g=='s')
  {

$sql="update `proveedores` set nombre='$nombre', rfc='$rfc', calle='$calle', noext='$noext', noint='$noint', colonia='$colonia', municipio='$municipio', estado='$estado', contacto='$contacto', telefono='$telefono', celular='$celular', vigencia='$vigencia', nocomprobante='$nocomprobante', email='$email' WHERE id='$no'";
mysql_query($sql);


echo <<<h
<SCRIPT language="JavaScript">
close();
</script>
h;
exit();
  }



if($acc=='captura')
{

if($s=='s')
$consulta="SELECT * FROM proveedores WHERE id='$cual'";

if($s=='n')
$consulta="SELECT * FROM proveedores WHERE nombre='$cual'";

$sql="$consulta"; 
$r=mysql_query($sql);
$lp=mysql_fetch_object ($r);
mysql_free_result($r);

$no=$lp->id; $nombre=$lp->nombre; $rfc=$lp->rfc; $calle=$lp->calle; $noext=$lp->noext; $noint=$lp->noint; $colonia=$lp->colonia; $municipio=$lp->municipio; $estado=$lp->estado; $contacto=$lp->contacto;  $telefono=$lp->telefono; $celular=$lp->celular;  $vigencia=$lp->vigencia; $nocomprobante=$lp->nocomprobante;$email=$lp->email;

	$sql="SELECT nombre FROM entidades WHERE id='$lp->estado'";
	$re=mysql_query($sql);
	$le=mysql_fetch_object($re);
	$entidadn=$le->nombre;
	mysql_free_result($re);

    $sql="SELECT nombre FROM municipios WHERE id='$lp->municipio'";
    $rm=mysql_query($sql);
    $lm=mysql_fetch_object ($rm);
    $municipion=$lm->nombre;
    mysql_free_result($rm);

echo <<<h
<BODY>
<BR>
<form name="f" method="post" action="proveedores.php?g=s&no=$no" onSubmit="return  validar(this)">
<table width="800" border="0" cellspacing="0" cellpadding="4" align="center" class=tform> 
<tr>
	<td align="center" colspan=4><B>Datos del proveedor</B></td>
</tr>
<tr>
	<td align="left">Nombre:</td>
	<td colspan="3"><input type="text" name="nombre" class="imputbox" size="101" maxlength="100" onChange="javascript:this.value=this.value.toUpperCase();" value="$nombre"></td>
</tr>
<tr>
	<td align="left">RFC:</td>
	<td><input type="text" name="rfc" class="imputbox" size="14" maxlength="13" onChange="javascript:this.value=this.value.toUpperCase();" value="$rfc"></td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</tr>
<tr>
	<td align="left">Calle:</td>
	<td colspan="2"><input type="text" name="calle" class="imputbox" size="51" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();" value="$calle"></td>
	<td>No Exterior:&nbsp;<input type="text" name="noext" class="imputbox" size="5" maxlength="4" onChange="javascript:this.value=this.value.toUpperCase();" value="$noext">&nbsp;No Interior:&nbsp;<input type="text" name="noint" class="imputbox" size="5" maxlength="4" onChange="javascript:this.value=this.value.toUpperCase();" value="$noint"></td>
</tr>
<tr>
	<td>Colonia:&nbsp;</td>
	<td><input type="text" name="colonia" class="imputbox" size="31" maxlength="30" onChange="javascript:this.value=this.value.toUpperCase();" value="$colonia"></td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</tr>
<tr>
	<td>Estado</td>
	<td>
	<SELECT name="estado" onChange="entimpio(this.form);" class="imputbox">
    <option value="$estado">$entidadn</option>
h;

 $sql="SELECT * FROM entidades order by nombre asc ";
 $rd=mysql_query($sql );
 $opt1='';
 $opt2='';
 while ($ld=mysql_fetch_object ($rd)) 
 {
echo <<<h
	 <option value="$ld->id">$ld->nombre
h;
 }
 mysql_free_result ($rd);

echo <<<h
    </select>
	</td>
	<td>Municipio</td>
	<td>
	<select name="municipio" class="imputbox">
	<option value="$municipio">$municipion
h;

echo <<<h
	</select>
	</td>
</tr>
<tr>
	<td align="left">Contacto:</td>
	<td><input type="text" name="contacto" class="imputbox" size="51" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();" value="$contacto"></td>
	<td align="left">Email:</td>
	<td><input type="text" name="email" class="imputbox" size="51" maxlength="50" onkeyup="javascript:this.value=this.value.toLowerCase();" value="$email"></td>
</tr>
<tr>
	<td align="left">Telefono:</td>
	<td><input type="text" name="telefono" class="imputbox" size="14" maxlength="13" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue=false;" value="$telefono"></td>
	<td align="left">Celular:</td>
	<td><input type="text" name="celular" class="imputbox" size="14" maxlength="13" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue=false;" value="$celular"></td>
</tr>
<tr>
	<td align="left">No. comprobante:</td>
	<td><input type="text" name="nocomprobante" class="imputbox" size="14" maxlength="13" onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue=false;" value="$nocomprobante"></td>
	<td align="left">Vigencia Factura:</td>
	<td><input type="text" name="vigencia" class="imputbox" size="11"  maxlength="10" value="$vigencia" readonly><a href="javascript:show_calendar('f.vigencia');" onmouseover="window.status='Calendario';return true;" onmouseout="window.status='';return true;"> <img src="img/show-calendar.gif"  border=0></a></td>
</tr>
<tr>
	<td colspan=4 align=center><input type="submit" value=" Guardar " class="botones" ONCLICK="" ></td>
</tr>
</table>
</form>
</BODY>
</HTML>
h;
}
?>