<link rel="stylesheet" href="css/font.css" type="text/css" />
<script>
function jobcard_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");
$show = 10;
$num_links = 9;
$from = $_GET['from'];
if (empty($from))
	 {
		$from = "0";
	 } 
else 
	{
	    $html_query = $html_query. "&from=$from";
	}
	
function get_operator_type($operator_type)
{
$sql_query11="select * from operator_creation where operator_name='$operator_type'";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $id=$rsdata11->id;
 } 
return $id;
}

$operator_typess=get_operator_type($_GET['operator_type']);
$operator_type=$_GET['operator_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($operator_type!=""){ $operator_types = "operator_name='$operator_typess'";}else{$operator_types="";}
{
$all_value101 = $from_date1."@".$to_date1."@".$operator_types;
}
$all_array101 = explode('@',$all_value101);
foreach($all_array101 as $value101)
{ 
if($value101!='')
{
$get_query106 .= $value101." AND ";
}
}	  
if($from_date!='')
{
$sql="select production_time as production_time1,shift_time as shift_time1,machine_no as machine_no1,operator_name as operator_name1,prod_qty as prod_qty1,job_card_no  as job_card_no1,prod_size as prod_size1 from  fusing_production_sublist where $get_query106 pr_id!=''  and deliv_status!='1'";
}
else
{ 
$sql="select production_time as production_time1,shift_time as shift_time1,machine_no as machine_no1,operator_name as operator_name1,prod_qty as prod_qty1,job_card_no  as job_card_no1,prod_size as prod_size1 from  fusing_production_sublist where  pr_id!=''  and deliv_status!='1'";
}
$html_query = "main_fram.php?file=operator_wise_fusing";
$result=mysql_query($sql);
$num_results=mysql_num_rows($result);
if ($num_results == 0) 
{
 $confirmation = "No Records!";
} 
elseif ($num_results == 1) 
{
$confirmation = "Found 1 Record.";
} 
else 
{
$confirmation = "Found $num_results Records.";
} 
$operator_type=$_GET['operator_type'];
$from_date=$_GET['from_date'];
$to_date=$_GET['to_date'];
?>
<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:jobcard_report_print('report/wages_report/wages_wise_print.php?from_date=<?php echo $_GET['from_date'];?>&to_date=<?php echo $_GET['to_date'];?>&operator_type=<?php echo $_GET['operator_type'];?>&operator_id=<?php echo $operator_typess;?>');" 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="97%"  align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ddd" >
<thead>
<tr>
    <th  height="23"  align="center" style="border:1px solid #ddd" >S.No</th>
    <th  align="left" style="border:1px solid #ddd" >Date</th>
    <th  align="left" style="border:1px solid #ddd" >Shift</th>
    <th  align="left" style="border:1px solid #ddd" >Jobcard No</th>
    <th  align="left" style="border:1px solid #ddd" >Machine No</th>
    <th  align="left" style="border:1px solid #ddd" >Operator Type</th>
    <th  align="left" style="border:1px solid #ddd" >Fabric Type</th>
    <th  align="left" style="border:1px solid #ddd" >Particulars</th>
    <th  align="right" style="border:1px solid #ddd" >Qty</th>
    <th  align="right" style="border:1px solid #ddd" >Con Rate</th>
    <th  align="right" style="border:1px solid #ddd" >Amount</th>
    </tr>
  <?php
include("../../include/db.php"); 

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


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_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_shift_name($shift_time)
{
$sql_query11="select * from shift_creation where id='$shift_time' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $shift_name=$rsdata11->shift_name;
 } 
return $shift_name;
}

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


function get_fabric_type($job_card_no)
{
$sql_query11="select fabric_type as fabric_type from fusing_production_main where job_card_no='$job_card_no' union  select fabric_type as fabric_type from printer_production_main where job_card_no='$job_card_no'";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $fabric_type=$rsdata11->fabric_type;
 } 
return $fabric_type;
}


