559 lines
25 KiB
PHP
559 lines
25 KiB
PHP
<style>
|
|
.celda_encabezado_general {
|
|
background-color: #00a65a;
|
|
border: 1px solid #ccc;
|
|
color: #ffffff;
|
|
font-weight: bold;
|
|
padding: 2px 4px;
|
|
text-align: center;
|
|
}
|
|
|
|
.fht-table th:nth-child(1),
|
|
.fht-table th:nth-child(2),
|
|
.fht-table th:nth-child(3)
|
|
{
|
|
position: sticky;
|
|
left: 0;
|
|
top: 0;
|
|
background-color: #00a65a;
|
|
z-index: 7!important;
|
|
border-right: 2px solid #ddd;
|
|
color: #ffffff;
|
|
}
|
|
|
|
|
|
.fht-table td:nth-child(1),
|
|
.fht-table td:nth-child(2),
|
|
.fht-table td:nth-child(3)
|
|
{
|
|
position: sticky;
|
|
left: 0;
|
|
background-color: #ffffff;
|
|
z-index: 2;
|
|
border-right: 2px solid #ddd;
|
|
color: #0e0b0b;
|
|
}
|
|
|
|
.table-responsive {
|
|
overflow-y: auto;
|
|
max-height: 450px;
|
|
}
|
|
|
|
.fht-table thead th {
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 5!important;
|
|
}
|
|
</style>
|
|
<?php
|
|
// echo "****";die;
|
|
|
|
$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>
|
|
$('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></center>
|
|
</h1>
|
|
</section>
|
|
<section class="content">
|
|
|
|
<input type="hidden" id="paydate" value="<?php echo $drop; ?>" />
|
|
<div class="row">
|
|
<div class="col-xs-12">
|
|
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
|
|
<div class="content-page">
|
|
<div class="content">
|
|
<!-- Start Content-->
|
|
<div class="container-fluid">
|
|
<!-- start page title -->
|
|
<div>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">HR</a></li>
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">PaySlip</a></li>
|
|
<li class="breadcrumb-item active">
|
|
<h4 class="page-title">Driver's Monthly Pay Information</h4>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<div class="box">
|
|
<div class="box-header">
|
|
<!--<center><h3 class="box-title">-->
|
|
<div class="box-tools">
|
|
|
|
<!-- <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> -->
|
|
|
|
</div>
|
|
<!--</h3></center>-->
|
|
|
|
</div><!-- /.box-header -->
|
|
<?php
|
|
|
|
$year = date("Y");
|
|
$current = date("m-Y");
|
|
|
|
//echo $current;
|
|
$month = date("m");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1);
|
|
}
|
|
$currentselection = $dropdownvalue; // $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="box-body">
|
|
<div class="row" style="margin-bottom:10px">
|
|
<div class="col-md-3">
|
|
<form id="formid">
|
|
<?php echo form_dropdown('month_year', $ot, set_value('month_year', $currentselection), 'id="month_year"', 'class="form-control select2'); ?>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="col-3 ">
|
|
<i id="exportButton" class="fas fa-download download-icon" style="font-size: x-large; margin-top:12px;" title="Export Excel"></i>
|
|
</div>
|
|
|
|
<div class="col-6 text-right" id="savebutton">
|
|
<input type="button" id="submit" value="Save" class="btn btn-success" onclick="getAllData();" style="margin-top:0px;">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-responsive" style="overflow-x:scroll;">
|
|
<table id="drivermonthlylistings" class="table table-bordered table-hover fht-table"
|
|
style="background-color:#fff;font-size:12px;white-space: nowrap;">
|
|
<thead style="background-color: #ddd;">
|
|
|
|
<tr>
|
|
<th style="display:none;">Driver Id</th>
|
|
<th class="celda_encabezado_general">S.No</th>
|
|
<th class="celda_encabezado_general">Driver Name </th>
|
|
<th class="celda_encabezado_general">Number Of Load</th>
|
|
<th class="celda_encabezado_general">Salary Amount ₹</th>
|
|
<th class="celda_encabezado_general">Food Amount ₹</th>
|
|
<th class="celda_encabezado_general">Total Amount ₹</th>
|
|
<th class="celda_encabezado_general">Diesel</th>
|
|
<th class="celda_encabezado_general">Shed Duty</th>
|
|
<th class="celda_encabezado_general">Grand Total in ₹</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<?php
|
|
$index = 0;
|
|
if (!empty($monthinputs)) {
|
|
foreach ($monthinputs as $i => $record) {
|
|
$index++;
|
|
?>
|
|
|
|
<tr class="lastvalue">
|
|
<td style="display:none;"><?php echo $record->driver_id; ?></td>
|
|
<td style="text-align:right;" style="background-color:blue;"><?php echo $index; ?></td> <!-- s.no -->
|
|
<td id="driver<?php echo $index ?>" style="max-width:80px"><?php echo $record->driver_name; ?></td>
|
|
<td id="loadno<?php echo $index ?>" style="max-width:40px;text-align:right;"><?php echo $record->no_of_loads; ?></td>
|
|
<td id="slryam<?php echo $index ?>" style="max-width:80px;text-align:right;">
|
|
<?php if (!empty($record->driver_monthly_salary_amount)) {
|
|
$totalforfooter[] = $record->driver_monthly_salary_amount;
|
|
echo number_format($record->driver_monthly_salary_amount, 2, '.', '');
|
|
} else {
|
|
echo number_format(0.00, 2, '.', '');
|
|
} ?>
|
|
<td id="foodam<?php echo $index ?>" style="max-width:80px;text-align:right;">
|
|
<?php if (!empty($record->driver_monthly_food_amount)) {
|
|
$totalforfooter2[] = $record->driver_monthly_food_amount;
|
|
echo number_format($record->driver_monthly_food_amount, 2, '.', '');
|
|
} else {
|
|
echo number_format(0.00, 2, '.', '');
|
|
} ?>
|
|
</td>
|
|
<td id="totala<?php echo $index ?>" style="max-width:80px;text-align:right;">
|
|
<?php $driver_earnings_amount = isset($record->driver_earnings_amount) ? $record->driver_earnings_amount : ($record->driver_monthly_salary_amount + $record->driver_monthly_food_amount);
|
|
if (!empty($driver_earnings_amount)) {
|
|
$totalforfooter3[] = $driver_earnings_amount;
|
|
echo number_format($driver_earnings_amount, 2, '.', '');
|
|
} else {
|
|
echo number_format(0.00, 2, '.', '');
|
|
} ?>
|
|
</td>
|
|
<td id="diesel<?php echo $index ?>" style="max-width:80px;text-align:right;" onkeypress="return isNumber(event);" onkeyup="changeInput(event, <?php echo $index; ?>);"
|
|
<?php if (empty($record->payroll_id)) {
|
|
echo "contenteditable='true';";
|
|
} ?>
|
|
<?php if (!empty($record->payroll_id)) { ?> title="Payslip Calculated" style="text-align:right;color:blue;"
|
|
<?php } else { ?>style="text-align:right;" <?php } ?>>
|
|
|
|
<?php if (!empty($record->diesel)) {
|
|
echo number_format($record->diesel, 2, '.', '');
|
|
$totalforfooter4[] = $record->diesel;
|
|
} else {
|
|
echo number_format(0.00, 2, '.', '');
|
|
} ?>
|
|
</td>
|
|
<td id="sheddu<?php echo $index ?>" onkeypress="return isNumber(event);" onkeyup="changeInput(event, <?php echo $index; ?>);"
|
|
<?php if (empty($record->payroll_id)) {
|
|
echo "contenteditable='true';";
|
|
} ?>
|
|
<?php if (!empty($record->payroll_id)) { ?> title="Payslip Calculated"
|
|
style="text-align:right;color:blue;"
|
|
<?php } else { ?>style="text-align:right;" <?php } ?>>
|
|
|
|
<?php if (!empty($record->shed_duty_amount)) {
|
|
echo number_format($record->shed_duty_amount, 2, '.', '');
|
|
$totalforfooter5[] = $record->shed_duty_amount;
|
|
} else {
|
|
echo number_format(0.00, 2, '.', '');
|
|
} ?>
|
|
</td>
|
|
<td id="grdttl<?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->driver_final_payment)) {
|
|
echo number_format($record->driver_final_payment, 2, '.', '');
|
|
$totalforfooter6[] = $record->driver_final_payment;
|
|
} else {
|
|
echo number_format(0.00, 2, '.', '');
|
|
}
|
|
?>
|
|
</td>
|
|
<input type="hidden" id="driver_id<?php echo $index ?>"
|
|
value="<?php echo $record->driver_id ?>">
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
<tr>
|
|
<th style="display:none;"></th>
|
|
<th></th>
|
|
<th>Total</th>
|
|
<th></th>
|
|
<th id="footercol4" style="text-align:right;">
|
|
<?php echo isset($totalforfooter) ? number_format(array_sum($totalforfooter), 2) : '0.00'; ?>
|
|
</th>
|
|
<th id="footercol5" style="text-align:right;">
|
|
<?php echo isset($totalforfooter2) ? number_format(array_sum($totalforfooter2), 2) : '0.00'; ?>
|
|
</th>
|
|
<th id="footercol6" style="text-align:right;">
|
|
<?php echo isset($totalforfooter3) ? number_format(array_sum($totalforfooter3), 2) : '0.00'; ?>
|
|
</th>
|
|
<th id="footercol7" style="text-align:right;">
|
|
<?php echo isset($totalforfooter4) ? number_format(array_sum($totalforfooter4), 2) : '0.00'; ?>
|
|
</th>
|
|
<th id="footercol8" style="text-align:right;">
|
|
<?php echo isset($totalforfooter5) ? number_format(array_sum($totalforfooter5), 2) : '0.00'; ?>
|
|
</th>
|
|
<th id="footercol9" style="text-align:right;">
|
|
<?php echo isset($totalforfooter6) ? number_format(array_sum($totalforfooter6), 2) : '0.00'; ?>
|
|
</th>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
</div><!-- /.box-body -->
|
|
</div><!-- /.box -->
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
</div>
|
|
</div> <!-- container -->
|
|
</div> <!-- content -->
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
function exportTableToExcel(tableId, filename = 'driverMonthlyPay.xlsx') {
|
|
var table = document.getElementById(tableId);
|
|
var rows = table.rows;
|
|
var data = [];
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
var row = rows[i];
|
|
var cols = row.querySelectorAll('td, th');
|
|
var rowData = [];
|
|
|
|
for (var j = 0; j < cols.length; j++) {
|
|
rowData.push(cols[j].innerText);
|
|
}
|
|
|
|
data.push(rowData);
|
|
}
|
|
|
|
var wb = XLSX.utils.book_new();
|
|
var ws = XLSX.utils.aoa_to_sheet(data);
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
|
|
XLSX.writeFile(wb, filename);
|
|
}
|
|
|
|
// Add click event listener to the export button
|
|
document.getElementById('exportButton').addEventListener('click', function () {
|
|
exportTableToExcel('drivermonthlylistings');
|
|
});
|
|
});
|
|
|
|
$('#month_year').attr('class', 'form-control');
|
|
|
|
|
|
|
|
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 getAllData() {
|
|
|
|
var alldata = $("#drivermonthlylistings").tableToJSON();
|
|
|
|
alldata = JSON.stringify(alldata)
|
|
// Parse the JSON string back into an array of objects
|
|
alldata = JSON.parse(alldata);
|
|
|
|
// Filter out objects where "Emp ID" is empty
|
|
alldata = alldata.filter(function(item) {
|
|
return item["Driver Id"].trim() !== "";
|
|
});
|
|
|
|
// Convert the filtered array back to a JSON string if needed
|
|
alldata = JSON.stringify(alldata);
|
|
var month = $('#month_year').val();
|
|
|
|
$('#loader').show();
|
|
$.ajax({
|
|
data: {
|
|
param1: alldata,
|
|
param2: month
|
|
},
|
|
//dataType:"json",
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>saveMonthlyData",
|
|
success: function(data) {
|
|
|
|
if (data) {
|
|
$('#loader').hide();
|
|
alert(data);
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
$("#month_year").change(function() {
|
|
|
|
$s = $('#month_year').val();
|
|
|
|
$("#formid").attr("method", "get");
|
|
|
|
$("#formid").attr("action", "<?php echo base_url() ?>driverMonthlyPayInputs");
|
|
|
|
$('#formid').submit();
|
|
|
|
|
|
});
|
|
|
|
function changeInput(event, sno) {
|
|
var str = event.target.id;
|
|
var salary_amount = parseFloat(document.getElementById('slryam' + sno).textContent) || 0;
|
|
var food_amount = parseFloat(document.getElementById('foodam' + sno).textContent) || 0;
|
|
var diesel_amount = parseFloat(document.getElementById('diesel' + sno).textContent) || 0;
|
|
var shedduty = parseFloat(document.getElementById('sheddu' + sno).textContent) || 0;
|
|
var grand_total = parseFloat(document.getElementById('grdttl' + sno).textContent) || 0;
|
|
var driver_final_payment = salary_amount+food_amount+diesel_amount+shedduty;
|
|
var employeeSalary = Math.round(driver_final_payment);
|
|
var cals = (employeeSalary).toFixed(2);
|
|
document.getElementById("grdttl" + sno).innerHTML = cals;
|
|
calculategrandtotal();
|
|
// return;
|
|
|
|
}
|
|
|
|
function calculategrandtotal()
|
|
{
|
|
var FooterColFourthIndex = 4;
|
|
var FooterColFourthVal = 0;
|
|
$('#drivermonthlylistings tbody tr').each(function() {
|
|
var value = $(this).find('td').eq(FooterColFourthIndex).text();
|
|
FooterColFourthVal += parseFloat(value) || 0;
|
|
});
|
|
let FourthVal = FooterColFourthVal.toLocaleString("en-IN", { minimumFractionDigits: 2,maximumFractionDigits: 2 });
|
|
$('#footercol4').text(FourthVal);
|
|
// $('#footercol4').text((FooterColFourthVal).toFixed(2));
|
|
|
|
var FooterColFifthIndex = 5;
|
|
var FooterColFifthVal = 0;
|
|
$('#drivermonthlylistings tbody tr').each(function() {
|
|
var value = $(this).find('td').eq(FooterColFifthIndex).text();
|
|
FooterColFifthVal += parseFloat(value) || 0;
|
|
});
|
|
let FifthVal = FooterColFifthVal.toLocaleString("en-IN", { minimumFractionDigits: 2,maximumFractionDigits: 2 });
|
|
$('#footercol5').text(FifthVal);
|
|
// $('#footercol5').text((FooterColFifthVal).toFixed(2));
|
|
|
|
var FooterColSixthIndex = 6;
|
|
var FooterColSixthVal = 0;
|
|
$('#drivermonthlylistings tbody tr').each(function() {
|
|
var value = $(this).find('td').eq(FooterColSixthIndex).text();
|
|
FooterColSixthVal += parseFloat(value) || 0;
|
|
});
|
|
let SixthVal = FooterColSixthVal.toLocaleString("en-IN", { minimumFractionDigits: 2,maximumFractionDigits: 2 });
|
|
$('#footercol6').text(SixthVal);
|
|
// $('#footercol6').text((FooterColSixthVal).toFixed(2));
|
|
|
|
var FooterColSeventhIndex = 7;
|
|
var FooterColSeventhVal = 0;
|
|
$('#drivermonthlylistings tbody tr').each(function() {
|
|
var value = $(this).find('td').eq(FooterColSeventhIndex).text();
|
|
FooterColSeventhVal += parseFloat(value) || 0;
|
|
});
|
|
let SeventhVal = FooterColSeventhVal.toLocaleString("en-IN", { minimumFractionDigits: 2,maximumFractionDigits: 2 });
|
|
$('#footercol7').text(SeventhVal);
|
|
// $('#footercol7').text((FooterColSeventhVal).toFixed(2));
|
|
|
|
var FooterColEigthIndex = 8;
|
|
var FooterColEigthVal = 0;
|
|
$('#drivermonthlylistings tbody tr').each(function() {
|
|
var value = $(this).find('td').eq(FooterColEigthIndex).text();
|
|
FooterColEigthVal += parseFloat(value) || 0;
|
|
});
|
|
let EigthVal = FooterColEigthVal.toLocaleString("en-IN", { minimumFractionDigits: 2,maximumFractionDigits: 2 });
|
|
$('#footercol8').text(EigthVal);
|
|
// $('#footercol8').text((FooterColEigthVal).toFixed(2));
|
|
|
|
var FooterColNinthIndex = 9;
|
|
var FooterColNinthVal = 0;
|
|
$('#drivermonthlylistings tbody tr').each(function() {
|
|
var value = $(this).find('td').eq(FooterColNinthIndex).text();
|
|
FooterColNinthVal += parseFloat(value) || 0;
|
|
});
|
|
let NinthVal = FooterColNinthVal.toLocaleString("en-IN", { minimumFractionDigits: 2,maximumFractionDigits: 2 });
|
|
$('#footercol9').text(NinthVal);
|
|
|
|
}
|
|
|
|
</script>
|