?
Current Path : /home1/savoy/www/savoyglobal.net/sgms/application/models/ |
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/sgms/application/models/payrollmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Payrollmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } function add($postdata) { $data=array(); $data['resfunction']=$postdata['resfunction']; $table = $postdata['tab_name']; unset ($postdata['tab_name']); unset ($postdata['resfunction']); $res=$this->db->insert($table,$postdata); $cnt=$this->db->insert_id(); if($res>0) { $data['res']=1; $data['msg']='Record Added Successfully'; } else { $data['res']=0; $data['msg']='Erron On Adding Record'; } return $data; } function update($postdata) { $data=array(); $data['resfunction']=$postdata['resfunction']; $table = $postdata['tab_name']; $field = $postdata['tab_field']; $id= $postdata['tab_id']; unset ($postdata['resfunction']); unset ($postdata['tab_name']); unset ($postdata['tab_field']); unset ($postdata['tab_id']); $this->db->where($field, $id); $res=$this->db->update($table,$postdata); if($res>0) { $data['res']=1; $data['msg']='Record Updated Successfully'; } else { $data['res']=0; $data['msg']='Erron On updating Record'; } return $data; } /*Search function starts here*/ function search_working_hour($pagenum) { $data=array(); $this->db->from('payroll_working_hour'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('payroll_working_hour'); $this->db->limit($perpage, $start); $this->db->order_by('working_hour_id','desc'); $data['results']=$this->db->get(); return $data; } function search_payroll_allowance($pagenum) { $data=array(); $this->db->from('payroll_allowance'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext, 'after'); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext, 'after'); } $this->db->select('*'); $this->db->from('payroll_allowance'); $this->db->limit($perpage, $start); $this->db->order_by('payroll_allowance_id','desc'); $data['results']=$this->db->get(); return $data; } function search_payroll_deduction($pagenum) { $data=array(); $this->db->from('payroll_deduction'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext, 'after'); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext, 'after'); } $this->db->select('*'); $this->db->from('payroll_deduction'); $this->db->limit($perpage, $start); $this->db->order_by('payroll_deduction_id','desc'); $data['results']=$this->db->get(); return $data; } function search_present_code($pagenum) { $data=array(); $this->db->from('payroll_present_code'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext, 'after'); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext, 'after'); } $this->db->select('*'); $this->db->from('payroll_present_code'); $this->db->limit($perpage, $start); $this->db->order_by('present_code_id','desc'); $data['results']=$this->db->get(); return $data; } function search_overtime_calculation($pagenum) { $data=array(); $this->db->from('payroll_overtime_calculation'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('payroll_overtime_calculation'); $this->db->limit($perpage, $start); $this->db->order_by('overtime_calculation_id','desc'); $data['results']=$this->db->get(); return $data; } function search_holiday_overtime_calculation($pagenum) { $data=array(); $this->db->from('payroll_holiday_overtime_calculation'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('payroll_holiday_overtime_calculation'); $this->db->limit($perpage, $start); $this->db->order_by('holiday_overtime_calculation_id','desc'); $data['results']=$this->db->get(); return $data; } function search_weekly_holiday($pagenum) { $data=array(); $count= 1; $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; $data['results']=''; return $data; } function search_special_holiday($pagenum) { $data=array(); $this->db->from('payroll_special_holiday'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('payroll_special_holiday'); $this->db->limit($perpage, $start); $this->db->order_by('special_holiday_id','desc'); $data['results']=$this->db->get(); return $data; } /*Search function ends here*/ /*Add function starts here*/ function insert_working_hour($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'working_hour_effective_date'=>$this->mastermodel->convertdateformat($postdata['working_hour_effective_date']), 'working_hours'=>$postdata['working_hours']); $this->db->insert('payroll_working_hour', $tblValues); $data['resfunction']='search_working_hour'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_overtime_calculation($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'overtime_calculation_effective_date'=>$this->mastermodel->convertdateformat($postdata['overtime_calculation_effective_date']), 'overtime_calculation_perc'=>$postdata['overtime_calculation_perc']); $this->db->insert('payroll_overtime_calculation', $tblValues); $data['resfunction']='search_overtime_calculation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_holiday_overtime_calculation($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'holiday_overtime_calculation_effective_date'=>$this->mastermodel->convertdateformat($postdata['holiday_overtime_calculation_effective_date']), 'holiday_overtime_calculation_perc'=>$postdata['holiday_overtime_calculation_perc']); $this->db->insert('payroll_holiday_overtime_calculation', $tblValues); $data['resfunction']='search_holiday_overtime_calculation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_special_holiday($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'special_holiday_date'=>$this->mastermodel->convertdateformat($postdata['special_holiday_date']), 'special_holiday_name'=>$postdata['special_holiday_name']); $this->db->insert('payroll_special_holiday', $tblValues); $data['resfunction']='search_special_holiday'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } /*Add function ends here*/ /*Update function starts here*/ function update_working_hour($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'working_hour_effective_date'=>$this->mastermodel->convertdateformat($postdata['working_hour_effective_date']), 'working_hours'=>$postdata['working_hours']); $this->db->where('working_hour_id', $postdata['working_hour_id']); $this->db->update('payroll_working_hour', $tblValues); $data['resfunction']='search_working_hour'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_overtime_calculation($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'overtime_calculation_effective_date'=>$this->mastermodel->convertdateformat($postdata['overtime_calculation_effective_date']), 'overtime_calculation_perc'=>$postdata['overtime_calculation_perc']); $this->db->where('overtime_calculation_id', $postdata['overtime_calculation_id']); $this->db->update('payroll_overtime_calculation', $tblValues); $data['resfunction']='search_overtime_calculation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_holiday_overtime_calculation($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'holiday_overtime_calculation_effective_date'=>$this->mastermodel->convertdateformat($postdata['holiday_overtime_calculation_effective_date']), 'holiday_overtime_calculation_perc'=>$postdata['holiday_overtime_calculation_perc']); $this->db->where('holiday_overtime_calculation_id', $postdata['holiday_overtime_calculation_id']); $this->db->update('payroll_holiday_overtime_calculation', $tblValues); $data['resfunction']='search_holiday_overtime_calculation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_weekly_holiday($postdata) { $data=array(); $this->db->trans_begin(); $this->db->truncate('payroll_weekly_holiday'); foreach($postdata['weekly_holiday'] as $holiday) { $tblValues=array('payroll_weekly_holiday'=>$holiday); $this->db->insert('payroll_weekly_holiday', $tblValues); } $data['resfunction']='search_weekly_holiday'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Holidays Updated Successfully'; return $data; } } function update_special_holiday($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'special_holiday_date'=>$this->mastermodel->convertdateformat($postdata['special_holiday_date']), 'special_holiday_name'=>$postdata['special_holiday_name']); $this->db->where('special_holiday_id', $postdata['special_holiday_id']); $this->db->update('payroll_special_holiday', $tblValues); $data['resfunction']='search_special_holiday'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } }