<?php
 
session_start();
$com = "M";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
require_once("DFJQUERY.inc");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script language="javascript">
$(document).ready(function(){
	/*AutoSugestion*/
	var idRetVal2="id_cli";
	var idRetDes2="nom_cli";
	

	$("#"+idRetDes2).autocomplete('DYCLIBASCPS.php',{
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		//max:3                        //maximo de resultados mostrados, se manda como limit en autosugestion
		delay: 200,                  //Retardo de autocompletar 
		width: 600,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: false,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 300,           //alto del cuadro para el scroll
		formatItem:formatItem,	     //formato de presentacion de las posibles busquedas
		extraParams:{typeRequest:'ac',tipBusCat:'nom'}     //Parametros Extra a Mandar en autosugestion
	});
	$("#"+idRetVal2).autocomplete('DYCLIBASCPS.php',{
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		//max:3                        //maximo de resultados mostrados, se manda como limit en autosugestion
		delay: 200,                  //Retardo de autocompletar 
		width: 600,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: false,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 300,           //alto del cuadro para el scroll
		formatItem:formatItem,       //formato de presentacion de las posibles busquedas
		formatResult:function(row){  //formato de seleccion de busqueda
			return row[1];
		},	                        
		extraParams:{tipBusCat:'id',typeRequest:'ac'}     //Parametros Extra a Mandar en autosugestion
	});
	$("#"+idRetVal2).result(function(event, data, formatted){
		$('#'+idRetDes2).val(data[0]);
		$('#'+idRetDes2).focus();
	});	
	$("#"+idRetDes2).result(function(event, data, formatted){
		$('#'+idRetVal2).val(data[1]);
	});		
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0]+", RFC:"+row[2]+", SUC:"+row[3];
	}	
	/**************/
	opciones();
});
</script>

<?php

