<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-bottom:dashed 1px; border-bottom-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-right:1px solid #999;

	
	border-bottom:1px solid #999;
}	
</style>
<table width="850" 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>Fusing Machine Wise Report</span></p></td>
  </tr>

<tr>
<td align="center" colspan="2" style="font-family:Verdana, sans-serif; font-size:16px; font-family:Verdana, sans-serif; "><table width="101%" height="26" border="0"  cellpadding="0" cellspacing="0">
    <tr>
      <td width="37%" height="26"  align="left" class="style4"><strong>From Date </strong><?php if($_GET['from_date']==''){ echo $curdate=date('d-m-Y');} else { echo date("d-m-Y",strtotime($_GET['from_date']));}?></td>
      <td colspan="2" align="left" scope="col" class="style4"><strong>To Date  </strong><?php if($_GET['to_date']==''){ echo $curdate=date('d-m-Y');} else { echo date("d-m-Y",strtotime($_GET['to_date'])); }?></td>
      <td width="40%" colspan="2" align="right" class="style4" scope="col"><strong>Machine Type </strong>
        <?php if($_GET['machine_type']!=''){  echo $_GET['machine_type'];} ?></td>
    </tr>
  </table></td>
</tr>
<tr>
  <td align="center" colspan="2" style="font-family:Verdana, sans-serif; font-size:16px; font-family:Verdana, sans-serif; "><table  width="100%"  cellpadding="0" cellspacing="0" style="border-top:dashed 1px" >
    <tr>
    <td width="44" height="26" align="center"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;"><strong>S.No</strong></td>
    <td width="127" align="left"  style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" scope="col"><strong>&nbsp;&nbsp;Date</strong><strong>&nbsp;</strong></td>
    <td width="172" align="left"  style="border-bottom: dashed 1px; font-family: Verdana, sans-serif; font-size: 12px; font-weight: bold;" scope="col">Jobcard No</td>
    <td width="136" align="left"  style="border-bottom: dashed 1px; font-family: Verdana, sans-serif; font-size: 12px; font-weight: bold;" scope="col"><strong>&nbsp;&nbsp;Shift	</strong></td>
    <td width="161" scope="col" align="left" style="border-bottom:dashed 1px; font-family:Verdana, sans-serif; font-size:12px;" ><strong>Machine No</strong></td>
    <td width="107"  align="left" style="border-bottom: dashed 1px; font-family: Verdana, sans-serif; font-size: 12px; font-weight: bold;" scope="col" >Operator Type</td>
    <td width="101" align="right" style="border-bottom: dashed 1px; font-family: Verdana, sans-serif; font-size: 12px; font-weight: bold;"    scope="col"><strong>Order Qty</strong></td>
        <td width="101" align="right" style="border-bottom: dashed 1px; font-family: Verdana, sans-serif; font-size: 12px; font-weight: bold;"    scope="col"><strong>Product Qty</strong><strong></strong></td>

    <td width="101" align="right" style="border-bottom: dashed 1px; font-family: Verdana, sans-serif; font-size: 12px; font-weight: bold;"    scope="col"><strong>Balance Qty</strong></td>
    </tr>
    <?php
include("../../include/db.php"); 
date_default_timezone_set('Asia/Kolkata');
function get_shift_name_from($shift_time)
{
$sql_query11="select * from shift_creation where id='$shift_time' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $from_time=$rsdata11->from_time;
 } 
return $from_time;
}
function get_order_qty($job_card_no,$prod_size)
{
	$sql_query="select * from fusing_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' ";
    $rs=mysql_query($sql_query);
    $rscount=mysql_num_rows($rs);
	return $rscount;
 }
 
 
 function get_max_order_qty($job_card_no,$prod_size)
{
$sql_query="select max(total_qty) as total_qty from fusing_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' ";
    $rs11=mysql_query($sql_query);
 while($rsdata=mysql_fetch_array($rs11))
 {
$total_qty=$rsdata['total_qty'];
}
return $total_qty;
}

 function get_order_qty1($job_card_no,$prod_size,$pr_id)
{
 $sql_query="select total_qty from fusing_production_sublist where job_card_no='$job_card_no' and prod_size='$prod_size' and pr_id='$pr_id'  ";
    $rs11=mysql_query($sql_query);
 while($rsdata=mysql_fetch_array($rs11))
 {
$total_qty=$rsdata['total_qty'];
}
return $total_qty;
}

function get_shift_time3($shift_time)
{
$sql="select * from shift_creation where id='$shift_time'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
{
$from_time[0]=$rsdata['from_time'];
$from_time[1]=$rsdata['to_time'];
$from_time[2]=$rsdata['shift_name'];
}
return $from_time;
}

function get_shift_name_to($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;
 } 
return $to_time;
}

function get_machine_name($machine_no)
{
 $sql_query11="select * from machine_creation where id='$machine_no' and  mach_type='Fusing'";
$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' and operator_type='fusing_operator' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $operator_name=$rsdata11->operator_name;
 } 
