<html>
<head>
   <title>Vendor</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
a:link {
	color: #000;
}
a:visited {
	color: #000;
}
a:hover {
	color: #000;
}
a:active {
	color: #000;
}
</style>
</head>
<body>
<script type="text/javascript">
function sendValue(s,a){
var selvalue = s;
var selvalue2 = a;
window.opener.document.form1.id_vendor.value = selvalue;
window.opener.document.form1.nama_vendor.value = selvalue2;
window.close();
}
</script>
<style type="text/css">
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 12px;
}
</style>
<h1>Vendor</h1><br>
  <strong><em>Search
by:</em></strong>
  <form name="form1" method="get" action="">
  <table width="455" border="0" cellspacing="1" cellpadding="1">
    <tr>
      <th bgcolor="#CCCCCC">Acc. Number :</th>
      <td><input name="txt_lifnr" type="text" id="txt_lifnr" value="<?php echo strtoupper($_GET['txt_lifnr']); ?>" size="10" maxlength="10"></td>
    </tr>
    <tr>
      <th bgcolor="#CCCCCC">Name :</th>
      <td><input name="txt_name1" type="text" id="txt_name1" value="<?php echo strtoupper($_GET['txt_name1']); ?>" size="30" maxlength="30"></td>
    </tr>
    <tr>
      <th width="156">&nbsp;</th>
      <td width="240"><label for="txt_max"></label>
        <label for="txt_maktx">
          <input type="submit" name="button" id="button" value="Search">
    </label></td>
    </tr>
  </table>
</form>
  <?php
  if($_GET['txt_name1'] != '' || $_GET['txt_lifnr'] != '' )
  		{
		
    	include_once("sap.php");
	   include_once("lib.php");

    $sap = new SAPConnection();
    $sap->Connect(connection_string());
    if ($sap->GetStatus() == SAPRFC_OK ) $sap->Open ();
    if ($sap->GetStatus() != SAPRFC_OK ) {
       $sap->PrintStatus();
       exit;
    }

    $fce = &$sap->NewFunction ("YFM_DISPVEN_CIS");
    if ($fce == false ) {
       $sap->PrintStatus();
       exit;
    }
	
	
	  	$fce->GR_NAME1->row["SIGN"] = "I";
		$fce->GR_NAME1->row["OPTION"] = "CP";
		$fce->GR_NAME1->row["LOW"] = "*".strtoupper($_GET['txt_name1'])."*";
		$fce->GR_NAME1->row["HIGH"] = " ";
		$fce->GR_NAME1->Append($fce->GR_NAME1->row);
		
		$fce->GR_LIFNR->row["SIGN"] = "I";
		$fce->GR_LIFNR->row["OPTION"] = "CP";
		$fce->GR_LIFNR->row["LOW"] = "*".strtoupper($_GET['txt_lifnr'])."*";
		$fce->GR_LIFNR->row["HIGH"] = " ";
		$fce->GR_LIFNR->Append($fce->GR_LIFNR->row); 
  		
	
	/*if($_GET['txt_max'] != '' )
  		{
			$fce->GV_MAX_ROWS=$_GET['txt_max'];
		}*/
    $fce->Call();
	
    if ($fce->GetStatus() == SAPRFC_OK) {
		
		
        //Tables
        echo "<table border=1 bordercolor='#000000' cellpadding='0' cellspacing='0'>
		<tr  bgcolor='#CCCCCC'>
		<th>Acc. number</th>
		<th>Name</th>
		<th>City</th>
		<th>Postal code</th>
		<th>House num and street</th>
		<th>Vat. reg</th>
		</tr>";
        $fce->GI_HEADER_LFA1->Reset();
		//Display Tables
        while ( $fce->GI_HEADER_LFA1->Next() ){
			if($bg==0)
           {
           echo"<tr style=background-color:#eeeeee;>";
           $bg++;
           }
          else
			{
			echo"<tr style=background-color:#;>";
			$bg--;
			}
       echo '<td><a href="#" onClick="sendValue('.'\''.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["LIFNR"]).'\''.','.'\''.$fce->GI_HEADER_LFA1->row["NAME1"].'\''.');" >'.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["LIFNR"]).'</a></td>
	   <td><a href="#" onClick="sendValue('.'\''.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["LIFNR"]).'\''.','.'\''.$fce->GI_HEADER_LFA1->row["NAME1"].'\''.');" >'.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["NAME1"]).'</a></td>
	   <td><a href="#" onClick="sendValue('.'\''.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["LIFNR"]).'\''.','.'\''.$fce->GI_HEADER_LFA1->row["NAME1"].'\''.');" >'.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["ORT01"]).'</a></td>
	   <td><a href="#" onClick="sendValue('.'\''.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["LIFNR"]).'\''.','.'\''.$fce->GI_HEADER_LFA1->row["NAME1"].'\''.');" >'.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["PSTLZ"]).'</a></td>
	   <td><a href="#" onClick="sendValue('.'\''.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["LIFNR"]).'\''.','.'\''.$fce->GI_HEADER_LFA1->row["NAME1"].'\''.');" >'.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["STRAS"]).'</a></td>
	   <td><a href="#" onClick="sendValue('.'\''.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["LIFNR"]).'\''.','.'\''.$fce->GI_HEADER_LFA1->row["NAME1"].'\''.');" >'.fm_delete_zero_value2($fce->GI_HEADER_LFA1->row["STCEG"]).'</a></td>';
		}
        echo "</table>";							
    } else
        $fce->PrintStatus();
		$sap->Close();
		}
		else
		{
			
			echo '<center><font color="#FF0000"><b>Please input your search keyword</b></font></center>';
			
		}
  ?>

</body>
</html>
