siddharth_application/application/models/payroll_model.php
2017-10-26 14:22:38 +05:30

337 lines
10 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Payroll_model extends CI_Model
{
/**
* This function is used to insert the File details in database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number $Payon : Insert row count will be the return value
*/
function UploadFileName($FileDetails)
{
$this->db->insert('T_Payroll_File', $FileDetails);
$Payon = $this->db->affected_rows();
return $Payon;
}
function model_sp($payon,$employee){
//echo "<script>alert('mod');</script>";
//echo "highlight_file(filename)";
//die();
$result=$this->db->query("call P_FINAL_PAYROLL_DATA('".$payon."','".$employee."')") or die(mysql_error());
//$result->next_result();
return $result;
}
/**
* This function is used to update the File details in which is already exists in the database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function UpdateFileName($FileDetails, $PayOn)
{
//echo $EmpID;
$this->db->where('PayOn', $PayOn);
$this->db->update('T_Payroll_File', $FileDetails);
//print_r($this->db->last_query());
return TRUE;
}
/**
* This function is used to check the File details is already exists in the database or not
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function checkFileDetailsExists($PayOn)
{
$this->db->select('PayOn');
$this->db->from('T_Payroll_File');
$this->db->where('PayOn',$PayOn);
$query = $this->db->get();
// print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result();
}
}
function checkExistPayData($empid,$payon)
{
$this->db->select('PayOn,EmpID');
$this->db->from('T_Payroll');
$this->db->where('PayOn',$payon);
$this->db->where('EmpID',$empid);
$query = $this->db->get();
return $query->result();
}
function checkFileDetailsExists2($PayOn,$EmpId)
{
//echo $EmpId;
//die();
$this->db->select('Month_Year','EmpID');
$this->db->from('T_Monthly_Pay_Inputs');
$this->db->where('EmpID',$EmpId);
$this->db->where('Month_Year',$PayOn);
$query = $this->db->get();
// print_r($this->db->last_query());
if ($query->num_rows > 0) {
//echo "success";
//return $query->result();
return TRUE;
}
else{
//echo "fail";
return FALSE;
}
}
/**
* This function is used to insert the File data in database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number $Payon : Insert row count will be the return value
*/
function UploadFileData($FileData)
{
$this->db->insert('T_Payroll', $FileData);
$Payon = $this->db->affected_rows();
//print_r($this->db->last_query());
return $Payon;
}
function UploadFileData2($FileData)
{
$this->db->insert('T_Monthly_Pay_Inputs', $FileData);
$Payon = $this->db->affected_rows();
//print_r($this->db->last_query());
return $Payon;
}
/**
* This function is used to update the File details in which is already exists in the database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function UpdateFiledata($FileData, $PayOn,$EmpId)
{
//echo $EmpID;
$this->db->where('PayOn', $PayOn);
$this->db->where('EmpID', $EmpId);
$this->db->update('T_Payroll', $FileData);
//print_r($this->db->last_query());
//print_r($this->db->last_query());
return TRUE;
}
/**
* This function is used to get the data details in which is already exists in the database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function GetPayslipdata($PayOn='',$EmpId='')
{
//echo "FROM MODEL" . $PayOn . $EmpId;
$this->db->select('Pay.*,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.DateofBirth as Dob,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.AadharNo,Emp.IFSCCode as IFSCCode,Emp.DateofJoining as DOJ,Emp.Designation as Designation,Dep.DepartmentName as DeptName');
$this->db->from('T_Payroll Pay');
//$this->db->join('T_Payroll_File payfile', 'Pay.PayOn = payfile.PayOn');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode');
if($PayOn != '')
{
$this->db->where('Pay.PayOn', $PayOn);
}
if($EmpId != '')
{
$this->db->where('Pay.EmpID', $EmpId);
}
if($PayOn != '')
{
$this->db->order_by("Pay.EmpID", "asc");
}
if($PayOn == '' && $EmpId == '')
{
$this->db->order_by("Pay.PayOn", "desc");
}
$query = $this->db->get();
return $query->result();
//print_r($query->result());die();
}
/* *//**
* This function is used to get the PayOn details from T_Payroll_File
* @return array $result : This is result of the query
*/
function getPayOn()
{
$this->db->select('DISTINCT(Month_Year)');
$this->db->from('T_Monthly_Pay_Inputs');
$this->db->order_by("Month_Year", "desc");
$query = $this->db->get();
return $query->result();
}
function getBankInfo($bank="")
{
$this->db->select('*');
$this->db->from('T_Bank_Details');
$this->db->where("Is_Active",1);
if(!empty($bank))
{
$this->db->where('Bank_name',$bank);
}
$query = $this->db->get();
return $query->result();
}
function getReportforBank($bank,$payon)
{
$this->db->select('Pay.*,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.IFSCCode as IFSC,Bank.Address as BAddress');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->join('T_Bank_Details Bank', 'Emp.BankBranchName = Bank.Bank_name');
$this->db->where('Emp.BankBranchName',$bank);
$this->db->where('Pay.PayOn',$payon);
$query = $this->db->get();
return $query->result();
}
function getReportforPFESI($payon)
{
$this->db->select('Pay.EmployeeESI,Pay.PF,Pay.CompanyESI,Pay.CompanyPF,Pay.NoofDaysWorked,Pay.OTperHours,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.PFNO,Emp.ESI');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->where('Pay.PayOn',$payon);
$query = $this->db->get();
return $query->result();
}
/* *//**
* This function is used to get the PayOn details from T_Payroll_FileOTperHours
* @return array $result : This is result of the query
*/
function getEmployeelist($Payon ='')
{
$this->db->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
if($Payon != '')
{
$this->db->where('Pay.PayOn', $Payon);
}
$this->db->order_by("Pay.EmpID", "asc");
$query = $this->db->get();
return $query;
}
function getEmployeelist2($Payon ='')
{
$this->db->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname');
$this->db->from('T_Monthly_Pay_Inputs Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
if($Payon != '')
{
$this->db->where('Pay.Month_Year', $Payon);
}
$this->db->order_by("Pay.EmpID", "asc");
$query = $this->db->get();
return $query;
}
/* *//**
* This function is used to get the PayOn details from T_Payroll_File
* @return array $result : This is result of the query
*/
function getEmpAll($Payon ='')
{
$this->db->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
if($Payon != '')
{
$this->db->where('Pay.PayOn', $Payon);
}
$this->db->order_by("Pay.EmpID", "asc");
$query = $this->db->get();
return $query->result_array();
}
/* *//**
* This function is used to delete the PayOn details from T_Payroll
* @return array $result : This is result of the query
*/
function deleteFileData($PayOn='')
{
$this->db->where("PayOn", $PayOn);
$this->db->delete('T_Payroll');
}
function getEmpID($q='')
{
$this->db->select('EmpID,FirstName,LastName');
$this->db->from('T_Employee_Details');
if($q == "addemppaydate"){
$this->db->where('EmpID NOT IN (SELECT EmpID from T_Emp_Pay_Data)',NULL,FALSE);
}
$query = $this->db->get();
return $query->result();
}
function getEmpIDfromPayData()
{
$this->db->select('EmpID');
$this->db->from('T_Emp_Pay_Data');
$query = $this->db->get();
return $query->result();
}
function updateEmpPayslip($data)
{
$key = $data['Key'];
$PayOn = $data['PayOn'];
$EmpID = $data['EmpID'];
$this->db->where('Key', $key);
$this->db->where('PayOn',$PayOn);
$this->db->where('EmpID',$EmpID);
$result = $this->db->update('T_Payroll',$data);
return $result;
}
function getCompanyInformation()
{
$subQuery = "select CompanyName,replace(Address,',','<br>') as Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode
from T_Company_Details ";
$query = $this->db->query($subQuery);
//print_r($query->result());die();
return $query->result();
}
}
?>