return $operator_name;
}


$machine_id=$_GET['machine_id'];
$machine_type=$_GET['machine_type'];
if(($_GET['from_date']!='')&&($_GET['to_date']!=''))
{
 $from_date=date('Y-m-d',strtotime($_GET['from_date']));
 $to_date=date('Y-m-d',strtotime($_GET['to_date']));
}
$current_date=date('Y-m-d');
if($from_date!=""){ $from_date1= "DATE_FORMAT(production_time,'%Y-%m-%d')>='$from_date'"; }else{$from_date1="DATE_FORMAT(production_time,'%Y-%m-%d')='$current_date'"; }
if($to_date!=""){ $to_date1 = "DATE_FORMAT(production_time,'%Y-%m-%d')<='$to_date'";}else{$to_date1="DATE_FORMAT(production_time,'%Y-%m-%d')='$current_date'";}
if($machine_type!=""){ $machine_types = "machine_no='$machine_id'";}else{$machine_types="";}
{
$all_value101 = $from_date1."/".$to_date1."/".$machine_types;
}
$all_array101 = explode('/',$all_value101);
foreach($all_array101 as $value102)
{ 
if($value102!='')
{
$get_query103 .= $value102." AND ";
}
}	  
 $sql="select * from  fusing_production_sublist where $get_query103 pr_id!=''   order by job_card_no,operator_name,prod_size ASC";
    $rs=mysql_query($sql);
   		while($rsdata=mysql_fetch_array($rs))
  			{
				 $from=$from+1;
				  $pr_id=$rsdata['pr_id'];
                 $production_time=$rsdata['production_time'];
				 $shift_time=$rsdata['shift_time'];
				 	$shift_time=get_shift_time3($shift_time);
				 $shift_name_from=get_shift_name_from($shift_time);
				 $shift_name_to=get_shift_name_to($shift_time);
				 $machine_no=$rsdata['machine_no'];
				 $machine_name=get_machine_name($machine_no);
				 $operator_id=$rsdata['operator_name'];
				 $operator_name=get_operator_id($operator_id);
				 $prod_qty=$rsdata['prod_qty'];
				 $job_card_no=$rsdata['job_card_no'];
				 $prod_size=$rsdata['prod_size'];
				   $total_qty=$rsdata['total_qty'];
				 $balance_qty=$rsdata['balance_qty'];
				 $count_order_qty = get_order_qty($job_card_no,$prod_size); 
	 $max_order_qty = get_max_order_qty($job_card_no,$prod_size);
	 $qty=  get_order_qty1($job_card_no,$prod_size,$pr_id);
	if($max_order_qty==$qty)
	{
		$qty=$max_order_qty;
	}
	else
	{
				$qty='';

		}
 ?>
    <tr>
      <td width="44" height="26" style=" font-family:Verdana, sans-serif; font-size:12px;"   align="center" ><?php echo $from; ?></td>
      �
      <td width="127"  align="left" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo date("d-m-Y",strtotime($production_time));?></td>
      <td width="172"  align="left" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $job_card_no;?></td>
      <td  align="left" style=" font-family:Verdana, sans-serif; font-size:12px;" >&nbsp;<?php echo $shift_time[2];?></td>
      <td width="161" style=" font-family:Verdana, sans-serif; font-size:12px;"  align="left" ><?php echo $machine_name;?>&nbsp;</td>
      <td align="left" style=" font-family:Verdana, sans-serif; font-size:12px;"><?php echo $prod_size;?>&nbsp;</td>
      <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;"><?php  echo $qty; ?>&nbsp;</td>
            <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;"><?php echo $prod_qty;?>&nbsp;</td>

      <td align="right" style=" font-family:Verdana, sans-serif; font-size:12px;"><?php  echo $balance_qty; ?>&nbsp;</td>
      </tr>
    <?php 
  $net_tot+=$net_total;
  $total1+=$qty; 
	$total2+=$prod_qty; 
	$total3+=$balance_qty;
  } ?>
  <tr>
   <td colspan="6" align="right" class="style20" style="border-top:dashed 1px"><strong>Total</strong></td>
   <td align="right" class="style20" style="border-top:dashed 1px"><strong><?php echo number_format($total1,2); ?></strong></td>
      <td align="right" class="style20" style="border-top:dashed 1px"><strong><?php echo number_format($total2,2); ?></strong></td>

   <td align="right" class="style20" style="border-top:dashed 1px"><strong><?php echo number_format($total1-$total2,2); ?></strong></td>

    </tr>
  <td height="30" colspan="17"align="right" style="font-family: Verdana, sans-serif; font-size: 12px; font-weight: bold; border-top:dashed 1px;"><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   : <?php echo $ip_address = $_SERVER['REMOTE_ADDR'];?>&nbsp;
    </p></td>
  </table></td>
</tr>
</table>
