<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" />
<script type="text/javascript" src="js/fusing_production_ajax.js"></script>
<script src="js/jquery/jquery.js" type="text/javascript"></script>
<script src="js/jquery/jquery-1.8.2.js"></script>
<script src="js/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery/autocomplete_jquery_plugin.js"></script>
<script src="js/shortcut.js"  type="text/javascript"></script>
<script type="text/javascript" src="js/enter_event_ajax.js"></script><script>
function payslip_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');
}



function payslip_validation()
{
    var tot_amount = document.getElementById("tot_amount").value;
	if(tot_amount=='')
	{
		document.getElementById("tot_amount_validation_div").innerHTML="* This field is Required.";
		document.getElementById("tot_amount").focus();
		return false;
	}
	var invoice_no = document.getElementById("invoice_no").value;
	if(invoice_no=='')
	{
		document.getElementById("invoice_no_validation_div").innerHTML="* This field is Required.";
		document.getElementById("invoice_no").focus();
		return false;
	}
}

function payslip_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("tot_amount_validation_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("invoice_no_validation_div").innerHTML="";
	}
}


function pay_slip_entry_add(from_date,to_date,operator_type,pay_slip_no,entry_time,tot_amount,invoice_no,action)
{
	if((pay_slip_no!='')&&(tot_amount!='')&&(invoice_no!=''))
	{
		jQuery.ajax({
		type: "POST",
		url: "pay_slip_entry_db.php",
		data: "from_date="+from_date+"&to_date="+to_date+"&operator_type="+operator_type+"&pay_slip_no="+pay_slip_no+"&entry_time="+entry_time+"&tot_amount="+tot_amount+"&invoice_no="+invoice_no+"&action="+action,
		success: function(msg){jQuery("#pay_slip_entry_list_div").html(msg);
		alert("PaySlip Billed Successfully");
        window.close();
        window.opener.location.reload(true);
 }
		});
	}
	else
	{
		payslip_validation();
	}
}
</script>
<style>
.txt { font-family:Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif; font-size:13px }
.border { border:1px solid #ddd }
</style>
<?php error_reporting(0);
include("../../include/db.php");

$create_date=date('Y-m-d');
$explodes=explode("-",$create_date);
$year1=$explodes[0];
$year2=$explodes[1];
$year=$year1."-".$year2;

if(($year=='2014-04')||($year=='2014-05')||($year=='2014-06')||($year=='2014-07')||($year=='2014-08')||($year=='2014-09')||($year=='2014-10')||($year=='2014-11')||($year=='2014-12')||($year=='2015-01')||($year=='2015-02')||($year=='2015-03'))
{
$acc_year='2015';
}

if(($year=='2015-04')||($year=='2015-05')||($year=='2015-06')||($year=='2015-07')||($year=='2015-08')||($year=='2015-09')||($year=='2015-10')||($year=='2015-11')||($year=='2015-12')||($year=='2016-01')||($year=='2016-02')||($year=='2016-03'))
{
$acc_year='2016';
}

if(($year=='2016-04')||($year=='2016-05')||($year=='2016-06')||($year=='2016-07')||($year=='2016-08')||($year=='2016-09')||($year=='2016-10')||($year=='2016-11')||($year=='2016-12')||($year=='2017-01')||($year=='2017-02')||($year=='2017-03'))
{
$acc_year='2017';
}

if(($year=='2017-04')||($year=='2017-05')||($year=='2017-06')||($year=='2017-07')||($year=='2017-08')||($year=='2017-09')||($year=='2017-10')||($year=='2017-11')||($year=='2017-12')||($year=='2018-01')||($year=='2018-02')||($year=='2018-03'))
{
$acc_year='2018';
}


if(($year=='2018-04')||($year=='2018-05')||($year=='2018-06')||($year=='2018-07')||($year=='2018-08')||($year=='2018-09')||($year=='2018-10')||($year=='2018-11')||($year=='2018-12')||($year=='2019-01')||($year=='2019-02')||($year=='2019-03'))
{
$acc_year='2019';
}



if(($year=='2019-04')||($year=='2019-05')||($year=='2019-06')||($year=='2019-07')||($year=='2019-08')||($year=='2019-09')||($year=='2019-10')||($year=='2019-11')||($year=='2019-12')||($year=='2020-01')||($year=='2020-02')||($year=='2020-03'))
{
$acc_year='2020';
}



if(($year=='2020-04')||($year=='2020-05')||($year=='2020-06')||($year=='2020-07')||($year=='2020-08')||($year=='2020-09')||($year=='2020-10')||($year=='2020-11')||($year=='2020-12')||($year=='2021-01')||($year=='2021-02')||($year=='2021-03'))
{
$acc_year='2021';
}



if(($year=='2021-04')||($year=='2021-05')||($year=='2021-06')||($year=='2021-07')||($year=='2021-08')||($year=='2021-09')||($year=='2021-10')||($year=='2021-11')||($year=='2021-12')||($year=='2022-01')||($year=='2022-02')||($year=='2022-03'))
{
$acc_year='2022';
}

if(($year=='2022-04')||($year=='2022-05')||($year=='2022-06')||($year=='2022-07')||($year=='2022-08')||($year=='2022-09')||($year=='2022-10')||($year=='2022-11')||($year=='2022-12')||($year=='2023-01')||($year=='2023-02')||($year=='2023-03'))
{
$acc_year='2023';
}

if(($year=='2023-04')||($year=='2023-05')||($year=='2023-06')||($year=='2023-07')||($year=='2023-08')||($year=='2023-09')||($year=='2023-10')||($year=='2023-11')||($year=='2023-12')||($year=='2024-01')||($year=='2024-02')||($year=='2024-03'))
{
$acc_year='2024';
}

if(($year=='2024-04')||($year=='2024-05')||($year=='2024-06')||($year=='2024-07')||($year=='2024-08')||($year=='2024-09')||($year=='2024-10')||($year=='2024-11')||($year=='2024-12')||($year=='2025-01')||($year=='2025-02')||($year=='2025-03'))
{
$acc_year='2025';
}

$date=date("Y");
$st_date=substr($date,2);
$month=date("m");	   
$datee=$st_date.$month;

if(!isset($_GET['pay_slip_no']))
{
	$rs1=mysql_query("select pay_slip_no from  pay_slip_entry where acc_year='$acc_year' order by id desc");
	if($res1=mysql_fetch_assoc($rs1))
	{
		$pur_array=explode('-',$res1['pay_slip_no']);
	
	    $year1=$pur_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$jobcard_no=$pur_array[2];
	}
	if($jobcard_no=='')
		$jobcard_number='PS-'.$datee.'-0001';
	else
	{
		$jobcard_no+=1;
		$jobcard_number='PS-'.$datee.'-'.str_pad($jobcard_no, 4, '0', STR_PAD_LEFT);
	}
}
	
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');
?>
<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" >
<thead> <tr>
             <td height="38">&nbsp;</td>
             <td colspan="5" align="center" class="text" style="font-size:14px; color:#080;"><span class="text" style="font-size:14px; color:#080;">&nbsp;<strong><span style="color: #F00;font-family:Verdana, sans-serif; ">Pay Slip No</span></strong>&nbsp;&nbsp;&nbsp;
                 <input type="hidden" readonly name="pay_slip_no" id="pay_slip_no" class="text_box" style="font-size:12px" value="<?php if($edit_id!='') { echo $jobcard_no; } else{ echo $jobcard_number;  } ?>">
                 <input type="hidden" name="edit_id" id="edit_id" value="<?php  echo $edit_id; ?>">
                 <strong> <span style="color:#B30000;font-family:Verdana, sans-serif;">
                 <?php if($edit_id!='') { echo $jobcard_no; } else{ echo $jobcard_number; } ?>
              </span> </strong></span></td>
             </tr>

<tr>
    <th  height="23"  align="center" class="txt border" >S.No</th>
    <th  align="center" class="txt border" >Date</th>
    <th  align="center" class="txt border" >Shift</th>
    <th  align="center" class="txt border" >Jobcard No</th>
    <th  align="center" class="txt border" >Machine No</th>
    <th  align="center" class="txt border" >Operator Name</th>
    <th  align="center" class="txt border" >Fabric Type</th>
    <th  align="left" class="txt border" >&nbsp;Particulars</th>
    <th  align="right" class="txt border" >Qty&nbsp;</th>
    <th  align="right" class="txt border">Con Rate&nbsp;</th>
    <th  align="right" class="txt border" >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= "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 ";
}
}	  
   $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 pay_slip_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="54"  align="center" class="txt border">&nbsp;<?php echo $from; ?></td>
    <td width="118" align="center" class="txt border" >&nbsp;<?php echo date("d-m-Y",strtotime($production_time));?></td>
    <td width="115" align="center" class="txt border" style="" >&nbsp;<?php echo $shift_names; ?></td>
    <td width="129" align="center" class="txt border" >&nbsp;<?php echo $job_card_no; ?></td>
    <td width="168" align="center" class="txt border">&nbsp;<?php echo $machine_name;?></td>
    <td width="128" align="center" class="txt border" >&nbsp;<?php echo $operator_name; ?></td>
    <td width="125" align="center" class="txt border" >&nbsp;<?php echo $fabric_type; ?></td>
    <td width="169" align="left" class="txt border">&nbsp;<?php  echo $prod_size; ?></td>
    <td width="81" align="right"class="txt border"><?php  echo $prod_qty; ?>&nbsp;</td>
    <td width="104" align="right" class="txt border" ><?php  echo number_format($contract_rate,2); ?>&nbsp;</td>
    <td width="97" align="right" class="txt border"><?php 
	 $aa=$prod_qty*$contract_rate;
	 echo number_format($aa,2); ?>&nbsp;</td>
    </tr>
  <?php $overall_amount_pay+=$aa;
  $overall_quantity+=$prod_qty;} ?>
 
  </thead>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0"> 
