<body background="i.jpg">
<?php include("../../include/dbconnect.php");


// Get all _POST VALUES HERE..

foreach($_POST as $p=>$t)
{
	$_POST[$p] = trim($t);
}

$myCustomer = $_POST['Customer'];



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

$myDate = $_POST['Date'];

foreach($_POST as $m=>$n)
{
	$_POST[$m] = trim($n);
}

$myDate = $_POST['Date'];
$result = mysql_query("select account_year from company") or die(mysql_error());
$row = mysql_fetch_row($result);
$account_year = $row[0];
?>
<title>Cancel Invoices</title>
<body background=blater01.gif  topmargin=0>
<center> 
<table cellpadding=0 cellspacing=4 width=590>
  <tr> 
    <td style="padding:3px;" colspan=2 bgcolor="#93BEE2"><font face="Verdana, Arial, Helvetica, sans-serif"><b><b>Cancel Invoices</b></font></td>
  </tr>
  <tr valign="top"> 
    <td colspan=2> <font >&nbsp;</font> </td>
  </tr>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="590">
<tr> 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Customer / Client
  &nbsp;</b></font></td><td>
<?

// Pull all the data from Customer master & populate it

$stQuery = mysql_query("select bcode,name,unit from buy where buyertype != 'LABOUR' order by name")or die( mysql_error() );


?>
<form name='myForm01' method='POST' action='<?=$_SERVER[PHP_SELF]?>'>
  <SELECT name='Customer' onChange="javascript:submit();">
    <?
echo "<option selected value=\" 0\"> Select Customer";
while($row = mysql_fetch_row($stQuery))
{
	
	$temp = $row[1].'&nbsp;&nbsp;'.$row[2];
	if(isset($myCustomer) && eregi("$myCustomer",$row[0]))
	{
		echo "<option selected value=\"$row[0]\">$temp";
	}
	else{
		echo "<option value=\"$row[0]\">$temp";
	}
}
?>
  </SELECT></td></tr>
<tr> 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Category
  &nbsp;</b></font></td><td>

<?  
$result= mysql_query(" select distinct invdate from expinv where bcode = '$myCustomer' and account_year = '$account_year' ")or die( mysql_error() );
 ?>
  <SELECT name='Date' onChange="javascript:submit();">
    <?
echo "<option selected value=\" 0\"> Select Date";
while($row = mysql_fetch_row($result))
{
	
	$temp = substr($row[0],8,2).'-'.substr($row[0],5,2).'-'.substr($row[0],0,4);
	if(isset($myDate) && eregi("$myDate",$row[0]))
	{
		echo "<option selected value=\"$row[0]\">$temp";
	}
	else{
		echo "<option value=\"$row[0]\">$temp";
	}
}
?>
  </SELECT></td></tr>  
  </table>
 </form>
<table width="862" border="1"  cellpadding="1">  
	<tr >
	<td bgcolor="#CCCC66"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Product</b></font></td>
	<td width="17" bgcolor="#EAE2C4"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Drawing No</b></font></td>
	<td width="53"  bgcolor="#D2D2FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Invoice No</b></font></td>
	<td width="68"  bgcolor="#FFCEE7"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Quantity</b></font></td>
	<td width="60"  bgcolor="#FFFFDD"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Cancel</b></font></td>
	<td width="157" bgcolor="#D0E8E8"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> Remarks</b></font>	</td>												
	</tr>

<?
$sdt = date(d).'-'.date(m).'-'.date(Y); 
// Pull all Customers from Customer  based on Selected Customer id and populate it.




// This form contain a hidden field CustomerID which can be later used in next  page..
?>
<form name='myForm02' method='POST' action='cancel_entry.php' >
<input type="hidden" name="bcode" value=<?echo($myCustomer);?>>
<?

$result = mysql_query("select account_year from company") or die(mysql_error());
$row = mysql_fetch_row($result);
$account_year = $row[0];

$ind=0;
$sBuyQuery = mysql_query("SELECT  distinct expinv.record,product.prodname,expinv.drawing_no,expinv.invno,expinv.quantity,account_year,order_record from expinv,product where expinv.bcode = '$myCustomer' and min_no = ' ' and (expinv.drawing_no=product.drawing_no and product.bcode ='$myCustomer' ) and expinv.invdate ='$myDate' and account_year ='$account_year' order by invno ") or die(mysql_error());
while($row1 = mysql_fetch_row($sBuyQuery))
{

		?>
		<input type="hidden" name="record[<? echo($ind);?>]" value="<?	echo($row1[0]); ?>">
		<input type="hidden" name="invnos[<? echo($ind);?>]" value="<?	echo($row1[3]); ?>">


		
		<tr >
		
		<td bgcolor="#CCCC66"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[1]); ?></b></font></td>
		<td width="17" bgcolor="#EAE2C4"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[2]); ?></b></font></td>
		<td width="53"  bgcolor="#D2D2FF" align="center"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[3]); ?></b></font></td>
		<td width="68" bgcolor="#FFCEE7"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[4]); ?></b></font></td>
		<td width="68" align="center" bgcolor="#FFFFDD"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><input type="checkbox" name="canc[<? echo($ind);?>]" value="Yes"></b></font></td>
		<td width="157" bgcolor="#D0E8E8"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> <textarea name = "remarks[<? echo($ind);?>]" cols="20" rows="2"></textarea></b></font>
		</td>												
		</tr>
		<?
		$ind++;	


}





?>

</table>
 
  
  
  <table cellpading=0 cellspacing=10 width= 50>
    <tr> 
      <td> <blockquote> <input type =submit name="submit" value = "Submit"></td></blockquote>
  </table>
</table>


<br><br><font size=1><center><a href= "../../index.html">Return to index page</a></center></font>
</body></form>
