345 lines
13 KiB
PHP
345 lines
13 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : emppaydate (Employee Payment details - Controller)
|
|
* emppaydate Class to control all employeepayment's related operations.
|
|
* @author : Venba Info Tech -
|
|
* @version : 1.1
|
|
* @since : 18 November 2017
|
|
*/
|
|
class emppaydate extends BaseController
|
|
{
|
|
/**
|
|
* default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('emppaydate_model');
|
|
$this->load->library('session');
|
|
$this->load->library('form_validation');
|
|
$this->isLoggedIn();
|
|
$this->CompanyName = $this->global['CompanyName'];
|
|
}
|
|
|
|
/**
|
|
* Index Page for this controller (default function of the class)
|
|
*/
|
|
public function index()
|
|
{
|
|
//$this->global['pageTitle'] = 'Resico : Employee Pay Details';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Employee Pay Details';
|
|
$this->loadViews("emppayListing", $this->global);
|
|
}
|
|
|
|
/**
|
|
* To load the payment list for a employee.
|
|
*/
|
|
function emppayListing()
|
|
{
|
|
|
|
|
|
$this->load->model('emppaydate_model');
|
|
|
|
$data['userRecords'] = $this->emppaydate_model->emppayListing();
|
|
|
|
//$this->global['pageTitle'] = 'Resico : Employee Pay List';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Employee Payment Details';
|
|
|
|
$this->loadViews("emppayListing", $this->global, $data, NULL);
|
|
}
|
|
|
|
/**
|
|
* To load the add new payment for an employee.
|
|
*/
|
|
function addemppaydate()
|
|
{
|
|
$q="addemppaydate";
|
|
$this->load->model('payroll_model');
|
|
$result['empdetails'] = $this->payroll_model->getEmpID($q);
|
|
//$this->global['pageTitle'] = 'Resico : Add Employee Pay';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Add Employee Pay';
|
|
$this->loadViews("addemppaydate", $this->global,$result);
|
|
|
|
}
|
|
|
|
/**
|
|
* To store Employeepayment data into DB.
|
|
*/
|
|
function addNewemppay()
|
|
{
|
|
|
|
|
|
$this->load->library('form_validation');
|
|
$EmpID = $this->input->post('EmpID');
|
|
$this->form_validation->set_rules('EmpID','EmpID','trim|required');
|
|
$this->form_validation->set_rules('HRA_Rate','HRA_Rate','trim|required');
|
|
$this->form_validation->set_rules('HRA_Amount','HRA_Amount','trim|required');
|
|
$this->form_validation->set_rules('Basic_Pay','Basic_Pay','trim|required');
|
|
$this->form_validation->set_rules('Total_salary','Total_salary','trim|required');
|
|
$this->form_validation->set_rules('Allowances','Allowances','trim|required');
|
|
$this->form_validation->set_rules('PF_Rate','PF_Rate','trim|required');
|
|
$this->form_validation->set_rules('ESI_Rate','ESI_Rate','trim|required');
|
|
$this->form_validation->set_rules('Food_Allowances','Food_Allowances','trim|required');
|
|
|
|
|
|
if($this->form_validation->run() == FALSE || $EmpID == -1)
|
|
{
|
|
$this->addemppaydate();
|
|
}
|
|
else
|
|
{
|
|
|
|
$EmpID = $this->input->post('EmpID');
|
|
$Total_Salary=$this->input->post('Total_salary');
|
|
$Basic_Pay=$this->input->post('Basic_Pay');
|
|
$HRA_Rate=$this->input->post('HRA_Rate');
|
|
$HRA_Amount=$this->input->post('HRA_Amount');
|
|
|
|
$Allowances=$this->input->post('Allowances');
|
|
$PF_Rate=$this->input->post('PF_Rate');
|
|
$ESI_Rate=$this->input->post('ESI_Rate');
|
|
$Food_Allowances=$this->input->post('Food_Allowances');
|
|
|
|
$Loan_Amount=$this->input->post('Loan_Amount');
|
|
$Load_Issued_date=$this->input->post('loan_issued_date');
|
|
if(!empty($Load_Issued_date)){
|
|
$Load_Issued_date=$Load_Issued_date=date('Y-m-d',strtotime($Load_Issued_date));
|
|
}else{$Load_Issued_date=null;}
|
|
$Due_Amount=$this->input->post('monthly_due');
|
|
$Due_Started=$this->input->post('due_started');
|
|
if(!empty($Due_Started)){
|
|
$Due_Started=$Due_Started=date('Y-m-d',strtotime($Due_Started));
|
|
}else{$Due_Started=null;}
|
|
|
|
|
|
$No_Of_Dues=$this->input->post('no_of_due');
|
|
$Paid_due=$this->input->post('paid_due');
|
|
$Remaining_Due=$this->input->post('remaining_due');
|
|
$Paid_Amount=$this->input->post('Paid_Amount');
|
|
|
|
|
|
|
|
$CreateBy = $this->session->userdata ( 'userId' );
|
|
$chked = $this->input->post('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,'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>alert('Employee Pay List Created successfully!');</script>";
|
|
redirect('emppaydate/emppayListing','refresh');
|
|
|
|
}
|
|
else
|
|
{
|
|
echo "<script>alert('Employee Pay List Not Created!');</script>";
|
|
redirect('emppaydate/emppayListing','refresh');
|
|
|
|
}
|
|
|
|
//}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* For editing purpose and it has oldest values only.
|
|
*/
|
|
function editOldemppay($paydataid="")
|
|
{
|
|
|
|
$data['emppay'] = $this->emppaydate_model->getUserInfo($paydataid);
|
|
|
|
//$this->global['pageTitle'] = 'Resico : Edit Employee Pay Monthly Details ';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Edit Employee Payment Details ';
|
|
|
|
$this->loadViews("editOldemppay", $this->global, $data,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* For stored new values after editing.
|
|
*/
|
|
function editemppay()
|
|
{
|
|
|
|
|
|
$this->load->library('form_validation');
|
|
|
|
$Pay_Data_ID= $this->input->post('Pay_Data_ID');
|
|
|
|
$this->form_validation->set_rules('EmpID','EmpID','trim|required');
|
|
$this->form_validation->set_rules('Total_Salary','Total_Salary','trim|required');
|
|
$this->form_validation->set_rules('Basic_Pay','Basic_Pay','trim|required');
|
|
$this->form_validation->set_rules('HRA_Rate','HRA_Rate','trim|required');
|
|
|
|
$this->form_validation->set_rules('Allowances','Allowances','trim|required');
|
|
$this->form_validation->set_rules('PF_Rate','PF_Rate','trim|required');
|
|
$this->form_validation->set_rules('ESI_Rate','ESI_Rate','trim|required');
|
|
$this->form_validation->set_rules('Food_Allowances','Food_Allowances','trim|required');
|
|
|
|
|
|
|
|
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
|
|
$this->editOldemppay($Pay_Data_ID);
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
$Pay_Data_ID=$this->input->post('Pay_Data_ID');
|
|
$EmpID = $this->input->post('EmpID');
|
|
$TotalSalary=$this->input->post('Total_Salary');
|
|
$Basic_Pay=$this->input->post('Basic_Pay');
|
|
$HRA_Rate=$this->input->post('HRA_Rate');
|
|
$HRA_Amount=$this->input->post('HRA_Amount');
|
|
|
|
$Allowances=$this->input->post('Allowances');
|
|
$PF_Rate=$this->input->post('PF_Rate');
|
|
$ESI_Rate=$this->input->post('ESI_Rate');
|
|
$loan_ID =$this->input->post('loanid');
|
|
$Loan_Amount=$this->input->post('Loan_Amount');
|
|
$Load_Issued_date=$this->input->post('loan_issued_date');
|
|
if(!empty($Load_Issued_date)){$Load_Issued_date=date('Y-m-d',strtotime($Load_Issued_date));}
|
|
else{$Load_Issued_date=null;}
|
|
|
|
|
|
$Due_Amount=$this->input->post('monthly_due');
|
|
$Due_Started=$this->input->post('due_started');
|
|
if(!empty($Due_Started)){$Due_Started=date('Y-m-d',strtotime($Due_Started));}
|
|
else{$Due_Started=null;}
|
|
|
|
|
|
$No_Of_Dues=$this->input->post('no_of_due');
|
|
$Paid_due=$this->input->post('paid_due');
|
|
$Remaining_Due=$this->input->post('remaining_due');
|
|
$Paid_Amount=$this->input->post('Paid_Amount');
|
|
$is_Active=$this->input->post('is_Active');
|
|
$Last_Mod_By=$this->session->userdata('userId');
|
|
$Last_Mod_Time=date('d-m-Y h:i:sa');
|
|
$Food_Allowances=$this->input->post('Food_Allowances');
|
|
|
|
|
|
|
|
|
|
$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,'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>alert('Employee Status Updated Sucessfully..!');</script>";
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
echo "<script>alert('Update Failed..!')</script>";
|
|
$this->session->set_flashdata('error', 'updation failed');
|
|
}
|
|
|
|
|
|
redirect('emppaydate/emppayListing');
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* To Delete employee payment details
|
|
*/
|
|
function deleteEmpPay()
|
|
{
|
|
$EmpID = $this->input->post('id');
|
|
$result = $this->emppaydate_model->deleteEmployeePay($EmpID);
|
|
if($result == 1)
|
|
{
|
|
echo "Deleted Sucessfully..!";
|
|
}
|
|
else
|
|
{
|
|
echo "Something Went wrong. Try Later..!";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* To load pagenotfound view
|
|
*/
|
|
function pageNotFound()
|
|
{
|
|
//$this->global['pageTitle'] = 'Resico : 404 - Page Not Found';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
|
|
/**
|
|
* To Convert the dateformat (date with time) and stored into DB
|
|
*/
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
|
|
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
|
|
return $retDate;
|
|
}
|
|
}
|
|
|
|
?>
|