function get_contract_rate($fabric_type)
{
$sql_query11="select * from fabric_type_creation where fabric_type='$fabric_type' ";
$rs11=mysql_query($sql_query11);
 while($rsdata11=mysql_fetch_object($rs11))
 {
 $contract_rate=$rsdata11->contract_rate;
 } 
return $contract_rate;
}


$operator_typess=get_operator_type11($_GET['operator_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($operator_type!=""){ $operator_types = "operator_name='$operator_typess'";}else{$operator_types="";}
{
$all_value102 = $from_date1."@".$to_date1."@".$operator_types;
}
$all_array102 = explode('@',$all_value102);
foreach($all_array102 as $value102)
{ 
if($value102!='')
{
  $get_query103 .= $value102." AND ";
}
}	  
if($from_date!='')
{
$sql="select production_time as production_time1,shift_time as shift_time1,machine_no as machine_no1,operator_name as operator_name1,prod_qty as prod_qty1,job_card_no  as job_card_no1,prod_size as prod_size1 from  fusing_production_sublist where $get_query103 pr_id!=''  and deliv_status!='1' ";
}
else
{ 
$sql="select production_time as production_time1,shift_time as shift_time1,machine_no as machine_no1,operator_name as operator_name1,prod_qty as prod_qty1,job_card_no  as job_card_no1,prod_size as prod_size1 from  fusing_production_sublist where  pr_id!=''  and deliv_status!='1' ";
}
    $rs=mysql_query($sql);
   		while($rsdata=mysql_fetch_array($rs))
  			{
				 $from=$from+1;
                 $production_time=$rsdata['production_time1'];
				 $shift_time=$rsdata['shift_time1'];
				 $shift_name_from=get_shift_name_from($shift_time);
				 $shift_name_to=get_shift_name_to($shift_time);
				 $machine_no=$rsdata['machine_no1'];
				 $machine_name=get_machine_name($machine_no);
				 $operator_id=$rsdata['operator_name1'];
				 $operator_name=get_operator_id($operator_id);
				 $prod_qty=$rsdata['prod_qty1'];
				 $prod_qty=$rsdata['prod_qty1'];
				 $prod_size=$rsdata['prod_size1'];
				 $job_card_no=$rsdata['job_card_no1'];
				 $fabric_type=get_fabric_type($job_card_no);
				 $contract_rate=get_contract_rate($fabric_type);
				 $shift_names=get_shift_name($shift_time);

 ?>
    <tr>
    <td width="45"  align="center" style="border:1px solid #ddd">&nbsp;<?php echo $from; ?></td>
    <td width="100" align="left" style="border:1px solid #ddd" >&nbsp;<?php echo date("d-m-Y",strtotime($production_time));?></td>
    <td width="97" align="left" style="border:1px solid #ddd" >&nbsp;<?php echo $shift_names; ?></td>
    <td width="127" align="left" style="border:1px solid #ddd" >&nbsp;<?php echo $job_card_no; ?></td>
    <td width="109" align="left" style="border:1px solid #ddd" >&nbsp;<?php  echo $machine_name;?></td>
    <td width="114" align="left" style="border:1px solid #ddd" >&nbsp;
      <?php  echo $operator_name; ?></td>
    <td width="108" align="left" style="border:1px solid #ddd" >&nbsp;
      <?php  echo $fabric_type; ?></td>
    <td width="150" align="left" style="border:1px solid #ddd" >&nbsp;<?php  echo $prod_size; ?></td>
    <td width="68" align="right" style="border:1px solid #ddd" ><?php  echo $prod_qty; ?>
      &nbsp;</td>
    <td width="88" align="right" style="border:1px solid #ddd" ><?php  echo number_format($contract_rate,2); ?>
      &nbsp;</td>
    <td width="77" align="right" style="border:1px solid #ddd" ><?php  echo number_format($prod_qty*$contract_rate,2); ?>&nbsp;</td>
    </tr>
  <?php } ?>
  </thead>
</table>
</div>
</div>
</div>
</div>

