<link rel="stylesheet" href="css/font.css" type="text/css" />
<script>
function stock_report_print(url)
{
onmouseover43= window.open(url,'onmouseover43','height=580,width=1100,scrollbars=yes,left=50,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no');
}
</script>
<?php error_reporting(0);
/*********************************Get Found Result And Pagination********************************************************/
include("../../include/db.php");
?>
<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
</style>
<table width="100%">
<tr>
<td width="1%" height="38">&nbsp;</td>
<td width="7%" class="style15">&nbsp;</td> 
<td width="13%" align="center">&nbsp;</td>
<td width="1%">&nbsp;</td>
<td width="6%" class="style15">&nbsp;</td>
<td width="14%" align="center"  class="style15">&nbsp;</td>
<td width="2%">&nbsp;</td>
<td width="11%" class="style15">&nbsp;</td>
<td width="24%" align="left" >&nbsp;</td>
<td width="8%" align="center">&nbsp;</td>
<td width="2%"></td>
<td width="7%" align="center"><a href="javascript:stock_report_print('report/stock_report/stock_report_print.php?item_name=<?php echo $_POST['item_name'];?>&from_date=<?php echo $_POST['from_date']; ?>&to_date=<?php echo $_POST['to_date']; ?>');" style="text-decoration:none;"><img src="img/PrinterBlack.png" width="35" height="30" title="Print" value="Print"/></a></td>
  </tr>
</table>
<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<div class="CSSTableGenerator">  
<table border="0" width="60%"  align="center" cellpadding="0" cellspacing="0"  >
<thead>
<tr>
    <th height="23" colspan="2" valign="middle">
<table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0"  >
<tr>
    <th width="65%"  align="left" >&nbsp;&nbsp;&nbsp;Media Particulars</th>
  
    <th width="35%"  align="center" >Qty In MTR</th>
    </tr>
    </table>
    </td>
    <th width="401" colspan="2" valign="middle">
    <table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" >
    <tr>
    <th width="66%"  align="left">&nbsp;&nbsp;&nbsp;Ink Particulars</th>
   
    <th width="34%"  align="center">Qty In Litter</th>
    </tr>
    </table>
    </td>
    </tr>
  <?php
include("../../include/db.php"); 
function get_total_qty($item_id,$from_date)
{
	$current_dates = date('Y-m-d');
if($from_date!='')
{
$sql="select sum(in_qty) as in_qty,sum(out_qty) as out_qty from  stock_table where  item_id='$item_id' and date<='$from_date' ";
}
else
{
$sql="select sum(in_qty) as in_qty,sum(out_qty) as out_qty from  stock_table where  item_id='$item_id' and date<='$current_dates' ";
}
		
        $rs=mysql_query($sql);
	    $s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
                 $in_qty=$rsdata['in_qty'];
				 $out_qty=$rsdata['out_qty'];
				 $totals=$in_qty-$out_qty; 
	        }
return $totals;
}


function get_total_qty_media($item_id,$from_date)
{
$current_dates = date('Y-m-d');
if($from_date!='')
{
   
$sql="select sum(in_qty) as in_qty,sum(out_qty) as out_qty from  stock_table where item_id='$item_id' and date<='$from_date' ";
}
else
{
  
$sql="select sum(in_qty) as in_qty,sum(out_qty) as out_qty from  stock_table where  item_id='$item_id' and date<='$current_dates' ";
}
        $rs=mysql_query($sql);
	    $s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
                 $in_qty=$rsdata['in_qty'];
				 $out_qty=$rsdata['out_qty'];
				$total=$in_qty-$out_qty; 
				 //$total=$rsdata['total_mtr'];
	        }
return $total;
}
  $item_name4=$_POST['item_name'];
  $from_date=$_POST['from_date'];
  $to_date=$_POST['to_date'];
 ?>
    <tr> 
    <td colspan="2">
      <table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ddd" >
      <?php 
if($item_name4=='')
{
  $sql="select id,particulars from consumable_creation where item='Media' order by particulars ASC ";
}
else
{  
  $sql="select id,particulars from consumable_creation where particulars='$item_name4' and item='Media'  order by particulars ASC";
}
    $rs=mysql_query($sql);
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
                 $id=$rsdata['id'];
			     $item_name=$rsdata['particulars'];
			     $total_qty=get_total_qty_media($id,$from_date);
		?><?php 
		if($total_qty!=0.00) 
		{ ?>
        <tr>
          
          <th width="260" height="28" align="left" style="border:1px solid #ddd" >&nbsp;&nbsp;&nbsp;<?php echo ucfirst($item_name); ?> </th>
          
          <th width="135" align="right" style="border:1px solid #ddd" ><?php  echo number_format($total_qty,2); ?>&nbsp;&nbsp;</th>
          </tr><?php $sum_tot+=$total_qty;} ?><?php } ?>
        
        </table>
    </td>
    <td colspan="2">
    <table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ddd" >
<?php 
if($item_name4=='')
{
$sql="select id,particulars from consumable_creation where item='Ink' order by particulars ASC ";
}
else
{  
$sql="select id,particulars from consumable_creation where particulars='$item_name4' and item='Ink' order by particulars ASC ";
}
    $rs=mysql_query($sql);
   		while($rsdata=mysql_fetch_array($rs))
  			{
                 $id=$rsdata['id'];
				 $item_name2=$rsdata['particulars'];
                 $total_qty2=get_total_qty($id,$from_date);
		?>
		<?php 
		if($total_qty2!=0.00) 
		{ ?>
    <tr>  
    <th width="263" height="29" align="left" style="border:1px solid #ddd" >&nbsp;&nbsp;&nbsp;<?php echo ucfirst($item_name2); ?></th>
    <th width="132" align="right" style="border:1px solid #ddd" ><?php  echo number_format($total_qty2,2); ?>&nbsp;&nbsp;</th>
    </tr><?php $sum_tot2+=$total_qty2;} ?><?php } ?>
    </table>
    </td>
    </tr>
 <tr>
 <td colspan="2"><table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ddd" >
 <tr>
          <th width="260" height="28" align="left" style="border:1px solid #ddd" >Total</th>
          <th width="135" align="right" style="border:1px solid #ddd" ><?php  echo number_format($sum_tot,2); ?>&nbsp;&nbsp;</th>
          </tr>
</table></td>
<td colspan="2">
<table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ddd" >
 <tr>
          <th width="260" height="28" align="left" style="border:1px solid #ddd" >Total</th>
          <th width="135" align="right" style="border:1px solid #ddd" ><?php  echo number_format($sum_tot2,2); ?>&nbsp;&nbsp;</th>
          </tr>
</table></td></tr>
  </thead>
</table>
</div>
</div>
</div>
</div>

