?
Current Path : /home1/savoy/www/savoyglobal.net/hr/application/controllers/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyglobal.net/hr/application/controllers/payroll.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Payroll extends MY_Controller { public function __construct() { parent::__construct(); $this->load->model('mastermodel'); $this->load->model('payrollmodel'); $this->load->model('onboardingmodel'); $this->load->model('administrationmodel'); $this->load->library('Fpaginate'); $this->load->helper('to_pdf'); } function get_post_values() { $data = array(); foreach ($_POST as $key => $value) { if($key != "submit") { $data[$key] = $this->input->post($key); } } return $data; } /* common function loading pages through jquery load method . * Usages:-used for displaying addform. */ function addformdisplay($page,$directory,$table="",$pagenum="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $this->load->view(''.$directory.'/'.$page.''); } } function deletedata($table,$id,$field) { $data=array(); $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],2); if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $data=$this->mastermodel->deletedata($table,$id,$field); $data['msg']=$data['msg']; if($data['res']==1) { $this->load->view('message',$data); } else { $this->load->view('message',$data); } } } function checkexistence($table,$field,$value) { if($this->mastermodel->checkexistence($table,$field,$value)>0) { echo 1; } } function checkexistencearray($table,$field,$value) { if($this->mastermodel->checkexistencearray($table,$field,$value)>0) { echo 1; } } function addinpayroll($modelfunction,$page) { $postdata=$this->get_post_values(); $path = './assets/uploads'; $data=$this->payrollmodel->$modelfunction($postdata); $data['msg']=$data['msg']; if($data['res']==1) { if(isset($data['batch_id'])) { $batch_id = $data['batch_id']; $batch_date = $data['batch_date']; $this->newaddpage($batch_id,$batch_date,'add_employee_joining'); } else if(isset($data['alert_id'])) { $alert_id = $data['alert_id']; $this->returntoalert($alert_id); } else { $this->viewinpayrollsearch($data['resfunction'],$page,'1'); } $this->load->view('message',$data); } else { $this->viewinpayrollsearch($data['resfunction'],$page,'1'); $this->load->view('message',$data); } } function viewinpayrollsearch($modelfunction,$page,$pagenum) { /*<---------------- For pagination purpose------------>*/ $perpage= $this->config->item('perpage'); $_SESSION['pagenum']=$pagenum; $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } if(isset($_POST['tab_name'])) { $postdata =""; } else { $postdata=$this->get_post_values(); } if(!empty ($postdata)) $_SESSION['searchdata']=$postdata; else if(!isset($_SESSION['searchdata'])) $_SESSION['searchdata']=""; /*<---------------- For pagination purpose------------> */ $output=$this->payrollmodel->$modelfunction($pagenum); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['viewinfo']=$output['results']; $this->load->view('Payroll/'.$page.'',$data); } function edit_page($id,$table,$field,$page,$alert_id='') { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); } else { $perm=1; } if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $data['viewinfo']=$this->mastermodel->get_data_srow($table,$id,$field); $data['id']=$id; $data['alert_id']=$alert_id; $this->load->view('Payroll/'.$page,$data); } } function single_page($id,$table,$field,$page,$alert_id='') { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],0); } else { $perm=1; } if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $data['viewinfo']=$this->mastermodel->get_data_srow($table,$id,$field); $data['id']=$id; $data['alert_id']=$alert_id; $this->load->view('Payroll/'.$page,$data); } } function enter_payroll_generation($payroll_generation_id) { $data=array(); $data['viewinfo']=$this->mastermodel->get_data_srow('payroll_generation',$payroll_generation_id,'payroll_generation_id'); $this->load->view('Payroll/enter_payroll_generation',$data); } function revise_payroll_generation($payroll_generation_id) { $data=array(); $data['viewinfo']=$this->mastermodel->get_data_srow('payroll_generation',$payroll_generation_id,'payroll_generation_id'); $this->load->view('Payroll/revise_payroll_generation',$data); } function display_payroll_generation($payroll_generation_id) { $data=array(); $data['viewinfo']=$this->mastermodel->get_data_srow('payroll_generation',$payroll_generation_id,'payroll_generation_id'); $this->load->view('Payroll/display_payroll_generation',$data); } function insert_payroll_generation_details() { $postdata=$this->get_post_values(); $data=$this->payrollmodel->enter_payroll_generation($postdata); $data['msg']="Payroll details added successfully"; $data['return_function']='search_payroll_generation'; $data['return_page']='view_payroll_generation'; echo "<script>alert('Payroll details entered successfully');</script>"; $this->load->view('message',$data); $this->load->view('Payroll/after_payroll_entry',$data); } function update_payroll_generation_details() { $postdata=$this->get_post_values(); $data=$this->payrollmodel->revise_payroll_generation($postdata); $data['msg']="Payroll details updated successfully"; $data['return_function']='search_payroll_generation'; $data['return_page']='view_payroll_generation'; echo "<script>alert('Payroll details updated successfully');</script>"; $this->load->view('message',$data); $this->load->view('Payroll/after_payroll_entry',$data); } function check_month_year($month,$year) { echo $this->mastermodel->number_rows('payroll_generation','payroll_generation_year',$year,'payroll_generation_month',$month); } function display_pay_slip($payroll_generation_details_id) { $data['viewinfo']=$this->mastermodel->get_data_srow('payroll_generation_details',$payroll_generation_details_id,'payroll_generation_details_id'); $data['salary']=$this->payrollmodel->get_payslip_details($data['viewinfo']->payroll_generation_details_id); $html = $this->load->view('Payroll/display_pay_slip',$data); } function generate_pay_slip($id,$table,$field,$page) { $data['viewinfo']=$this->mastermodel->get_data_srow($table,$id,$field); $data['salary']=$this->payrollmodel->get_payslip_details($data['viewinfo']->payroll_generation_details_id); $html = $this->load->view('Payroll/'.$page,$data,TRUE); pdf_create($html, $data['salary']->emp_non_no,'true'); } function generate_all_payslips($payroll_generation_id,$page) { $employee=$this->payrollmodel->get_payroll_generation_details_payment($payroll_generation_id); $file_array=array(); if(!empty($employee)) { $i=0; foreach($employee as $emp) { $data['viewinfo']=$this->mastermodel->get_data_srow('payroll_generation_details',$emp['payroll_generation_details_id'],'payroll_generation_details_id'); $data['salary']=$this->payrollmodel->get_payslip_details($emp['payroll_generation_details_id']); $html = $this->load->view('Payroll/'.$page,$data,TRUE); $filename = $data['salary']->emp_non_no.".pdf"; pdf_zip($html, $filename, 'true'); $file_array[$i++] = $filename; chmod($filename, 0777); } $zipname = 'payslips.zip'; $zip = new ZipArchive; $res = $zip->open($zipname, ZipArchive::CREATE); if($res==true) { foreach ($file_array as $file) { $zip->addFile($file); } $zip->close(); foreach ($file_array as $file) { unlink($file); } header('Content-Type: application/zip'); header('Content-disposition: attachment; filename='.$zipname); header('Content-Length: ' . filesize($zipname)); readfile($zipname); unlink($zipname); } } } function payroll_xls($payroll_generation_id) { $data=array(); $data['viewinfo']=$this->mastermodel->get_data_srow('payroll_generation',$payroll_generation_id,'payroll_generation_id'); $this->load->view('Payroll/xls_payroll_generation',$data); } } /* End of file payroll.php */ /* Location: ./application/controllers/payroll.php */