<?php include("../../include/dbconnect.php"); 

foreach($_POST as $q=>$r)
{
	$_POST[$q] = trim($r);
}

$myCompany = $_POST['Company'];

?>
<center>
<h2><font face="Arial, Helvetica, sans-serif"><b>View Sales Return</font></h2>
<?

$result= mysqli_query($conn," select distinct compcode,name from company  order by name")or die( mysqli_error() );

?>
<form  name='myform' method='POST' action='<?=$_SERVER['PHP_SELF']?>'>
<table border=0 cellpadding=3 cellspacing=4 width="568" bgcolor="#E6E6FF">

<tr > 
    <td width="74" height="31" align="left" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Company 
      </b></font></td>
    <td width="167">

  <SELECT name='Company' onChange="javascript:submit();">
<?php 
	 echo "<option selected value=\" 0\"> Select Company";	  
      while ( $row1= mysqli_fetch_row($result))
      {
	  	if(isset($myCompany) && preg_match("/" . preg_quote($myCompany, '/') . "/", $row1[0]))
		{
			echo "<option selected value=\"$row1[0]\">$row1[1]";
	  	}
	  	else
	  	{
			echo "<option value=\"$row1[0]\">$row1[1]";
	  	}
	}
?>
</select></td></tr>
<tr><td>
<?

mysqli_query($conn,"truncate tpurch") or die(mysqli_error());

$aresult = mysqli_query($conn,"select distinct account_year from branches ");
$arow = mysqli_fetch_row($aresult);
$account_year = $arow[0];

// Pull all the data from date master & populate it
$stQuery = mysqli_query($conn,"select  distinct  salesreturn.poinv_date, salesreturn.poinv_no, buy.name  from salesreturn, buy where salesreturn.bcode=buy.bcode and salesreturn.prodcode='TOTAL' and account_year = '$account_year' and compcode = '$myCompany' order by salesreturn.poinv_no, salesreturn.poinv_date") or die(mysqli_error());
?>
</font>
</form>
<form name='myForm01' method='POST' action="editview.php?compcode=<?=$myCompany?>&pono=<?=$mypono?>&account_year=<?=$account_year?>&dis=T&pk=T ">
<tr>
    <td width="74" height="31" align="left" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> Select Inv No
      </b></font></td><td>
  <font face="Arial, Helvetica, sans-serif">
<SELECT  name='mypono'>
  
  <?
     echo "<option  selected value=\" 0\"> Select Inv No";
    while($row = mysqli_fetch_row($stQuery))
    {

		$temp1 = 'Inv No : '.$row[1].'&nbsp;Dt : &nbsp;'.british($row[0]).'&nbsp;Name :&nbsp;'.$row[2];
        echo "<option value=\"$row[1]\">$temp1";

		
    }
?>
</SELECT>
</td>
</tr>

<tr>

<td align=center colspan="100%"> <blockquote>
   <input  type =submit name=submit value = "Submit"></blockquote></td> </tr>
</table>
  
</form>

<center>
  <font size="1" face="Arial, Helvetica, sans-serif"><a href="index.html">Return to Index page </a></font> 
</center>
</body>