if ($_REQUEST['bot']==""){
	echo '<h2>!!! Selecciona un Registro !!!</h2>';
	echo '<meta content="1; url=DX40000_PR.php"  HTTP-EQUIV="REFRESH">';
}else{
	
	include('DX40000_CL.php');
	$varible_clase = new clase_cli_pro();
	$res=$varible_clase->lista_busqueda($_REQUEST["bot"]);
	//$result=mysqli_fetch_array($res);
	$reg = $_REQUEST['bot'];
	$dato = mysqli_fetch_array ($res);
	if(!isset($_POST['ttipo'])){
		$registro=mysqli_fetch_array(mysqli_query($con ,"select * from geoyos_jc.dxcoloni where cve_col = '".$dato['des_colonia']."'"));
		$_REQUEST['tcol']=$registro['des_colonia'];
		$_REQUEST['tcp']=$dato['cod_pos'];
		$_REQUEST['pais']=$dato['cve_pais'];
		$_REQUEST['estados']=$dato['cve_estado'];
		$_REQUEST['tmun']=$dato['cve_delmun'];
		$_REQUEST['ttel']=$dato['tel'];
		$_REQUEST['tfax']=$dato['fax'];
		$_REQUEST['tmail']=$dato['mail'];
		$_REQUEST['tsuc']=$dato['nom_suc'];
		$_REQUEST['tap']=$dato['ap_paterno'];
		$_REQUEST['tam']=$dato['ap_materno'];
		$_REQUEST['tne']=$dato['nombre'];		
		$_REQUEST['trfc']=$dato['rfc'];
		$_REQUEST['tnom']=$dato['nom_con'];
		$_REQUEST['tappa']=$dato['app_con'];
		$_REQUEST['tapemat']=$dato['apm_con'];
		$_REQUEST['tgiro']=$dato['giro'];
		$_REQUEST['tcalle']=$dato['calle'];
		$_REQUEST['text']=$dato['no_ext'];
		$_REQUEST['tint']=$dato['no_int'];
		$_REQUEST['tentre']=$dato['entre_calle'];
		$_REQUEST['ty']=$dato['y_calle'];
		$_REQUEST['ttit']=$dato['titulo'];
		$_REQUEST['ttipo']=$dato['tipo'];
		$_REQUEST['tgen']=$dato['gener'];
		$_REQUEST['no_suc']=$dato['no_suc'];
		$_REQUEST['id_cli']=$dato['self_codigo'];
		$dt_self=mysqli_fetch_array(mysqli_query($con ,"SELECT CONCAT(ap_paterno,' ',ap_materno,' ',nombre) as nom_cli FROM dxbascps WHERE codigo='".$dato['self_codigo']."'"));
		$_REQUEST['nom_cli']=$dt_self['nom_cli'];		
	}
	
	
?>

<body
<?php
 
if(isset($_REQUEST['bot3'])){
	echo ' onLoad="deshab()"';
}
?>
>
<form name="frm1" method="post">
<input name="bot" type="hidden" value="<?php
 echo $_REQUEST['bot'];?>">
<input name="tipAgr" id="tipAgr" type="hidden" value="<?php
 echo $_REQUEST['tipAgr'];?>">
<input name="retAct" id="retAct" type="hidden" value="<?php
 echo $_REQUEST['retAct'];?>">
<input name="botCat" id="botCat" type="hidden" value="<?php
 echo $_REQUEST['botCat'];?>">
  <table  align="center">
    <tr> 
      <th colspan="6" nowrap class="titulo"><div align="center">VERIFICA ALTAS DE CLIENTES 
          / PROVEEDORES / HONORARIOS </div></th>
    </tr>
    <tr> 
      <td nowrap class="genStyleTit">Persona:</td>
      <?php

		echo '<input type="hidden" name="t1" value ="' . $dato['codigo'] . '"/>';
		?>
      <td nowrap>
	  <select name="ttipo" id="ttipo" onChange="opciones()">
        <option value="">--SELECCIONE--</option>
		 <?php

		 	if($_REQUEST['ttipo']=="MORAL"){
				echo '<option selected>MORAL</option>';
			}else{
				echo '<option>MORAL</option>';
			}
			if($_REQUEST['ttipo']=="FISICA CON ACT/EMPRE"){
				echo '<option selected>FISICA CON ACT/EMPRE</option>';
			}else{
				echo '<option>FISICA CON ACT/EMPRE</option>';
			}
			if($_REQUEST['ttipo']=="FISICA SIN ACT/EMPRE"){
				echo '<option selected>FISICA SIN ACT/EMPRE</option>';
			}else{
				echo '<option>FISICA SIN ACT/EMPRE</option>';
			}
		?>
        </select></td>
      <td nowrap>Generico: </td>
      <td nowrap><select name="tgen" id="tgen">
          <?php

		  if($_REQUEST['tgen']==""){
				echo '<option selected></option>';
			}else{
				echo '<option></option>';
			}
			if($_REQUEST['tgen']=="MASCULINO"){
				echo '<option selected>MASCULINO</option>';
			}else{
				echo '<option>MASCULINO</option>';
			}
		if($_REQUEST['tgen']=="FEMENINO"){
				echo '<option selected>FEMENINO</option>';
			}else{
				echo '<option>FEMENINO</option>';
			}
?>
        </select></td>
      <td nowrap>Titulo:</td>
      <td nowrap><select name="ttit">
          <option></option>
<?php

	include("DMMYSQLG.php");
	@$resultado=mysqli_query($con ,"select * from dxramtit");
	while($registro=mysqli_fetch_array($resultado)){
		if($_REQUEST['ttit']==$registro['titulo']){
			echo '<option value="' . $registro['titulo'] . '" selected>' . $registro['nom_tit'] . '</option>';
		}else{
			echo '<option value="' . $registro['titulo'] . '">' . $registro['nom_tit'] . '</option>';
		}
	}
	include("DMMYSQLG.php");
?>
       </select></td>
    </tr>
    <tr> 
      <td nowrap class="genStyleTit">Cli./Prov.:</td>
	  <td colspan="5" nowrap>
	  	  <span class="genStyle"> 
        Ape. Pat.:
        <input name="tap" type="text" onKeyUp="may(this)" size="20" 
		<?php

					echo 'value="' . $_REQUEST['tap'] . '"';
		?>/>
		</span>
		 <span class="genStyle">
        Ape. Mat.: 
        <input name="tam" type="text" onKeyUp="may(this)" size="20" 
		  <?php

						echo 'value="' . $_REQUEST['tam'] . '"';
			?>/>
		</span>
		<span class="genStyle">
        Nom./Emp.: 
        <input name="tne" type="text" onKeyUp="may(this)" size="50"
	  		<?php

			echo 'value="' . $_REQUEST['tne'] . '"';
			?>/>
	  </span>	  </td>
    </tr>
    <tr> 
      <td nowrap>
	  <span class="genStyleTit">
	  R.F.C.:	  </span>
	  &nbsp;</td>

      <td nowrap><span class="genStyle">
        <input name="trfc" type="text" size="20" maxlength="13" 
	  	<?php

						echo 'value="' . $_REQUEST['trfc'] . '"';
			?>
	  onKeyUp="may(this)"/>
      </span></td>
      <td colspan="4" nowrap>
	  <span class="genStyleTit">
	  Telefono:
      <input name="ttel" type="text" id="ttel"
	 
		onKeyPress="return validar(event)" size="20" maxlength="10"
	  <?php

			if(isset($_REQUEST['ttel'])){ //este es el truco
				echo 'value="' . $_REQUEST['ttel'] .  '"';
			}
	  ?>/>
      Fax:
      <input name="tfax" type="text" id="tfax"	
	  onKeyPress="return soloNumeros(event)" size="20"
	  <?php

			if(isset($_REQUEST['tfax'])){ //este es el truco
				echo 'value="' . $_REQUEST['tfax'] .  '"';
			}
	  ?>/>
	  </span>	  </td>
    </tr>
    <tr> 
      <th colspan="6" nowrap class="titulo"><div align="center">DIRECCION</div></th>
    </tr>
    <tr> 
      <td nowrap class="genStyleTit">Contacto:  </td>
      <td colspan="5" nowrap><span class="genStyle">Ape. Pat.: 
      <input name="tappa" type="text"	
	  onKeyUp="may(this)" size="20"
	  		<?php

			echo 'value="' . $_REQUEST['tappa'] . '"';
			?>/>Ape. Mat.:
      <input name="tapemat" type="text"
	  onKeyUp="may(this)" size="20"
	  		<?php

			echo 'value="' . $_REQUEST['tapemat'] . '"';
			?>/>
     </span>
	 <span class="genStyle" style="width:63px;">
	    Nom.:
		</span>
	<span class="genStyle">	
      <input name="tnom" type="text"	
		onKeyUp="may(this)" size="50"
			<?php

			echo 'value="' . $_REQUEST['tnom'] . '"';
			?>/>
		</span>		</td>
    </tr>
    <tr> 
      <td nowrap>Giro:</td>
      <td nowrap><input type="text" name="tgiro"
	  		<?php

			echo 'value="' . $_REQUEST['tgiro'] . '"';
			?>
	  onKeyUp="may(this)"/></td>
      <td nowrap>Calle: </td>
      <td nowrap><input type="text" name="tcalle"
	  		<?php

				echo 'value="' . $_REQUEST['tcalle'] . '"';
			?>
	  onKeyUp="may(this)"/></td>
      <td nowrap># Ext:</td>
      <td nowrap><input name="text" type="text" id="text" 
	  		<?php

			echo 'value="' . $_REQUEST['text'] . '"';
			?>
			onKeyUp="may(this)"/></td>
    </tr>
    <tr> 
      <td nowrap># Int. </td>
      <td nowrap><input type="text" name="tint" onBlur="may(this)"
	  		<?php

			echo 'value="' . $_POST['tint'] . '"';
			?>
	/> </td>
      <td nowrap>Entre calle: </td>
      <td nowrap><input type="text" name="tentre"
	  		<?php

			echo 'value="' . $_REQUEST['tentre'] . '"';
			?>
	  onKeyUp="may(this)"/></td>
      <td nowrap>Y:</td>
      <td nowrap><input type="text" name="ty"
	  		<?php

			echo 'value="' . $_REQUEST['ty'] . '"';
			?>
	  onKeyUp="may(this)"/></td>
    </tr>
    <tr>
      <td nowrap>Colonia:</td>
      <td nowrap><input type="hidden" name="tcol1" id="tcve" value="<?php
echo $_REQUEST['tcve'];?>">
          <input type="text" name="tcol" id="tcol" value="<?php
echo $_REQUEST['tcol'];?>">
          <input name="?" type="button" value="..." onClick="window.open('DX40000_AG1.php?retPag=DX40000_MO.php','popuppage','width=750,height=300,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')" ></td>
      <td nowrap>Codigo Postal:</td>
      <td nowrap><input name="tcp" type="text" onKeyPress="return validar(event)" maxlength="5" value="<?php
echo $_REQUEST['tcp'];?>"></td>
      <td nowrap>&nbsp;</td>
      <td nowrap>&nbsp;</td>
    </tr>
    <tr>
      <td height="29" colspan="6" nowrap>
	  <span class="genStyle">
	  Pais:
	  <select name="pais" id="pais" onChange="javascript: document.getElementById('frm1').submit()">
        <option value="" selected>---Selecciona---</option>
        <?php
   
		  include("DMMYSQLG.php");
			@$resultado=mysqli_query($con ,"select * from dxpaises");
			if(!isset($_REQUEST['pais'])){
				$dt_paises=mysqli_fetch_array($resultado);
				$selPais=$dt_paises['cve_pais'];
				if(mysqli_num_rows($resultado)>0)
					mysqli_data_seek($resultado,0);		
			}
			else{
				$selPais=$_REQUEST['pais'];
			}
			while($registro=mysqli_fetch_array($resultado)){
				if($selPais==$registro['cve_pais']){
					echo '<option value="' . $registro['cve_pais'] . '" selected>' . $registro['des_pais'] . '</option>';
				}else{
					echo '<option value="' . $registro['cve_pais'] . '">' . $registro['des_pais'] . '</option>';
				}
				
			}			
		?>
      </select>
	  Estado:
        <select name="estados" onChange="javascript: document.getElementById('frm1').submit()">
          <option  value="">-----Selecciona-----</option>
          <?php
  
		@$resultado=mysqli_query($con ,"select * from dxestado where cve_pais='$selPais'");
		if(!isset($_REQUEST['estados'])){
			$dt_estado=mysqli_fetch_array($resultado);
			$selEnt=$dt_estado['cve_estado'];
			if(mysqli_num_rows($resultado)>0)
				mysqli_data_seek($resultado,0);		
		}
		else{
			$selEnt=$_REQUEST['estados'];
		}
		while($registro=mysqli_fetch_array($resultado)){
			if($selEnt==$registro['cve_estado'] ){ 
				echo '<option value="' . $registro['cve_estado'] . '" selected>' . $registro['des_estado'] . '</option>';
			}else{
				echo '<option value="' . $registro['cve_estado'] . '">' . $registro['des_estado'] . '</option>';
			}
			
		}
?>
        </select>Delegacion o Mun: 
        <select name="tmun" id="tmun" >
          <option  value="">-----Selecciona-----</option>
          <?php
 
		@$resultado=mysqli_query($con ,"select * from dxdelmun where cve_estado='$selEnt' and cve_pais='$selPais'");
		if(!isset($_REQUEST['tmun'])){
			$dt_delmun=mysqli_fetch_array($resultado);
			$selDelMun=$dt_delmun['cve_delmun'];
			if(mysqli_num_rows($resultado)>0)
				mysqli_data_seek($resultado,0);		
		}
		else{
			$selDelMun=$_REQUEST['tmun'];
		}
		while(@$registro=mysqli_fetch_array($resultado)){
			if($selDelMun==$registro['cve_delmun']){ 
				echo '<option value="' . $registro['cve_delmun'] . '" selected>' .$registro['des_delmun'] . '</option>';
			}else{
				echo '<option value="' . $registro['cve_delmun'] . '">' . $registro['des_delmun'] . '</option>';
			}
		}
?>
        </select></span>    </td>
    </tr>
    
    <tr>
      <td nowrap>E- Mail: </td>
      <td nowrap><input name="tmail" type="text" id="tmail"
	   <?php

			if(isset($_REQUEST['tmail'])){ //este es el truco
				echo 'value="' . $_REQUEST['tmail'] .  '"';
			}
	  ?>
	  ></td>
      <td nowrap>Sucursal:</td>
      <td nowrap><input name="tsuc" type="text" id="tsuc" onBlur="may(this)"
	  <?php

			if(isset($_REQUEST['tsuc'])){ //este es el truco
				echo 'value="' . $_REQUEST['tsuc'] .  '"';
			}
	  ?>
	  ></td>
      <td nowrap>N. Sucursal: </td>
      <td nowrap><input name="no_suc" type="text" id="no_suc" onBlur="may(this)"
	  <?php

			if(isset($_REQUEST['no_suc'])){ //este es el truco
				echo 'value="' . $_REQUEST['no_suc'] .  '"';
			}
	  ?>
	  ></td>
    </tr>
    <tr>
      <td colspan="6" nowrap class="titulo">Promotor:<span class="style13">
      <input name="id_cli" type="text" id="id_cli" size="10" value="<?php
echo trim($_REQUEST['id_cli']);?>" >
      <input name="nom_cli" type="text" id="nom_cli" size="60" value="<?php
echo trim($_REQUEST['nom_cli']);?>">
      </span></td>
    </tr>
    <tr> 
      <th colspan="6" nowrap class="titulo"><div align="center">ACTIVIDAD</div></th>
    </tr>
    <tr> 
      <td colspan="6" nowrap><div align="center"> 
          CLIENTE :
          <select name="tact" id="tact">
<?php

if($dato['act1']=="1"){
	echo '<option value="0">NO</option>';
	echo '<option value="1" selected>SI</option>';
}else{
	echo '<option value="0" selected>NO</option>';
	echo '<option value="1" >SI</option>';
}
?>
          </select>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PROVEEDOR:&nbsp;
          <select name="tact1" id="tact1">
<?php
 
if($dato['act2']=="0"){
	echo '<option value="0" selected>NO</option>';
	echo '<option value="1" >PROVEEDOR</option>';
	echo '<option value="2" >ACREEDOR</option>';
}
if($dato['act2']=="1"){
	echo '<option value="0">NO</option>';
	echo '<option value="1" selected>PROVEEDOR</option>';
	echo '<option value="2" >ACREEDOR</option>';
}
if($dato['act2']=="2"){
	echo '<option value="0" >NO</option>';
	echo '<option value="1" >PROVEEDOR</option>';
	echo '<option value="2" selected>ACREEDOR</option>';
}
?>
                    </select>
</div></td>
    </tr>
    <tr> 
      <td colspan="6" nowrap>  <div align="center"> 
          <input type="button" name="Submit" value="Modificar" onClick="openpage('DX40000_MC.php','_self')">
          <?php
if($_REQUEST['tipAgr']==''){?>
		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          <input type="button" name="Submit2" value="Regresar" onClick="openpage('DX40000_PR.php','_self')">
          <?php
;}?>
		</div>        </td>
    </tr>
  </table>
</form>
<?php
 
if(isset($_REQUEST['bot3'])){
	echo '<div align="center">
	<form id="form1" name="form1" action="DX40000_PR.php" target="_self">
		<input type="submit" name="submit" value="Regresar">
	</form>
	</div>';
	
}
?>
</body>
<?php
 
mysqli_close($con);
}
?>
</html>