<style type="text/css">
.style20 {
	font-family: Verdana;
	font-size: 12px;
}
.style5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.style10{ border-top:solid 1px; border-top-color:#999;}
.style11{ border-left:solid 1px; border-left-color:#333333;}
.style12{ border-right:solid 1px; border-right-color:#333333;}

.style4 {font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.style23 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	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-bottom:1px solid #999;
}	
</style>
<?php 
$type_1 = isset($_GET['type_1']) ? $_GET['type_1'] : '';
?>
<table width="980" height="30" border="0" align="center"  cellpadding="0" cellspacing="0">
<tr style="height:60">
<td width="137" height="106" align="right" style="font-size:12px;"><img src="../../img/logo_image.png" width="126" height="130"/></td>
<td width="711" 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>Ink Usage Consolidated Report</span></p></td>
  </tr>
 
  <tr>
<td align="center" colspan="3" height="10px" style="font-family: Verdana, sans-serif; font-size: 14px; font-family: Verdana, sans-serif; font-weight: bold;"></td>
</tr>
<tr> <td align="left" width="212" class="style4 text" scope="col"><strong>&nbsp;From Date&nbsp;:&nbsp;</strong>
    <?php if($_GET['from_date']!=''){  echo $_GET['from_date'];} else { echo date("d-m-Y"); }?></td>
      <td width="220"  align="center" class="style4 text" scope="col"><strong>&nbsp;Item Name&nbsp;:&nbsp;</strong>
    <?php if($_GET['item_name']!=''){  echo $_GET['item_name'];} else { echo "All"; }?></td>
    <td width="150"  align="right" class="style4 text" scope="col"><strong>To Date&nbsp;:&nbsp;</strong>
    <?php if($_GET['to_date']!=''){  echo $_GET['to_date'];} else { echo date("d-m-Y"); }?>&nbsp;</td>
    <!--<td width="150"  align="center" class="style4 text" scope="col"><strong>&nbsp;Type&nbsp;:&nbsp;</strong>-->
    <!--<?php if($_GET['type_1']!=''){  echo $_GET['type_1'];} else { echo "Purchases"; }?></td>-->
  </tr>
  <tr>
<td align="center" colspan="3" height="10px" style="font-family: Verdana, sans-serif; font-size: 14px; font-family: Verdana, sans-serif; font-weight: bold;"></td>
</tr>

  </table></td>
</tr></table>
<table border="0" width="100%"  align="center" cellpadding="0" cellspacing="0"  >
<thead>
<!--<tr >-->
  

<!-- <td width="52%" height="23" class="stylebottom style10 text style11 style12" align="center" colspan="6" valign="middle"><strong>Usages</strong></td>-->
<!--</tr>-->

<tr>   
   <?php
        include("../../include/db.php"); 
        error_reporting(0);
        $machine_numbers1 = array(); 
        $sql_user1 = "SELECT * FROM machine_creation WHERE mach_type='printer' ORDER BY machine_no ASC";
        $rs_user1 = mysql_query($sql_user1);
        while ($rsdata_user1 = mysql_fetch_object($rs_user1)) {
            $machine_no1 = $rsdata_user1->machine_no;
            $machine_numbers1[] = $machine_no1;
        }
            ?>
    <td height="18" colspan="<?php echo count($machine_numbers1) + 3; ?>" valign="middle" class="stylebottom">
    
    <tr>
   <td width="12%"  align="left" class="text style11"><strong>&nbsp;Date</strong></td>
  
   <!--<td width="20%"  align="left" class="text"><strong>Shift</strong></td>-->
      
   <!--<td width="16%"  align="left" class="text"><strong>Operator</strong></td>-->
   
   <td width="15%"  align="left" class="text"><strong>Particulars</strong></td>
   <?php
        $machine_numbers = array(); 
        $sql_user = "SELECT * FROM machine_creation WHERE mach_type='printer' ORDER BY machine_no ASC";
        $rs_user = mysql_query($sql_user);
        while ($rsdata_user = mysql_fetch_object($rs_user)) {
            $machine_no = $rsdata_user->machine_no;
            $machine_numbers[] = $machine_no; 
            ?>
   <td width="11%"  align="left" class="text"><strong><?php echo $machine_no; ?></strong></td>
   <?php } ?>
    <td width="12%"  align="right" class="text style12" ><strong>Qty</strong></td>
    </tr>
   
    </td>
    </tr>
  
  <?php
function get_shift_name_from_mach($shift_time)
{
$sql_query11="select * from shift_creation where id='$shift_time' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $to_time=$rsdata11->to_time;
 $shift_name=$rsdata11->shift_name;
  $from_time=$rsdata11->from_time;

 } 
 $tot_shift=array($from_time,$to_time,$shift_name);
 return $tot_shift;
}


function get_machine_name($machine_no)
{
 $sql_query11="select * from machine_creation where id='$machine_no' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $machine_no=$rsdata11->machine_no;
 } 
return $machine_no;
}

function get_operator_id($operator_id)
{
$sql_query11="select * from operator_creation where id='$operator_id' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $operator_name=$rsdata11->operator_name;
 } 
return $operator_name;
}

