<script language="Javascript">

function preguntar(inst1,dato){

eliminar=confirm("Do you really want to delete it ? " + dato);

if (eliminar)

window.location.href = inst1; 
}
</script>

<script> 
function ponPrefijo(invoicename,invoice_address,rfc,calle_clientes,no_exterior_clientes,no_interior_clientes,colonia_clientes , municipio_clientes , estado_clientes , localidad_clientes , codigo_postal_clientes , pais_clientes , telefono_clientes , email_facturas_clientes){ 
opener.document.form1facturas.txtcodigo_postal_facturas.value = codigo_postal_clientes 



     opener.document.form1facturas.txtrazon_social_factura.value = invoicename

     opener.document.form1facturas.txtdomicilio_factura.value = invoice_address

     opener.document.form1facturas.txtrfc_factura.value = rfc	  	 

	 

	 opener.document.form1facturas.txtcalle_facturas.value = calle_clientes

opener.document.form1facturas.txtno_exterior_facturas.value = no_exterior_clientes

opener.document.form1facturas.txtno_interior_facturas.value = no_interior_clientes

opener.document.form1facturas.txtcolonia_facturas.value = colonia_clientes

opener.document.form1facturas.txtmunicipio_facturas.value = municipio_clientes

opener.document.form1facturas.txtestado_facturas.value = estado_clientes



opener.document.form1facturas.txtlocalidad_facturas.value = localidad_clientes

//opener.document.form1facturas.txtcodigo_postal_facturas.value = codigo_postal_clientes



opener.document.form1facturas.txtpais_facturas.value = pais_clientes

//opener.document.form1facturas.txtreferencia_facturas.value = 

opener.document.form1facturas.txtemail_de_envio_receptor_facturas.value = email_facturas_clientes



	  

//      opener.document.form1.txtcliente.value = pref 

//    opener.document.form2.txtcliente.value =  pref 	

    window.close() 

} 

function ponref(pref){ 

    this.document.form12.txtbusca.value =pref

		this.document.form12.submit();

}  



</script> 

<form action="searchcustomerfacimp.php" method="post" name="form12" id="form12">

<?

$txtrs=$_GET['rs'];



?>

  <div align="center">

    <table width="314" border="0">

      <tr> 

        <td width="116"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Search 

          by </font></td>

        <td width="253"><select name="txtbuscapor" id="txtbuscapor">

            <option value="socialreason" selected>Company Name</option>

            <option value="nickname">Nick Name </option>

            <option value="invoicename">Invoice Name</option>

            <option value="city">City</option>

            <option value="rfc">RFC</option>

            <option value="creditOceanfreights">Credit Oceanfreights</option>

            <option value="creditlocalcharges">Credit Local Charges</option>

            <?

if ($txtbuscapor!="")

  echo "          <option value=\"$txtbuscapor\" selected>$txtbuscapor</option>			";

?>

          </select></td>

      </tr>

      <tr> 

        <td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Search:</font></td>

        <td><input name="txtbusca" type="text" id="txtbusca"  value ="<? echo $txtrs;?>" ></td>

      </tr>

      <tr> 

        <td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Contact 

          Name:</font></td>

        <td><input name="txtcontactname" type="text" id="txtcontactname"></td>

      </tr>

      <tr> 

        <td><?

		if ($txtrs!="")

echo "<script> this.document.form12.submit();</script>";

?></td>

        <td><input type="submit" name="Submit" value="Search"> <input type="button" name="Submit2" value="Back" onclick ="history.back()"></td>

      </tr>

    </table>

    

  </div>

</form>

<p> 

  <?

$txtbusca=$_POST['txtbusca'];

$txtbuscapor=$_POST['txtbuscapor'];

if ($txtbuscapor=="" )

		$authors = mysqli_query("SELECT * FROM customerexpint where socialreason like 'f' order by socialreason"  );

		else

			$authors = mysqli_query("SELECT * FROM customerexpint where $txtbuscapor like '$txtbusca' order by socialreason limit 100"  );



		$author = mysqli_fetch_array($authors);



$txtrazonsocial= $author['razonsocial'];

   $txtrfc= $author['rfc'];

   $txtcp= $author['cp'];

   $txtinvoicezip = $author['invoicezip '];



   $txtciudad= $author['ciudad'];

   $txtdireccion= $author['direccion'];

   $txtatencion= $author['atencion'];

   $txttel1= $author['tel1'];

   $txttel2= $author['tel2'];

   $txttel3= $author['tel3'];

   $txtfax= $author['fax'];

   $txtemail= $author['email'];

   $txtobservaciones= $author['observaciones'];

   $txtno= $author['no'];

?>

</p>

<p> 

  <?

$results = mysqli_query("SELECT * FROM customerexpint where id='$id'");

$row=mysqli_fetch_array($results);

 



	$txtid=$row['id'];

	$txtsocialreason= $row['socialreason']; 

	$txtnickname= $row['nickname']; 



	$txtrfc= $row['rfc']; 

	$txtcp= $row['cp']; 

	$txtcity= $row['city']; 

	$txtdirection= $row['direction']; 

	$txtcontact= $row['contact']; 

	$txttel1= $row['tel1']; 

	$txttel2= $row['tel2']; 

	$txttel3= $row['tel3']; 

	$txtfax = $row['fax']; 

	$txtemail= $row['email']; 

	$txtobservations= $row['observations']; 

	$txtcountry= $row['country']; 

	

	

echo "  <form name=\"form1\" method=\"post\" action=\"guardacambiocustomerexpint.php?id=" . $txtid . "\">";	    

?>



<?

  

  if ($txtbusca=="" )

