<body background="i.jpg">
<?php include("../../include/dbconnect.php");
$f_date = substr($from_date,6,4).'-'.substr($from_date,3,2).'-'.substr($from_date,0,2);
$t_date = substr($to_date,6,4).'-'.substr($to_date,3,2).'-'.substr($to_date,0,2);
?>


<title>Turnover Report</title>
<body background=blater01.gif  topmargin=0>
<center> 
<table cellpadding=0 cellspacing=4 width=671>
  <tr> 
    <td style="padding:3px;" colspan=2 bgcolor="#93BEE2"><font face="Verdana, Arial, Helvetica, sans-serif"><b><b> Turnover</b></font></td>
  </tr>
  <tr valign="top"> 
    <td colspan=2 align="center" bgcolor="#CA95FF"> <font  size="+1"  color="#0000FF" >Credit Sales Turnover  from <? echo($from_date);?> to <? echo($to_date);?></font> </td>
  </tr>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="590">
<table width="668" border="1"  cellpadding="1">  
	<tr >

	<td width="60"  bgcolor="#D9D9FF" ><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Sl No</b></font></td>
	<td width="356" bgcolor="#B9B9FF"><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Customer</b></font></td>
	<td width="117" bgcolor="#FFE1C4"> <font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Turnover </b></font></td>
	<td width="107" bgcolor="#99CCCC" ><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Inclusive of Tax</b></font></td>

	</tr>
<?
$totvalue=0;
$grandtotal=0;
$ind=1;
$sBuyQuery = mysql_query("SELECT  distinct salesreg.bcode,buy.name,buy.unit from salesreg,buy where  invdate >= '$f_date' and invdate <= '$t_date'  and buy.bcode = salesreg.bcode order by buy.name  ") or die(mysql_error());
while($row1 = mysql_fetch_row($sBuyQuery))
{
	
	
	$turnslct = mysql_query("select sum(value),sum(packing_amt),sum(gtotal) from salesreg where bcode ='$row1[0]' and drawing_no = 'TOTAL' and  invdate >= '$f_date' and invdate <= '$t_date' ") or die(mysql_error());
	$turnrow = mysql_fetch_row($turnslct);
	$value = $turnrow[0];
	$packing_amt=$turnrow[1];
	$gtotal = $turnrow[2];
	$totalvalue = $totalvalue+$value+$packing_amt;
	$grandtotal = $grandtotal+$gtotal;
		
		if($value >0)
		{
		?>

		<tr >
	<td width="60"  bgcolor="#D9D9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><? echo($ind);?></b></font></td>		
		<td  bgcolor="#B9B9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[1].'&nbsp;'.$row1[2]); ?></b></font></td>
		<td width="117" bgcolor="#FFE1C4" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($value+$packing_amt,0),2,'.','')); ?></b></font></td>
		<td width="107" bgcolor="#99CCCC" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($gtotal,0),2,'.','')); ?></b></font></td>

		</tr>
		<?
	
		$ind++;
		}
}





?>
</table>
<table width="668" border="1"  cellpadding="1">  
		<tr >
	<td width="61"  bgcolor="#D9D9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;</b></font></td>		
		<td width="355" align="center" bgcolor="#B9B9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>TOTAL</b></font></td>
		<td width="117" bgcolor="#FFE1C4" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($totalvalue,0),2,'.','')); ?></b></font></td>
		<td width="107" bgcolor="#99CCCC" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($grandtotal,0),2,'.','')); ?></b></font></td>

		</tr>
		</table>

 <?
 //  LABOUR INVOICES BELOW
 ?>
  
<table cellpadding=0 cellspacing=4 width=671>

  <tr valign="top"> 
    <td colspan=2 align="center" bgcolor="#CA95FF"> <font  size="+1"  color="#0000FF" >Labour Invoices Turnover  from <? echo($from_date);?> to <? echo($to_date);?></font> </td>
  </tr>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="590">
<table width="668" border="1"  cellpadding="1">  
	<tr >

	<td width="60"  bgcolor="#D9D9FF"><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Sl No</b></font></td>
	<td width="356" bgcolor="#B9B9FF"><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Customer</b></font></td>
	<td width="117" bgcolor="#FFE1C4"><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Turnover </b></font></td>


	</tr>