$item_name4=$_GET['item_name'];
  $from_date=$_GET['from_date'];
 $to_date=$_GET['to_date'];
 $cur_date=date("Y-m-d");
if($from_date!=""){ $from_date1= "DATE_FORMAT(ink_date,'%Y-%m-%d')>='$from_date'"; }else{$from_date1=""; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(ink_date,'%Y-%m-%d')<='$to_date'";}else{$to_date1="";}
if($item_name4!=""){ $item_name41 = "particulars='$item_name4'";}else{$item_name41="";}

$all_value10 = $from_date1."@".$to_date1."@".$item_name41;
$all_array10 = explode('@',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query102 .= $value10." AND ";
}
} ?>

    <tr>
    <td colspan="<?php echo count($machine_numbers) + 3; ?>" class="stylebottom style11 style12" >
    
 <?php $item_name4=$_GET['item_name'];
  $from_date=$_GET['from_date'];
 $to_date=$_GET['to_date'];
 $cur_date=date("Y-m-d");
if($from_date!=""){ $from_date1= "DATE_FORMAT(ink_date,'%Y-%m-%d')>='$from_date'"; }else{$from_date1=""; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(ink_date,'%Y-%m-%d')<='$to_date'";}else{$to_date1="";}
if($item_name4!=""){ $item_name41 = "prod_size='$item_name4'";}else{$item_name41="";}

$all_value10 = $from_date1."@".$to_date1."@".$item_name41;
$all_array10 = explode('@',$all_value10);
foreach($all_array10 as $value10)
{ 
if($value10!='')
{
$get_query105 .= $value10." AND ";
}
}	   ?>

     <?php 
     $machine_totals = array_fill(0, count($machine_numbers), 0);
       if ($from_date != '') {
        $sql = "SELECT * FROM ink_sublist WHERE $get_query105 ink_sub_id!='' ORDER BY prod_size ASC";
        } else {
        $sql = "SELECT * FROM ink_sublist WHERE DATE_FORMAT(ink_date,'%Y-%m-%d')='$cur_date' ORDER BY prod_size ASC";
        }
    $rs=mysql_query($sql);
	 $rscount=mysql_num_rows($rs);
	if($rscount!='')
	{
	$s_no=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				 $s_no=$s_no+1;
				 $from=$from+1;
                 $id=$rsdata['ink_sub_id'];
                 $item_id=$rsdata['ink_entry_no	'];
                 $ink_date = $rsdata['ink_date'];
                 $prod_size = $rsdata['prod_size'];
                 $total_qty = $rsdata['total_req'];
                 $machine_no = $rsdata['machine_no'];
				 $operator_name=$rsdata['operator_name'];
				 list($frm_time,$to_ti,$type)=get_shift_name_from_mach($shift_time);
				 $machine_names=get_machine_name($machine_no);
				 $operatorss=get_operator_id($operator_name);
				  
				
		?>
    <tr>  
    <td width="107" height="29" align="left" class="text style11">&nbsp;<?php echo date("d-m-Y",strtotime($ink_date)); ?></td>
  
    <!--<td width="98" align="left" class="text"   ><?php  echo $type; ?>&nbsp;&nbsp;</td>-->
       
    <!-- <td width="82" align="left" class="text"  ><?php  echo $operatorss; ?>&nbsp;&nbsp;</td>-->

    <td width="81" align="left" class="text" ><?php  echo $prod_size; ?>&nbsp;&nbsp;</td>
    <?php
       foreach ($machine_numbers as $index => $machine_no) {
        ?>
    <td width="87" align="left" class="text"  >
    <?php   if ($machine_no == $machine_names) {
                echo number_format($total_qty, 2); 
                $machine_totals[$index] += $total_qty;
            } else {
                echo ""; 
            }
            ?>
            &nbsp;&nbsp;</td>
      <?php } ?>
    <td width="47" align="right" class="text style12" ><?php  echo number_format($total_qty,2); ?>&nbsp;&nbsp;</td>

    </tr>
	<?php $sum_tot2+=$total_qty;}
	} else { ?>
        <tr>  
    <td width="107" height="29" align="left" class="text"></td>
  
    <td width="98" align="left" class="text"   ></td>
        <td width="82" align="left" class="text"  >No Usages</td>

    <td width="87" align="left" class="text"  ></td>

    <td width="81" align="left" class="text" ></td>

    <td width="47" align="right" class="text"  ></td>

     </tr>
<?php } ?>

<tr>
        <th height="28" colspan="2" align="right" style="border:1px solid #ddd"><strong>Total&nbsp;&nbsp;</strong></th>
        <?php
        foreach ($machine_totals as $machine_total) {
        echo "<th align='left' style='border:1px solid #ddd'>" . number_format($machine_total, 2) . "&nbsp;&nbsp;</th>";
        }
        ?>
        <th width="55" align="right" style="border:1px solid #ddd"><strong><?php echo number_format($sum_tot2, 2); ?>&nbsp;&nbsp;</strong></th>
</tr>
        </table>
        </div>
        </div>
        </div>
        </div>
        </div>