<html>
<head>
   <title>Plant</title>
</head>
<body>
<script type="text/javascript">
function sendValue(s,a){
var selvalue = s;
var selvalue2 = a
window.opener.document.form1.txt_werks.value = selvalue;
window.opener.document.form1.txt_werks2.value = selvalue2;
window.close();
}
</script>
<style type="text/css">
a:link {
	color: #000;
}
a:visited {
	color: #000;
}
a:hover {
	color: #000;
}
a:active {
	color: #000;
}
</style>
<style type="text/css">
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 12px;
}
</style>
<h1>Plant</h1>
  <?php
    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_PLANT_CIS");
    if ($fce == false ) {
       $sap->PrintStatus();
       exit;
    }
	
    $fce->Call();
	
    if ($fce->GetStatus() == SAPRFC_OK) {
        //Tables
        echo "<table border=1 bordercolor='#000000' cellpadding='0' cellspacing='0'>
		<tr  bgcolor='#CCCCCC'>
		<th>Plnt</th>
		<th>Name</th>
		</tr>";
        $fce->GI_HEADER_T001W->Reset();
		//Display Tables
        while ( $fce->GI_HEADER_T001W->Next() ){
			if($bg==0)
           {
           echo"<tr style=background-color:#eeeeee;>";
           $bg++;
           }
          else
			{
			echo"<tr style=background-color:#;>";
			$bg--;
			}
        echo '<td><a href="#" onClick="sendValue('.'\''.$fce->GI_HEADER_T001W->row["WERKS"].'\''.','.'\''.$fce->GI_HEADER_T001W->row["NAME1"].'\''.');" >'.$fce->GI_HEADER_T001W->row["WERKS"].'</a></td>
	  <td><a href="#" onClick="sendValue('.'\''.$fce->GI_HEADER_T001W->row["WERKS"].'\''.','.'\''.$fce->GI_HEADER_T001W->row["NAME1"].'\''.');" >'.$fce->GI_HEADER_T001W->row["NAME1"].'</a></td></tr>';
		}
        echo "</table>";							
    } else
        $fce->PrintStatus();
	$sap->Close();
  ?>

</body>
</html>
