db->insert('T_Payroll_File', $FileDetails); $Payon = $this->db->affected_rows(); return $Payon; } function model_sp($payon,$employee){ //echo ""; //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->distinct(); $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->order_by("Pay.EmpID", "asc"); $this->db->where('Emp.BankBranchName',$bank); $this->db->where('Pay.PayOn',$payon); $this->db->where('Pay.TotalSalary > 0'); $query = $this->db->get(); return $query->result(); } function getReportforPFESI($payon) { $this->db->distinct(); $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); $this->db->where('Pay.EmployeeESI > 0 '); $this->db->where('Pay.CompanyESI > 0'); $this->db->order_by("Pay.EmpID", "asc"); $query = $this->db->get(); return $query->result(); } function getLoanReport($source='',$year1="",$year2="") { // echo "
---------------------------"; // echo "
From Model-"; // echo $source.'-'.$year1.'-'.$year2; $this->db->distinct(); $this->db->select('Pay.EmpID,Emp.FirstName as FName ,Emp.LastName as Lname,sum(loan.Loan_Amount) as Loan_Amount,sum(loan.Paid_Amount) as Paid_Amount'); $this->db->from('T_Emp_Pay_Data Pay'); $this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID'); $this->db->join('T_Loan_Master loan', 'Pay.EmpID = loan.EmpID'); if($source != 'company'){ $this->db->where('Pay.EmpID',$source); } if($year1 != "" and $year2 != ""){ $this->db->where('month(loan.Loan_Issued_Date)>=',4); $this->db->where('year(loan.Loan_Issued_Date)=',$year1); $this->db->or_where('month(loan.Loan_Issued_Date)<=',3); $this->db->where('year(loan.Loan_Issued_Date)=',$year2); } $this->db->group_by('Pay.EmpID'); $this->db->order_by('Pay.EmpID','asc'); $query = $this->db->get(); return $query->result(); //print_r($query->result());die(); } function getEmpDetailsforLoan() { $this->db->select('Pay.EmpID,Pay.FirstName as FName ,Pay.LastName as Lname'); $this->db->from('T_Employee_Details Pay'); $this->db->join('T_Loan_Master loan', 'Pay.EmpID = loan.EmpID'); $this->db->order_by('Pay.EmpID','asc'); $query = $this->db->get(); return $query->result(); } function getLoanReportforEmp($eid='',$year1="",$year2="",$string="") { //$this->db->distinct(); if($string == 'emp'){ $this->db->select('Pay.EmpID,Emp.FirstName as FName ,Emp.LastName as Lname,loan.*'); $this->db->from('T_Emp_Pay_Data Pay'); $this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID'); $this->db->join('T_Loan_Master loan', 'Pay.EmpID = loan.EmpID','left'); // if($source != 'company'){ $this->db->where('Pay.EmpID',$eid); //} if($year1 != "" and $year2 != ""){ $this->db->where('month(loan.Loan_Issued_Date)>=',4); $this->db->where('year(loan.Loan_Issued_Date)=',$year1); $this->db->or_where('month(loan.Loan_Issued_Date)<=',3); $this->db->where('year(loan.Loan_Issued_Date)=',$year2); //$this->db->group_by('Pay.EmpID'); } $this->db->order_by('loan.Loan_Issued_Date','asc'); $query = $this->db->get(); return $query->result(); } elseif($string == 'history') { $this->db->select('T_Loan_Master.EmpID,Emp.FirstName,Emp.LastName,T_Loan_Master.Loan_Amount,T_Loan_Master.Loan_Issued_Date,T_Loan_History.*'); $this->db->from('T_Loan_History'); $this->db->join('T_Loan_Master','T_Loan_Master.Loan_ID=T_Loan_History.Loan_ID'); $this->db->join('T_Employee_Details Emp', 'T_Loan_Master.EmpID = Emp.EmpID'); $this->db->where('T_Loan_History.Loan_ID',$eid); $q = $this->db->get(); // $this->db->order_by('Entry_Date','asc'); // $this->db->where('Loan_ID',$eid); // $q = $this->db->get('T_Loan_History'); //print_r($q->result()); return $q->result(); // print_r($q->result()); // die(); } //print_r($query->result());die(); } /* *//** * 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,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(); } function ChequeDetails($cheque){ $this->db->insert('T_ChequeDetails', $cheque); } function getChequeInfo($bank,$payon) { $sql = "SELECT Cheque.* FROM T_ChequeDetails Cheque WHERE Cheque.BankName = ? AND Cheque.MonthYear = ? "; $query = $this->db->query($sql,array($bank,$payon)); //$query_count = $query->num_rows(); //return $query_count; return $query->result(); } } ?>