ria/application/controllers/payslip.php
2018-11-28 10:33:46 +05:30

1539 lines
51 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
require APPPATH . '/third_party/mpdf/mpdf.php';
/**
* Class : payslip (Pay Slip - Controller)
* payslip Class to control all payslip related operations.
* @author : Venba Info Tech
* @version : 1.1
* @since : 18 November 2017
*/
class payslip extends BaseController
{
/**
* Default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('payroll_model');
$this->load->model('monthlypay_model');
$this->load->library('form_validation');
$this->isLoggedIn();
$this->CompanyName = $this->global['CompanyName'];
}
/**
* To display the alert message
*/
function phpAlert($msg) {
echo '<script type="text/javascript">alert("' . $msg . '")</script>';
}
/**
* To call stored procedure named with final_payroll_data()
*/
public function callsp(){
$payon = $this->input->post('payon');
$employee = $this->input->post('employee');
$result = $this->payroll_model->model_sp($payon,$employee);
return $result;
}
/**
* To load bank report screen for payslip
*/
function loadBankreportScreen()
{
$Data['Payon'] = $this->payroll_model->getPayOn();
$Data['Bank'] = $this->payroll_model->getBankInfo();
//$this->global['pageTitle'] = 'Resico : Bank Report Screen';
$this->global['pageTitle'] = $this->CompanyName.' : Bank Report';
$this->loadViews("bankreport", $this->global,$Data,NULL);
}
/**
* To get report for payslip
* its generated a payslip's ESI,PF,Bank reports
*/
function getBankReport()
{
$bank = $this->input->post('bank');
$payon = $this->input->post('month');
$chequeno = $this->input->post('chequeno');
$chequedate = date("Y-m-d", strtotime($this->input->post('chequedate')));
$createdby = $this->session->userdata ( 'userId' );
$monthsoptions = array("01" => "Jan", "02" => "Feb","03" => "Mar","04" => "Apr","05" => "May","06" => "June","07"=> "July","08"=> "Aug","09" => "Sep","10"=> "Oct","11" => "Nov","12"=>"Dec");
$m = substr($payon,0,2);
$y = substr($payon,3);
$month = $monthsoptions[$m]."-".$y;
$excel = $this->input->post('excel');
$HTML = '';
$filename = '';
if($this->input->post('Bank_Report'))
{
$data['result'] = $this->payroll_model->getReportforBank($bank,$payon);
if($chequeno != '' && $chequedate != '')
{
$empcount=count($data['result']);
$cheque = array('ChequeNO'=>$chequeno, 'ChequeDate'=>$chequedate, 'BankName'=>$bank, 'Monthyear'=>$payon, 'Empcount'=>$empcount, 'CreatedBy'=>$createdby);
$data['insertcheque'] = $this->payroll_model->ChequeDetails($cheque);
}
$totamtwords = '';
$totalamt=0.00;
if(!empty($data['result'])){
foreach($data['result'] as $amt)
{
$totalamt += $amt->LessAdvance;
}
}
$totamtwords = $this->convertNumber($totalamt);
$data['bankdetails']=$this->payroll_model->getBankInfo($bank);
$data['chequedetails']=$this->payroll_model->getChequeInfo($bank,$payon);
$data['Totalamount']=$totalamt;
$data['Totalamtwords']=$totamtwords;
$data['PayMonth']=$month;
$filename = 'Bank Report for'.$payon ;
$HTML = $this->load->view("bankreportprint",$data,true);
}
if($this->input->post('PF_Report'))
{
$data['PFESI'] = $this->payroll_model->getReportforPFESI($payon);
$data['PayMonth']=$month;
$data['companyinfo']=$this->payroll_model->getCompanyInformation();
$totamtwords = '';
$totalamt=0.00;
$totemppf = 0.00;
$totemprpf = 0.00;
if(!empty($data['PFESI'])){
foreach($data['PFESI'] as $pf)
{
$totalamt += ($pf->PF + $pf->CompanyPF);
$totemppf += ($pf->PF);
$totemprpf += ($pf->CompanyPF);
}
}
$data['Totalamount']=$totalamt;
$data['TotalEmployeeContribution']=$totemppf;
$data['TotalEmployerContribution']=$totemprpf;
$totamtwords = $this->convertNumber($totalamt);
$data['Totalamtwords']=$totamtwords;
if(empty($excel)){
$filename = 'PF Report for'.$payon ;
$HTML = $this->load->view("pfreportprint",$data,true);
}
else{
$this->load->library('excel');
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('Employee PF Report ' . $data['PayMonth']);
$this->excel->getActiveSheet()->setCellValue('A1', 'Employee PF Report ' . $data['PayMonth']);
$this->excel->getActiveSheet()->setCellValue('A4', 'S.No.');
$this->excel->getActiveSheet()->setCellValue('B4', 'Employee Name');
$this->excel->getActiveSheet()->setCellValue('C4', 'PF Account No');
$this->excel->getActiveSheet()->setCellValue('D4', 'Employee Contribution');
$this->excel->getActiveSheet()->setCellValue('E4', 'Employeer Contribution');
$this->excel->getActiveSheet()->setCellValue('F4', 'No Of Days Worked');
$this->excel->getActiveSheet()->setCellValue('G4', 'OT Hrs Worked');
$this->excel->getActiveSheet()->setCellValue('H4', 'Total Amount');
$this->excel->getActiveSheet()->mergeCells('A1:F1');
$this->excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(16);
$this->excel->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setARGB('#333');
for($col = ord('A'); $col <= ord('H'); $col++){
$this->excel->getActiveSheet()->getColumnDimension(chr($col))->setAutoSize(true);
$this->excel->getActiveSheet()->getStyle(chr($col))->getFont()->setSize(12);
$this->excel->getActiveSheet()->getStyle(chr($col))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
$i=6;
$j=1;
$total=0;
$overall=0;
$totemp = 0;
$overallemp = 0;
$totemr = 0;
$overallemr = 0;
foreach($data['PFESI'] as $row){
$this->excel->getActiveSheet()->setCellValue('A' . (string)($i),$j);
$this->excel->getActiveSheet()->setCellValue('B' . (string)($i),$row->FName . $row->Lname);
$this->excel->getActiveSheet()->setCellValue('C' . (string)($i),$row->PFNO);
$this->excel->getActiveSheet()->setCellValue('D' . (string)($i),number_format($row->PF,2,'.',''));
$this->excel->getActiveSheet()->getStyle('D'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('D'.(string)($i))->getNumberFormat()->setFormatCode('0.00');
$this->excel->getActiveSheet()->setCellValue('E' . (string)($i),number_format($row->CompanyPF,2,'.',''));
$this->excel->getActiveSheet()->getStyle('E'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('E'.(string)($i))->getNumberFormat()->setFormatCode('0.00');
$this->excel->getActiveSheet()->setCellValue('C' . (string)($i+1),'Total');
$this->excel->getActiveSheet()->setCellValue('F' . (string)($i),number_format($row->NoofDaysWorked,2,'.',''));
$this->excel->getActiveSheet()->getStyle('F'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->setCellValue('G' . (string)($i),number_format($row->OTperHours,2,'.',''));
$this->excel->getActiveSheet()->getStyle('G'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$total = $row->PF + $row->CompanyPF;
$totemp = $row->PF;
$totemr = $row->CompanyPF;
$overall=$overall + $total;
$overallemp = $overallemp + $totemp;
$overallemr = $overallemr + $totemr;
$this->excel->getActiveSheet()->setCellValue('H' . (string)($i),($total));
$this->excel->getActiveSheet()->getStyle('H'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('H'.(string)($i))->getNumberFormat()->setFormatCode('0.00');
$this->excel->getActiveSheet()->setCellValue('H' . (string)($i+1),($overall));
$this->excel->getActiveSheet()->setCellValue('D' . (string)($i+1),($overallemp));
$this->excel->getActiveSheet()->setCellValue('E' . (string)($i+1),($overallemr));
$this->excel->getActiveSheet()->getStyle('H'.(string)($i+1))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('H'.(string)($i+1))->getNumberFormat()->setFormatCode('0.00');
$i++;
$j++;
}
$this->excel->getActiveSheet()->getProtection()->setSheet(true);
$this->excel->getActiveSheet()->getProtection()->setSort(true);
$this->excel->getActiveSheet()->getProtection()->setInsertRows(true);
$this->excel->getActiveSheet()->getProtection()->setFormatCells(true);
$filename='EmployeePFReport'.$payon.'xls';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
}
if($this->input->post('ESI_Report'))
{
$data['PFESI'] = $this->payroll_model->getReportforPFESI($payon);
$data['PayMonth']=$month;
$data['companyinfo']=$this->payroll_model->getCompanyInformation();
$totamtwords = '';
$totalamt=0.00;
$totemppf = 0.00;
$totemprpf = 0.00;
if(!empty($data['PFESI'])){
foreach($data['PFESI'] as $pf)
{
$totalamt += ($pf->EmployeeESI + $pf->CompanyESI);
$totemppf += ($pf->EmployeeESI);
$totemprpf += ($pf->CompanyESI);
}
}
$data['Totalamount']=$totalamt;
$totamtwords = $this->convertNumber($totalamt);
$data['TotalEmployeeContribution']=$totemppf;
$data['TotalEmployerContribution']=$totemprpf;
$data['Totalamtwords']=$totamtwords;
if(empty($excel)){
$filename = 'ESI Report for'.$payon;
$HTML = $this->load->view("esireportprint",$data,true);
}
else {
$this->load->library('excel');
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('Employee ESI Report ' . $data['PayMonth']);
$this->excel->getActiveSheet()->setCellValue('A1', 'Employee ESI Report ' . $data['PayMonth']);
$this->excel->getActiveSheet()->setCellValue('A4', 'S.No.');
$this->excel->getActiveSheet()->setCellValue('B4', 'Employee Name');
$this->excel->getActiveSheet()->setCellValue('C4', 'ESI Account No');
$this->excel->getActiveSheet()->setCellValue('D4', 'Employee Contribution');
$this->excel->getActiveSheet()->setCellValue('E4', 'Employeer Contribution');
$this->excel->getActiveSheet()->setCellValue('F4', 'No Of Days Worked');
$this->excel->getActiveSheet()->setCellValue('G4', 'OT Hrs Worked');
$this->excel->getActiveSheet()->setCellValue('H4', 'Total Amount');
$this->excel->getActiveSheet()->mergeCells('A1:F1');
$this->excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(16);
$this->excel->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setARGB('#333');
for($col = ord('A'); $col <= ord('H'); $col++){
$this->excel->getActiveSheet()->getColumnDimension(chr($col))->setAutoSize(true);
$this->excel->getActiveSheet()->getStyle(chr($col))->getFont()->setSize(12);
$this->excel->getActiveSheet()->getStyle(chr($col))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
$i=6;
$j=1;
$total=0;
$overall=0;
$totemp = 0;
$overallemp = 0;
$totemr = 0;
$overallemr = 0;
foreach($data['PFESI'] as $row){
$this->excel->getActiveSheet()->setCellValue('A' . (string)($i),$j);
$this->excel->getActiveSheet()->setCellValue('B' . (string)($i),$row->FName . $row->Lname);
$this->excel->getActiveSheet()->setCellValue('C' . (string)($i),$row->ESI);
$this->excel->getActiveSheet()->setCellValue('D' . (string)($i),number_format($row->EmployeeESI,2,'.',''));
$this->excel->getActiveSheet()->getStyle('D'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('D'.(string)($i))->getNumberFormat()->setFormatCode('0.00');
$this->excel->getActiveSheet()->setCellValue('E' . (string)($i),number_format($row->CompanyESI,2,'.',''));
$this->excel->getActiveSheet()->getStyle('E'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('E'.(string)($i))->getNumberFormat()->setFormatCode('0.00');
$this->excel->getActiveSheet()->setCellValue('C' . (string)($i+1),'Total');
$this->excel->getActiveSheet()->setCellValue('F' . (string)($i),number_format($row->NoofDaysWorked,2,'.',''));
$this->excel->getActiveSheet()->getStyle('F'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->setCellValue('G' . (string)($i),number_format($row->OTperHours,2,'.',''));
$this->excel->getActiveSheet()->getStyle('G'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$total = $row->EmployeeESI + $row->CompanyESI;
$overall=$overall + $total;
$totemp = $row->EmployeeESI;
$totemr = $row->CompanyESI;
$overallemp = $overallemp + $totemp;
$overallemr = $overallemr + $totemr;
$this->excel->getActiveSheet()->setCellValue('H' . (string)($i),($total));
$this->excel->getActiveSheet()->getStyle('H'.(string)($i))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('H'.(string)($i))->getNumberFormat()->setFormatCode('0.00');
$this->excel->getActiveSheet()->setCellValue('D' . (string)($i+1),($overallemp));
$this->excel->getActiveSheet()->setCellValue('E' . (string)($i+1),($overallemr));
$this->excel->getActiveSheet()->setCellValue('H' . (string)($i+1),($overall));
$this->excel->getActiveSheet()->getStyle('H'.(string)($i+1))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$this->excel->getActiveSheet()->getStyle('H'.(string)($i+1))->getNumberFormat()->setFormatCode('0.00');
$i++;
$j++;
}
$this->excel->getActiveSheet()->getProtection()->setSheet(true);
$this->excel->getActiveSheet()->getProtection()->setSort(true);
$this->excel->getActiveSheet()->getProtection()->setInsertRows(true);
$this->excel->getActiveSheet()->getProtection()->setFormatCells(true);
$filename='EmployeeESIReport'.$payon.'xls';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
}
if(empty($excel)){
$mpdf=new mPDF('utf-8','A4-P',10, 12,12, 10, 10, 38, 4, 6);
$HTMLFooter = $this->load->view('includes/bankreport_footer',$data, true);
$mpdf->SetDisplayMode('fullpage');
//$mpdf->SetTitle('Resico : PDF'.$filename);
$mpdf->SetTitle($this->CompanyName.' : PDF'.$filename);
/*$mpdf->setTitle('Resico : PayrollReport');*/
//$mpdf->SetHTMLHeader($HtmlHeading);
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
// $mpdf->setFooter("Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($HTML);
$mpdf->Output("".$filename.'.pdf','I',$php);
}
}
/**
* To load Loan report for the employee.( whole employee / selected employee)
*/
function loadLoanReport()
{
$currentyear = '';
$nxtyear = '';
$eid = $this->uri->segment(3);
$fyr = $this->uri->segment(4);
if(!empty($eid) and !empty($fyr) and !is_numeric($eid) and !($fyr =='Overall'))
{
$currentyear = substr($fyr,0,4);
$nxtyear = substr($fyr,5,4);
$data['fyear'] = $currentyear.'-'.$nxtyear;
$data['loanrecords'] = $this->payroll_model->getLoanReportforEmp($eid,$currentyear,$nxtyear,'emp');
$data['selsource'] = $eid;
}
else if(!empty($eid) and !empty($fyr) and $fyr=='Overall')
{
$data['fyear'] = "Overall";
$currentyear ='';
$nxtyear = '';
$data['loanrecords'] = $this->payroll_model->getLoanReportforEmp($eid,$currentyear,$nxtyear,'emp');
$data['selsource'] = $eid;
}
else if(is_numeric($eid))
{
$currentyear ='';
$nxtyear = '';
$data['selsource'] = $eid;
$data['fyear'] = $currentyear.'-'.$nxtyear;
$data['childdata'] = $this->payroll_model->getLoanReportforEmp($eid,$currentyear="",$nxtyear="",'history');
}
else
{
if(empty($this->input->post('finyear')))
{
$year = date("Y");
$month = date("m");
$currentyear = '';
$nxtyear = '';
$source = $this->input->post('source');
$data['selsource'] = 'Company';
}
else
{
if(!empty($this->input->post('finyear')))
{
$source = $this->input->post('source');
$data['selsource'] =$source;
$finyear = $this->input->post('finyear');
$currentyear = substr($finyear,0,4);
$nxtyear = substr($finyear,5,4);
$data['fyear'] = $currentyear.'-'.$nxtyear;
}
}
$data['loanrecords'] = $this->payroll_model->getLoanReport($source,$currentyear,$nxtyear);
}
$data['loanemployees'] = $this->payroll_model->getEmpDetailsforLoan();
//$this->global['pageTitle'] = 'Resico : Loan Reports';
$this->global['pageTitle'] = $this->CompanyName.' : Loan Reports';
$this->loadViews("loanreports", $this->global,$data, NULL);
}
/**
* To upload the payslip data.
*/
public function viewUpload2()
{
//$this->global['pageTitle'] = 'Resico : Payroll Data Upload2';
$this->global['pageTitle'] = $this->CompanyName.' : Monthly Payroll Data Upload';
$this->loadViews("payslipupload2", $this->global, NULL);
}
/**
* To load Monthly Pay inputs screen based month-year.
*/
public function monthlyInputs()
{
$current = date("m-Y");
$data['month'] = $this->monthlypay_model->monthlyListing($current);
$data['dropdownvalue'] = $current;
$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current);
$employeeSalary = [];
foreach($data['fresh'] as $value){
$NoofDays=$value->NoofDays;//Month day 30,31,28
$HRA_Amount = $value->HRA_Amount;
$Basic_Pay = $value->Basic_Pay;
$TotalSalary = $value->TotalSalary;
$Food_Allowances= $value->Food_Allowances;
$Days_worked = $value->Days_worked; // working day
$LOP_Days = $value->LOP_Days; // not working day
$Paid_leave = $value->Paid_leave; // leave day
$OT_Hrs_Worked = $value->OT_Hrs_Worked; //OT hours
$Monthly_Due = $value->Monthly_Due;// AUTO LOAN DUE
$Loan_Recovered = $value->Loan_Recovered; //MANUAL LOAN DUE
$MasterIncentives=$value->MasterIncentives;//Master values get
// echo 'master'.$MasterIncentives;
$due_start_date = $value->DueDate;
$paydate = $current;//From POST parm
$pmonth = substr($paydate,0,2);
$pyear = substr($paydate,-4);
$pday=cal_days_in_month(CAL_GREGORIAN,$pmonth,$pyear);
$paymonth = $pyear.'-'.$pmonth.'-'.$pday;
$Loan_amount = $value->Loan_Amount;
$Paid_Amount = $value->Paid_Amount;
$Balance_Amount = $Loan_amount - $Paid_Amount;
$loan=0;
if($Loan_Recovered =='NA'){
$loan=0.00;
}
else if($Loan_Recovered == 0.00)
{
if(strtotime($due_start_date) <= strtotime($paymonth))
{
$loan=$Monthly_Due;
}
}
else if($Loan_Recovered >= 0.00)
{
if(strtotime($due_start_date) <= strtotime($paymonth))
{
$loan = $Loan_Recovered;
}
}
if($Monthly_Due > $Balance_Amount)
{
// current= Balance_Amount - autoLoan;
//alert('hi');
$loan = $Balance_Amount;
}
$Allowances =$value->Allowances;
$HRA_Rate=$value->HRA_Rate;
$PF_Rate=$value->PF_Rate;
$ESI_Rate=$value->ESI_Rate;
$MonthIncentive = $value->MonthlyIncentives;//T_Monthly_Pay_Inputs,for change month
$Incentive = 0;
if(empty($MonthIncentive))
{
$Incentive = $MasterIncentives;
}
else
{
$Incentive = $MonthIncentive;
}
// echo $Incentive;
$daySalarys = $Days_worked + $Paid_leave;
//echo "hra amount";print_r(array($HRA_Amount,$Basic_Pay,$totalsalary));
//$Allowances = $allowances * $values;
$dayFood_Allowance = $Food_Allowances * $Days_worked;
$daySalary = $Basic_Pay / $NoofDays;
/**per day salary working hour**/
//echo $daySalary.'<br/>';
$dayHra = $HRA_Amount / $NoofDays;
/** per day hra amount **/
//echo $dayHra.'<br/>';
$onehoursSalary = ($daySalary + $dayHra) / 8;
/**one hour salay ot calculation**/
if ($OT_Hrs_Worked != 0)
{
$totSalayOT = $OT_Hrs_Worked * $onehoursSalary;
}
else
{
$totSalayOT = 0;
}
$currentDaySalary = $daySalary * $daySalarys;
/** current day salary working days calculation**/
$currentDayHra = $dayHra * $daySalarys;
/** total working days hra calculations**/
// echo $currentDayHra.'<br/>';
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
/** current date pf calculation**/
if ($TotalSalary <= 20000)
{
$esiAmount = $currentDatePF * $ESI_Rate/ 100;
/** esiamount not elgiable for 20000 **/
}
else
{
$esiAmount = 0;
}
$pfAmount = $currentDaySalary * $PF_Rate/ 100;
/** pf amount per day**/
//echo $totalothour;die;
$empSalaryAdd = $currentDaySalary + $totSalayOT + $currentDayHra + $dayFood_Allowance + $Allowances + $Incentive;
$empSalarySub = $esiAmount + $pfAmount + $loan;
$salaryInCurrentday= $empSalaryAdd - $empSalarySub;
$employeeSalary []= round($salaryInCurrentday);
}
$data['empSalary'] = $employeeSalary;
//$this->global['pageTitle'] = 'Resico : Payroll Monthly Inputs';
$this->global['pageTitle'] = $this->CompanyName.' : Monthly Payroll Details';
$this->loadViews("monthlypayinputs", $this->global,$data,NULL);
}
function changeMonth()
{
// $current = $this->input->post('param1');
// $month = $this-> monthlypay_model->monthlyListing($current);
// $fresh = $this-> monthlypay_model->getEmpPayDetailsforMonthInputs($current);
// $data = json_encode(array_merge($month,$fresh));
// echo $data;
$current = $this->input->post('monthyear');
$data['month'] = $this->monthlypay_model->monthlyListing($current);
$data['dropdownvalue'] = $current;
$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current);
$employeeSalary = [];
foreach($data['fresh'] as $value){
//print_r($value);
//die();
$NoofDays=$value->NoofDays;//Month day 30,31,28
$HRA_Amount = $value->HRA_Amount;
$Basic_Pay = $value->Basic_Pay;
$TotalSalary = $value->TotalSalary;
$Food_Allowances= $value->Food_Allowances;
$Days_worked = $value->Days_worked; // working day
$LOP_Days = $value->LOP_Days; // not working day
$Paid_leave = $value->Paid_leave; // leave day
$OT_Hrs_Worked = $value->OT_Hrs_Worked; //OT hours
$Monthly_Due = $value->Monthly_Due;// AUTO LOAN DUE
$due_start_date = $value->DueDate;
$paydate = $current;//From POST parm
if(strlen($paydate) == 6)
{
$paydate = '0'.$paydate;
}
$pmonth = substr($paydate,0,2);
$pyear = substr($paydate,-4);
$pday=cal_days_in_month(CAL_GREGORIAN,$pmonth,$pyear);
$paymonth = $pyear.'-'.$pmonth.'-'.$pday;
$Loan_Recovered = $value->Loan_Recovered; //MANUAL LOAN DUE
$MasterIncentives=$value->MasterIncentives;//Master values get
// echo 'master'.$MasterIncentives;
$Loan_amount = $value->Loan_Amount;
$Paid_Amount = $value->Paid_Amount;
$Balance_Amount = $Loan_amount - $Paid_Amount;
$loan=0;
if($Loan_Recovered =='NA'){
$loan=0.00;
}
else if($Loan_Recovered == 0.00)
{
if(strtotime($due_start_date) <= strtotime($paymonth))
{
$loan=$Monthly_Due;
}
}
else if($Loan_Recovered >= 0.00)
{
if(strtotime($due_start_date) <= strtotime($paymonth))
{
$loan = $Loan_Recovered;
}
}
if($Monthly_Due > $Balance_Amount)
{
// current= Balance_Amount - autoLoan;
//alert('hi');
$loan = $Balance_Amount;
}
$Allowances =$value->Allowances;
$HRA_Rate=$value->HRA_Rate;
$PF_Rate=$value->PF_Rate;
$ESI_Rate=$value->ESI_Rate;
$MonthIncentive = $value->MonthlyIncentives;//T_Monthly_Pay_Inputs,for change month
$Incentive = 0;
if(empty($MonthIncentive))
{
$Incentive = $MasterIncentives;
}
else
{
$Incentive = $MonthIncentive;
}
// echo $Incentive;
$daySalarys = $Days_worked + $Paid_leave;
//echo "hra amount";print_r(array($HRA_Amount,$Basic_Pay,$totalsalary));
//$Allowances = $allowances * $values;
$dayFood_Allowance = $Food_Allowances * $Days_worked;
$daySalary = $Basic_Pay / $NoofDays;
/**per day salary working hour**/
//echo $daySalary.'<br/>';
$dayHra = $HRA_Amount / $NoofDays;
/** per day hra amount **/
//echo $dayHra.'<br/>';
$onehoursSalary = ($daySalary + $dayHra) / 8;
/**one hour salay ot calculation**/
if ($OT_Hrs_Worked != 0)
{
$totSalayOT = $OT_Hrs_Worked * $onehoursSalary;
}
else
{
$totSalayOT = 0;
}
$currentDaySalary = $daySalary * $daySalarys;
/** current day salary working days calculation**/
$currentDayHra = $dayHra * $daySalarys;
/** total working days hra calculations**/
// echo $currentDayHra.'<br/>';
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
/** current date pf calculation**/
if ($TotalSalary <= 20000)
{
$esiAmount = $currentDatePF * $ESI_Rate/ 100;
/** esiamount not elgiable for 20000 **/
}
else
{
$esiAmount = 0;
}
$pfAmount = $currentDaySalary * $PF_Rate/ 100;
/** pf amount per day**/
//echo $totalothour;die;
$empSalaryAdd = $currentDaySalary + $totSalayOT + $currentDayHra + $dayFood_Allowance + $Allowances + $Incentive;
$empSalarySub = $esiAmount + $pfAmount + $loan;
$salaryInCurrentday= $empSalaryAdd - $empSalarySub;
$employeeSalary []= round($salaryInCurrentday);
}
$data['empSalary'] = $employeeSalary;
//$this->global['pageTitle'] = 'Resico : Payroll Monthly Inputs';
$this->global['pageTitle'] = $this->CompanyName.' : Monthly Payroll Inputs';
$this->loadViews("monthlypayinputs", $this->global,$data,NULL);
}
/**
* To Store the Month in payslip datas
*/
function saveMonthlyData()
{
$month = $this->input->post('param2');
$jsondata =$this->input->post('param1');
$json = json_decode($jsondata,true);
$mon='';
$year='';
if(strlen($month) == 7)
{
$mon = substr($month,0,2);
$year = substr($month,3);
}
else
{
$mon = substr($month,0,1);
$year = substr($month,2);
if((int)$mon < 10)
{
$mon = '0'.$mon;
}
}
$month = $mon ."-". $year;
$total = 0;
$ErrorEmpId = '';
$TotalErrorFlag = 0;
$i = sizeof($json);
$len = $i-2;
foreach($json as $index=>$j)
{
if($index<=$len){
$ErrorFlag = 0;
$Emp = $j['Employee'];
$EmpID = substr($Emp,0,4);
$DaysWorked = $j['Days Worked'];
$LOP_Days = $j['LOP Days'];
$Paid_leave = $j['Paid Leave'];
$OT_Hrs_Worked = $j['OT Hrs'];
$Loan_Recovered = $j['Manual Loan Due ₹'];
$Incentives = $j['Incentives in ₹'];
$Festival_Bonus = $j['Festival Bonus in ₹'];
$Other_Deductions = $j['Other Deductions in ₹'];
$Estimate =$j['Estimate in ₹'];
$Created_By = $this->session->userdata ( 'userId' );
if(!is_numeric($DaysWorked) || ($DaysWorked > 31) || (strlen((string)$DaysWorked)) > 5 )
{
$ErrorFlag++;
}
if(!is_numeric($LOP_Days) || ($LOP_Days > 31) || (strlen((string)$LOP_Days)) > 5 )
{
$ErrorFlag++;
}
if(!is_numeric($Paid_leave) || ($Paid_leave > 31) || (strlen((string)$Paid_leave)) > 5)
{
$ErrorFlag++;
}
$OT_Hrs_Worked_first = explode(".",$OT_Hrs_Worked);
if(!is_numeric($OT_Hrs_Worked) || (strlen((string)$OT_Hrs_Worked))>6 || (strlen((string)$OT_Hrs_Worked_first[0])) >= 4)// || (strlen((string)$OT_Hrs_Worked_first[1]))> 3 )
{
$ErrorFlag++;
}
if(is_numeric($Loan_Recovered)){
$Loan_Recovered_first = explode(".",$Loan_Recovered);
if((strlen((string)$Loan_Recovered))>8 || (strlen((string)$Loan_Recovered_first[0]))> 5)
{
$ErrorFlag++;
}
}
else if(is_string($Loan_Recovered))
{
if(strcasecmp($Loan_Recovered,'NA'))
{
$ErrorFlag++;
}
}
$Incentives_first = explode(".",$Incentives);
if(!is_numeric($Incentives) || (strlen((string)$Incentives))>8 || (strlen((string)$Incentives_first[0]))> 5)
{
$ErrorFlag++;
}
$Festivalbonus_first = explode(".",$Festival_Bonus);
if(!is_numeric($Festival_Bonus) || (strlen((string)$Festival_Bonus))>8 || (strlen((string)$Festivalbonus_first[0]))> 5)
{
$ErrorFlag++;
}
$Other_Deductions_first = explode(".",$Other_Deductions);
if(!is_numeric($Other_Deductions) || (strlen((string)$Other_Deductions))>8 || (strlen((string)$Other_Deductions_first[0]))> 5)
{
$ErrorFlag++;
}
$Estimate_first = explode(".",$Estimate);
if(!is_numeric($Estimate) || (strlen((string)$Estimate))>8 || (strlen((string)$Estimate_first[0]))> 5)
{
//echo $EmpID . "-Loan Recoverd Invalid Data!";
$ErrorFlag++;
}
if($ErrorFlag != 0)
{
$ErrorEmpId = $ErrorEmpId ."|". $EmpID;
$TotalErrorFlag++;
}
else//if($ErrorFlag == 0)
{
//nothing
}
}
}
if($TotalErrorFlag == 0)
{
foreach($json as $index=>$j)
{
// $EmpID = $j['Employee Id'];
// $Name = $j['Employee Name'];
$Emp = $j['Employee'];
$EmpID = substr($Emp,0,4);
$DaysWorked = $j['Days Worked'];
$LOP_Days = $j['LOP Days'];
$Paid_leave = $j['Paid Leave'];
$OT_Hrs_Worked = $j['OT Hrs'];
$Loan_Recovered = $j['Manual Loan Due ₹'];
if(is_string($Loan_Recovered))
{
$Loan_Recovered = strtoupper($Loan_Recovered);
}
$Incentives = $j['Incentives in ₹'];
$Festival_Bonus = $j['Festival Bonus in ₹'];
$Other_Deductions = $j['Other Deductions in ₹'];
$Estimate =$j['Estimate in ₹'];
$Created_By = $this->session->userdata ( 'userId' );
$monthlypaydata = array('Month_Year'=>$month,'EmpID'=>$EmpID,'Days_worked'=>$DaysWorked,'LOP_Days'=>$LOP_Days,'Paid_leave'=>$Paid_leave,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Festival_Bonus'=>$Festival_Bonus,'Other_Deductions'=>$Other_Deductions,'Estimate'=>$Estimate,'Created_By'=>$Created_By);
$result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata);
$total = $total + $result;
}
}
$total = $total -1;
if(!empty($ErrorEmpId))
{
echo $ErrorEmpId . "- are have Invalid Data!";
}
echo $total . "- Employees Updated Successfully ";
}
/**
* To load the payslip list
*/
function payslipLisiting()
{
$curr_year = date('Y');
$curr_month =date('m');
$curr_monthyear = $curr_month.'-'.$curr_year;
//$this->global['pageTitle'] = 'Resico : Payslip Listing';
$this->global['pageTitle'] = $this->CompanyName.' : Payslip Details';
$data['PayInfo'] = $this->payroll_model->GetPayslipdata();
$data['dropdownvalue'] = $curr_monthyear;
$this->loadViews("paysliplist", $this->global, $data , NULL);
}
function reload_paysliplist()
{
$pre_monthyear = $this->input->post('month');
//$this->global['pageTitle'] = 'Resico : Payslip Listing';
$this->global['pageTitle'] = $this->CompanyName.' : Payslip Details';
$data['PayInfo'] = $this->payroll_model->GetPayslipdata($pre_monthyear);
$data['dropdownvalue'] = $pre_monthyear;
$this->loadViews("paysliplist", $this->global, $data , NULL);
}
/**
* To view the Supplier information and load's the edit supplier screen
*/
function editPayslip($EmpID,$PayOn)
{
//$this->global['pageTitle'] = 'Resico : Edit Employee Payslip';
$this->global['pageTitle'] = $this->CompanyName.' : Edit Payslip';
$data['PayInfo'] = $this->payroll_model->GetPayslipdata($PayOn,$EmpID);
$this->loadViews("editPayslip", $this->global, $data , NULL);
}
/**
* To view the payroll generater
*/
public function viewGenerator()
{
$Data['Payon'] = $this->payroll_model->getPayOn();
//$this->global['pageTitle'] = 'Resico : Payroll Generater';
$this->global['pageTitle'] = $this->CompanyName.' : PaySlip Generater';
//print_r($Data);die;
$this->loadViews("payslipgenerate", $this->global, $Data , NULL);
}
/**
* Validation for Employee Dropdown
*/
function Employee_validate($selectValue)
{
if($selectValue == '-1')
{
$this->form_validation->set_message('Employee_validate', 'Please Select Employee.');
return false;
}
else // user picked something
{
return true;
}
}
/**
* Get data for Employee Dropdown
*/
function getEmployee()
{
$id = $this->input->post('id1');
$result = $this->payroll_model->getEmployeelist2($id );
$HTML="";
if($result->num_rows() > 0){
foreach($result->result() as $list){
$HTML.="<option value='".$list->EmpId."'>".$list->EmpId."-".$list->Fname."</option>";
}
}
echo $HTML;
}
/*
* Validation for PayOn Dropdown
*/
function PayOn_validate($selectValue)
{
if($selectValue == '-1')
{
$this->form_validation->set_message('PayOn_validate', 'Please Select PayOn.');
return false;
}
else // user picked something
{
return true;
}
}
/**
* To Generate the payslip as pdf
*/
public function PrintPdf()
{
$filename=" ";
$html="";
$All = $this->input->post('All');
if($All == '')
{
$this->form_validation->set_rules('Employee','Employee','trim|callback_Employee_validate');
}
$this->form_validation->set_rules('PayOn','PayOn','trim|callback_PayOn_validate');
if($this->form_validation->run() == FALSE)
{
$this->viewGenerator();
}
else
{
$Payon = $this->input->post('PayOn');
$m =date("M", mktime(0, 0, 0, $Payon, 10));
$y=substr($Payon,3);
if($All != '')
{
$filename='PayslipFor-'.$m.'-'.$y;
$result = $this->payroll_model->getEmpAll($Payon);
if($result > 0 )
{
for($i=0; $i<count($result) ;$i++ )
{
$EmpID = $result[$i]['EmpId'];
$Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon,$EmpID);
$Data['CompanyDetails'] = $this->payroll_model->Companydetails();
$totalsalary =$Data['PayDetails'][0]->LessAdvance;
$totalsalaryinwords = $this->convertNumber(round($totalsalary));
$Data['amtinwords']=$totalsalaryinwords;
$html.=$this->load->view("payslipgenerateprint", $Data,true );
}
}
}
else
{
$EmpID = $this->input->post('Employee');
$Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon,$EmpID);
$fname=$Data['PayDetails'][0]->FName;
$filename='PayslipFor-'.$EmpID.' '.$fname.' '.$m.' '.$y;
$totalsalary =$Data['PayDetails'][0]->LessAdvance;
$totalsalaryinwords = $this->convertNumber(round($totalsalary));
$Data['amtinwords']=$totalsalaryinwords;
$Data['CompanyDetails'] = $this->payroll_model->Companydetails();
$html=$this->load->view("payslipgenerateprint", $Data,true );
}
$mpdf=new mPDF('utf-8','A4-P',10, 10,10, 10, 10, 24, 4, 6);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($HtmlHeading);
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$mpdf->setFooter("Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
//$mpdf->SetTitle('Resico : Payslip');
$mpdf->SetTitle($this->CompanyName.' : Payslip');
$mpdf->Output("".$filename.'.pdf','I',$php);
}
}
/**
* To update payslip
*/
function updatePayslip()
{
$paykey = $this->input->post("Key");
$EmpID = $this->input->post("EmpID");
$PayOn = $this->input->post("PayOn");
$otherallowence = $this->input->post("otherallowence");
$otherdeductions = $this->input->post("otherdeductions");
$incentive = $this->input->post("incentive");
$netpay = $this->input->post("netpay");
$esi = $this->input->post("txtesi");
$pf = $this->input->post("txtpf");
$basic = $this->input->post("txtbasicda");
$hra = $this->input->post("txthra");
$otsalary = $this->input->post("otsalary");
$Totaldeduction = $esi + $pf + $otherdeductions;
$SalaryAsPerPF = ($basic + $hra + $otsalary) - $Totaldeduction;
$userid = $this->session->userdata ( 'userId' );
$remarks = 'Manual Edit By' . $userid ." On " . date('Y-m-d');
$paydetails = array('Key'=>$paykey,'EmpID'=>$EmpID,'PayOn'=>$PayOn,'Other_allowances'=>$otherallowence,'OtherDeductions'=>$otherdeductions,'Incentive'=>$incentive,'LessAdvance'=>$netpay,'TotalSalary'=>$netpay,'SalaryAsPerPF'=>$SalaryAsPerPF,'Totaldeduction'=>$Totaldeduction,'remarks'=>$remarks);
$monthdetails = array('Month_Year'=>$PayOn,'Other_Deductions'=>$otherdeductions,'Incentives'=>$incentive);
$result = $this->payroll_model->updateEmpPayslip($paydetails);
$res = $this->monthlypay_model->editmonth($monthdetails,$EmpID);
echo $result;
}
/**
* To upload the Excel file Details2
*/
function uploadExcel2(){
$PayrollFileName = '';
//Check whether user upload picture
if(!empty($_FILES['userfile']['name']))
{
$pathinfo = pathinfo($_FILES['userfile']['name']);
$config['upload_path'] = 'uploads/files/';
$config['allowed_types'] = 'xls|xlsx|csv';
$config['file_name'] = $_FILES['userfile']['name'];
$config['overwrite'] = true;
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
if (($pathinfo['extension'] == 'xlsx' || $pathinfo['extension'] == 'xls')
&& $_FILES['userfile']['size'] > 0 )
{
if($this->upload->do_upload('userfile'))
{
$uploadData = $this->upload->data();
$PayrollFileName = $uploadData['file_name'];
}
else
{
$error = array('error' => $this->upload->display_errors());
$PayrollFileName = '';
}
$inputFileName = $_FILES['userfile']['tmp_name'];
require_once APPPATH .'third_party/PHPExcel/IOFactory.php';
$objTpl = PHPExcel_IOFactory::load($inputFileName);
$sheet = $objTpl->getActiveSheet(0) ;//->toArray(null, NULL, True, True);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$x = 8;
$month=$this->input->post('mon');
$year=$this->input->post('yr');
$PayOn= $month . "-" . $year;
$createdby = $this->session->userdata ( 'userId' );
if($month=='01' || $month=='03' || $month=='05' || $month=='07' || $month=='08' || $month=='10' || $month=='12')
{
$Totaldays = 31;
}
else if($month=='04' || $month=='06' || $month=='09' || $month=='11'){
$Totaldays = 30;
}
else{
$Totaldays = 28;
}
$FileDetails = array('PayOn'=>$PayOn,'TotalNoofDays'=>$Totaldays,'FileName'=> $config['file_name'],'CreatedBy'=>$createdby);
$result = $this->payroll_model->UploadFileName($FileDetails);
$emplid=$this->payroll_model->getEmpID($q='');
$payEmpID=$this->payroll_model->getEmpIDfromPayData();
$nopaydata=0;
$nopayid='';
$nopayrowid='';
$Unknowncount=0;
$Unknown="";
$row="";
$d=array("-1"=>"");
$fail=0;
$success=0;
for($x=8;$x<=$highestRow;$x++){
$EmpId = $sheet->getCell('A'.$x)->getValue();
/**** For Check Uploading EmpID existing in Employee Details(Valid or Not) *****/
$flag=0;
foreach($emplid as $e){
if(strtoupper($EmpId) == $e->EmpID){
$flag++;
}
}
if($flag==0){
$Unknowncount++;
$Unknown.='-'.$EmpId;
$row.='-'.$x;
}
/***** For Check Uploading EmpID existing in Emp Pay Data Details(Whether master pay data available or not) *****/
if($flag != 0)
{
$flag2=0;
foreach($payEmpID as $p)
{
if(strtoupper($EmpId) == $p->EmpID)
{
$flag2++;
}
}
if($flag2==0)
{
$nopaydata++;
$nopayid.='-'.$EmpId;
$nopayrowid.='-'.$x;
}
}
$FileDataExists = $this->payroll_model->checkFileDetailsExists2($PayOn,$EmpId);
if ($FileDataExists=='' || $FileDataExists==0)
{
$EmpId = $sheet->getCell('A'.$x)->getValue();
$EmpId=strtoupper($EmpId);
$Days_worked = $sheet->getCell('C'.$x)->getValue();
$LOPDays = $sheet->getCell('D'.$x)->getValue();
$Paid_leave =$sheet->getCell('E'.$x)->getValue();
$OTHoursWorked =$sheet->getCell('F'.$x)->getValue();
$LoanRecovered=$sheet->getCell('G'.$x)->getValue();
if(is_string($loanRecovered))
{
$loanRecovered = strtoupper($loanRecovered);
}
$Incentive =$sheet->getCell('G'.$x)->getValue();
$Other_Deductions =$sheet->getCell('H'.$x)->getValue();
if( $EmpId != '')
{
if($flag!=0 && $flag2!=0){
$FileData = array('Month_Year'=>$PayOn,'EmpID'=>$EmpId,'Days_worked'=>$Days_worked,'LOP_Days'=>$LOPDays,'Paid_leave'=>$Paid_leave,'OT_Hrs_Worked'=>$OTHoursWorked,'Loan_Recovered'=>$loanRecovered,'Incentives'=>$Incentive,'Other_Deductions'=>$Other_Deductions,'Created_By'=>$createdby,'Created_Time'=>date("Y-m-d h:i:sa"));
$result = $this->payroll_model->UploadFileData2($FileData);
$success++;
}
}
}
else{
$fail++;}
} //End of For Loop
echo "<script>alert('File Uploaded Successfully!');</script>";
echo "<script> alert($success +' - Data Uploaded sucessfully and ' + $fail + ' - Duplicate Data Found'); </script>";
echo "<script>alert($Unknowncount+'-data invalid, and data are'+'$Unknown'+'- found at rows'+'$row');</script>";
echo "<script>alert($nopaydata+'-data no have pay data, and data are'+'$nopayid'+'- found at rows'+'$nopayrowid');</script>";
echo "<script>window.location.href='ExcelUpload2';</script>";//redirect('payslip/viewUpload2');
} else
{
echo "<script>alert('Please select valid Excel file to Upload!');window.location.href='ExcelUpload2';</script>";
}
}
else
{
echo "<script>alert('Please select Excel file to Upload!');window.location.href='ExcelUpload2';</script>";
}
}
/**
* Validation For Payslip - which is already exists are not
*/
function checkExistPay()
{
$empid = $this->input->post('employee');
$payon = $this->input->post('payon');
$result = $this->payroll_model->checkExistPayData($empid,$payon);
echo json_encode(count($result));
}
/**
* For Bonus and Incentive report
*/
function Bonusreport()
{
//$this->global['pageTitle'] = 'Resico : Incentive and Bonus Reports';
$this->global['pageTitle'] = $this->CompanyName.' : Incentive and Bonus Reports';
$fin_year = $this->input->post('finyear');
$data['finyear'] = $fin_year;
$data['Reportvalue'] = $this->monthlypay_model->reportvalue($fin_year);
$this->loadViews("Bonusreport", $this->global,$data,NULL);
}
function MonthwiseBonusreport()
{
$EmployeeID = $_GET['EID'];
$Fin_year = $_GET['Finyear'];
$data['finyear'] = $Fin_year;
//$this->global['pageTitle'] = 'Resico : Monthwise Incentive and Bonus Reports';
$this->global['pageTitle'] = $this->CompanyName.' : Monthwise Incentive and Bonus Reports';
$data['MonthwiseReport'] = $this->monthlypay_model->Monthwisereportvalue($Fin_year,$EmployeeID);
$this->loadViews("Bonusreportmonthwise", $this->global,$data,NULL);
}
/**
* 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 numbers into words
*/
function convertNumber($amt){
$ShowPaise='0';
$totalAmt=explode(".",$amt);
$number = $totalAmt[0];
$no = $number;
if(!empty($totalAmt[1]) && $totalAmt[1]!=0){
$point = $totalAmt[1];
$ShowPaise='1';
}
else{
$point=0;
$ShowPaise='0';
}
$hundred = null;
$digits_1 = strlen($no);
$i = 0;
$str = array();
$words = array('0' => '', '1' => 'One', '2' => 'Two',
'3' => 'Three', '4' => 'Four', '5' => 'Five', '6' => 'Six',
'7' => 'Seven', '8' => 'Eight', '9' => 'Nine',
'10' => 'Ten', '11' => 'Eleven', '12' => 'Twelve',
'13' => 'Thirteen', '14' => 'Fourteen',
'15' => 'Fifteen', '16' => 'Sixteen', '17' => 'Seventeen',
'18' => 'Eighteen', '19' =>'Nineteen', '20' => 'Twenty',
'30' => 'Thirty', '40' => 'Fourty', '50' => 'Fifty',
'60' => 'Sixty', '70' => 'Seventy',
'80' => 'Eighty', '90' => 'Ninety');
$digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');
while ($i < $digits_1) {
$divider = ($i == 2) ? 10 : 100;
$number = floor($no % $divider);
$no = floor($no / $divider);
$i += ($divider == 10) ? 1 : 2;
if ($number) {
$plural = (($counter = count($str)) && $number > 1) ? 's' : null;
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
$str [] = ($number < 21) ? $words[$number] . " " . $digits[$counter] . $plural . " " . $hundred : $words[floor($number / 10) * 10]. " " . $words[$number % 10] . " ". $digits[$counter] . $plural . " " . $hundred;
}
else $str[] = null;
}
$str = array_reverse($str);
$result = implode('', $str);
$points = ($point) ? " " . $words[$point / 10] . " " . $words[$point = $point % 10] : '';
if($ShowPaise=='0'){
$amountInWords = "Rupees " . $result." Only";
}
else{
$amountInWords = "Rupees " . $result ." Paise ". $points." Only";
}
return $amountInWords;
}
function ValidationCheque(){
$bank = $this->input->post("id1");
$payon = $this->input->post("id2");
$result = $this->payroll_model->getChequeInfo($bank,$payon);
$count = count($result);
echo $count;
}
}
?>