<?
$labourvalue=0;
$labourtotal=0;
$ind=1;
$sBuyQuery = mysql_query("SELECT  distinct labourinv.bcode,buy.name,buy.unit from labourinv,buy where  invdate >= '$f_date' and invdate <= '$t_date'  and buy.bcode = labourinv.bcode order by buy.name  ") or die(mysql_error());
while($row1 = mysql_fetch_row($sBuyQuery))
{
	
	
	$turnslct = mysql_query("select sum(value),sum(packing_amt),sum(gtotal) from labourinv where bcode ='$row1[0]' and drawing_no = 'TOTAL' and  invdate >= '$f_date' and invdate <= '$t_date' ") or die(mysql_error());
	$turnrow = mysql_fetch_row($turnslct);
	$value = $turnrow[0];
	$gtotal = $turnrow[2];
	$labourvalue = $labourvalue+$value;
	$labourtotal = $labourtotal+$gtotal;
		
		if($value >0)
		{
		?>

		<tr >
	<td width="60"  bgcolor="#D9D9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><? echo($ind);?></b></font></td>		
		<td  bgcolor="#B9B9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[1].'&nbsp;'.$row1[2]); ?></b></font></td>
		<td width="117" bgcolor="#FFE1C4" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($value,0),2,'.','')); ?></b></font></td>


		</tr>
		<?
	
		$ind++;
		}
}





?>
</table>
<table width="668" border="1"  cellpadding="1">  
		<tr >
	<td width="51"  bgcolor="#D9D9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;</b></font></td>		
		<td width="476" align="center"  bgcolor="#B9B9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>TOTAL</b></font></td>
		<td width="119" bgcolor="#FFE1C4" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($labourvalue,0),2,'.','')); ?></b></font></td>


		</tr>
		</table>

  

 <?
 //  EXPORT INVOICES TURNOVER 
 ?>
  
<table cellpadding=0 cellspacing=4 width=671>

  <tr valign="top"> 
    <td colspan=2 align="center" bgcolor="#CA95FF"> <font  size="+1"  color="#0000FF" >EXPORT Invoices Turnover  from <? echo($from_date);?> to <? echo($to_date);?></font> </td>
  </tr>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="590">
<table width="668" border="1"  cellpadding="1">  
	<tr >

	<td width="60"  bgcolor="#D9D9FF"><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Sl No</b></font></td>
	<td width="356" bgcolor="#B9B9FF"><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Customer</b></font></td>
	<td width="117" bgcolor="#FFE1C4"><font color="#003366" size="+1" face="Verdana, Arial, Helvetica, sans-serif"><b>Turnover </b></font></td>


	</tr>
<?
$labourvalue=0;
$labourtotal=0;
$ind=1;
$sBuyQuery = mysql_query("SELECT  distinct expinv.bcode,buy.name,buy.unit from expinv,buy where  invdate >= '$f_date' and invdate <= '$t_date'  and buy.bcode = expinv.bcode order by buy.name  ") or die(mysql_error());
while($row1 = mysql_fetch_row($sBuyQuery))
{
	
	
	$turnslct = mysql_query("select sum(value),sum(packing_amt),sum(gtotal) from expinv where bcode ='$row1[0]' and drawing_no = 'TOTAL' and  invdate >= '$f_date' and invdate <= '$t_date' ") or die(mysql_error());
	$turnrow = mysql_fetch_row($turnslct);
	$value = $turnrow[0];
	$gtotal = $turnrow[2];
	$labourvalue = $labourvalue+$value;
	$labourtotal = $labourtotal+$gtotal;
		
		if($value >0)
		{
		?>

		<tr >
	<td width="60"  bgcolor="#D9D9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><? echo($ind);?></b></font></td>		
		<td  bgcolor="#B9B9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[1].'&nbsp;'.$row1[2]); ?></b></font></td>
		<td width="117" bgcolor="#FFE1C4" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($value,0),2,'.','')); ?></b></font></td>


		</tr>
		<?
	
		$ind++;
		}
}





?>
</table>
<table width="668" border="1"  cellpadding="1">  
		<tr >
	<td width="51"  bgcolor="#D9D9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&nbsp;</b></font></td>		
		<td width="476" align="center"  bgcolor="#B9B9FF"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>TOTAL</b></font></td>
		<td width="119" bgcolor="#FFE1C4" align="right"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo(number_format(round($labourvalue,0),2,'.','')); ?></b></font></td>


		</tr>
		</table>



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