452 lines
16 KiB
PHP
Executable File
452 lines
16 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : Cost Center (Cost Center Controller)
|
|
* User Class to control all user related operations.
|
|
* @author : VenbaMail Mali
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
*/
|
|
class emppaydate extends BaseController
|
|
{
|
|
/**
|
|
* This is 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->load->library('pagination');
|
|
|
|
$this->isLoggedIn();
|
|
}
|
|
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : Employee Pay Details';
|
|
|
|
$this->loadViews("emppayListing", $this->global);
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the payment list for a employee.
|
|
*/
|
|
function emppayListing()
|
|
{
|
|
|
|
|
|
$this->load->model('emppaydate_model');
|
|
|
|
$data['userRecords'] = $this->emppaydate_model->emppayListing();
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : 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";
|
|
$this->load->model('payroll_model');
|
|
|
|
$result['empdetails'] = $this->payroll_model->getEmpID($q);
|
|
|
|
//$data['emp_id'] = $this->monthlypay_model->getmonthlypay();
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Add Employee Pay';
|
|
|
|
$this->loadViews("addemppaydate", $this->global,$result);
|
|
|
|
}
|
|
|
|
|
|
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('OT_Rate','OT_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');
|
|
//$Loan_Amount=$this->input->post('Loan_Amount');
|
|
// echo "before if";
|
|
// if($Loan_Amount != 0.00 || $Loan_Amount != "")
|
|
// {
|
|
// echo "indisde ";
|
|
// $Load_Issued_date=$this->input->post('loan_issued_date');
|
|
// $Due_Amount=$this->input->post('monthly_due');
|
|
// $Due_Started=$this->input->post('due_started');
|
|
// echo $Load_Issued_date ."-".$Due_Amount."-".$Due_Started;
|
|
// if($Load_Issued_date == "" || $Due_Started =="" || $Due_Amount == "" || $Due_Amount == 0)
|
|
// //echo "FAIL";die();
|
|
|
|
// $this->form_validation->set_rules('Loan_Amount','Loan_Amount','trim|required');
|
|
// $this->form_validation->set_rules('loan_issued_date','loan_issued_date','trim|required');
|
|
// $this->form_validation->set_rules('monthly_due','monthly_due','trim|required');
|
|
// $this->form_validation->set_rules('Food_Allodue_startedwances','due_started','trim|required');
|
|
|
|
// }
|
|
//die();
|
|
|
|
if($this->form_validation->run() == FALSE || $EmpID == -1)
|
|
{
|
|
$this->addemppaydate();
|
|
}
|
|
else
|
|
{
|
|
//$Pay_Data_ID=$this->input->post('Pay_Data_ID');
|
|
$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');
|
|
$OT_Rate=$this->input->post('OT_Rate');
|
|
$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=$this->getDateformat2($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=$this->getDateformat2($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');
|
|
|
|
//$All = $this->input->post('All');
|
|
|
|
$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, 'OT_Rate'=>$OT_Rate, 'Allowances'=>$Allowances, 'PF_Rate'=>$PF_Rate, 'ESI_Rate'=>$ESI_Rate ,'Food_Allowances'=>$Food_Allowances,'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,'Created_By'=>$CreateBy);
|
|
|
|
//print_r($emppay);die();
|
|
$result = $this->emppaydate_model->addNewemppay($emppay);
|
|
|
|
if($result > 0)
|
|
{
|
|
// $this->session->set_flashdata('success', 'New Asset created successfully');
|
|
|
|
redirect('emppaydate/emppayListing','refresh');
|
|
echo "<script>alert('Employee Pay List Created successfully!');</script>";
|
|
}
|
|
else
|
|
{
|
|
redirect('emppaydate/emppayListing','refresh');
|
|
echo "<script>alert('Employee Pay List Not Created!');</script>";
|
|
}
|
|
|
|
//}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This function is used for editing purpose and it has oldest values only.
|
|
*/
|
|
function editOldemppay($paydataid="")
|
|
{
|
|
|
|
$data['emppay'] = $this->emppaydate_model->getUserInfo($paydataid);
|
|
// print_r($data);
|
|
//$data['monthly_pay_inputs'] = $this->monthlylisting_model->getUserInfo($employeeid);
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Edit Employee Pay Monthly Details ';
|
|
|
|
$this->loadViews("editOldemppay", $this->global, $data,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* This function is used 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('Pay_Data_ID','Pay_Data_ID','trim|required');
|
|
$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('OT_Rate','OT_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');
|
|
$OT_Rate=$this->input->post('OT_Rate');
|
|
$Allowances=$this->input->post('Allowances');
|
|
$PF_Rate=$this->input->post('PF_Rate');
|
|
$ESI_Rate=$this->input->post('ESI_Rate');
|
|
$Loan_Amount=$this->input->post('Loan_Amount');
|
|
$Load_Issued_date=$this->input->post('loan_issued_date');
|
|
if(!empty($Load_Issued_date)){$Load_Issued_date=$this->getDateformat2($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=$this->getDateformat2($Due_Started);}
|
|
else{$Due_Started=null;}
|
|
|
|
//echo $Load_Issued_date. "-" . $Due_Started;die();
|
|
$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');
|
|
// $chked = $this->input->post('is_Active');
|
|
|
|
// if( $chked != '')
|
|
// {
|
|
// $IsActive = '1';
|
|
// }
|
|
// else
|
|
// {
|
|
// $IsActive = '0';
|
|
// }
|
|
|
|
|
|
|
|
//$emppaydatas = array();
|
|
|
|
|
|
|
|
$emppaydatas = array('Pay_Data_ID'=>$Pay_Data_ID,'EmpID'=>$EmpID,'TotalSalary'=>$TotalSalary,'Basic_Pay'=>$Basic_Pay,'HRA_Rate'=>$HRA_Rate,'HRA_Amount'=>$HRA_Amount, 'OT_Rate'=>$OT_Rate, 'Allowances'=>$Allowances, 'PF_Rate'=>$PF_Rate, 'ESI_Rate'=>$ESI_Rate ,'Food_Allowances'=>$Food_Allowances,'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,'Last_Mod_By'=>$Last_Mod_By,'Last_Mod_Time'=>$Last_Mod_Time);
|
|
// print_r($emppaydatas);die();
|
|
|
|
$result = $this->emppaydate_model->editemppay($emppaydatas);
|
|
|
|
|
|
if($result == true)
|
|
{
|
|
echo "<script>alert('Employee Status Updated Sucessfully..!');</script>";
|
|
//$this->session->set_flashdata('success', 'updated successfully');
|
|
|
|
}
|
|
else
|
|
{
|
|
echo "<script>alert('Update Failed..!')</script>";
|
|
$this->session->set_flashdata('error', 'updation failed');
|
|
}
|
|
|
|
|
|
redirect('emppaydate/emppayListing');
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* This function is used load user edit information
|
|
* @param number $userId : Optional : This is user id
|
|
*/
|
|
/*function editOldcost($CostCode = NULL)
|
|
{
|
|
|
|
if($CostCode == '')
|
|
{
|
|
$CostCenterID = $_GET['CostCode'];
|
|
}
|
|
else
|
|
{
|
|
|
|
$CostCenterID = $CostCode; }
|
|
|
|
$data['CostMaster'] = $this->costcenter_model->GetCostCenterMaster($CostCenterID);
|
|
$data['CostDepts'] = $this->costcenter_model->GetCostCenterDepartment($CostCenterID);
|
|
$data['CostBudget'] = $this->costcenter_model->GetCostCenterBudget($CostCenterID);
|
|
// $data['DeptList'] = $this->costcenter_model->GetDepartmentNotinCostCenter($CostCenterID);
|
|
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Edit Cost';
|
|
|
|
$this->loadViews("editOldcost", $this->global, $data,NULL);
|
|
|
|
}
|
|
|
|
function ech()
|
|
{
|
|
|
|
echo $this->input->post('CostCentreID');
|
|
echo $this->input->post('CostName');
|
|
echo $this->input->post('Description');
|
|
|
|
}
|
|
|
|
/**
|
|
* This function is used to edit the user information
|
|
|
|
function editcost()
|
|
{
|
|
|
|
$this->load->library('form_validation');
|
|
|
|
$CostCenterID = $this->input->post('CostCentreID');
|
|
|
|
$this->form_validation->set_rules('CostName','Cost Name','trim|required|');
|
|
$this->form_validation->set_rules('Description','Description','trim|required|');
|
|
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
$this->editcost($CostCenterID);
|
|
}
|
|
else
|
|
{
|
|
$CostCenterID = $this->input->post('CostCentreID');
|
|
$CostName = ucwords(strtolower($this->input->post('CostName')));
|
|
$Description = $this->input->post('Description');
|
|
|
|
|
|
|
|
//$this->costcenter_model->editcost($Cost);
|
|
|
|
$cost = array();
|
|
|
|
|
|
|
|
$Cost = array('CostCentreID'=>$CostCenterID,'CostName'=>$CostName, 'Description'=>$Description,'createdDate'=>date('Y-m-d H:i:sa'));
|
|
|
|
|
|
|
|
|
|
$result = $this->costcenter_model->editcost($Cost, $CostCenterID);
|
|
|
|
if($result == true)
|
|
{
|
|
$this->session->set_flashdata('success', 'Cost updated successfully');
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_flashdata('error', 'Cost updation failed');
|
|
}
|
|
|
|
redirect('costListing');
|
|
}
|
|
|
|
}
|
|
function viewcost($CostCenterID = NULL)
|
|
{
|
|
|
|
if($CostCenterID == null)
|
|
{
|
|
redirect('costListing');
|
|
}
|
|
|
|
$data['Cost'] = $this->costcenter_model->getuserinfo($CostCenterID);
|
|
//$data['users'] = $this->purchaseorder_model->getusers();
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : View Cost';
|
|
|
|
$this->loadViews("viewcost", $this->global, $data,NULL);
|
|
|
|
}
|
|
|
|
/**
|
|
* This function is used to delete the user using userId
|
|
* @return boolean $result : TRUE / FALSE
|
|
|
|
function deletecost()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
echo(json_encode(array('status'=>'access')));
|
|
}
|
|
else
|
|
{
|
|
$CostCenterID = $this->input->Costst('CostCentreID');
|
|
$cost = array('CreateDate'=>date('Y-m-d H:i:sa'));
|
|
|
|
$result = $this->costcenter_model->deletecost($Cost, $CostCenterID);
|
|
|
|
if ($result > 0) { echo(json_encode(array('status'=>TRUE))); }
|
|
else { echo(json_encode(array('status'=>FALSE))); }
|
|
}
|
|
}
|
|
*/
|
|
|
|
function pageNotFound()
|
|
{
|
|
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
function getDateformat2($Val)
|
|
{
|
|
$date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
|
|
|
|
$retDate = $date->format('d-m-Y');
|
|
|
|
return $retDate;
|
|
}
|
|
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
|
|
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
|
|
return $retDate;
|
|
}
|
|
}
|
|
|
|
?>
|