siddharth_application/application/views/monthlypayinputs.php
venbatechnologies dd19057792 poeditable
2018-05-16 11:39:08 +05:30

717 lines
23 KiB
PHP
Executable File

<?php
$sample = array_merge($month,$fresh);
$show_hide_column_value = true;
foreach($sample as $s)
{
if(!empty($s->Key))
{
$show_hide_column_value = false;
}
else
{
$show_hide_column_value = true;
}
break;
}
$ex = explode('-',$dropdownvalue);
if(strlen($ex[0])== '2')
{
if($ex[0] < 10)
{
$ex1 = substr($ex[0],1);
}
else{
$ex1 = $ex[0];
}
}
else{
$ex1 = $ex[0];
}
$drop = $ex1.'-'.$ex[1];
?>
<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>
$('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">-->
<p><b>The <span style="background-color:#ff4d4d;">Red</span> highlighted Employee have loan to pay. Put <span style="background-color:#66ff33;">'NA'</span> for Skip Current Month Loan Due.</b></p>
<form action="<?php echo base_url() ?>monthlypay/monthlyListing" method="POST" id="searchList">
</form>
</div><!--</h3></center>-->
</div><!-- /.box-header -->
<?php
//print_r($sample);
$year = date("Y");
$current = date("m-Y");
//echo $current;
$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">
<form id="formid">
<?php echo form_dropdown('monthyear',$ot,set_value('monthyear',$currentselection),'id="monthyear"' ,'class="form-control select2');?>
</form>
</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 </th>
<!-- <th>Employee Name</th> -->
<th>Days Worked</th>
<th>LOP Days</th>
<th>Paid Leave</th>
<th>OT Hrs</th>
<th>Auto Loan Due ₹</th>
<th>Manual Loan Due ₹</th>
<th>Incentives in ₹</th>
<th>Other Deductions in ₹</th>
<th>Festival Bonus in ₹</th>
<th>Estimate in ₹</th>
</tr>
</thead>
<tbody>
<?php
$index=0;
$testarray=array();
if(!empty($sample))
{
//print_r($sample);
$index = 0;
$i = 0;
$totalempSal = [];
foreach($sample as $i=> $record)
{
//echo 'PAY'.$record->Key;
$index++;
if(in_array($record->EmpID,$testarray))
{
$index--;
}
else{
array_push($testarray,$record->EmpID);
?>
<tr>
<td style="text-align:right;" style="background-color:blue;"><?php echo $index; ?></td>
<!-- <td style="text-align:right;"><?php echo $record->EmpID ?></td> -->
<td style="max-width:80px"><?php echo $record->EmpID ."-".$record->FirstName ."". $record->LastName ?></td>
<td id="dayWork<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Days_worked)){echo $record->Days_worked;}else{echo "0.00";}?></td>
<td id="lopDay<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->LOP_Days)){echo $record->LOP_Days;}else{echo "0.00";}?></td>
<td id="paidLeave<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Paid_leave)){echo number_format($record->Paid_leave,2,'.','');}else { echo number_format(0.00,2,'.','');} ?></td>
<td id="otHrsWork<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->OT_Hrs_Worked)){echo $record->OT_Hrs_Worked;}else { echo number_format(0.00,2,'.','');} ?></td>
<td id="monthDue<?php echo $index?>" <?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Monthly_Due)){echo $record->Monthly_Due;}else { echo number_format(0.00,2,'.','');} ?></td>
<td id="loanRecd<?php echo $index?>" onkeypress="return isCheckKeyCode(event);" onkeyup="changeInput(event);"<?php if(empty($record->Key) && !empty($record->Loan_ID)){ echo "contenteditable='true'; style='background-color:#ffcccc;text-align:right' title='Loan Pending'"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> >
<?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 id="incentie<?php echo $index?>" onkeypress="return isNumber(event);" onkeyup="changeInput(event);"<?php if(empty($record->Key)){echo "contenteditable='true';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> >
<!-- <?php if(!empty($record->MasterIncentives)){echo $record->MasterIncentives;}else {echo $record->MonthlyIncentives;} ?> -->
<?php if(!empty($record->MonthlyIncentives)){echo $record->MonthlyIncentives;}else {echo $record->MasterIncentives;} ?>
</td>
<!-- else{ echo number_format(0.00,2,'.','');;} -->
<td id ="otherDet<?php echo $index?>" onkeypress="return isNumber(event);" onkeyup="changeInput(event);"<?php if(empty($record->Key)){echo "contenteditable='true';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Other_Deductions)){echo $record->Other_Deductions; }else{ echo number_format(0.00,2,'.','');;} ?></td>
<td id="Festival<?php echo $index?>"onkeypress="return isNumber(event);" onkeyup="changeInput(event);"<?php if(empty($record->Key)){echo "contenteditable='true';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Festival_Bonus)){echo $record->Festival_Bonus; }else{ echo number_format(0.00,2,'.','');;} ?></td>
<td id="empsal<?php echo $index?>"><?php echo $empSalary[$i];?></td>
<?php $totalempSal [] = $empSalary[$i];?>
<!-- <input type="hidden" id = "eid" value="<?php echo $record->EmpID?>">
<input type="hidden" id = "inv" value="<?php echo $record->Incentives?>">
<input type="hidden" id = "pdi" value="<?php echo $record->Pay_Data_ID?>"> -->
<input type="hidden" id = "bPay<?php echo $index?>" value="<?php echo $record->Basic_Pay?>">
<input type="hidden" id = "hraRate<?php echo $index?>" value="<?php echo $record->HRA_Rate?>">
<input type="hidden" id = "allow<?php echo $index?>" value="<?php echo $record->Allowances?>">
<input type="hidden" id = "fAllow<?php echo $index?>" value="<?php echo $record->Food_Allowances?>">
<input type="hidden" id = "pfRate<?php echo $index?>" value="<?php echo $record->PF_Rate?>">
<input type="hidden" id = "eslRate<?php echo $index?>" value="<?php echo $record->ESI_Rate?>">
<input type="hidden" id = "hraAmt<?php echo $index?>" value="<?php echo $record->HRA_Amount?>">
<input type="hidden" id = "loanamt<?php echo $index?>" value="<?php echo $record->Loan_amount?>">
<input type="hidden" id = "paidamt<?php echo $index?>" value="<?php echo $record->Paid_Amount?>">
<!-- <input type="hidden" id = "eid" value="<?php echo $record->TotalSalary?>">
<input type="hidden" id = "eid" value="<?php echo $record->LOP_Days?>">
<input type="hidden" id = "eid" value="<?php echo $record->Paid_leave?>">
<input type="hidden" id = "eid" value="<?php echo $record->OT_Hrs_Worked?>">
<input type="hidden" id = "eid" value="<?php echo $record->NoofDays?>">
<input type="hidden" id = "eid" value="<?php echo $record->Monthly_Due?>"> -->
</tr>
<?php
}
}
}
?>
</tbody>
<tfoot><tr>
<th colspan="4"></th>
<th colspan="4"></th>
<th colspan="2"></th>
<th>Total</th>
<th> <?php echo array_sum($totalempSal);?></th>
</tr>
</tfoot>
</table>
<p>&nbsp;</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
}); */
var key = <?php echo $show_hide_column_value; ?>
show_hide_column(11,key);
var t = $('#monthlylistings').DataTable( {
"columnDefs": [ {
"searchable": false,
"orderable": false,
"targets": 0
} ],
"searching": true,
"lengthChange": true,
"info": true,
"paging": false,
"autoWidth": true,
"order": [[ 1, 'asc' ]]
} );
t.on( 'order.dt search.dt', function () {
t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
} );
} ).draw();
var s = "<?php echo $drop; ?>";
$('#monthyear').val(s);
savebuttonvalidation();
});
function isNumber(evt) {
//alert("hi");
var iKeyCode = (evt.which) ? evt.which : evt.keyCode
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57))
{ return false;}
return true;
}
function isCheckKeyCode(event){
var iKeyCode = (event.which) ? event.which : event.keyCode
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57 ) && (iKeyCode ==78 && iKeyCode == 65))
{ return false;}
return true;
}
function getAllData()
{
var alldata = $("#monthlylistings").tableToJSON();
//alert(JSON.stringify(alldata));
alldata=JSON.stringify(alldata)
var month = $('#monthyear').val();
$('.content').loader('show');
$.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(){
$s = $('#monthyear').val();
//echo $dropdownvalue;
//$('#monthyear').attr('selected',true);
//alert($s);
$("#formid").attr("method", "post");
//alert($s);
$("#formid").attr("action", "<?php echo base_url() ?>payslip/changeMonth");
$('#formid').submit();
});
function savebuttonvalidation()
{
var curselection = $("#monthyear").val();
//alert('current selection'+curselection);
var currentdate = new Date();
var currentmonth = currentdate.getMonth();
var currentyear = currentdate.getFullYear();
currentmonth++;
//alert('currentmonth'+currentmonth);
var res = curselection.split("-");
var selmonth = res[0];
var selyear = res[1];
//alert('current selec month '+ selmonth + 'current selec year '+ selyear);
var savebuttonstatus = currentmonth - selmonth;
var year = currentyear - selyear ;
//alert(selyear + currentyear);
if(savebuttonstatus >= 2)
{
if(year == 1)
{
// $("#savebutton").hide();
$("#savebutton").show();
}
else
{
//$("#savebutton").hide();
$("#savebutton").show();
}
}
else if(savebuttonstatus < 0 )
{
if(year == 1)
{
$("#savebutton").show();
}
else if(year == 0)
{
//$("#savebutton").hide();
$("#savebutton").show();
}
else
{
//$("#savebutton").hide();
$("#savebutton").show();
}
}
else if(savebuttonstatus == 0 && year == 0)
{
//$("#savebutton").hide();
$("#savebutton").show();
}
else if(savebuttonstatus == 1)
{
if(year == 0 || year == 1)
{
$("#savebutton").show();
}
else
{
$("#savebutton").show();
}
}
}
var totalinst = [];
function changeInput(event,k)
{
var str=event.target.id;
var sno = str.substr(8);
//alert(sno);
var dayWorks=parseFloat(document.getElementById('dayWork'+sno).textContent);
var lopDay=parseFloat(document.getElementById('lopDay'+sno).textContent);
var paidLeave =parseFloat(document.getElementById('paidLeave'+sno).textContent);
var otHrsWork =parseFloat(document.getElementById('otHrsWork'+sno).textContent);
var monthDue =parseFloat(document.getElementById('monthDue'+sno).textContent);
var loanRecd=document.getElementById('loanRecd'+sno).textContent;
var incentie=parseFloat(document.getElementById('incentie'+sno).textContent);
var otherDet =parseFloat(document.getElementById('otherDet'+sno).textContent);
var Festival =parseFloat(document.getElementById('Festival'+sno).textContent);
var empsal =parseFloat(document.getElementById('empsal'+sno).textContent);
var bpay =parseFloat(document.getElementById('bPay'+sno).value);
var hraRate=parseFloat(document.getElementById('hraRate'+sno).value);
var allow=parseFloat(document.getElementById('allow'+sno).value);
var fAllow =parseFloat(document.getElementById('fAllow'+sno).value);
var pfRate =parseFloat(document.getElementById('pfRate'+sno).value);
var eslRate =parseFloat(document.getElementById('eslRate'+sno).value);
var hraAmt =parseFloat(document.getElementById('hraAmt'+sno).value);
// var Balance_Amount =parseFloat(document.getElementById('Balance'+sno).value);
var loanamt =parseFloat(document.getElementById('loanamt'+sno).value);
var paidamt =parseFloat(document.getElementById('paidamt'+sno).value);
var dayWorkPaid=dayWorks+paidLeave;
// console.log("day"+dayWorkPaid);
var NoofDays=dayWorks+paidLeave +lopDay;
// console.log("monthday"+NoofDays);
var Food_Allowances = fAllow * dayWorks;
// console.log("workedFA"+Food_Allowances);
var daySalary = bpay / NoofDays;
// console.log("1daysalary "+daySalary);
var dayHra = hraAmt / NoofDays;
// console.log("1dayHRA"+dayHra);
var onehoursSalary = (daySalary + dayHra) / 8;
//console.log("onehours "+onehoursSalary);
var totSalayOT =0;
if (otHrsWork!= 0)
{
totSalayOT = otHrsWork * onehoursSalary;
}
else
{
totSalayOT = 0;
}
//console.log(totSalayOT);
var currentDaySalary = daySalary * dayWorkPaid;
//console.log("11days salary"+currentDaySalary);
var currentDayHra = dayHra * dayWorkPaid;
// console.log("11days hra"+currentDayHra);
var current_loan_amt = 0;
var autoLoan =parseFloat(monthDue);
var manualLoan =parseFloat(loanRecd);
// var manualLoan = Math.min.apply(null, arrayOfNumbers.filter(function(loanRecd) { return !isNaN(loanRecd); }))
//alert(manualLoan);
if(manualLoan == 0.00){
current_loan_amt = autoLoan;
//alert('0.00');
}
else if(isNaN(manualLoan))
{
//alert('N');
current_loan_amt = 0.00;
}
else if(manualLoan == 'NA')
{
//alert('NA');
current_loan_amt = 0.00;
}
else if(manualLoan >= 0.00)
{
current_loan_amt = manualLoan;
//alert('manual');
}
var Balance_Amount = loanamt - paidamt;
if(autoLoan > Balance_Amount) {
// current= Balance_Amount - autoLoan;
current_loan_amt = Balance_Amount;
//alert('HI');
}
// console.log(current_loan_amt);
if(parseFloat(incentie) == parseFloat(incentie)){
var incent =parseFloat(incentie);
//console.log("Incentives"+incent);
}
if(parseFloat(Festival) == parseFloat(Festival)){
var Festivals =parseFloat(Festival);
//console.log("Festivals"+Festivals);
}
if(parseFloat( otherDet) == parseFloat( otherDet)){
var otherDets =parseFloat( otherDet);
//console.log("otherDets"+ otherDets);
}
var currentDatePF = currentDaySalary + currentDayHra + totSalayOT;
// console.log("pf "+currentDatePF);
// var totalsalary= empsal + hraAmt;
var totalsalary =currentDaySalary+currentDayHra;
// console.log("total"+totalsalary);
var esiAmount=0;
if (totalsalary <= 20000)
{
esiAmount = currentDatePF * eslRate / 100;
/** esiamount not elgiable for 20000 **/
}
else
{
esiAmount = 0;
}
var pfAmount = currentDaySalary * pfRate / 100;
// console.log("11daypf"+pfAmount);
var empSalaryAdd= currentDaySalary + totSalayOT + currentDayHra + Food_Allowances + allow +incent+Festivals;
var empSalarySub = current_loan_amt + esiAmount + pfAmount + otherDets;
var empMonthSalary = empSalaryAdd - empSalarySub
var employeeSalary = Math.round(empMonthSalary);
//console.log( employeeSalary);
var cals =(employeeSalary).toFixed(0);
document.getElementById("empsal"+sno).innerHTML = cals;
}
function show_hide_column(col_no, do_show) {
var rows = document.getElementById('monthlylistings').rows;
for (var row = 0; row < rows.length; row++) {
var cols = rows[row].cells;
if (col_no >= 0 && col_no < cols.length) {
cols[col_no].style.display = do_show ? '' : 'none';
}
}
}
</script>