?
Current Path : /home1/savoy/www/savoyglobal.net/horeitia/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/horeitia/application/models/employeemodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Employeemodel 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; } /*Search function starts here*/ function search_employee_personal_office($pagenum) { $data=array(); $this->db->from('office_employee'); $this->db->join('designation','office_employee_designation_id=designation_id'); $this->db->where('office_employee_active','1'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $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']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('office_employee'); $this->db->join('designation','office_employee_designation_id=designation_id'); $this->db->where('office_employee_active','1'); $this->db->limit($perpage, $start); $this->db->order_by('office_employee_no','desc'); $data['results']=$this->db->get(); return $data; } function search_leave_office($pagenum) { $data=array(); $this->db->from('office_leave'); $this->db->join('leave_type','office_leave_type_id=leave_type_id'); $this->db->join('office_employee','office_employee_id=office_leave_employee_id'); $this->db->where('office_employee_active','1'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $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']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('office_leave'); $this->db->join('leave_type','office_leave_type_id=leave_type_id'); $this->db->join('office_employee','office_employee_id=office_leave_employee_id'); $this->db->where('office_employee_active','1'); $this->db->limit($perpage, $start); $this->db->order_by('office_leave_starting_date','desc'); $data['results']=$this->db->get(); return $data; } function search_settlement_office($pagenum) { $data=array(); $this->db->from('office_leave'); $this->db->join('leave_type','office_leave_type_id=leave_type_id'); $this->db->join('office_employee','office_employee_id=office_leave_employee_id'); $this->db->where('office_employee_active','1'); $this->db->where('office_leave_status','Approved'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $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']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('office_leave'); $this->db->join('leave_type','office_leave_type_id=leave_type_id'); $this->db->join('office_employee','office_employee_id=office_leave_employee_id'); $this->db->where('office_employee_active','1'); $this->db->where('office_leave_status','Approved'); $this->db->limit($perpage, $start); $this->db->order_by('office_leave_starting_date','desc'); $data['results']=$this->db->get(); return $data; } function search_exit_office($pagenum) { $data=array(); $this->db->from('office_leave'); $this->db->join('leave_type','office_leave_type_id=leave_type_id'); $this->db->join('office_employee','office_employee_id=office_leave_employee_id'); $this->db->join('office_settlement','office_settlement.office_settlement_leave_id=office_leave.office_leave_id'); $this->db->where('office_employee_active','1'); $this->db->where('office_leave_status','Approved'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $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']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('office_leave'); $this->db->join('leave_type','office_leave_type_id=leave_type_id'); $this->db->join('office_employee','office_employee_id=office_leave_employee_id'); $this->db->join('office_settlement','office_settlement.office_settlement_leave_id=office_leave.office_leave_id'); $this->db->where('office_employee_active','1'); $this->db->where('office_leave_status','Approved'); $this->db->limit($perpage, $start); $this->db->order_by('office_leave_starting_date','desc'); $data['results']=$this->db->get(); return $data; } /*Search function ends here*/ /*Add function starts here*/ function insert_employee_personal_office($postdata) { if($postdata['office_employee_name']!="" && (strstr($postdata['office_employee_name'], '<') != "")) { $no_array = explode('<', $postdata['office_employee_immediate_superior_id']); $employee_no = trim($no_array[1],">"); $office_employee_immediate_superior_id = $this->mastermodel->getSingleFieldValue('office_employee','office_employee_id','office_employee_no',$employee_no); } else { $office_employee_immediate_superior_id=""; } $num_rows_emp = $this->mastermodel->number_rows('office_employee'); $num_rows_emp++; $office_employee_no = "Emp ".str_pad($num_rows_emp, 3, "0", STR_PAD_LEFT); $data=array(); $this->db->trans_begin(); $doj= $this->mastermodel->convertdateformat($postdata['office_employee_joining_date']); $tblValues=array( 'office_employee_name'=>$postdata['office_employee_name'], 'office_employee_no'=>$office_employee_no, 'office_employee_joining_date'=>$doj, 'office_employee_visa_type_id'=>$postdata['office_employee_visa_type_id'], 'office_employee_grade_id'=>$postdata['office_employee_grade_id'], 'office_employee_designation_id'=>$postdata['office_employee_designation_id'], 'office_employee_department'=>$postdata['office_employee_department'], 'office_employee_immediate_superior_id'=>$office_employee_immediate_superior_id, 'office_employee_highest_education'=>$postdata['office_employee_highest_education'], 'office_employee_passing_year'=>$postdata['office_employee_passing_year'], 'office_employee_work_experience'=>$postdata['office_employee_work_experience'], 'office_employee_comments'=>$postdata['office_employee_comments'], 'office_employee_photo_name'=>$postdata['office_employee_photo_name'], 'office_employee_photo_doc'=>$postdata['office_employee_photo_doc'], 'office_employee_application_form_name'=>$postdata['office_employee_application_form_name'], 'office_employee_application_form_doc'=>$postdata['office_employee_application_form_doc'], 'office_employee_offer_letter_name'=>$postdata['office_employee_offer_letter_name'], 'office_employee_offer_letter_doc'=>$postdata['office_employee_offer_letter_doc'], 'office_employee_other_doc_name'=>$postdata['office_employee_other_doc_name'], 'office_employee_other_doc_doc'=>$postdata['office_employee_other_doc_doc'] ); $this->db->insert('office_employee', $tblValues); $data['resfunction']='search_employee_personal_office'; 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_leave_office($postdata) { $data=array(); $data['resfunction']='search_leave_office'; if($postdata['office_employee_name']!="" && (strstr($postdata['office_employee_name'], '<') != "")) { $no_array = explode('<', $postdata['office_employee_name']); $employee_no = trim($no_array[1],">"); $office_employee_id = $this->mastermodel->getSingleFieldValue('office_employee','office_employee_id','office_employee_no',$employee_no); if($office_employee_id != "") { $this->db->trans_begin(); $office_leave_starting_date= $this->mastermodel->convertdateformat($postdata['office_leave_starting_date']); if($postdata['office_leave_type_id']=='3') { $postdata['office_leave_ending_date']='00-00-0000'; } $office_leave_ending_date= $this->mastermodel->convertdateformat($postdata['office_leave_ending_date']); $tblValues=array( 'office_leave_type_id'=>$postdata['office_leave_type_id'], 'office_leave_reason'=>$postdata['office_leave_reason'], 'office_leave_starting_date'=>$office_leave_starting_date, 'office_leave_ending_date'=>$office_leave_ending_date, 'office_leave_remarks'=>$postdata['office_leave_remarks'], 'office_leave_employee_id'=>$office_employee_id, 'office_leave_status'=>$postdata['office_leave_status'] ); $this->db->insert('office_leave', $tblValues); 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; } } else { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Please select correct employee'; return $data; } } else { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Please select correct employee'; return $data; } } function insert_settlement_office($postdata) { $data=array(); $this->db->trans_begin(); $office_settlement_date= $this->mastermodel->convertdateformat($postdata['office_settlement_date']); $tblValues=array( 'office_settlement_leave_id'=>$postdata['office_leave_id'], 'office_settlement_date'=>$office_settlement_date, 'office_settlement_status'=>$postdata['office_settlement_status'] ); $this->db->insert('office_settlement', $tblValues); $data['resfunction']='search_settlement_office'; 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_exit_office($postdata) { $data=array(); $this->db->trans_begin(); $office_exit_resignation_date= $this->mastermodel->convertdateformat($postdata['office_exit_resignation_date']); $office_exit_relieving_date= $this->mastermodel->convertdateformat($postdata['office_exit_relieving_date']); $tblValues=array('office_exit_leave_id'=>$postdata['office_leave_id'], 'office_exit_resignation_date'=>$office_exit_resignation_date, 'office_exit_relieving_date'=>$office_exit_relieving_date, 'office_exit_clearence_form_name'=>$postdata['office_exit_clearence_form_name'], 'office_exit_clearence_form_doc'=>$postdata['office_exit_clearence_form_doc'], 'office_exit_resignation_letter_name'=>$postdata['office_exit_resignation_letter_name'], 'office_exit_resignation_letter_doc'=>$postdata['office_exit_resignation_letter_doc'], 'office_exit_relieving_letter_name'=>$postdata['office_exit_relieving_letter_name'], 'office_exit_relieving_letter_doc'=>$postdata['office_exit_relieving_letter_doc'], 'office_exit_status'=>$postdata['office_exit_status'], ); $this->db->insert('office_exit', $tblValues); $data['resfunction']='search_exit_office'; 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_employee_personal_office($postdata) { if($postdata['office_employee_name']!="" && (strstr($postdata['office_employee_name'], '<') != "")) { $no_array = explode('<', $postdata['office_employee_immediate_superior_id']); $employee_no = trim($no_array[1],">"); $office_employee_immediate_superior_id = $this->mastermodel->getSingleFieldValue('office_employee','office_employee_id','office_employee_no',$employee_no); } else { $office_employee_immediate_superior_id = ""; } $data=array(); $this->db->trans_begin(); $doj= $this->mastermodel->convertdateformat($postdata['office_employee_joining_date']); $tblValues=array( 'office_employee_name'=>$postdata['office_employee_name'], 'office_employee_joining_date'=>$doj, 'office_employee_visa_type_id'=>$postdata['office_employee_visa_type_id'], 'office_employee_grade_id'=>$postdata['office_employee_grade_id'], 'office_employee_designation_id'=>$postdata['office_employee_designation_id'], 'office_employee_department'=>$postdata['office_employee_department'], 'office_employee_immediate_superior_id'=>$office_employee_immediate_superior_id, 'office_employee_highest_education'=>$postdata['office_employee_highest_education'], 'office_employee_passing_year'=>$postdata['office_employee_passing_year'], 'office_employee_work_experience'=>$postdata['office_employee_work_experience'], 'office_employee_comments'=>$postdata['office_employee_comments'], 'office_employee_photo_name'=>$postdata['office_employee_photo_name'], 'office_employee_photo_doc'=>$postdata['office_employee_photo_doc'], 'office_employee_application_form_name'=>$postdata['office_employee_application_form_name'], 'office_employee_application_form_doc'=>$postdata['office_employee_application_form_doc'], 'office_employee_offer_letter_name'=>$postdata['office_employee_offer_letter_name'], 'office_employee_offer_letter_doc'=>$postdata['office_employee_offer_letter_doc'], 'office_employee_other_doc_name'=>$postdata['office_employee_other_doc_name'], 'office_employee_other_doc_doc'=>$postdata['office_employee_other_doc_doc'] ); $this->db->where('office_employee_id', $postdata['office_employee_id']); $this->db->update('office_employee', $tblValues); $data['resfunction']='search_employee_personal_office'; 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_leave_office($postdata) { $data=array(); $this->db->trans_begin(); $office_leave_starting_date= $this->mastermodel->convertdateformat($postdata['office_leave_starting_date']); if($postdata['office_leave_type_id']=='3') { $postdata['office_leave_ending_date']='00-00-0000'; } $office_leave_ending_date= $this->mastermodel->convertdateformat($postdata['office_leave_ending_date']); $tblValues=array( 'office_leave_type_id'=>$postdata['office_leave_type_id'], 'office_leave_reason'=>$postdata['office_leave_reason'], 'office_leave_starting_date'=>$office_leave_starting_date, 'office_leave_ending_date'=>$office_leave_ending_date, 'office_leave_remarks'=>$postdata['office_leave_remarks'], 'office_leave_status'=>$postdata['office_leave_status'] ); $this->db->where('office_leave_id', $postdata['office_leave_id']); $this->db->update('office_leave', $tblValues); $data['resfunction']='search_leave_office'; 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 Updated Successfully'; return $data; } } function update_settlement_office($postdata) { $data=array(); $this->db->trans_begin(); $office_settlement_date= $this->mastermodel->convertdateformat($postdata['office_settlement_date']); $tblValues=array( 'office_settlement_date'=>$office_settlement_date, 'office_settlement_status'=>$postdata['office_settlement_status'] ); $this->db->where('office_settlement_id', $postdata['office_settlement_id']); $this->db->update('office_settlement', $tblValues); $data['resfunction']='search_settlement_office'; 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 Updated Successfully'; return $data; } } function update_exit_office($postdata) { $data=array(); $this->db->trans_begin(); $office_exit_date= $this->mastermodel->convertdateformat($postdata['office_exit_date']); $tblValues=array( 'office_exit_date'=>$office_exit_date, 'office_exit_status'=>$postdata['office_exit_status'] ); $this->db->where('office_exit_id', $postdata['office_exit_id']); $this->db->update('office_exit', $tblValues); $data['resfunction']='search_exit_office'; 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 Updated Successfully'; return $data; } } function get_all_employees_office() { $data = array(); $sql = "select office_employee_name, office_employee_no from office_employee"; $sql.= " where office_employee_active =1 order by office_employee_name"; $Q = $this->db->query($sql); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } }