390 lines
11 KiB
PHP
Executable File
390 lines
11 KiB
PHP
Executable File
<?php
|
|
|
|
$sample = array_merge($month,$fresh);
|
|
|
|
?>
|
|
|
|
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
|
|
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
|
|
|
|
|
|
|
|
|
|
</script>
|
|
<script>
|
|
|
|
|
|
$('html').bind('keypress', function(e)
|
|
{
|
|
//alert('Key Pressed');
|
|
if(e.keyCode == 13)
|
|
{
|
|
return false;
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
.num {
|
|
text-align:right;
|
|
}
|
|
</style>
|
|
<div class="content-wrapper">
|
|
<!-- Content Header (Page header) -->
|
|
<section class="content-header">
|
|
<h1>
|
|
<center>Employee Monthly Payment Listing</center>
|
|
</h1>
|
|
</section>
|
|
<section class="content">
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-xs-12">
|
|
<div class="box">
|
|
<div class="box-header">
|
|
<!--<center><h3 class="box-title">-->
|
|
<div class="box-tools">
|
|
<!-- <form action="<?php echo base_url() ?>assetListing" method="POST" id="searchList">-->
|
|
<form action="<?php echo base_url() ?>monthlypay/monthlyListing" method="POST" id="searchList">
|
|
|
|
</form>
|
|
</div><!--</h3></center>-->
|
|
|
|
</div><!-- /.box-header -->
|
|
<?php
|
|
|
|
$year = date("Y");
|
|
$current = date("m-Y");
|
|
$month = date("m");
|
|
if($month < 10)
|
|
{
|
|
$month = substr($month,1);
|
|
}
|
|
$currentselection = $month . "-" . $year;
|
|
$options = array();
|
|
$monthsoptions = array("1" => "Jan", "2" => "Feb","3" => "Mar","4" => "Apr","5" => "May","6" => "June","7"=> "July","8"=> "Aug","9" => "Sep","10"=> "Oct","11" => "Nov","12"=>"Dec");
|
|
|
|
$currentmontharray = array(array($month."-".$year => $monthsoptions[$month]."-".$year));
|
|
// For find out Next and previous month and year from current year
|
|
$aftersix = array();
|
|
for ($i = 0; $i <3;$i++){
|
|
|
|
$month++;;
|
|
if($month > 12)
|
|
{
|
|
$month = 1;
|
|
$year = $year +1;
|
|
}
|
|
|
|
$aftersix[]=array($month."-".$year => $monthsoptions[$month]."-".$year);
|
|
|
|
}
|
|
|
|
$year = date("Y");
|
|
$month = date("m");
|
|
|
|
$beforesix = array();
|
|
for ($i = 3; $i >0;$i--){
|
|
|
|
$month--;
|
|
if($month < 1 )
|
|
{
|
|
$month = 12;
|
|
$year = $year - 1;
|
|
}
|
|
|
|
$beforesix[]=array($month."-".$year => $monthsoptions[$month]."-".$year);
|
|
|
|
}
|
|
|
|
$beforesix = array_reverse($beforesix);
|
|
|
|
|
|
$options = array_merge($options,$beforesix);
|
|
//echo count($options);
|
|
|
|
$options = array_merge($options,$currentmontharray);
|
|
$options = array_merge($options,$aftersix);
|
|
|
|
$ot = array();
|
|
foreach($options as $o)
|
|
{
|
|
|
|
foreach($o as $key => $value)
|
|
{
|
|
|
|
$ot[$key] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
?>
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<?php echo form_dropdown('name="monthyear"',$ot,set_value('monthyear',$currentselection),'id="monthyear"' ,'class="form-control select2');?>
|
|
</div>
|
|
</div>
|
|
<div class="box-body">
|
|
<table id="monthlylistings" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
|
|
<thead style="background-color:#ddf">
|
|
<tr>
|
|
|
|
<th>S.No</th>
|
|
<th>Employee Id</th>
|
|
<th>Employee Name</th>
|
|
<th>LOP Days</th>
|
|
<th>Paid Leave</th>
|
|
<th>OT Hours Worked in Hrs</th>
|
|
<th>Loan Recovered in ₹</th>
|
|
|
|
<th>Incentives in ₹</th>
|
|
<th>Other Deductions in ₹</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<?php
|
|
|
|
|
|
$index=0;
|
|
$testarray=array();
|
|
|
|
|
|
|
|
if(!empty($sample))
|
|
{
|
|
|
|
foreach($sample as $record)
|
|
{
|
|
|
|
$index++;
|
|
|
|
if(in_array($record->EmpID,$testarray))
|
|
{
|
|
$index--;
|
|
|
|
|
|
}
|
|
else{
|
|
|
|
|
|
array_push($testarray,$record->EmpID);
|
|
|
|
|
|
|
|
?>
|
|
|
|
<tr>
|
|
<td style="text-align:right;"><?php echo $index ?></td>
|
|
<td style="text-align:right;"><?php echo $record->EmpID ?></td>
|
|
<td><?php echo $record->FirstName ." ". $record->LastName ?></td>
|
|
<td contenteditable='true' style="text-align:right;"><?php if(!empty($record->LOP_Days)){echo $record->LOP_Days;}else{echo "0.00";}?></td>
|
|
<td contenteditable='true' style="text-align:right;"><?php if(!empty($record->Paid_leave)){echo $record->Paid_leave;}else { echo number_format(0.00,2,'.','');} ?></td>
|
|
<td contenteditable='true' style="text-align:right;"><?php if(!empty($record->OT_Hrs_Worked)){echo $record->OT_Hrs_Worked;}else { echo number_format(0.00,2,'.','');} ?></td>
|
|
<td contenteditable='true' style="text-align:right;"><?php if(!empty($record->Loan_Recovered)){if(is_numeric($record->Loan_Recovered)){echo number_format($record->Loan_Recovered,2,'.','');}else {echo $record->Loan_Recovered;}}else{echo number_format(0.00,2,'.','');} ?></td>
|
|
<td contenteditable='true' style="text-align:right;"><?php if(!empty($record->Incentives)){echo $record->Incentives;}else{ echo number_format(0.00,2,'.','');;} ?></td>
|
|
<td contenteditable='true' style="text-align:right;"><?php if(!empty($record->Other_Deductions)){echo $record->Other_Deductions; }else{ echo number_format(0.00,2,'.','');;} ?></td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<p> </p>
|
|
<div class="row">
|
|
<div class="col-md-3" id="savebutton">
|
|
<input type="button" id="submit" value = "Save" class="btn btn-primary" onclick="getAllData();">
|
|
</div>
|
|
</div>
|
|
</div><!-- /.box-body -->
|
|
<!-- <div class="box-footer clearfix">
|
|
|
|
</div> -->
|
|
</div><!-- /.box -->
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
|
|
$('#monthlylisting').DataTable({
|
|
"paging": true,
|
|
"lengthChange": true,
|
|
"searching": true,
|
|
"ordering": true,
|
|
"aaSorting": [[ 0, "asc" ]],
|
|
"info": true,
|
|
"autoWidth": true
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getAllData()
|
|
{
|
|
|
|
var alldata = $("#monthlylistings").tableToJSON();
|
|
// alert(JSON.stringify(alldata));
|
|
alldata=JSON.stringify(alldata)
|
|
var month = $('#monthyear').val();
|
|
$('#content').loader('hide');
|
|
$.ajax({
|
|
data:{param1:alldata,param2:month},
|
|
//dataType:"json",
|
|
type:"POST",
|
|
url:"<?php echo base_url() ?>payslip/saveMonthlyData",
|
|
success:function(data) {
|
|
if(data)
|
|
{
|
|
$('#content').loader('hide');
|
|
alert(data);
|
|
//console.log(data);
|
|
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
$("#monthyear").change(function(){
|
|
|
|
var curselection = $("#monthyear").val();
|
|
// alert('current selection'+curselection);
|
|
var currentdate = new Date();
|
|
var currentmonth = currentdate.getMonth();
|
|
currentmonth++;
|
|
//alert('currentmonth'+currentmonth);
|
|
var res = curselection.split("-");
|
|
var selmonth = res[0];
|
|
//alert('current selec month '+ selmonth);
|
|
var savebuttonstatus = currentmonth - selmonth;
|
|
//alert('status'+savebuttonstatus);
|
|
if(savebuttonstatus >= 2)
|
|
{
|
|
$("#savebutton").hide();
|
|
}
|
|
|
|
else if(savebuttonstatus < 0)
|
|
{
|
|
$("#savebutton").hide();
|
|
}
|
|
else if(savebuttonstatus == 0)
|
|
{
|
|
$("#savebutton").show();
|
|
}
|
|
else if(savebuttonstatus == 1)
|
|
{
|
|
$("#savebutton").show();
|
|
}
|
|
|
|
|
|
$("#monthlyListings tbody tr").remove();
|
|
|
|
var zero = '0';
|
|
var month='';
|
|
var hyphan = '-';
|
|
var currentselection = $("#monthyear").val();
|
|
//alert(currentselection);
|
|
var res = currentselection.split("-");
|
|
month = res[0];
|
|
if(res[0] <10)
|
|
{
|
|
var month = zero.concat(res[0]);
|
|
}
|
|
var finaldate = month.concat(hyphan);
|
|
var finaldate = finaldate.concat(res[1]);
|
|
//alert(finaldate);
|
|
$.ajax({
|
|
data:{param1:finaldate},
|
|
|
|
type:"POST",
|
|
url:"<?php echo base_url() ?>payslip/changeMonth",
|
|
success:function(data)
|
|
{
|
|
//alert(data);
|
|
if(data)
|
|
{
|
|
$('#content').loader('hide');
|
|
//alert(data);
|
|
var trHTML="";
|
|
var obj =JSON.parse(data);
|
|
var temparray = [];
|
|
var j=0;
|
|
jQuery.each(obj, function(i, val) {
|
|
function checkExist(emp) {
|
|
return emp == val.EmpID;
|
|
}
|
|
//++i;
|
|
var tmp= temparray.find(checkExist);
|
|
if(tmp != null)
|
|
{
|
|
j++;
|
|
|
|
|
|
}else{
|
|
//alert(val.EmpID + "First");
|
|
temparray.push(val.EmpID);
|
|
++i
|
|
i=i-j;
|
|
|
|
var LOP_Days = val.LOP_Days;
|
|
if(LOP_Days == null){ LOP_Days="0.00";}
|
|
var Paid_leave = val.Paid_leave;
|
|
if(Paid_leave == null){ Paid_leave = "0.00";}
|
|
var OT_Hrs_Worked = val.OT_Hrs_Worked;
|
|
if(OT_Hrs_Worked == null){ OT_Hrs_Worked = "0.00";}
|
|
var Loan_Recovered = val.Loan_Recovered;
|
|
if(Loan_Recovered == null){ Loan_Recovered = "0.00";}
|
|
var Incentives = val.Incentives;
|
|
if(Incentives == null){ Incentives = "0.00";}
|
|
var Other_Deductions = val.Other_Deductions;
|
|
if(Other_Deductions == null){ Other_Deductions = "0.00";}
|
|
|
|
//alert(val.EmpID +"-"+val.FirstName+"-"+val.LastName);
|
|
trHTML += '<tr>' +
|
|
'<td style="text-align:right;">' + (i) + '</td>' +
|
|
'<td style="text-align:right;">' + val.EmpID + '</td>' +
|
|
'<td>' + val.FirstName+" "+ val.LastName + '</td>' +
|
|
'<td contenteditable="true" style="text-align:right;">' + LOP_Days + '</td>' +
|
|
'<td contenteditable="true" style="text-align:right;">' + Paid_leave + '</td>' +
|
|
'<td contenteditable="true" style="text-align:right;">' + OT_Hrs_Worked + '</td>' +
|
|
'<td contenteditable="true" style="text-align:right;">' + Loan_Recovered + '</td>' +
|
|
'<td contenteditable="true" style="text-align:right;">' + Incentives + '</td>' +
|
|
'<td contenteditable="true" style="text-align:right;">' + Other_Deductions+ '</td>' +
|
|
'</tr>';
|
|
}
|
|
|
|
|
|
});
|
|
// //alert(trHTML);
|
|
//alert(temparray);
|
|
$('#monthlyListings > tbody').append(trHTML);
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
</script>
|