<?php
 
session_start();
include("DMMYSQLG.php");
$com = "M";
include("DSA3000.php");
include("JQUERY.inc");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<?php

if (!isset($_REQUEST['bot'])){
	echo '<h2>!!! Selecciona un Registro !!!</h2>';
	echo '<meta content="1; url=cat_codigos_PR.php"  HTTP-EQUIV="REFRESH">';
}else{
	include('cat_codigos_CL.php');
	if(!isset($_POST['paises1'])){
		$data['idColonia']=$_REQUEST['bot'];
		$varible_clase = new Coloni($data);	
		$res=$varible_clase->busReg();
		$reg=mysqli_fetch_array($res);
		$_REQUEST['tcod']=$reg['cod_pos'];
		$_REQUEST['paises1']=$reg['cve_pais'];
		$_REQUEST['estados']=$reg['cve_estado'];
		$_REQUEST['mun']=$reg['cve_delmun'];
		$_REQUEST['tcol']=$reg['des_colonia'];	
	}
?>
<body
<?php
 
if(isset($_REQUEST['bot3'])){
	echo ' onLoad="deshab()"';
}
?>
>
<form  name="frm1" id="frm1" method="post" action="">
<input name="bot" type="hidden" value="<?php
 echo $_REQUEST["bot"]?>">
  <table width="408"  align="center">
    <tr> 
      <th colspan="2" class=\"titulo\"><div align="center">MODIFICAR COLONIA </div></th>
    </tr>
    <tr> 
      <td nowrap>Pais al que pertenece: </td>
      <td nowrap>
        <select name="paises1" onChange="javascript: document.getElementById('frm1').submit()">
		<OPTION value="">--SELECCIONE--</OPTION>
		<?php
 
			@$resultado2=mysqli_query($con ,"select * from dxpaises ORDER BY des_pais");
			while($registro2=mysqli_fetch_array($resultado2)){
				if($_REQUEST['paises1']==$registro2['cve_pais'])
					echo '<option value="'. $registro2['cve_pais'] .'" selected>'.$registro2['des_pais'].'</option>';
				else
					echo '<option value="'. $registro2['cve_pais'] .'">'.$registro2['des_pais'].'</option>';
			}
		?>
      </select>	  </td>
    </tr>
    <tr>
      <td nowrap>Estado  al que pertenece: </td>
      <td nowrap>
	<select name="estados" onChange="javascript: document.getElementById('frm1').submit()">
	<OPTION value="">--SELECCIONE--</OPTION>
	<?php

	if(isset($_REQUEST['paises1'])){ 
		@$res=mysqli_query($con ,"select * from dxestado where cve_pais='".$_REQUEST['paises1']."'");
		while($reg=mysqli_fetch_array($res)){
			if($_REQUEST['estados']==$reg['cve_estado'])
				echo '<option value="' . $reg['cve_estado'] . '" selected>' . $reg['des_estado'] . '</option>';
			else
				echo '<option value="' . $reg['cve_estado'] . '">' . $reg['des_estado'] . '</option>';
		}
	}
	?>
</select></td>
    </tr>
    <tr>
      <td nowrap>Municipio al que pertenece </td>
      <td nowrap><select name="mun">
	  	<OPTION value="">--SELECCIONE--</OPTION>
        <?php

			if(isset($_REQUEST['estados'])){ 
				@$res=mysqli_query($con ,"select * from dxdelmun where cve_estado='".$_REQUEST['estados']."' AND cve_pais='".$_REQUEST['paises1']."'");
				while($reg=mysqli_fetch_array($res)){
					if($_REQUEST['mun']==$reg['cve_delmun'])
						echo '<option value="' . $reg['cve_delmun'] . '" selected>' . $reg['des_delmun'] . '</option>';
					else
						echo '<option value="' . $reg['cve_delmun'] . '">' . $reg['des_delmun'] . '</option>';
				}
			}

		?>
      </select></td>
    </tr>
    <tr>
      <td nowrap> Codigo Postal: </td>
      <td nowrap><input name="tcod" type="text" id="tmun" size="6" maxlength="25" onKeyPress="return validar(event)" value="<?php
 echo $_REQUEST['tcod'];?>"/></td>
    </tr>
    <tr>
      <td width="59" nowrap> Colonia: </td>
      <td width="302" nowrap><input name="tcol" type="text" id="tcta_pais" size="40" maxlength="50" onBlur="may(this)" value="<?php
 echo $_REQUEST['tcol'];?>"/></td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center"> 
          <input type="button" name="Submit2" value="Modificar" onClick="openpage('cat_codigos_MC.php','_self')"/>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          <input type="button" name="Submit2" value="Regresar" onClick="openpage('cat_codigos_PR.php','_self')"/>
        </div></td>
    </tr>
  </table>
</form>
<?php
 
if(isset($_REQUEST['bot3'])){
	echo '<div align="center">
	<form id="form1" name="form1" action="cat_codigos_PR.php" target="_self">
		<input type="submit" name="submit" value="Regresar">
	</form>
	</div>';
	
}
?>
 </body>
<?php
 
mysqli_close($con);
}
?>
</html>