IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Generate Salary</strong></h2>
</div>
<div class="body table-responsive">
<?php echo Form::open(['method' => 'GET', 'action' => ['School\EmpPaymentController@salaryGeneration'], 'class' => 'form-horizontal']); ?>
<p style="color: red;">Note : If You Want to Generate all Employee Salaries Just Select month and click on generate</p>
<div class="row clearfix" style="margin-bottom:30px;">
<div class="col-sm-12">
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Department</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php echo Form::select('idDepartment', $departments, null, ['class' => 'form-control show-tick ms select2']); ?>
<?php if($errors->has('idDepartment')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idDepartment')); ?></strong>
</label>
<?php endif; ?>
<span id='depterror'></span>
</div>
</div>
<div class="col-sm-2 form-control-label">
<label for="classname">Designation</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<div id="idDesignation" style="border:1px solid #ccc; width:200px; height: 110px; overflow-y: scroll;">
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label">
<label for="classname">EC No.</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<div id="idEmployee" style="border:1px solid #ccc; width:250px; height: 140px; overflow-y: scroll;">
</div>
</div>
</div>
</div>
<div class="row clearfix">
<?php if($errors->has('employee')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('employee')); ?></strong>
</label>
<?php endif; ?>
<?php if(isset($_GET['idDepartment'])): ?>
<input type="hidden" name="idDepartment" value="<?php echo e($_GET['idDepartment']); ?>"/>
<?php endif; ?>
<?php if(isset($_GET['designations'])): ?>
<?php
$arr = $_GET['designations'];
foreach ($arr as $key => $value) {
echo '<input type="hidden" name="designations[]" value="' . $value . '"/>';
}
?>
<?php endif; ?>
<?php if(isset($_GET['employees'])): ?>
<?php
$arr = $_GET['employees'];
foreach ($arr as $key => $value) {
echo '<input type="hidden" name="employees[]" value="' . $value . '"/>';
}
?>
<?php endif; ?>
<div class="col-sm-2">
<label><strong>Select a FY (Financial Year)</strong></label>
</div>
<div class="col-sm-3">
<?php echo Form::select('fy', fys(), Session::get('idFinancialYear'), ['class' => 'form-control show-tick ms', 'required' => 'required']); ?>
<?php if($errors->has('fy')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('fy')); ?></strong>
</label>
<?php endif; ?>
</div>
<div class="col-sm-2">
<label><strong>Select a Month & Year</strong></label>
</div>
<div class="col-sm-3">
<?php echo Form::select('idMonth', getMonths(), null, ['class' => 'form-control show-tick ms', 'required' => 'required']); ?>
<?php echo Form::select('year', ['2024' => '2024', '2025' => '2025', '2021' => '2021', 2022 => '2022', '2023' => '2023', '2020' => '2020', '2019' => '2019'], null, ['class' => 'form-control show-tick ms']); ?>
<?php if($errors->has('idMonth')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idMonth')); ?></strong>
</label>
<?php endif; ?>
</div>
<div class="col-sm-2">
<input type="submit" value="GENERATE" class="btn btn-raised btn-success btn-round waves-effect">
</div>
</div>
</div>
</div>
<?php echo Form::close(); ?>
<?php $employeeId = array(); ?>
<?php if(isset($financialYear) && isset($month)): ?>
<button class="btn btn-raised btn-success btn-round waves-effect" id="print_data" onclick="printData()"> Print Salary Data</button>
<?php endif; ?>
<?php if(isset($financialYear) && isset($month)): ?>
<div class="progress" id="salaryparent">
<div id="salarybar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" style="width: 1%"></div>
</div>
<table class="table table-bordered" id="salary">
<thead>
<?php $financialYears = \App\FinancialYear::where('idFinancialYear', $financialYear)->first();
$prevfinancialYear = \App\FinancialYear::where('idFinancialYear', '<', $financialYear)->orderBy('idFinancialYear', 'DESC')->first();?>
<tr>
<th>#</th>
<th>EC No.</th>
<th>Name of the Employee</th>
<th>Designation</th>
<th>Date of Joining</th>
<th>Salary Offered <?php if($prevfinancialYear != null): ?> of <?php echo e($prevfinancialYear->financialYearName); ?> <?php endif; ?></th>
<th>Increment of <?php echo e($financialYears->financialYearName); ?></th>
<th>Gross Salary</th>
<th>Basic</th>
<th>Other Allowances</th>
<th>Gross Salary</th>
<th>Total leaves (Year)</th>
<th>Previous month leaves</th>
<th>During month leaves</th>
<th>Total leaves availed</th>
<th>Leave balance</th>
<th>Incomplete Attendance</th>
<th>Absent (AB)</th>
<th>Late Remark (Half-Day)</th>
<th>Leave deduction</th>
<th>Leave deduction Amt.</th>
<th>Salary Deduction</th>
<th>Gross Salary for month</th>
<th>Loan Deduction</th>
<th>Canteen Deduction</th>
<th>EPF</th>
<th>P.T Deduction</th>
<th>Net Salary Payable</th>
</tr>
</thead>
<tbody>
<?php $k = 1; ?>
<?php $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php
$basic = 0;
$other_allowance = 0;
$increments = 0;
$ptDeduction = 0;
$otherDeduction = 0;
$totalLeaves = 0;
$prev_month_leave = 0;
$during_month_leave = 0;
$availed_leave = 0;
$balance_leave = 0;
$absent = 0;
$late_mark = 0;
$leave_deduction = 0;
$leave_deduction_amount = 0;
$salary_deduction = 0;
$loan_deduction = 0;
$net_salary = 0;
$designationYearWise = \App\LeaveMaster::where('idSchool', '=', $value->idSchool)
->where('idDesignation', $value->idDesignation)
->where('idFinancialYear', $financialYear)
->where('leaveType', "yearly")
->whereNull('idEmployee')
->sum('paidLeaves');
$paidYearLeaves = \App\LeaveMaster::where('idSchool', '=', $value->idSchool)
->where('idDesignation', $value->idDesignation)
->where('idEmployee', $value->idEmployee)
->where('idFinancialYear', $financialYear)
->where('leaveType', "yearly")
->sum('paidLeaves');
$designationMonthWise = \App\LeaveMaster::where('idSchool', '=', $value->idSchool)
->where('idDesignation', $value->idDesignation)
->where('idFinancialYear', $financialYear)
->where('leaveType', "monthly")
->whereNull('idEmployee')
->sum('paidLeaves') * 12;
$paidMonthLeaves = \App\LeaveMaster::where('idSchool', '=', $value->idSchool)
->where('idDesignation', $value->idDesignation)
->where('idEmployee', $value->idEmployee)
->where('idFinancialYear', $financialYear)
->where('leaveType', "monthly")
->sum('paidLeaves') * 12;
$totalLeaves = $designationYearWise + $paidYearLeaves + $designationMonthWise + $paidMonthLeaves;
$ifSalaryExists = \App\EmpPayment::where('idMonth', $month)->where('idFinancialYear', $financialYear)->where('idSchool', Auth::guard('school')->user()->idSchool)->where('idEmployee', $value->idEmployee)->first();
if ($ifSalaryExists == null) {
$emp_shift = \App\AssignShift::where('idEmployee', '=', $value->idEmployee)->first();
if ($emp_shift != null) {
$shift = \App\Shift::where('idShift', '=', $emp_shift->idShift)->first();
}
$emp_salstr = \App\SalaryStructure::where('idEmployee', '=', $value->idEmployee)->where('idFinancialYear', '=', $financialYear)->first();
if ($emp_salstr != null) {
$deductions = \App\SalaryStrDeduction::where('idSalaryStr', '=', $emp_salstr->idSalaryStr)->get();
$earnings = \App\SalaryStrAllowances::where('idSalaryStr', '=', $emp_salstr->idSalaryStr)->get();
if ($emp_salstr != null) {
foreach ($earnings as $earning) {
$basic = $basic + $earning->amount;
}
foreach ($deductions as $deduction) {
$deductionName = \App\Deduction::where('idDeduction', '=', $deduction->idDeduction)->first();
if ($deductionName != null) {
if (str_contains($deductionName->deductionName, 'P.T. deduction')) {
$ptDeduction = $deduction->amount;
}
}
}
}
}
}else{
$emp_shift = \App\AssignShift::where('idEmployee', '=', $value->idEmployee)->first();
if ($emp_shift != null) {
$shift = \App\Shift::where('idShift', '=', $emp_shift->idShift)->first();
}
$emp_salstr = \App\SalaryStructure::where('idEmployee', '=', $value->idEmployee)->where('idFinancialYear', '=', $financialYear)->first();
if ($emp_salstr != null) {
$deductions = \App\SalaryStrDeduction::where('idSalaryStr', '=', $emp_salstr->idSalaryStr)->get();
$earnings = \App\SalaryStrAllowances::where('idSalaryStr', '=', $emp_salstr->idSalaryStr)->get();
if ($emp_salstr != null) {
foreach ($earnings as $earning) {
$basic = $basic + $earning->amount;
}
foreach ($deductions as $deduction) {
$deductionName = \App\Deduction::where('idDeduction', '=', $deduction->idDeduction)->first();
if ($deductionName != null) {
if (str_contains($deductionName->deductionName, 'P.T. deduction')) {
$ptDeduction = $deduction->amount;
}
}
}
}
}
}
array_push($employeeId, $value->idEmployee);
?>
<tr>
<th scope="row"><?php echo e($k); ?></th>
<td><?php echo e(isset($value->enrollmentNo) ? $value->enrollmentNo : ''); ?></td>
<td><?php echo e($value->firstName); ?> <?php echo e($value->middleName); ?> <?php echo e($value->lastName); ?></td>
<td><?php echo e(isset($value->designation->designationName) ? $value->designation->designationName : ''); ?></td>
<td><?php if($value->doj): ?> <?php echo e(\Carbon\Carbon::parse($value->doj)->format('d.m.Y')); ?> <?php endif; ?></td>
<td><?php echo e($basic + $other_allowance - $increments); ?></td>
<td><?php echo e($increments); ?></td>
<td><?php echo e($basic + $other_allowance); ?></td>
<td><?php echo e($basic); ?></td>
<td><?php echo e($other_allowance); ?></td>
<td><?php echo e($basic + $other_allowance); ?></td>
<td><?php echo e($totalLeaves); ?></td>
<td id="<?php echo e($value->idEmployee); ?>_prev_month"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_pl"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_total_avail"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_lbalance"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_inc"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_ab"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_hf"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_lcount"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_ldeduction"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_deduction"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_gross"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_loan"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_canteen"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_epf"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_pt"><span class="text-muted">Generating..</span></td>
<td id="<?php echo e($value->idEmployee); ?>_salary"><span class="text-muted">Generating..</span></td>
</tr>
<?php $k++; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody>
</table>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
var table = $('#salary').DataTable({
dom: 'Bfrtip',
pageLength: 500,
buttons: [
'excel', 'csv'
]
});
$(document).ready(function() {
$('#print_data').hide();
$('select[name="idDepartment"]').on('change', function() {
var departmentID = $(this).val();
if(departmentID) {
$.ajax({
url: "<?php echo e(url('/school/departments')); ?>"+'/' +departmentID + "/designations",
type: "GET",
dataType: "json",
success:function(data) {
$('#idDesignation').empty();
$('#idDesignation').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-all" id="selectall"></div>');
$.each(data, function(key, value) {
$('#idDesignation').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:100px;">'+value+'</label><input type="checkbox" name="designations[]" value="'+key+'" class="designationclass"></div>');
});
}
});
}else{
$('select[name="idDesignation"]').empty();
}
});
fetchEmployees(0);
});
<?php if(isset($financialYear) && isset($month)): ?>
function printData(){
const url = window.location.href;
window.location.href = url.replace("salgen", "salgen-print");;
}
<?php endif; ?>
function fetchEmployees(posi){
var idEmployee = <?php echo json_encode($employeeId);?>;
var total = idEmployee.length;
var percentage = (posi/total)* 100;
$('#salarybar').css('width',percentage.toFixed(2)+"%");
if(percentage == 100){
$('#salaryparent').hide();
alert("Salary generated successfully");
}
var createRequestObject = {};
<?php if(isset($financialYear)): ?>
createRequestObject["fy"] = "<?php echo e($financialYear); ?>";
<?php endif; ?>
<?php if(isset($month)): ?>
createRequestObject["idMonth"] = "<?php echo e($month); ?>";
createRequestObject['year'] ="<?php echo e($year); ?>";
createRequestObject["idEmployee"] = idEmployee[posi];
createRequestObject["pos"] = posi;
if(idEmployee.length > posi){
$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("X-CSRF-TOKEN", "<?php echo e(csrf_token()); ?>");
request.setRequestHeader('Content-Type', 'application/json');
},
url: "<?php echo e(url('/school/salgen')); ?>",
data: JSON.stringify({
fy : createRequestObject["fy"],
idMonth : createRequestObject["idMonth"],
idEmployee : createRequestObject["idEmployee"],
pos : createRequestObject["pos"],
year : createRequestObject['year']
}),
processData: false,
success: function(msg) {
$("#"+msg.data.idEmployee+"_p").html(msg.data.present);
$("#"+msg.data.idEmployee+"_ab").html(msg.data.absent);
$("#"+msg.data.idEmployee+"_hf").html(msg.data.half_day);
$("#"+msg.data.idEmployee+"_ia").html(msg.data.incomplete);
$("#"+msg.data.idEmployee+"_pl").html(msg.data.paid_leave);
$("#"+msg.data.idEmployee+"_leave").html(msg.data.leave);
$("#"+msg.data.idEmployee+"_salary").html(msg.data.salary);
$("#"+msg.data.idEmployee+"_loan").html(msg.data.loan);
$("#"+msg.data.idEmployee+"_canteen").html(msg.data.canteen);
$("#"+msg.data.idEmployee+"_inc").html(msg.data.incomplete);
$("#"+msg.data.idEmployee+"_prev_month").html(msg.data.prev);
$("#"+msg.data.idEmployee+"_during_month").html(msg.data.current);
$("#"+msg.data.idEmployee+"_total_avail").html(msg.data.total);
$("#"+msg.data.idEmployee+"_lbalance").html(msg.data.balance);
$("#"+msg.data.idEmployee+"_lcount").html(msg.data.leave_count);
$("#"+msg.data.idEmployee+"_ldeduction").html(msg.data.deduction);
$("#"+msg.data.idEmployee+"_deduction").html(msg.data.salary_deduction);
$("#"+msg.data.idEmployee+"_gross").html(msg.data.gross_salary);
$("#"+msg.data.idEmployee+"_epf").html(msg.data.epf);
$("#"+msg.data.idEmployee+"_pt").html(msg.data.pt);
if(msg.data.btEnable == 1){
$("#"+msg.data.idEmployee+"_gen").html('<button class="btn btn-primary" id="'+msg.data.idEmployee+'_bt" onclick="generateSalary('+msg.data.idEmployee+','+createRequestObject["idMonth"]+','+createRequestObject["fy"]+','+createRequestObject["year"]+')">Confirm and Generate Salary</button>');
}else $("#"+msg.data.idEmployee+"_gen").empty();
var currentPos = +msg.data.pos + 1;
fetchEmployees(currentPos);
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Failed to generate salary for a employee. Skipping that employee");
var currentPos = +posi + 1;
fetchEmployees(currentPos);
}
});
}else{
//$('#print_data').show();
table.rows().invalidate().draw();
}
<?php endif; ?>
}
function generateSalary(idEmployee,month,fy,year){
$("#"+idEmployee+"_bt").text('Generating please wait..');
$("#"+idEmployee+"_bt").prop('disabled', true);
$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("X-CSRF-TOKEN", "<?php echo e(csrf_token()); ?>");
request.setRequestHeader('Content-Type', 'application/json');
},
url: "<?php echo e(url('/school/pay-salary')); ?>",
data: JSON.stringify({
fy : fy,
idMonth : month,
year : year,
employees : idEmployee
}),
processData: false,
success: function(msg) {
$("#"+msg.data.idEmployee+"_gen").empty();
$("#"+msg.data.idEmployee+"_gen").html('<a href="<?php echo e(url('school/emppayments')); ?>" target="_blank">Click to view generated salary</a>');
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Failed to generate salary");
$("#"+idEmployee+"_bt").text('Confirm and Generate Salary');
$("#"+idEmployee+"_bt").prop('disabled', false);
}
});
}
$('.selectAll').on('click', function () {
var checkAll = this.checked;
if(checkAll === true){
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}else{
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}
});
$(document).on('click', '.select-all', function(){
var checkAll = this.checked;
if(checkAll === true){
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
var designationIds = [];
$("input:checkbox[name='designations[]']:checked").each(function () {
designationIds.push($(this).val());
});
if (designationIds.length > 0) {
$.ajax({
url: "<?php echo e(url('/school/designations')); ?>"+'/' +designationIds + "/employees",
type: "GET",
dataType: "json",
success:function(data) {
$('#idEmployee').empty();
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
$.each(data, function(key, value) {
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="employees[]" value="'+key+'" class="empallselect"></div>');
});
}
});
}
}else{
$('#idEmployee').empty();
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}
});
$(document).on('click', '.designationclass', function(){
var designationIds = [];
$("input:checkbox[name='designations[]']:checked").each(function () {
designationIds.push($(this).val());
});
if (designationIds.length > 0) {
$.ajax({
url: "<?php echo e(url('/school/designations')); ?>"+'/' +designationIds + "/employees",
type: "GET",
dataType: "json",
success:function(data) {
$('#idEmployee').empty();
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-allstd" id="selectallstd"></div>');
$.each(data, function(key, value) {
$('#idEmployee').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:50px;">'+value+'</label><input type="checkbox" name="employees[]" value="'+key+'" class="empallselect"></div>');
});
}
});
}else{
$('#idEmployee').empty();
}
});
$(document).on('click', '.select-allstd', function(){
var checkAllstd = this.checked;
if(checkAllstd === true){
$("input:checkbox[name='employees[]']").each(function () {
this.checked = checkAllstd;
});
}else{
$('.empallselect').each(function () {
this.checked = checkAllstd;
});
}
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Copyright © 2021 -