<tr>
<td width="194" align="left" class="txt " >&nbsp;</td>
<td width="109" align="left" class="txt " >Date</td>
<td width="334" align="left" class="txt " ><input type="datetime-local"  name="entry_time" id="entry_time" class="types_class1" autofocus onKeyPress="enterevent(event,'tot_amount','entry_time')" tabindex="1" style="font-size:12px; height:25px; width:200px; " value="<?php if($edit_id!='') { echo $entry_date; }  else{ echo  date('Y-m-d').'T'.date('H:i'); }?>"></td>
<td width="194" align="left" class="txt " ></td>
<td width="137" align="left" class="txt " ></td>
 <td width="126" height="38" align="left" class="txt " >Quantity</td>
 <td width="22" align="left" class="txt " ></td>
    <td width="212" align="left" class="txt " ><?php if($edit_id!='') { echo $overall_quantity; }  else{ echo $overall_quantity; }?></td>
    </tr>

<tr>
  <td colspan="5" align="left" class="txt " ></td>
  <td width="126" height="40" align="left" class="txt">Amount</td>
  <td width="22" align="left" class="txt "></td>
  <td width="212" align="left" class="txt " ><input type="text" class="types_class1" name="tot_amount" id="tot_amount"    style="width:200px; height:20px;"  tabindex="3"  value="<?php if($edit_id!='') { echo $overall_amount_pay; } else { echo $overall_amount_pay; } ?>" readonly  onKeyUp="payslip_clear_validation(this.value)" onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false,enterevent(event,'invoice_no','entry_time');"><div id="tot_amount_validation_div" style="color:#FF0000;"></div></td>
</tr>
    <tr>
    <td height="36" colspan="5" align="left" class="txt " ></td>
   <td width="126" align="left" class="txt ">Voucher No</td>
   <td width="22" align="left" class="txt "></td>
    <td width="212" align="left"class="txt" ><input type="text" class="types_class1" name="invoice_no" id="invoice_no"   style="width:200px; height:20px;"  tabindex="4"  value="<?php if($edit_id!='') { echo $tot_amount; } else { } ?>"  onKeyUp="payslip_clear_validation(this.value)" onKeyPress="enterevent(event,'submit','tot_amount')" ><div id="invoice_no_validation_div" style="color:#FF0000;"></div></td>
    </tr>
    <tr>
<td align="center" colspan="13"><input type="button" name="submit" tabindex="5" id="submit" style="background-color: #87BB07;color: #fff;    border: 0px; font-family:verdana; font-size:14px; width:120px; height:27px; " value="SUBMIT"  onClick="pay_slip_entry_add(from_date.value,to_date.value,operator_type.value,pay_slip_no.value,entry_time.value,tot_amount.value,invoice_no.value,this.value)" ></td>
</tr>
     </table>
</div>
</div>
</div>
</div>

