<link rel="stylesheet" href="css/jquery-ui.css" />
<link rel="stylesheet" href="css/jquery.autocomplete.css" type="text/css" />
<link rel="stylesheet" href="css/font.css" type="text/css" />
<style>
.txt {
	font-family: Verdana, sans-serif;
	font-size: 13px;
}
.border { border:1px solid #ddd }
</style>
<?php error_reporting(0);
include("../../include/db.php");
$date=date("Y");
$st_date=substr($date,2);
$month=date("m");	   
$datee=$st_date.$month;

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');

    $sql="select * from pay_slip_entry where pay_slip_no='$_GET[pay_slip_no]' order by pay_slip_no DESC";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				$sno=$sno+1;
				$from=$from+1;
   				$pay_slip_no=$rsdata['pay_slip_no'];
   				$from_date11=$rsdata['from_date'];
				$to_date11=$rsdata['to_date'];
				$invoice_no=$rsdata['invoice_no'];
	   			$operator_type=$rsdata['operator_type'];
				$entry_time=$rsdata['entry_time'];
            }

?>
<table border="0" width="850px"  align="center" cellpadding="0" cellspacing="0" >
<thead> 
  <tr>
    <td height="21" colspan="9" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; font-size: 16px; text-align: center; font-weight: bold;">Pay Slip </td>
  </tr>
  <tr>
             <td height="38" colspan="9"><table width="850px" border="0" align="center" cellpadding="0" cellspacing="0">
               <tr>
                   <td align="left" class="txt " >&nbsp;</td>
                   <td align="left" class="txt " style="font-weight: bold" ><span style="color: #F00;font-family:Verdana, sans-serif; font-size:14px; font-weight:bold; ">Pay Slip No </span></td>
                   <td align="left" class="txt " ><span style="color: #F00;font-family:Verdana, sans-serif; font-size:14px; font-weight:bold; ">
                     <?php  echo $_GET['pay_slip_no'];  ?>
                   </span></td>
                   <td height="24" align="left" class="txt " ><strong>Operator Name</strong></td>
                   <td align="left" class="txt " ><?php  echo $_GET['operator_type'];  ?>&nbsp;</td>
                 </tr>
                 <tr>
                   <td align="left" class="txt " >&nbsp;</td>
                   <td align="left" class="txt " style="font-weight: bold" >From Date </td>
                   <td align="left" class="txt " ><?php  echo date('d-m-Y',strtotime($from_date11));  ?></td>
                   <td height="27" align="left" class="txt " ><strong>To Date</strong></td>
                   <td align="left" class="txt " >&nbsp;<?php echo date('d-m-Y',strtotime($to_date11));  ?></td>
                 </tr>
                 <tr>
                   <td width="75" align="left" class="txt " >&nbsp;</td>
                   <td width="161" align="left" class="txt " style="font-weight: bold" >Date</td>
                   <td width="340" align="left" class="txt " ><?php  echo  date('d-m-Y h:m a',strtotime($entry_time)); ?></td>
                   <td width="144" height="27" align="left" class="txt " >&nbsp;</td>
                   <td width="130" align="left" class="txt " >&nbsp;</td>
                 </tr>
                 <tr>
                   <td align="left" class="txt " ></td>
                   <td align="left" class="txt " style="font-weight: bold" >Voucher No</td>
                   <td align="left" class="txt " ><span class="txt"><?php echo $invoice_no;?></span></td>
                   <td height="27" align="left" class="txt">&nbsp;</td>
                   <td width="130" align="left" class="txt " >&nbsp;</td>
                 </tr>
             </table></td>
</tr>
<tr>
    <th width="88"  height="24"  align="center" class="txt" style="border-bottom:1px dashed; border-top:1px dashed;" >Date</th>
    <th  align="left" class="txt" style="border-bottom:1px dashed; border-top:1px dashed;">Jobcard No</th>
    <th width="121"  align="left" class="txt" style="border-bottom:1px dashed; border-top:1px dashed;">Machine No</th>
    <th  align="left" class="txt" style="border-bottom:1px dashed; border-top:1px dashed;">Fabric </th>
    <th  align="left"   class="txt" style="border-bottom:1px dashed; border-top:1px dashed;">&nbsp;Particulars</th>
    <th  align="right"  class="txt" style="border-bottom:1px dashed; border-top:1px dashed;">Qty&nbsp;</th>
    <th  align="right"  class="txt" style="border-bottom:1px dashed; border-top:1px dashed;"> Rate&nbsp;</th>
    <th  align="right"  class="txt" style="border-bottom:1px dashed; border-top:1px dashed;">Amount&nbsp;</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'";
$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= "from_date>='$from_date'"; }else{$from_date1="from_date='$current_date'"; }
if($to_date!=""){ $to_date1 = "to_date<='$to_date'";}else{$to_date1="to_date='$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 ";
}
}	  

$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 DATE_FORMAT(production_time,'%Y-%m-%d')>='$from_date11' and DATE_FORMAT(production_time,'%Y-%m-%d')<='$to_date11' and  pay_slip_no='$_GET[pay_slip_no]' ";

        $rs=mysql_query($sql);
		 $count=mysql_num_rows($rs);
   		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 height="25"  align="center" class="txt ">&nbsp;<?php echo date("d-m-Y",strtotime($production_time));?></td>
    <td width="102" align="left" class="txt " >&nbsp;<?php echo $job_card_no; ?></td>
    <td align="left" class="txt ">&nbsp;<?php echo $machine_name;?></td>
    <td width="152" align="left" class="txt " >&nbsp;<?php echo $fabric_type; ?></td>
    <td width="143" align="left" class="txt ">&nbsp;<?php  echo $prod_size; ?></td>
    <td width="71" align="right"class="txt "><?php  echo $prod_qty; ?>&nbsp;</td>
    <td width="84" align="right" class="txt " ><?php  echo number_format($contract_rate,2); ?>&nbsp;</td>
    <td width="89" align="right" class="txt "><?php 
	 $total_amts=$prod_qty*$contract_rate;
	echo number_format($total_amts,2); ?>&nbsp;</td>
    </tr>
  <?php 
   $overall_amount+=$total_amts;
  $overall_quantity+=$prod_qty;} ?>
  <tr>
    <td  align="center" class="txt ">&nbsp;</td>
    <td width="102" align="left" class="txt " >&nbsp;</td>
    <td align="left" class="txt ">&nbsp;</td>
    <td width="152" align="left" class="txt " >&nbsp;</td>
    <td width="143" align="right" class="txt" style="border-bottom:1px dashed; border-top:1px dashed; font-weight:bold;">Total</td>
    <td width="71" align="right"class="txt" style="border-bottom:1px dashed; border-top:1px dashed; font-weight:bold;"><?php  echo $overall_quantity; ?>&nbsp;</td>
    <td width="84" align="right" class="txt " style="border-bottom:1px dashed; border-top:1px dashed; font-weight:bold;">&nbsp;</td>
    <td width="89" align="right" class="txt " style="border-bottom:1px dashed; border-top:1px dashed; font-weight:bold;"><?php echo number_format($overall_amount,2); ?>&nbsp;</td>
    </tr>
  </thead>
</table>