$result = mysqli_query("SELECT * FROM customerexpint where socialreason like 'f' order by nickname"  );

		else

$result = mysqli_query("SELECT * FROM customerexpint where $txtbuscapor like '$txtbusca' order by nickname"  );

if ($row = mysqli_fetch_array($result)){ 

      echo "<table border = '1' align=\"center\"  bordercolorlight=\"#0000FF\" bgcolor=\"#CCFFFF\" > \n"; 

echo "<tr>"; 



      echo "</tr>"; 



//Mostramos los nombres de las tablas 



$i=0;

//encabezado

//printf("<TR><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Aceptar</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Cambiar</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Razon Social</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">RFC</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">CP</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Ciudad</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Direccion</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Atencion</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Telefono 1</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Telefono 2</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Telefono 3</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Fax</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">E-mail</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Observaciones</TD></TR>");

//printf("<TR><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Company Name</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">RFC</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">CP</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Ciudad</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Direccion</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Atencion</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Telefono 1</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Telefono 2</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Telefono 3</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Fax</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">E-mail</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Observaciones</TD></TR>");

printf("<TR><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Option</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Invoice Name</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Address</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Zip</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">City</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">RFC</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Credit Oceanfreights</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Credit Local Charges</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Delete</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Change</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Contacts</TD></TR>");



do {

	$i=$i+1; 

echo "<tr \n";

echo "          <LABEL \n";

echo "        <TD \n";

//impresion

//ponPrefijo(pref)

//echo "      <td><input name=\"che\" type=\"button\" id=\"che\" onClick=\"ponref(document.form1.txtmarcasynumeros1.value )\" value=\"Agregar\" > " ;

//echo "  <input name=\"Button2\" type=\"Button\" onClick=\"ponPrefijo('$txtsocialreason')\" value=\"Aceptar\">";

//printf("<TR><td> <input name=\"Buttonf$i\" type=\"Button\" onClick=\"ponPrefijo('" . $row["razonsocial"] . "')\" value=\"Aceptar\"></td><TD><input name=\"Button2$i\" type=\"Button\" onClick=\"ponref('" . $row["razonsocial"] . "')\" value=\"Cambiar\"></TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD></TR>",$row["razonsocial"],$row["rfc"],$row["cp"],$row["ciudad"],$row["direccion"],$row["atencion"],$row["tel1"],$row["tel2"],$row["tel3"],$row["fax"],$row["email"],$row["observaciones"]);

///printf("<TR><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD></TR>",$row["socialreason"],$row["rfc"],$row["cp"],$row["ciudad"],$row["direccion"],$row["atencion"],$row["tel1"],$row["tel2"],$row["tel3"],$row["fax"],$row["email"],$row["observaciones"]);





if($row["no_ext_invoice"]=="")

printf("<TR><td>DEBES CAPTURAR EL DETALLE DE LA DIRECCION PARA FACTURA ELECTRONICA</td>

<TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><a href=\"javascript:preguntar('customers/borracustomerexpint.php?id=%s','')\">Delete</a></TD><TD><a href=\"customers/cambiocustomerexpint.php?id=%s\">Change</a></TD><TD><a href=\"customers/customercontactdetails.php?id=%s\">Administrate</a></TD></TR>",$row["invoicename"],$row["invoiceaddress"],$row["cp"],$row["invoicecity"],$row["rfc"],$row["creditforoceanfreights"],$row["creditforlocalcharges"],$row["id"],$row["id"],$row["id"]);

else

printf("<TR><td> <input name=\"Buttonf$i\" type=\"Button\" onClick=\"ponPrefijo('" . $row["invoicename"] . "','" . $row["invoiceaddress"] . " C.P. " . $row["invoicezip"] . " " . $row["invoicecity"] . "','" . $row["rfc"]         ."', '" . $row["calle_invoice"] ."', '" . $row["no_ext_invoice"] ."', '" . $row["no_int_invoice"] ."', '" . $row["colonia_invoice"] ."', '" . $row["municipio_invoice"] ."', '" .$row["estado_invoice"] ."', '" . $row["localidad_invoice"] ."', '" . $row["cp"] ."', '" . $row["pais_invoice"] ."', '" . $row["telefono_invoice"] ."', '" . $row["email"] . "')\" value=\"OK\"></td>

<TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">%s</TD><TD><a href=\"javascript:preguntar('customers/borracustomerexpint.php?id=%s','')\">Delete</a></TD><TD><a href=\"customers/cambiocustomerexpint.php?id=%s\">Change</a></TD><TD><a href=\"customers/customercontactdetails.php?id=%s\">Administrate</a></TD></TR>",$row["invoicename"],$row["invoiceaddress"],$row["invoicezip"],$row["invoicecity"],$row["rfc"],$row["creditforoceanfreights"],$row["creditforlocalcharges"],$row["id"],$row["id"],$row["id"]);

//, . " " . $row["creditforoceanfreightsdays"],$row["creditforoceanfreightsfromdate"],$row["creditforlocalcharges"] . " " . $row["creditforlocalchargesdays"],$row["creditforlocalchargesfromdate"]

echo "        <TD \n";



$txtidc=$row["id"];

echo "      </TR>";



   } while ($row = mysqli_fetch_array($result)); 



   echo  "</table>" ;





}

else

{

if ($txtbusca!="")

{

echo "</p>";

echo "<p align=\"center\"><strong><font color=\"#FF0000\" size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Not Found $txtbusca</font></strong></p>";

echo "</p>";

}

}

?>

<p>&nbsp; </p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p><p>&nbsp;</p>

  <p>&nbsp;</p>

  <p>&nbsp;</p>

</form>
