317 lines
12 KiB
PHP
317 lines
12 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use App\Models\Emppaydate_model;
|
|
|
|
use App\Models\Payroll_model;
|
|
|
|
|
|
/**
|
|
* Module : Payslip
|
|
* Emppaydate Class to control all Employee paydate related operations.
|
|
* @author : Venba
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
*/
|
|
class Emppaydate extends BaseController
|
|
{
|
|
protected $emppaydate_model;
|
|
protected $payroll_model;
|
|
protected $session;
|
|
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->emppaydate_model = new Emppaydate_model();
|
|
$this->payroll_model = new payroll_model();
|
|
$this->session = session();
|
|
helper('form'); //$this->load->library('form_validation');
|
|
// $this->load->library('pagination');
|
|
|
|
$this->isLoggedIn();
|
|
|
|
}
|
|
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Employee Pay Details';
|
|
|
|
$this->loadViews("emppayListing", $this->global);
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the payment list for a employee.
|
|
*/
|
|
function emppayListing()
|
|
{
|
|
|
|
|
|
|
|
$data['userRecords'] = $this->emppaydate_model->emppayListing();
|
|
|
|
$this->global['pageTitle'] = 'Employee Pay List';
|
|
|
|
$this->loadViews("emppayListing", $this->global, $data, NULL);
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the add new payment for an employee.
|
|
*/
|
|
function addemppaydate()
|
|
{
|
|
$q = "addemppaydate";
|
|
|
|
|
|
$result['empdetails'] = $this->payroll_model->getEmpID($q);
|
|
|
|
|
|
|
|
$this->global['pageTitle'] = 'Add Employee Pay';
|
|
|
|
$this->loadViews("addemppaydate", $this->global, $result);
|
|
}
|
|
|
|
|
|
function addNewemppay()
|
|
{
|
|
|
|
|
|
helper('form'); //$this->load->library('form_validation');
|
|
$EmpID = $this->request->getPost('EmpID');
|
|
// $this->validator->setRules([
|
|
// 'ContactNumber'=> 'trim|required|min_length[10]|max_length[10]',
|
|
// 'EmpID'=> 'trim|required',
|
|
// 'HRA_Rate'=> 'trim|required',
|
|
// 'HRA_Amount'=> 'trim|required',
|
|
// 'Basic_Pay'=> 'trim|required',
|
|
// 'Total_salary'=> 'trim|required',
|
|
// 'Allowances'=> 'trim|required',
|
|
// 'PF_Rate'=> 'trim|required',
|
|
// 'ESI_Rate'=> 'trim|required',
|
|
// 'Food_Allowances'=> 'trim|required',
|
|
// 'Incentives'=> 'trim|required']);
|
|
|
|
|
|
|
|
// if ($this->validator->run() == FALSE || $EmpID == -1) {
|
|
// $this->addemppaydate();
|
|
// } else {
|
|
|
|
$EmpID = $this->request->getPost('EmpID');
|
|
$Total_Salary = $this->request->getPost('Total_salary');
|
|
$Basic_Pay = $this->request->getPost('Basic_Pay');
|
|
$HRA_Rate = $this->request->getPost('HRA_Rate');
|
|
$HRA_Amount = $this->request->getPost('HRA_Amount');
|
|
|
|
$Allowances = $this->request->getPost('Allowances');
|
|
$PF_Rate = $this->request->getPost('PF_Rate');
|
|
$ESI_Rate = $this->request->getPost('ESI_Rate');
|
|
$Food_Allowances = $this->request->getPost('Food_Allowances');
|
|
$Incentives = $this->request->getPost('Incentives');
|
|
|
|
$Loan_Amount = $this->request->getPost('Loan_Amount');
|
|
$Load_Issued_date = $this->request->getPost('loan_issued_date');
|
|
if (!empty($Load_Issued_date)) {
|
|
$Load_Issued_date = $Load_Issued_date = format_date($Load_Issued_date);
|
|
} else {
|
|
$Load_Issued_date = null;
|
|
}
|
|
$Due_Amount = $this->request->getPost('monthly_due');
|
|
$Due_Started = $this->request->getPost('due_started');
|
|
if (!empty($Due_Started)) {
|
|
$Due_Started = $Due_Started = format_date($Due_Started);
|
|
} else {
|
|
$Due_Started = null;
|
|
}
|
|
|
|
|
|
$No_Of_Dues = $this->request->getPost('no_of_due');
|
|
$Paid_due = $this->request->getPost('paid_due');
|
|
$Remaining_Due = $this->request->getPost('remaining_due');
|
|
$Paid_Amount = $this->request->getPost('Paid_Amount');
|
|
|
|
|
|
|
|
$CreateBy = $this->session->get('userId');
|
|
$chked = $this->request->getPost('is_Active');
|
|
$IsActive = '1';
|
|
|
|
$emppay = array('EmpID' => $EmpID, 'TotalSalary' => $Total_Salary, 'Basic_Pay' => $Basic_Pay, 'HRA_Rate' => $HRA_Rate, 'HRA_Amount' => $HRA_Amount, 'Allowances' => $Allowances, 'PF_Rate' => $PF_Rate, 'ESI_Rate' => $ESI_Rate, 'Food_Allowances' => $Food_Allowances, 'Incentives' => $Incentives, 'Created_By' => $CreateBy);
|
|
$loandetails = array('EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Created_By' => $CreateBy);
|
|
|
|
|
|
$result = $this->emppaydate_model->addNewemppay($emppay);
|
|
if ($Loan_Amount != 0) {
|
|
$result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'add');
|
|
if ($result2 > 0) {
|
|
echo "<script>alert('Loan Information Saved successfully!');</script>";
|
|
} else {
|
|
echo "<script>alert('Something Went Wrong..! Loan Information Not Saved. Try later..!');</script>";
|
|
}
|
|
}
|
|
if ($result > 0) {
|
|
echo "<script type='text/javascript'>alert('Employee Pay List Created successfully!');
|
|
window.location = '".base_url()."emppayListings';</script>";
|
|
} else {
|
|
echo "<script type='text/javascript'>alert('Employee Pay List Not Created!');
|
|
window.location = '".base_url()."emppayListings';</script>";
|
|
|
|
}
|
|
|
|
//}
|
|
// }
|
|
}
|
|
|
|
/**
|
|
* This function is used for editing purpose and it has oldest values only.
|
|
*/
|
|
function editOldemppay($paydataid = "")
|
|
{
|
|
|
|
$data['emppay'] = $this->emppaydate_model->getUserInfo($paydataid);
|
|
|
|
|
|
$this->global['pageTitle'] = 'Edit Employee Pay Monthly Details ';
|
|
|
|
$this->loadViews("editOldemppay", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* This function is used for stored new values after editing.
|
|
*/
|
|
function editemppay()
|
|
{
|
|
|
|
|
|
helper('form'); //$this->load->library('form_validation');
|
|
|
|
$Pay_Data_ID = $this->request->getPost('Pay_Data_ID');
|
|
|
|
//'Pay_Data_ID'=>'trim|required';
|
|
// $this->validator->setRules([
|
|
// 'EmpID'=> 'trim|required',
|
|
// 'Total_Salary'=> 'trim|required',
|
|
// 'Basic_Pay'=> 'trim|required',
|
|
// 'HRA_Rate'=> 'trim|required',
|
|
// 'Allowances'=> 'trim|required',
|
|
// 'PF_Rate'=> 'trim|required',
|
|
// 'ESI_Rate'=> 'trim|required',
|
|
// 'Food_Allowances'=> 'trim|required',
|
|
// 'Incentives'=> 'trim|required']);
|
|
|
|
// if ($this->validator->run() == FALSE) {
|
|
|
|
// $this->editOldemppay($Pay_Data_ID);
|
|
// } else {
|
|
|
|
$Pay_Data_ID = $this->request->getPost('Pay_Data_ID');
|
|
$EmpID = $this->request->getPost('EmpID');
|
|
$TotalSalary = $this->request->getPost('Total_Salary');
|
|
$Basic_Pay = $this->request->getPost('Basic_Pay');
|
|
$HRA_Rate = $this->request->getPost('HRA_Rate');
|
|
$HRA_Amount = $this->request->getPost('HRA_Amount');
|
|
|
|
$Allowances = $this->request->getPost('Allowances');
|
|
$PF_Rate = $this->request->getPost('PF_Rate');
|
|
$ESI_Rate = $this->request->getPost('ESI_Rate');
|
|
$loan_ID = $this->request->getPost('loanid');
|
|
$Loan_Amount = $this->request->getPost('Loan_Amount');
|
|
$Load_Issued_date = $this->request->getPost('loan_issued_date');
|
|
if (!empty($Load_Issued_date)) {
|
|
$Load_Issued_date = format_date($Load_Issued_date);
|
|
} else {
|
|
$Load_Issued_date = null;
|
|
}
|
|
|
|
|
|
$Due_Amount = $this->request->getPost('monthly_due');
|
|
$Due_Started = $this->request->getPost('due_started');
|
|
if (!empty($Due_Started)) {
|
|
$Due_Started = format_date($Due_Started);
|
|
} else {
|
|
$Due_Started = null;
|
|
}
|
|
|
|
|
|
//echo $Load_Issued_date. "-" . $Due_Started;die();
|
|
$No_Of_Dues = $this->request->getPost('no_of_due');
|
|
$Paid_due = $this->request->getPost('paid_due');
|
|
$Remaining_Due = $this->request->getPost('remaining_due');
|
|
$Paid_Amount = $this->request->getPost('Paid_Amount');
|
|
$is_Active = $this->request->getPost('is_Active');
|
|
$Last_Mod_By = $this->session->get('userId');
|
|
$Last_Mod_Time = date('d-m-Y h:i:sa');
|
|
$Food_Allowances = $this->request->getPost('Food_Allowances');
|
|
$Incentives = $this->request->getPost('Incentives');
|
|
|
|
|
|
|
|
|
|
|
|
$emppay = array('Pay_Data_ID' => $Pay_Data_ID, 'EmpID' => $EmpID, 'TotalSalary' => $TotalSalary, 'Basic_Pay' => $Basic_Pay, 'HRA_Rate' => $HRA_Rate, 'HRA_Amount' => $HRA_Amount, 'Allowances' => $Allowances, 'PF_Rate' => $PF_Rate, 'ESI_Rate' => $ESI_Rate, 'Food_Allowances' => $Food_Allowances, 'Incentives' => $Incentives, 'Last_Mod_By' => $Last_Mod_By);
|
|
$loandetails = array('Loan_ID' => $loan_ID, 'EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Last_Mod_By' => $Last_Mod_By);
|
|
|
|
|
|
if ($Loan_Amount != 0 and $loan_ID != '') {
|
|
$result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'update');
|
|
if ($result2 > 0) {
|
|
echo "<script>alert('Loan Information Saved successfully!');</script>";
|
|
} else {
|
|
echo "<script>alert('Something Went Wrong..! Loan Information Not Saved. Try later..!');</script>";
|
|
}
|
|
} else if ($Loan_Amount != 0 and $loan_ID == '') {
|
|
$loandetails = array('EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Created_By' => $Last_Mod_By);
|
|
$result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'add');
|
|
if ($result2 > 0) {
|
|
echo "<script>alert('Loan Information Saved successfully!');</script>";
|
|
} else {
|
|
echo "<script>alert('Something Went Wrong..! Loan Information Not Saved. Try later..!');</script>";
|
|
}
|
|
}
|
|
|
|
|
|
$result = $this->emppaydate_model->editemppay($emppay);
|
|
if ($result == true) {
|
|
echo "<script type='text/javascript'>alert('Employee Status Updated Sucessfully..!');
|
|
window.location = '".base_url()."emppayListings';</script>";
|
|
} else {
|
|
echo "<script type='text/javascript'>alert('Update Failed..!';
|
|
window.location = '".base_url()."emppayListings';</script>";
|
|
|
|
}
|
|
|
|
// redirect('emppaydate/emppayListing');
|
|
// }
|
|
}
|
|
|
|
|
|
|
|
function deleteEmpPay()
|
|
{
|
|
$EmpID = $this->request->getPost('id');
|
|
//echo $EmpID;
|
|
$result = $this->emppaydate_model->deleteEmployeePay($EmpID);
|
|
if ($result == 1) {
|
|
echo "Deleted Sucessfully..!";
|
|
} else {
|
|
echo "Something Went wrong. Try Later..!";
|
|
}
|
|
}
|
|
|
|
|
|
}
|