latest commit 19-05-2025
This commit is contained in:
parent
e1d3064cd5
commit
8a1dc9dd4d
@ -243,6 +243,10 @@ $routes->post('payslip/checkExistPay', 'Payslip::checkExistPay');
|
|||||||
$routes->post('payslip/callsp', 'Payslip::callsp');
|
$routes->post('payslip/callsp', 'Payslip::callsp');
|
||||||
$routes->get('payslip/editPayslip/(:any)', 'Payslip::editPayslip/$1');
|
$routes->get('payslip/editPayslip/(:any)', 'Payslip::editPayslip/$1');
|
||||||
$routes->post('payslip/updatePayslip', 'Payslip::updatePayslip');
|
$routes->post('payslip/updatePayslip', 'Payslip::updatePayslip');
|
||||||
|
$routes->post('payslip/isPaySlipGenerated', 'Payslip::isPaySlipGenerated');
|
||||||
|
$routes->post('payslip/allowEdit', 'Payslip::allowEdit');
|
||||||
|
|
||||||
|
|
||||||
// Application Requisition Flow Routes
|
// Application Requisition Flow Routes
|
||||||
$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'Requisition', 'Requisitionform::requisitionlisting');
|
$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'Requisition', 'Requisitionform::requisitionlisting');
|
||||||
$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'RequisitionForm', 'Requisitionform::requisition');
|
$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'RequisitionForm', 'Requisitionform::requisition');
|
||||||
|
|||||||
@ -1074,7 +1074,7 @@ class Payslip extends BaseController
|
|||||||
$result = array_merge($employee, $driver);
|
$result = array_merge($employee, $driver);
|
||||||
|
|
||||||
|
|
||||||
$HTML = "";
|
$HTML = "<option value='-1'>Select Employee</option>";
|
||||||
|
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
|
|
||||||
@ -1529,6 +1529,46 @@ class Payslip extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isPaySlipGenerated(){
|
||||||
|
|
||||||
|
$empid = $this->request->getPost('employee');
|
||||||
|
$payon = $this->request->getPost('payon');
|
||||||
|
|
||||||
|
$is_driver = $this->driver_model->getDriverName($empid,1);
|
||||||
|
|
||||||
|
if($is_driver){
|
||||||
|
$result = $this->driver_model->checkDriverExistPay($empid, $payon);
|
||||||
|
return $this->response->setJSON(['count' => count($result)]);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$result = $this->payroll_model->checkExistPayData($empid, $payon);
|
||||||
|
return $this->response->setJSON(['count' => count($result)]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function allowEdit(){
|
||||||
|
|
||||||
|
$empid = $this->request->getPost('employee');
|
||||||
|
$payon = $this->request->getPost('payon');
|
||||||
|
|
||||||
|
$is_driver = $this->driver_model->getDriverName($empid,1);
|
||||||
|
|
||||||
|
if($is_driver){
|
||||||
|
|
||||||
|
$result = $this->driver_model->allowEdit($empid, $payon);
|
||||||
|
return $this->response->setJSON(['result' => $result]);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$result = $this->payroll_model->allowEdit($empid, $payon);
|
||||||
|
return $this->response->setJSON(['result' => $result]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -264,6 +264,40 @@ class Driver_model extends Model
|
|||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function allowEdit($empid, $payon)
|
||||||
|
{
|
||||||
|
// Start a transaction
|
||||||
|
$this->db->transBegin();
|
||||||
|
|
||||||
|
// Delete record from t_payroll
|
||||||
|
$builder1 = $this->db->table('t_driver_payroll')
|
||||||
|
->where('PayOn', $payon)
|
||||||
|
->where('driver_id', $empid);
|
||||||
|
|
||||||
|
$deleteSuccess = $builder1->delete();
|
||||||
|
|
||||||
|
|
||||||
|
// Check if either failed
|
||||||
|
if ($deleteSuccess === false ) {
|
||||||
|
// Rollback all changes if any query failed
|
||||||
|
$this->db->transRollback();
|
||||||
|
return [
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Transaction failed: Delete or update unsuccessful.' ,
|
||||||
|
'result' => false
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// If both succeeded, commit the transaction
|
||||||
|
$this->db->transCommit();
|
||||||
|
return [
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Both t_driver_payroll row deleted successfully...!!',
|
||||||
|
'result' => true
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function getMonthlyPayDetails($driver_id, $PayOn)
|
function getMonthlyPayDetails($driver_id, $PayOn)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('t_driver_monthly_pay_inputs MonthlyPay ')
|
$builder = $this->db->table('t_driver_monthly_pay_inputs MonthlyPay ')
|
||||||
|
|||||||
@ -74,6 +74,47 @@ class Payroll_model extends Model
|
|||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function allowEdit($empid, $payon)
|
||||||
|
{
|
||||||
|
// Start a transaction
|
||||||
|
$this->db->transBegin();
|
||||||
|
|
||||||
|
// Delete record from t_payroll
|
||||||
|
$deleteSuccess = $this->db->table('t_payroll')
|
||||||
|
->where('PayOn', $payon)
|
||||||
|
->where('EmpID', $empid)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
// Update record in t_monthly_pay_inputs
|
||||||
|
$updateSuccess = $this->db->table('t_monthly_pay_inputs')
|
||||||
|
->where('Month_Year', $payon)
|
||||||
|
->where('EmpID', $empid)
|
||||||
|
->set('is_payslip_generated', 0)
|
||||||
|
->update();
|
||||||
|
|
||||||
|
// Check if either failed
|
||||||
|
if ($deleteSuccess === false || $updateSuccess === false) {
|
||||||
|
// Rollback all changes if any query failed
|
||||||
|
$this->db->transRollback();
|
||||||
|
return [
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Transaction failed: Delete or update unsuccessful.' ,
|
||||||
|
'result' => false
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// If both succeeded, commit the transaction
|
||||||
|
$this->db->transCommit();
|
||||||
|
return [
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Both t_payroll row deleted and t_monthly_pay_inputs updated successfully...!!',
|
||||||
|
'result' => true
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function checkFileDetailsExists2($PayOn, $EmpId)
|
function checkFileDetailsExists2($PayOn, $EmpId)
|
||||||
{
|
{
|
||||||
//echo $EmpId;
|
//echo $EmpId;
|
||||||
|
|||||||
@ -37,6 +37,84 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#Employee").change(function() {
|
||||||
|
|
||||||
|
let payon = $('#PayOn').val();
|
||||||
|
let employee = $('#Employee').val();
|
||||||
|
|
||||||
|
if (payon != '-1' && employee != '-1') {
|
||||||
|
$('#loader').show();
|
||||||
|
$.ajax({
|
||||||
|
data: {
|
||||||
|
payon,
|
||||||
|
employee
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
url: "<?php echo base_url(); ?>payslip/isPaySlipGenerated",
|
||||||
|
success: function(data) {
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
|
||||||
|
if(data.count > 0){
|
||||||
|
|
||||||
|
$('#allowEdit').show();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$('#allowEdit').hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error("Error occurred: " + error);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$('#loader').hide();
|
||||||
|
console.log("Request completed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert('Please select the Employee');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#allowEdit").click(function() {
|
||||||
|
let payon = $('#PayOn').val();
|
||||||
|
let employee = $('#Employee').val();
|
||||||
|
|
||||||
|
if (payon != '-1' && employee != '-1') {
|
||||||
|
$('#loader').show();
|
||||||
|
$.ajax({
|
||||||
|
data: {
|
||||||
|
payon,
|
||||||
|
employee
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
url: "<?php echo base_url(); ?>payslip/allowEdit",
|
||||||
|
success: function(data) {
|
||||||
|
if (data && typeof data === 'object' && data.result?.status === "success") {
|
||||||
|
$('#allowEdit').hide();
|
||||||
|
alert("Edit allowed successfully for Employee -Id: " + employee + " for : " + payon + " Kindly visit the Monthly Pay Information ..!!");
|
||||||
|
} else {
|
||||||
|
alert("Error in Allow Edit");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error("Error occurred: " + error);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$('#loader').hide();
|
||||||
|
console.log("Request completed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert('Please select the Employee');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
$("#Calculate").click(function() {
|
$("#Calculate").click(function() {
|
||||||
var payon = $('#PayOn').val();
|
var payon = $('#PayOn').val();
|
||||||
var employee = $('#Employee').val();
|
var employee = $('#Employee').val();
|
||||||
@ -102,6 +180,7 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr
|
|||||||
$('form#PayslipGenerator').submit();
|
$('form#PayslipGenerator').submit();
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
alert("Payslip Downloaded Successfully..!");
|
alert("Payslip Downloaded Successfully..!");
|
||||||
|
$('#allowEdit').show();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -116,6 +195,7 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr
|
|||||||
$('form#PayslipGenerator').submit();
|
$('form#PayslipGenerator').submit();
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
alert("Salary Calculated Successfully..!");
|
alert("Salary Calculated Successfully..!");
|
||||||
|
$('#allowEdit').show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -158,7 +238,6 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr
|
|||||||
<form id="PayslipGenerator" action="<?php echo base_url() ?>PrintPdf" method="post" role="form" style="border:2px dotted; padding:5%">
|
<form id="PayslipGenerator" action="<?php echo base_url() ?>PrintPdf" method="post" role="form" style="border:2px dotted; padding:5%">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
|
|
||||||
<span for="selectmonth">Select Month</span>
|
<span for="selectmonth">Select Month</span>
|
||||||
<select id="PayOn" name="PayOn" class="form-control select2" style="width: 100%;">
|
<select id="PayOn" name="PayOn" class="form-control select2" style="width: 100%;">
|
||||||
<option value="-1">Select Payon Month</option>
|
<option value="-1">Select Payon Month</option>
|
||||||
@ -187,11 +266,18 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr
|
|||||||
<br />
|
<br />
|
||||||
<!-- <input type="checkbox" name="All" id="All"> Select All<br> -->
|
<!-- <input type="checkbox" name="All" id="All"> Select All<br> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
<div class="col-md-6" align="right">
|
<div class="col-md-6" align="right">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 col-md-offset-6" align="right" style="padding-top: 23px;">
|
<div class="col-md-4 col-md-offset-6" align="right" style="padding-top: 23px;">
|
||||||
<input type="button" class="btn btn-info" id="Calculate" value="Calculate Pay" />
|
<input type="button" class="btn btn-info" id="Calculate" value="Calculate Pay" />
|
||||||
|
<input type="button" class="btn btn-danger" id="allowEdit" value="Allow Edit" style="display:none;" />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<?php
|
<?php
|
||||||
helper('form');
|
helper('form');
|
||||||
@ -212,14 +298,8 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr
|
|||||||
<?php echo session()->getFlashdata('success'); ?>
|
<?php echo session()->getFlashdata('success'); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<?php // echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button></div>');
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user