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

.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-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 dashed #000000;

	
	border-bottom:1px dashed #000000;
}	
</style>

<?php 
  include ("../../include/db.php");
  date_default_timezone_set('Asia/Kolkata');
error_reporting(0);
	 ?>
<table width="1000px" height="30" border="0" align="center"  cellpadding="0" cellspacing="0">
<tr style="height:60" >
<td width="127" height="106" align="right" style="font-size:12px; "><img src="../../img/logo_image.png" width="110" height="113"/></td>
<td colspan="10" align="center" valign="top"><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="title1" style="font-size:14px;font-family:Verdana, sans-serif; font-weight:bold"><b></b>SELLANDIAMMAN THURAI ROAD,</span><br />
       <span width="80%" class="title1" 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="title1" 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>Operator Wise Fusing Report</span></p></td>
</tr>
  
<tr>
<td  class="style4" colspan="2"><strong>From Date :</strong></td>
<td  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 class="style4" align="center"><strong>To Date :</strong> </td>
<td  align="left" scope="col" class="style4"> <?php if($_GET['to_date']==''){ echo $curdate=date('d-m-Y');} else { echo date("d-m-Y",strtotime($_GET['to_date'])); }?></td>
<td height="28"  colspan="5"  class="style4"><strong>Operator Name :</strong> 
  <?php  if($_GET['operator_name']==''){ echo 'All';} else {echo $_GET['operator_name'];}?>&nbsp;&nbsp;</td>
</tr>
      <tr>
      <th  height="23"  align="center" class="stylebottom style20"  >S.No</th>
      <th  align="left"  class="stylebottom style20">Date</th>
      <th width="112"  align="left"  class="stylebottom style20">Jobcard No</th>

	  <th width="118"  align="left" class="stylebottom style20" >Operator Name</th>
      <th width="104"  align="left"  class="stylebottom style20">Shift </th>
      <th  align="left"  class="stylebottom style20">Machine No</th>
      <th width="72"  align="left"  class="stylebottom style20">Particulars</th>
              <th width="94"  align="right" class="stylebottom style20" >Order Qty&nbsp;</th>

            <th width="95"  align="right" class="stylebottom style20" >Product Qty</th>

      <th width="101"  align="right" class="stylebottom style20" >Balance Qty&nbsp;</th>
  </tr>
  <?php
include("../../include/db.php"); 
function get_operator_id($ope_name)
{
$sql="select * from operator_creation where operator_name='$ope_name'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$operator_id=$rsdata['id'];
}
return $operator_id;
}

function get_operator_name2($ope_name)
{
$sql="select * from operator_creation where id='$ope_name'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$operator_namess=$rsdata['operator_name'];
}
return $operator_namess;
}

function get_total_quants1($job_card_no)
{
 $sql="select sum(qty) as qty from jobcard_sublist where jobcard_no='$job_card_no'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$qty1=$rsdata['qty'];
}
return $qty1;
}

function get_shift_time2($shift_id)
{
$sql="select * from shift_creation where id='$shift_id'";
$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_machine_no2($machine_no)
{
$sql="select * from machine_creation where id='$machine_no'";
$rs11=mysql_query($sql);
 while($rsdata=mysql_fetch_array($rs11))
 {
$machine_no=$rsdata['machine_no'];
}
return $machine_no;
}

$from_date=$_GET['from_date']; 
  $to_date=$_GET['to_date']; 
  $operator_names=$_GET['operator_name'];
  $operator_id=get_operator_id($operator_names); 
$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($operator_id!=""){ $operator_id1 = "operator_name='$operator_id'";}else{$operator_id1="";}
{
$all_value102 = $from_date1."/".$to_date1."/".$operator_id1;
}
$all_array102 = explode('/',$all_value102);
foreach($all_array102 as $value102)
{ 
if($value102!='')
{
  $get_query104 .= $value102." AND ";
}
}	

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;
}

 $sql="select * from  fusing_production_sublist where $get_query104 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_id=$rsdata['shift_time'];
				 $shift_time=get_shift_time2($shift_id);
				 $machine_id=$rsdata['machine_no'];
				 $machine_no=get_machine_no2($machine_id);
				 $operator_id=$rsdata['operator_name'];
				 $operator_name=get_operator_name2($operator_id);
				 $prod_size=$rsdata['prod_size'];
				 $prod_qty=$rsdata['prod_qty'];
				 $job_card_no=$rsdata['job_card_no'];
				 $total_qty=$rsdata['total_qty'];
				 $balance_qty=$rsdata['balance_qty'];
				 $total_quant=get_total_quants1($job_card_no);
				 
				 $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="126" height="26" class="style20"    align="center" ><?php echo $from; ?></td>
    <td width="42" class="style20"   align="left" >&nbsp;<?php echo date("d-m-Y",strtotime($production_time));;?></td>
    <td align="left" class="style20"   >&nbsp;<?php echo $job_card_no;?></td>

    <td align="left" class="style20"   >&nbsp;<?php echo $operator_name; ?></td>
    <td align="left"  class="style20" >&nbsp;<?php  echo $shift_time[2];?></td>
    <td width="136" class="style20"   align="left" >&nbsp;<?php echo $machine_no;?></td>
   <td align="left"  class="style20"  >&nbsp;<?php  echo $prod_size;?></td>
               <td align="right"  class="style20"  ><?php  echo $qty;?>&nbsp;</td>

                <td align="right"  class="style20"  ><?php  echo number_format($prod_qty,2);?>&nbsp;</td>

        <td align="right"  class="style20"  ><?php  echo $balance_qty;?>&nbsp;</td>
   </tr>
  <?php 
  
  $net_tot+=$net_total;
   $total1+=$qty; 
	$total2+=$prod_qty; 
	$total3+=$balance_qty;
  } ?> <tr>
   <td colspan="7" 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; 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;</td>
</table>
</td>