<style type="text/css">
.style20 {
	font-family: Verdana;
	font-size: 12px;
}

.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.style10{ border-left:solid 1px; border-left-color:#999;}
.style15{ border-right:solid 1px; border-right-color:#999;}

.style11{ border-bottom:solid 1px; border-bottom-color:#999;}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.style23 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 15px;
	font-weight: bold;
}
.style27 {font-size: 12px}
.style28 {
	font-size: 16px;
	font-weight: bold;
}
.text {font-family: Verdana; font-size:13px;}
.style29 {	font-family: Verdana;
	font-size: 14px;

}
.stylebottom
{
	border-top:1px solid #999;
}	
</style>

<table border="0" width="980"  align="center"  cellpadding="0" cellspacing="0"  >
<thead>
<tr style="height:60">
<td width="126" height="106" align="right" style="font-size:12px;"><img src="../../img/logo_image.png" width="126" height="130"/></td>
<td colspan="5" align="center" valign="top" style=""><strong style="font-size: 30px; color: #06F; padding-top: 5px; width: 80px; font-family: Verdana, sans-serif">SRI AMMAN DIGITAL PRINTS</strong><br />
        <span width="80%" class="title1" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b> DOOR No: 1/2,1/3  KOMBAI THOTTAM MAIN ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>SELLANDIAMMAN THURAI ROAD,</span><br />
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>TIRUPPUR-641604 TAMILNADU STATE INDIA,</span><br/>
       <span width="80%" class="title00" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Contact Office: 0421-4355333,+91 83442-33555,+91 83442-33888,</span><br/>
       <span width="80%" class="title0" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Email Id : sriammandigitalprints@gmail.com/yahoo.com.</span><br/>

     <span width="80%" class="title1" style="font-size:18px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>Stock Report</span>
  </tr>

<tr><td colspan="9" height="20"></td></tr>
<tr>
<td width="126" align="right"  class="style4"  ><strong>From Date :</strong></td>
<td width="127"  align="left" class="style4"> <?php if($_GET['from_date']==''){ echo $curdate=date('d-m-Y');} else { echo date("d-m-Y",strtotime($_GET['from_date']));}?></td>
<td width="109" align="right"  class="style4"  ><strong>Item Name :</strong></td>
<td width="150"  align="left" class="style4"> <?php if($_GET['item_name']==''){ echo "All";} else { echo $_GET['item_name'];}?></td>
<td width="179" align="right" class="style4"><strong>To Date :</strong> 
<td width="109"  align="left" class="style4" scope="col"> <?php if($_GET['to_date']==''){ echo $curdate=date('d-m-Y');} else { echo date("d-m-Y",strtotime($_GET['to_date'])); }?></td>

</tr><tr><td colspan="9" height="10"></td></tr>

</thead>
</table>
<table width="980" height="93" border="0"  align="center"  cellpadding="0" cellspacing="0"  >
<thead>

<tr>
    <td height="23" colspan="2" valign="middle" class="style10 style11 stylebottom" >
<table width="532" height="23" border="0"  align="center" cellpadding="0" cellspacing="0"   >
<tr>
    <th width="70%" class="text "  align="left" >&nbsp;&nbsp;Media Particulars</th>
  
    <th width="30%" class=" text"  align="right" >Qty In MTR&nbsp;</th>
    </tr>
    </table>
    </td>
    <td width="467" colspan="2" valign="middle" class="style10 style15 style11 stylebottom">
    <table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" >
    <tr>
    <th width="66%" class=" text"  align="left">&nbsp;&nbsp;&nbsp;Ink Particulars</th>
   
    <th width="34%" class=" text"  align="right">Qty In Litter&nbsp;</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=$_GET['item_name'];
  $from_date=$_GET['from_date'];
  $to_date=$_GET['to_date'];	  
 ?>
    <tr> 
    <td colspan="2" class=" style11 style10">
      <table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0"  >
 <?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>
          
          <td width="372" height="28" align="left" class="text" style="border-bottom: 1px solid;" >&nbsp;&nbsp;&nbsp;<?php echo ucfirst($item_name); ?></td>
          
          <td width="155" align="right" class=" text" style="border-bottom: 1px solid;"><?php  echo number_format($total_qty,2); ?>&nbsp;</td>
          </tr><?php $sum_tot+=$total_qty;} }?>
         
        </table>
    </td>
    <td colspan="2" class="style11 style10 style15" >
    <table border="0" width="99%" height="0"  align="center" cellpadding="0" cellspacing="0">
  <?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>  
    <td width="263" height="28" align="left" class="text" style="border-bottom: 1px solid;"  >&nbsp;&nbsp;&nbsp;<?php echo ucfirst($item_name2); ?></td>
  
    <td width="132" align="right" class="text" style="border-bottom: 1px solid;"  ><?php  echo number_format($total_qty2,2); ?>&nbsp;</td>
    </tr><?php $sum_tot2+=$total_qty2;} }?>
          
    </table>
    </td>
    </tr>
 <tr>
 <td colspan="2" class="style11 style10 "><table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0"  >
 
    <tr>
          
          <td width="371" height="28" align="left" class=" text ">&nbsp;&nbsp;<strong>Total</strong></td>
          
          <td width="156" align="right" class=" text" ><?php  echo number_format($sum_tot,2); ?>&nbsp;</td>
          </tr>
    

 
    <tr>
    </table>
    <td colspan="2" class="style11 style10 style15"><table border="0" width="99%"  align="center" cellpadding="0" cellspacing="0" >
       <tr>   
          <td width="260" height="28" align="left" class=" text " >&nbsp;&nbsp;<strong>Total</strong></td>
          
          <td width="132" align="right" class="text"><?php  echo number_format($sum_tot2,2); ?>&nbsp;</td>
          </tr>
    </table>
 </tr>
  </thead>
</table>
<table>
 
 <td align="center" style="padding-left: 850px; " class="text"><br>Printed Date : <?php echo $curdate=date('d-m-Y');?>&nbsp;&nbsp;&nbsp;&nbsp;<br>Printed Time : <?php echo $current_time=date('h:i:s A');?>&nbsp;&nbsp;<br>IP Address   &nbsp;&nbsp;&nbsp;: <?php echo $ip_address = $_SERVER['REMOTE_ADDR'];?>&nbsp;</p></td>
 </table>