<? 
include("../comun/conexion3.php");?>

<link rel="stylesheet" type="text/css" href="../../../style.css" media="all" />

<script language="Javascript">
function preguntar(inst1,dato){
eliminar=confirm("Do you really want to delete it ? " + dato);
if (eliminar)
window.location.href = inst1; 
}

function ponPrefijo(pref,name,tel,fax,email,nick1){ 
     parent.document.getElementById('txtcustomer').value = pref 
	 parent.document.getElementById('txtcustomer_nick_name').value = nick1 

      parent.document.getElementById('txtcustomercontact').value = name

      parent.document.getElementById('txtcustomerfax').value = fax

      parent.document.getElementById('txtcustomertel').value = tel

      parent.document.getElementById('txtcustomeremail').value = email
   parent.document.getElementById('ClientesBox').close()

} 

function ponref(pref,nick1){ 

    this.document.form12.txtbusca.value =pref

	

opener.document.form1.txtcustomer_nick_name.value = nick1 

		this.document.form12.submit();

}  



</script> 

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

  <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" <?=$_POST[txtbuscapor]=='socialreason' ? 'selected="selected"' : ''?>>Company Name</option>

            <option value="nickname" <?= ($_POST[txtbuscapor]=='nickname' or $_POST[txtbuscapor]=='') ? 'selected="selected"' : ''?>>Nick Name </option>

            <option value="invoicename" <?=$_POST[txtbuscapor]=='invoicename' ? 'selected="selected"' : ''?>>Invoice Name</option>

            <option value="city" <?=$_POST[txtbuscapor]=='city' ? 'selected="selected"' : ''?>>City</option>

            <option value="rfc" <?=$_POST[txtbuscapor]=='rfc' ? 'selected="selected"' : ''?>>RFC</option>

            <option value="creditOceanfreights" <?=$_POST[txtbuscapor]=='creditOceanfreights' ? 'selected="selected"' : ''?>>Credit Oceanfreights</option>

            <option value="creditlocalcharges" <?=$_POST[txtbuscapor]=='creditlocalcharges' ? 'selected="selected"' : ''?>>Credit Local Charges</option>

            <?

			$txtbusca=$_POST['txtbusca'];

$txtbuscapor=$_POST['txtbuscapor'];

$txtcontactname=$_POST['txtcontactname'];

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="<?=$_POST[txtbusca]?>"></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>&nbsp;</td>

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

      </tr>

    </table>

    

  </div>

</form>

 

  <?


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

//echo "SELECT * FROM customerexpint where $txtbuscapor like '$txtbusca%' order by socialreason limit 100";

//$author = mysqli_fetch_array($result);

/*echo mysqli_num_rows($result);
$txtid=$author['id'];
$txtno= $author['no'];*/

//$result = mysqli_query("SELECT * FROM customerexpint where id='$txtid'");

//echo "  <form name=\"form1\" method=\"post\" action=\"guardacambiocustomerexpint.php?id=" . $txtid . "\">";	  
  
if ($row = mysqli_fetch_array($result)){ 

      echo "<br><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\">Company Name</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Nick Name</TD><TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\">Invoice Name</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"]);



printf("<TR><td> <input name=\"Buttonf$i\" type=\"Button\" onClick=\"ponPrefijo('" . $row["socialreason"] . "','" . $rowc["name"] . "','" . $rowc["tel"] . "','" . $rowc["fax"] . "','" . $rowc["email"] . "','" . $row["nickname"]  . "')\" value=\"Tariff EXPO\"></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><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\"><a href=\"javascript:preguntar('borracustomerexpint.php?id=%s','')\">Delete</a></TD>
																																																																																																																																																																																														 <TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\"><a href=\"cambiocustomerexpint.php?id=%s\">Change</a></TD>
																																																																																																																																																																																														 <TD><strong><font size=\"1\" face=\"Arial, Helvetica, sans-serif\"><a href=\"customercontactdetails.php?id=%s\">Administrate</a></TD>
																																																																																																																																																																																														 </TR>",$row["socialreason"],$row["nickname"],$row["invoicename"],$row["city"],$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"];

$resultc = mysqli_query("SELECT * FROM contact  where id = '$txtidc' and section ='CUSTOMER' and name like '$txtcontactname%' order by name, function"); 

while ($rowc = mysqli_fetch_array($resultc)){ 

echo "        <TR>";

printf("<TR><td> <input name=\"Buttonf$i\" type=\"Button\" onClick=\"ponPrefijo('" . $row["socialreason"] . "','" . $rowc["name"] . "','" . $rowc["tel"] . "','" . $rowc["fax"] . "','" . $rowc["email"] . "','" . $row["nickname"]  . "')\" value=\"Select\"></td><td></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>",$rowc["name"],$rowc["function"],$rowc["tel"],$rowc["fax"],$rowc["movil"],$rowc["nextel"],$rowc["email"]);





}



//echo "  ;

//echo "<td><input name=\"ches$i\" type=\"button\" id=\"ches$i\" onClick=\"ponref()\" value=\"Subir\"></TD>";

echo "      </TR>";



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



   echo  "</table>" ;





}

else

{

if ($txtbusca!="")

{

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



}

}

?>

</form>

</body>