?
Current Path : /home1/savoy/www/savoyglobal.net/hr/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/hr/application/models/onboardingmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Onboardingmodel 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_expected_arrival($pagenum) { $data=array(); $this->db->from('expected_arrival'); $this->db->join('master','master_id=expected_arrival_id'); $this->db->join('trade','trade_id=expected_arrival_trade'); $this->db->join('nationality','nationality_id=expected_arrival_nationality'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'expected_arrival_date') { $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 == 'expected_arrival_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('expected_arrival'); $this->db->join('master','master_id=expected_arrival_id'); $this->db->join('trade','trade_id=expected_arrival_trade'); $this->db->join('nationality','nationality_id=expected_arrival_nationality'); $this->db->limit($perpage, $start); $this->db->order_by('created_time','desc'); $data['results']=$this->db->get(); return $data; } function search_employee_joining($pagenum) { $data=array(); $this->db->from('employee_non_main'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('nationality','nationality_id=emp_non_nationality_id'); $this->db->join('batch','id=batch_id'); $this->db->where('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); } $sql =("SELECT emp_non_full_name,trade_name,nationality_name,emp_non_date_joining,emp_non_id,batch_code, CONCAT(`employee_non_main`.`emp_non_no_old`,',' ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no FROM (`employee_non_main`) JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_id` JOIN `nationality` ON `nationality_id`=`emp_non_nationality_id` JOIN `batch` ON `id`=`batch_id` JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` where active = '1'"); if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY emp_non_id ORDER BY `emp_non_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_employee_rejoining($pagenum) { $data=array(); $this->db->from('employee_non_main'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('nationality','nationality_id=emp_non_nationality_id'); $this->db->join('batch','id=batch_id'); $this->db->where('active','0'); $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); } $sql =("SELECT emp_non_full_name,trade_name,nationality_name,emp_non_date_joining,emp_non_id,batch_code, CONCAT(`employee_non_main`.`emp_non_no_old`,',' ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no FROM (`employee_non_main`) JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_id` JOIN `nationality` ON `nationality_id`=`emp_non_nationality_id` JOIN `batch` ON `id`=`batch_id` JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` where active = '0'"); if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY emp_non_id ORDER BY `emp_non_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_employee_personal($pagenum) { $data=array(); $this->db->from('employee_non_main'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('nationality','nationality_id=emp_non_nationality_id'); $this->db->join('batch','id=batch_id'); $this->db->where('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; $sql =("SELECT emp_non_full_name,trade_name,nationality_name,emp_non_date_joining,`employee_non_main`.`emp_non_id`,batch_code, CONCAT(`employee_non_main`.`emp_non_no_old`,',' ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no , IFNULL(`emp_non_personal`.`emp_non_id`,'9999999999999') as emp_non_id_new,emp_non_personal.rejoined FROM (`employee_non_main`) JOIN `master` ON `master_id`=`employee_non_main`.`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_id` JOIN `nationality` ON `nationality_id`=`emp_non_nationality_id` JOIN `batch` ON `id`=`batch_id` JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` LEFT JOIN emp_non_personal ON `emp_non_personal`.`emp_non_id` = `employee_non_main`.`emp_non_id` where active = '1'"); if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'emp_non_date_joining') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY emp_non_id ORDER BY emp_non_id_new DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_joining($pagenum) { $data=array(); $data['startpage']=""; $data['endpage']=""; $data['count']=""; $this->db->select('*'); $this->db->from('joining'); $this->db->order_by('joining_id','asc'); $data['results']=$this->db->get(); return $data; } function search_batch($pagenum) { $data=array(); $this->db->from('batch'); $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('batch'); $this->db->limit($perpage, $start); $this->db->order_by('batch_date','desc'); $data['results']=$this->db->get(); return $data; } function search_camp_allotment($pagenum) { $data=array(); $this->db->from('camp'); $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('camp'); $this->db->limit($perpage, $start); $this->db->order_by('camp_id','desc'); $data['results']=$this->db->get(); return $data; } function search_site_allotment($pagenum) { $data=array(); $this->db->from('site'); $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('site'); $this->db->limit($perpage, $start); $this->db->order_by('site_id','desc'); $data['results']=$this->db->get(); return $data; } function search_item_allotment($pagenum) { $data=array(); $arr=$this->fpaginate->paginate($pagenum,'1'); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']='1'; $data['results']=''; return $data; } function search_employee_popup($search_field,$search_text) { $data=array(); $this->db->like($search_field, $search_text, 'after'); $this->db->select('*'); $this->db->from('employee_non_main'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('nationality','nationality_id=emp_non_nationality_id'); $this->db->join('batch','id=batch_id'); $this->db->order_by('batch_date','desc'); $data['results']=$this->db->get(); return $data; } /*Search function ends here*/ /*Add function starts here*/ function insert_expected_arrival($postdata) { $data=array(); $this->db->trans_begin(); $master_id = $this->mastermodel->insertmasterdata(); $arrival_date = $this->mastermodel->convertdateformat($postdata['expected_arrival_date']); $tblValues=array('expected_arrival_id'=>$master_id, 'expected_arrival_date'=>$arrival_date, 'expected_arrival_trade'=>$postdata['expected_arrival_trade'], 'no_employees'=>$postdata['no_employees'], 'expected_arrival_nationality'=>$postdata['expected_arrival_nationality']); $this->db->insert('expected_arrival', $tblValues); $i=1; while (isset($postdata['user_id_'.$i])) { if(isset($postdata['select_user_'.$i])) { $master_id = $this->mastermodel->insertmasterdata($postdata['user_id_'.$i]); $tblValues=array('reminder_id'=>$master_id, 'reminder_date'=>$arrival_date, 'remind_before'=>'5', 'reminder_subject'=>'Expected arrival of employees', 'reminder_description'=>''); $this->db->insert('reminder', $tblValues); } $i++; } $data['resfunction']='search_expected_arrival'; 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_batch($postdata) { $data=array(); $this->db->trans_begin(); $batch_date = $this->mastermodel->convertdateformat($postdata['batch_date']); $num=$this->mastermodel->norecords("batch"); $batch_code = $postdata['batch_date']."-".($num+1); $tblValues=array( 'batch_date'=>$batch_date, 'batch_code'=>$batch_code); $this->db->insert('batch', $tblValues); $data['resfunction']='search_joining'; $data['batch_id']= mysql_insert_id(); $data['batch_date']= $postdata['batch_date']; 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']='New Batch Created Successfully'; return $data; } } function insert_emp_non_main($postdata) { $data=array(); $this->db->trans_begin(); $num_rows_emp_no=0; $joining_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_joining']); $passport_issue_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_passport_issue']); $passport_expiry_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_passport_expiry']); $visa_issue_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_visa_issue']); $visa_expiry_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_visa_expiry']); $master_id = $this->mastermodel->insertmasterdata(); $visa_code = $this->mastermodel->getSingleFieldValue('visa_type','visa_code','visa_type_id',$postdata['emp_non_visa_type_id']); $nationality_code = $this->mastermodel->getSingleFieldValue('nationality','nationality_code','nationality_id',$postdata['emp_non_nationality_id']); $num_rows_emp = $this->mastermodel->number_rows('employee_non_main','emp_non_visa_type_id',$postdata['emp_non_visa_type_id'],'emp_non_sponsor_id',$postdata['emp_non_sponsor_id'],'emp_non_nationality_id',$postdata['emp_non_nationality_id']); $sponsor_code= $this->mastermodel->getSingleFieldValue('sponsor','sponsor_code','sponsor_id',$postdata['emp_non_sponsor_id']); do { if($visa_code == 0) { $emp_non_no = $sponsor_code.$nationality_code.str_pad($num_rows_emp, 4, "0", STR_PAD_LEFT); } else { $emp_non_no = "2".$sponsor_code.$nationality_code.str_pad($num_rows_emp, 3, "0", STR_PAD_LEFT); } $num_rows_emp_no = $this->mastermodel->number_rows('visa_processing','employee_no',$emp_non_no); $num_rows_emp++; }while($num_rows_emp_no!=0); $tblValues=array( 'emp_non_id'=>$master_id, 'batch_id'=>$postdata['batch_id'], 'emp_non_no'=>$emp_non_no, 'emp_non_no_old'=>$postdata['emp_non_no_old'], 'emp_non_full_name'=>$postdata['emp_non_full_name'], 'emp_non_date_joining'=>$joining_date, 'emp_non_nationality_id'=>$postdata['emp_non_nationality_id'], 'emp_non_trade_id'=>$postdata['emp_non_trade_id'], 'emp_non_visa_type_id'=>$postdata['emp_non_visa_type_id'], 'emp_non_date_visa_issue'=>$visa_issue_date, 'emp_non_date_visa_expiry'=>$visa_expiry_date, 'emp_non_visa_remind_before'=>$postdata['emp_non_visa_remind_before'], 'emp_non_visa_no'=>$postdata['emp_non_visa_no'], 'emp_non_sponsor_id'=>$postdata['emp_non_sponsor_id'], 'emp_non_agency_id'=>$postdata['emp_non_agency_id'], 'emp_non_passport_no'=>$postdata['emp_non_passport_no'], 'emp_non_date_passport_issue'=>$passport_issue_date, 'emp_non_date_passport_expiry'=>$passport_expiry_date, 'emp_non_passport_remind_before'=>$postdata['emp_non_passport_remind_before'], 'agreement_name'=>$postdata['agreement_name'], 'agreement_doc'=>$postdata['agreement_doc'], 'attestment_name'=>$postdata['attestment_name'], 'attestment_doc'=>$postdata['attestment_doc']); $this->db->insert('employee_non_main', $tblValues); $tblValues=array( 'employee_id'=>$master_id, 'trade_change_date'=>$joining_date, 'trade_id'=>$postdata['emp_non_trade_id']); $this->db->insert('trade_change', $tblValues); $tblValues=array( 'employee_id'=>$master_id, 'visa_type_id'=>$postdata['emp_non_visa_type_id'], 'visa_issue_date'=>$visa_issue_date, 'visa_expiry_date'=>$visa_expiry_date, 'visa_remind_before'=>$postdata['emp_non_visa_remind_before'], 'visa_no'=>$postdata['emp_non_visa_no'], 'sponsor_id'=>$postdata['emp_non_sponsor_id'], 'employee_no'=>$emp_non_no); $this->db->insert('visa_processing', $tblValues); $tblValues=array( 'employee_id'=>$master_id, 'effective_date'=>$joining_date, 'employee_no'=>$emp_non_no, 'employee_status'=> '1'); $this->db->insert('employee_status', $tblValues); $tblValues=array( 'employee_id'=>$master_id, 'passport_no'=>$postdata['emp_non_passport_no'], 'passport_issue_date'=>$passport_issue_date, 'passport_expiry_date'=>$passport_expiry_date, 'passport_remind_before'=>$postdata['emp_non_passport_remind_before'], ); $this->db->insert('passport_processing', $tblValues); $i=1; $alert_id = $this->mastermodel->insert_alert('1',$master_id); while (isset($postdata['user_id_'.$i])) { if(isset($postdata['select_user_'.$i])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id_'.$i]); $this->db->insert('alert_user', $tblValues); } $i++; } $remind_before = $postdata['emp_non_visa_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($visa_expiry_date)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('2',$master_id,$alert_date); $user_list = $this->mastermodel->get_alert_users('2'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } $remind_before = $postdata['emp_non_passport_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($passport_expiry_date)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('29',$master_id,$alert_date); $user_list = $this->mastermodel->get_alert_users('29'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } $data['resfunction']='search_joining'; $data['batch_id']= $postdata['batch_id']; $data['batch_date']= $postdata['batch_date']; 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']='New Employee added to Batch.. Add another'; return $data; } } function insert_employee_rejoining($postdata) { $data=array(); $this->db->trans_begin(); $num_rows_emp_no=0; $joining_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_joining']); $nationality_code = $this->mastermodel->getSingleFieldValue('nationality','nationality_code','nationality_id',$postdata['emp_non_nationality_id']); $old_details = $this->mastermodel->get_data_srow('employee_non_main',$postdata['emp_non_id'],'emp_non_id'); if(isset ($postdata['change_emp_no']) || isset ($postdata['new_visa'])) { if(isset ($postdata['new_visa'])) { $visa_issue_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_visa_issue']); $visa_expiry_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_visa_expiry']); $visa_remind_before = $postdata['emp_non_visa_remind_before']; $visa_no = $postdata['emp_non_visa_no']; $visa_type_id=$postdata['emp_non_visa_type_id']; $visa_code = $this->mastermodel->getSingleFieldValue('visa_type','visa_code','visa_type_id',$postdata['emp_non_visa_type_id']); $num_rows_emp = $this->mastermodel->number_rows('employee_non_main','emp_non_visa_type_id',$postdata['emp_non_visa_type_id'],'emp_non_sponsor_id',$postdata['emp_non_sponsor_id'],'emp_non_nationality_id',$postdata['emp_non_nationality_id']); } else { $visa_issue_date = $old_details->emp_non_date_visa_issue; $visa_expiry_date = $old_details->emp_non_date_visa_expiry; $visa_remind_before = $old_details->emp_non_visa_remind_before; $visa_no = $old_details->emp_non_visa_no; $visa_code = $this->mastermodel->getSingleFieldValue('visa_type','visa_code','visa_type_id',$old_details->emp_non_visa_type_id); $visa_type_id=$old_details->emp_non_visa_type_id; $num_rows_emp = $this->mastermodel->number_rows('employee_non_main','emp_non_visa_type_id',$old_details->emp_non_visa_type_id,'emp_non_sponsor_id',$postdata['emp_non_sponsor_id'],'emp_non_nationality_id',$postdata['emp_non_nationality_id']); } $sponsor_code= $this->mastermodel->getSingleFieldValue('sponsor','sponsor_code','sponsor_id',$postdata['emp_non_sponsor_id']); do { if($visa_code == 0) { $emp_non_no = $sponsor_code.$nationality_code.str_pad($num_rows_emp, 4, "0", STR_PAD_LEFT); } else { $emp_non_no = "2".$sponsor_code.$nationality_code.str_pad($num_rows_emp, 3, "0", STR_PAD_LEFT); } $num_rows_emp_no = $this->mastermodel->number_rows('visa_processing','employee_no',$emp_non_no); $num_rows_emp++; }while($num_rows_emp_no!=0); } else { $visa_issue_date = $old_details->emp_non_date_visa_issue; $visa_no = $old_details->emp_non_visa_no; $visa_expiry_date = $old_details->emp_non_date_visa_expiry; $visa_remind_before = $old_details->emp_non_visa_remind_before; $visa_type_id=$old_details->emp_non_visa_type_id; $emp_non_no=$postdata['emp_non_no']; } if(isset ($postdata['new_passport'])) { $passport_no=$postdata['emp_non_passport_no']; $passport_issue_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_passport_issue']); $passport_expiry_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_passport_expiry']); $passport_remind_before=$postdata['emp_non_passport_remind_before']; $tblValues=array( 'employee_id'=>$postdata['emp_non_id'], 'passport_no'=>$passport_no, 'passport_issue_date'=>$passport_issue_date, 'passport_expiry_date'=>$passport_expiry_date, 'passport_remind_before'=>$passport_remind_before, ); $this->db->insert('passport_processing', $tblValues); $remind_before = $postdata['emp_non_passport_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($passport_expiry_date)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('29',$postdata['emp_non_id'],$alert_date); $user_list = $this->mastermodel->get_alert_users('29'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } else { $passport_no= $old_details->emp_non_passport_no; $passport_issue_date= $old_details->emp_non_date_passport_issue; $passport_expiry_date= $old_details->emp_non_date_passport_expiry; $passport_remind_before=$old_details->emp_non_passport_remind_before; } $tblValues=array( 'batch_id'=>$postdata['batch_id'], 'emp_non_no'=>$emp_non_no, 'emp_non_no_old'=>$postdata['emp_non_no_old'], 'emp_non_full_name'=>$postdata['emp_non_full_name'], 'emp_non_date_joining'=>$joining_date, 'emp_non_nationality_id'=>$postdata['emp_non_nationality_id'], 'emp_non_trade_id'=>$postdata['emp_non_trade_id'], 'emp_non_visa_type_id'=>$visa_type_id, 'emp_non_date_visa_issue'=>$visa_issue_date, 'emp_non_date_visa_expiry'=>$visa_expiry_date, 'emp_non_visa_remind_before'=>$visa_remind_before, 'emp_non_visa_no'=>$visa_no, 'emp_non_sponsor_id'=>$postdata['emp_non_sponsor_id'], 'emp_non_agency_id'=>$postdata['emp_non_agency_id'], 'emp_non_passport_no'=>$passport_no, 'emp_non_date_passport_issue'=>$passport_issue_date, 'emp_non_date_passport_expiry'=>$passport_expiry_date, 'emp_non_passport_remind_before'=>$passport_remind_before, 'active'=>1); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('employee_non_main', $tblValues); if($postdata['agreement_doc']!='') { $tblValues=array( 'agreement_doc'=>$postdata['agreement_doc']); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('employee_non_main', $tblValues); } if($postdata['attestment_doc']!='') { $tblValues=array( 'attestment_doc'=>$postdata['attestment_doc']); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('employee_non_main', $tblValues); } if(isset ($postdata['new_visa'])) { $tblValues=array( 'employee_id'=>$postdata['emp_non_id'], 'visa_type_id'=>$postdata['emp_non_visa_type_id'], 'visa_issue_date'=>$visa_issue_date, 'visa_expiry_date'=>$visa_expiry_date, 'visa_remind_before'=>$visa_remind_before, 'visa_no'=>$postdata['emp_non_visa_no'], 'sponsor_id'=>$postdata['emp_non_sponsor_id'], 'employee_no'=>$emp_non_no); $this->db->insert('visa_processing', $tblValues); $remind_before = $visa_remind_before; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($visa_expiry_date)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('2',$postdata['emp_non_id'],$alert_date); $user_list = $this->mastermodel->get_alert_users('2'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } $tblValues=array( 'employee_id'=>$postdata['emp_non_id'], 'effective_date'=>$joining_date, 'employee_no'=>$emp_non_no, 'employee_status'=> '1'); $this->db->insert('employee_status', $tblValues); $i=1; $alert_id = $this->mastermodel->insert_alert('1',$postdata['emp_non_id']); while (isset($postdata['user_id_'.$i])) { if(isset($postdata['select_user_'.$i])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id_'.$i]); $this->db->insert('alert_user', $tblValues); } $i++; } $tblValues=array( 'rejoined'=>'1'); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('emp_non_personal', $tblValues); $data['resfunction']='search_employee_rejoining'; 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']='Employee Activated'; return $data; } } function insert_emp_non_personal($postdata) { $data=array(); $this->db->trans_begin(); $dob= $this->mastermodel->convertdateformat($postdata['emp_non_personal_dob']); $vacation_date= $this->mastermodel->convertdateformat($postdata['emp_non_personal_vacation_date']); $tblValues=array( 'emp_non_id'=>$postdata['emp_non_id'], 'emp_non_personal_dob'=>$dob, 'emp_non_personal_father_name'=>$postdata['emp_non_personal_father_name'], 'emp_non_personal_religion_id'=>$postdata['emp_non_personal_religion_id'], 'emp_non_personal_permanent_address'=>$postdata['emp_non_personal_permanent_address'], 'emp_non_personal_contact_no'=>$postdata['emp_non_personal_contact_no'], 'emp_non_personal_nok_name'=>$postdata['emp_non_personal_nok_name'], 'emp_non_personal_nok_contact_no'=>$postdata['emp_non_personal_nok_contact_no'], 'emp_non_personal_vacation_date'=>$vacation_date, 'emp_non_personal_vacation_remind_before'=>$postdata['emp_non_personal_vacation_remind_before'], 'emp_non_personal_other_trade'=>$postdata['emp_non_personal_other_trade'], 'photo_name'=>$postdata['photo_name'], 'photo_doc'=>$postdata['photo_doc']); $this->db->insert('emp_non_personal', $tblValues); $salary_increment_date= $this->mastermodel->convertdateformat($postdata['emp_non_personal_wef_salary_date']); $tblValues=array( 'salary_increment'=>$postdata['emp_non_personal_salary'], 'salary_increment_date'=>$salary_increment_date, 'employee_id'=>$postdata['emp_non_id']); $this->db->insert('salary', $tblValues); if($postdata['emp_non_personal_vacation_date']!="") { $remind_before = $postdata['emp_non_personal_vacation_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($vacation_date)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('3',$postdata['emp_non_id'],$alert_date); $user_list = $this->mastermodel->get_alert_users('3'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } $alert_id = $this->mastermodel->insert_alert('8',$postdata['emp_non_id']); $i=1; while (isset($postdata['user_id_'.$i])) { if(isset($postdata['select_user_'.$i])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id_'.$i]); $this->db->insert('alert_user', $tblValues); } $i++; } $alert_id = $this->mastermodel->insert_alert('9',$postdata['emp_non_id']); $i=1; while (isset($postdata['user_id1_'.$i])) { if(isset($postdata['select_user1_'.$i])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id1_'.$i]); $this->db->insert('alert_user', $tblValues); } $i++; } if($postdata['alert_id']=="") { $this->mastermodel->mark_completed_emp($postdata['emp_non_id'],'1'); $data['resfunction']='search_employee_personal'; } else { $this->mastermodel->mark_completed($postdata['alert_id']); $data['resfunction'] = 'return_page'; $data['alert_id'] = $postdata['alert_id']; } 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_camp_allotment($postdata) { $data=array(); $this->db->trans_begin(); $camp_allotment_date= $this->mastermodel->convertdateformat($postdata['camp_allotment_date']); $i=1; while (isset($postdata['employee_id_'.$i])) { if(isset($postdata['select_employee_'.$i])) { $employee = $postdata['employee_id_'.$i]; $tblValues=array( 'camp_id'=>$postdata['camp_id'], 'camp_allotment_date'=>$camp_allotment_date, 'employee_id'=>$employee); $this->db->insert('camp_allotment', $tblValues); $data['resfunction']='search_camp_allotment'; $number = $this->mastermodel->number_rows('alert','alert_master_id','12','employee_id',$employee); if($number==0) { $alert_id = $this->mastermodel->insert_alert('12',$employee); $j=1; while (isset($postdata['user_id_'.$j])) { if(isset($postdata['select_user_'.$j])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id_'.$j]); $this->db->insert('alert_user', $tblValues); } $j++; } } $this->mastermodel->mark_completed_emp($employee,'8'); $data['resfunction']='search_camp_allotment'; } $i++; } 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']='Selected Employees alloted to camp'; return $data; } } function insert_site_allotment($postdata) { $data=array(); $this->db->trans_begin(); $site_allotment_date= $this->mastermodel->convertdateformat($postdata['site_allotment_date']); $i=1; while (isset($postdata['employee_id_'.$i])) { if(isset($postdata['select_employee_'.$i])) { $employee = $postdata['employee_id_'.$i]; $tblValues=array( 'site_id'=>$postdata['site_id'], 'site_allotment_date'=>$site_allotment_date, 'employee_id'=>$employee); $this->db->insert('site_allotment', $tblValues); $data['resfunction']='search_site_allotment'; $number = $this->mastermodel->number_rows('alert','alert_master_id','12','employee_id',$employee); if($number==0) { $alert_id = $this->mastermodel->insert_alert('12',$employee); $j=1; while (isset($postdata['user_id_'.$j])) { if(isset($postdata['select_user_'.$j])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id_'.$j]); $this->db->insert('alert_user', $tblValues); } $j++; } } $this->mastermodel->mark_completed_emp($employee,'9'); $data['resfunction']='search_site_allotment'; } $i++; } 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']='Selected Employees allocated to site'; return $data; } } function insert_item_allotment($postdata) { $data=array(); $this->db->trans_begin(); $item_allotment_date= $this->mastermodel->convertdateformat($postdata['item_allotment_date']); $tblValues=array( 'item_tool_allotment_date'=>$item_allotment_date, 'employee_id'=>$postdata['employee_id'], 'tool_remarks'=>$postdata['tool_remarks'], 'item_remarks'=>$postdata['item_remarks']); $this->db->insert('item_tool_allotment', $tblValues); $allotment_id = mysql_insert_id(); $i=1; $data['resfunction']='search_item_allotment'; while (isset($postdata['tool_id_'.$i])) { if(isset($postdata['select_tool_'.$i])) { $tool_allotment_expiry= $this->mastermodel->convertdateformat($postdata['tool_expiry_date_'.$i]); $tool = $postdata['tool_id_'.$i]; $tblValues=array( 'allotment_id'=>$allotment_id, 'tool_id'=>$tool, 'tool_allotment_expiry'=>$tool_allotment_expiry, 'tool_remind_before'=>$postdata['tool_remind_before_'.$i]); $this->db->insert('tool_allotment', $tblValues); $tool_alert=$this->mastermodel->getSingleFieldValue('tool_list','tool_alert','tool_id',$tool); if($tool_alert==1) { $remind_before = $postdata['tool_remind_before_'.$i]; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($tool_allotment_expiry)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('17',$postdata['employee_id'],$alert_date); $tblValues=array( 'alert_id'=>$alert_id, 'tool_id'=>$tool, ); $this->db->insert('alert_tool', $tblValues); $user_list = $this->mastermodel->get_alert_users('17'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } } $i++; } $i=1; while (isset($postdata['item_id_'.$i])) { if(isset($postdata['select_item_'.$i])) { $item = $postdata['item_id_'.$i]; if(isset ($postdata['item_size_'.$i])) { $item_size=$postdata['item_size_'.$i]; } else { $item_size=""; } $item_allotment_expiry= $this->mastermodel->convertdateformat($postdata['item_expiry_date_'.$i]); $tblValues=array( 'allotment_id'=>$allotment_id, 'item_id'=>$item, 'item_size'=>$item_size, 'item_allotment_expiry'=>$item_allotment_expiry, 'item_remind_before'=>$postdata['item_remind_before_'.$i]); $this->db->insert('item_allotment', $tblValues); $item_alert=$this->mastermodel->getSingleFieldValue('general_item','item_alert','item_id',$item); if($item_alert==1) { $remind_before = $postdata['item_remind_before_'.$i]; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($item_allotment_expiry)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('17',$postdata['employee_id'],$alert_date); $tblValues=array( 'alert_id'=>$alert_id, 'item_id'=>$item, ); $this->db->insert('alert_item', $tblValues); $user_list = $this->mastermodel->get_alert_users('17'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } } $i++; } $training = $this->mastermodel->get_if_training($postdata['employee_id']); if($training > 0) { $alert_id = $this->mastermodel->insert_alert('18',$postdata['employee_id']); $j=1; while (isset($postdata['user_id_'.$j])) { if(isset($postdata['select_user_'.$j])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id_'.$j]); $this->db->insert('alert_user', $tblValues); } $j++; } } if(isset($postdata['alert_id'])=="") { $this->mastermodel->mark_completed_emp($postdata['employee_id'],'12'); $data['resfunction']='search_item_allotment'; } else { $this->mastermodel->mark_completed($postdata['alert_id']); $data['resfunction'] = 'return_page'; $data['alert_id'] = $postdata['alert_id']; } 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']='Selected items allocated to employee'; return $data; } } /*Add function ends here*/ /*Update function starts here*/ function update_expected_arrival($postdata) { $data=array(); $this->db->trans_begin(); $arrival_date = $this->mastermodel->convertdateformat($postdata['expected_arrival_date']); $tblValues=array('expected_arrival_date'=>$arrival_date, 'expected_arrival_trade'=>$postdata['expected_arrival_trade'], 'no_employees'=>$postdata['no_employees'], 'expected_arrival_nationality'=>$postdata['expected_arrival_nationality']); $this->db->where('expected_arrival_id', $postdata['expected_arrival_id']); $this->db->update('expected_arrival', $tblValues); $data['resfunction']='search_expected_arrival'; 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_batch($postdata) { $data=array(); $this->db->trans_begin(); $num=$this->mastermodel->norecords("batch"); $batch_date = $this->mastermodel->convertdateformat($postdata['batch_date']); $batch_code = $postdata['batch_date']."-".($num+1); $tblValues=array('batch_date'=>$batch_date, 'batch_code'=>$batch_code); $this->db->where('id', $postdata['batch_id']); $this->db->update('batch', $tblValues); $data['resfunction']='search_batch'; 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_emp_non_main($postdata) { $data=array(); $this->db->trans_begin(); $today=date("Y-m-d"); $joining_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_joining']); $tblValues=array( 'emp_non_full_name'=>$postdata['emp_non_full_name'], 'emp_non_date_joining'=>$joining_date, 'emp_non_no_old'=>$postdata['emp_non_no_old'], 'emp_non_agency_id'=>$postdata['emp_non_agency_id'], 'emp_non_trade_id'=>$postdata['emp_non_trade_id'], 'agreement_name'=>$postdata['agreement_name'], 'agreement_doc'=>$postdata['agreement_doc'], 'attestment_name'=>$postdata['attestment_name'], 'attestment_doc'=>$postdata['attestment_doc']); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('employee_non_main', $tblValues); $tblValues=array( 'employee_id'=>$postdata['emp_non_id'], 'trade_change_date'=>$today, 'trade_id'=>$postdata['emp_non_trade_id']); $this->db->insert('trade_change', $tblValues); if($postdata['agreement_doc']!='') { $tblValues=array( 'agreement_doc'=>$postdata['agreement_doc']); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('employee_non_main', $tblValues); } if($postdata['attestment_doc']!='') { $tblValues=array( 'attestment_doc'=>$postdata['attestment_doc']); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('employee_non_main', $tblValues); } $data['resfunction']='search_joining'; 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']='Employee details updated successfully'; return $data; } } function update_emp_non_personal($postdata) { $data=array(); $this->db->trans_begin(); $today=date("Y-m-d"); $dob= $this->mastermodel->convertdateformat($postdata['emp_non_personal_dob']); $vacation_date= $this->mastermodel->convertdateformat($postdata['emp_non_personal_vacation_date']); $joining_date= $this->mastermodel->convertdateformat($postdata['emp_non_date_joining']); $tblValues=array( 'emp_non_full_name'=>$postdata['emp_non_full_name'], 'emp_non_date_joining'=>$joining_date, 'emp_non_no_old'=>$postdata['emp_non_no_old'], 'emp_non_agency_id'=>$postdata['emp_non_agency_id'], 'emp_non_trade_id'=>$postdata['emp_non_trade_id'], ); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('employee_non_main', $tblValues); $tblValues=array( 'employee_id'=>$postdata['emp_non_id'], 'trade_change_date'=>$today, 'trade_id'=>$postdata['emp_non_trade_id']); $this->db->insert('trade_change', $tblValues); $tblValues=array('emp_non_personal_dob'=>$dob, 'emp_non_personal_father_name'=>$postdata['emp_non_personal_father_name'], 'emp_non_personal_religion_id'=>$postdata['emp_non_personal_religion_id'], 'emp_non_personal_permanent_address'=>$postdata['emp_non_personal_permanent_address'], 'emp_non_personal_contact_no'=>$postdata['emp_non_personal_contact_no'], 'emp_non_personal_nok_name'=>$postdata['emp_non_personal_nok_name'], 'emp_non_personal_nok_contact_no'=>$postdata['emp_non_personal_nok_contact_no'], 'emp_non_personal_vacation_date'=>$vacation_date, 'emp_non_personal_vacation_remind_before'=>$postdata['emp_non_personal_vacation_remind_before'], 'emp_non_personal_other_trade'=>$postdata['emp_non_personal_other_trade'], 'photo_name'=>$postdata['photo_name'], 'photo_doc'=>$postdata['photo_doc']); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('emp_non_personal', $tblValues); if($postdata['salary_id']==0) { $tblValues=array( 'employee_id'=>$postdata['emp_non_id'], 'salary_increment'=>$postdata['emp_non_personal_salary'], 'salary_increment_date'=>$this->mastermodel->convertdateformat($postdata['emp_non_personal_wef_salary_date']) ); $this->db->insert('salary', $tblValues); } else { $tblValues=array( 'salary_increment'=>$postdata['emp_non_personal_salary'], 'salary_increment_date'=>$this->mastermodel->convertdateformat($postdata['emp_non_personal_wef_salary_date']) ); $this->db->where('salary_id', $postdata['salary_id']); $this->db->update('salary', $tblValues); } $i=1; while (isset($postdata['camp_allotment_id_'.$i])) { $tblValues=array( 'camp_allotment_date'=>$this->mastermodel->convertdateformat($postdata['camp_allotment_date_'.$i]) ); $this->db->where('camp_allotment_id', $postdata['camp_allotment_id_'.$i]); $this->db->update('camp_allotment', $tblValues); $i++; } $i=1; while (isset($postdata['site_allotment_id_'.$i])) { $tblValues=array( 'site_allotment_date'=>$this->mastermodel->convertdateformat($postdata['site_allotment_date_'.$i]) ); $this->db->where('site_allotment_id', $postdata['site_allotment_id_'.$i]); $this->db->update('site_allotment', $tblValues); $i++; } $this->db->select_min('alert_id'); $this->db->where('employee_id',$postdata['emp_non_id']); $this->db->where('alert_master_id','3'); $query = $this->db->get('alert'); $row=$query->row(); if(isset($row->alert_id)!="") { if($postdata['emp_non_personal_vacation_date']!="") { $remind_before = $postdata['emp_non_personal_vacation_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($vacation_date)) . " -$remind_before day")); $tblValues=array('alert_date'=>$alert_date); $this->db->where('alert_id', $row->alert_id); $this->db->update('alert', $tblValues); } else { $this->db->where('alert_id', $row->alert_id); $this->db->delete('alert'); } } else { if($postdata['emp_non_personal_vacation_date']!="") { $remind_before = $postdata['emp_non_personal_vacation_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($vacation_date)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('3',$postdata['emp_non_id'],$alert_date); $user_list = $this->mastermodel->get_alert_users('3'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } } $data['resfunction']='search_employee_personal'; 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 insert_emp_personal_rejoining($postdata) { $data=array(); $this->db->trans_begin(); $dob= $this->mastermodel->convertdateformat($postdata['emp_non_personal_dob']); $vacation_date= $this->mastermodel->convertdateformat($postdata['emp_non_personal_vacation_date']); $tblValues=array('emp_non_personal_dob'=>$dob, 'emp_non_personal_father_name'=>$postdata['emp_non_personal_father_name'], 'emp_non_personal_religion_id'=>$postdata['emp_non_personal_religion_id'], 'emp_non_personal_permanent_address'=>$postdata['emp_non_personal_permanent_address'], 'emp_non_personal_contact_no'=>$postdata['emp_non_personal_contact_no'], 'emp_non_personal_nok_name'=>$postdata['emp_non_personal_nok_name'], 'emp_non_personal_nok_contact_no'=>$postdata['emp_non_personal_nok_contact_no'], 'emp_non_personal_vacation_date'=>$vacation_date, 'emp_non_personal_vacation_remind_before'=>$postdata['emp_non_personal_vacation_remind_before'], 'emp_non_personal_other_trade'=>$postdata['emp_non_personal_other_trade'], 'photo_name'=>$postdata['photo_name'], 'photo_doc'=>$postdata['photo_doc'], 'rejoined'=>'0'); $this->db->where('emp_non_id', $postdata['emp_non_id']); $this->db->update('emp_non_personal', $tblValues); if($postdata['salary_id']==0) { $tblValues=array( 'employee_id'=>$postdata['emp_non_id'], 'salary_increment'=>$postdata['emp_non_personal_salary'], 'salary_increment_date'=>$this->mastermodel->convertdateformat($postdata['emp_non_personal_wef_salary_date']) ); $this->db->insert('salary', $tblValues); } else { $tblValues=array( 'salary_increment'=>$postdata['emp_non_personal_salary'], 'salary_increment_date'=>$this->mastermodel->convertdateformat($postdata['emp_non_personal_wef_salary_date']) ); $this->db->where('salary_id', $postdata['salary_id']); $this->db->update('salary', $tblValues); } if($postdata['emp_non_personal_vacation_date']!="") { $remind_before = $postdata['emp_non_personal_vacation_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($vacation_date)) . " -$remind_before day")); $alert_id = $this->mastermodel->insert_alert('3',$postdata['emp_non_id'],$alert_date); $user_list = $this->mastermodel->get_alert_users('3'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } $alert_id = $this->mastermodel->insert_alert('8',$postdata['emp_non_id']); $i=1; while (isset($postdata['user_id_'.$i])) { if(isset($postdata['select_user_'.$i])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id_'.$i]); $this->db->insert('alert_user', $tblValues); } $i++; } $alert_id = $this->mastermodel->insert_alert('9',$postdata['emp_non_id']); $i=1; while (isset($postdata['user_id1_'.$i])) { if(isset($postdata['select_user1_'.$i])) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$postdata['user_id1_'.$i]); $this->db->insert('alert_user', $tblValues); } $i++; } if($postdata['alert_id']=="") { $this->mastermodel->mark_completed_emp($postdata['emp_non_id'],'1'); $data['resfunction']='search_employee_personal'; } else { $this->mastermodel->mark_completed($postdata['alert_id']); $data['resfunction'] = 'return_page'; $data['alert_id'] = $postdata['alert_id']; } 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 get_unalloted_employees($table,$batch_code='',$employee_name='',$allotment_date="") { $data = array(); $sql = "select employee_non_main.emp_non_id, emp_non_full_name, emp_non_date_joining, batch_code, trade_name, CONCAT(`employee_non_main`.`emp_non_no_old`,',' ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no from employee_non_main JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` inner join emp_non_personal on emp_non_personal.emp_non_id=employee_non_main.emp_non_id inner join batch on id=batch_id inner join trade on emp_non_trade_id=trade_id where"; $sql .= " employee_non_main.emp_non_id not in (select employee_id from $table inner join employee_non_main e1 on e1.emp_non_id=$table.employee_id where ".$table."_date > e1.emp_non_date_joining)"; if($batch_code != "") { $sql.=" and batch_code like '$batch_code%'"; } if($employee_name != "") { $sql.=" and emp_non_full_name like '$employee_name%'"; } if($allotment_date != "") { $allotment_date= $this->mastermodel->convertdateformat($allotment_date); $sql.=" and emp_non_date_joining <= '$allotment_date'"; } $sql.= " and active = 1 GROUP BY emp_non_id order by batch_code, emp_non_full_name"; $Q = $this->db->query($sql); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /*Update function ends here*/ function get_emp_info($employee_no) { $data = array(); $this->db->select('*'); $this->db->from('employee_non_main'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('batch','id=batch_id'); $this->db->join('trade','emp_non_trade_id=trade_id'); $this->db->where('emp_non_no',$employee_no); $this->db->order_by('batch_date','desc'); $Q=$this->db->get(); $row=$Q->row(); return $row; } function get_joined_info($table,$id,$field,$table2,$field2,$order_field="") { $data = array(); $this->db->join($table2,"$table.$field2=$table2.$field2"); $this->db->where($field,$id); if($order_field != "") $this->db->order_by($order_field,'desc'); $Q= $this->db->get($table); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_joined_info_single($table,$id,$field,$table2,$field2) { $this->db->join($table2,"$table.$field2=$table2.$field2"); $this->db->where($field,$id); $Q = $this->db->get($table); $row=$Q->row(); return $row; } function get_item_info($employee_id) { $data = array(); $this->db->select('*, item_allotment.item_remind_before as item_allotment_remind_before'); $this->db->join("item_allotment","item_allotment.allotment_id=item_tool_allotment.allotment_id"); $this->db->join("general_item","general_item.item_id=item_allotment.item_id"); $this->db->where("item_tool_allotment.employee_id",$employee_id); $this->db->order_by("item_tool_allotment_date",'desc'); $Q= $this->db->get("item_tool_allotment"); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_tool_info($employee_id) { $data = array(); $this->db->select('*, tool_allotment.tool_remind_before as tool_allotment_remind_before'); $this->db->join("tool_allotment","tool_allotment.allotment_id=item_tool_allotment.allotment_id"); $this->db->join("tool_list","tool_list.tool_id=tool_allotment.tool_id"); $this->db->where("item_tool_allotment.employee_id",$employee_id); $this->db->order_by("item_tool_allotment_date",'desc'); $Q= $this->db->get("item_tool_allotment"); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_emp_camp_info($id) { $data = array(); $sql = "SELECT tt.*,employee_non_main.*,batch.*, CONCAT(`employee_non_main`.`emp_non_no_old`,',', GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no FROM camp_allotment tt INNER JOIN employee_non_main on employee_non_main.emp_non_id=tt.employee_id JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` INNER JOIN batch on employee_non_main.batch_id=batch.id INNER JOIN (SELECT employee_id, MAX(camp_allotment_date) AS alloted_date FROM camp_allotment GROUP BY employee_id) groupedtt ON tt.employee_id = groupedtt.employee_id AND tt.camp_allotment_date = groupedtt.alloted_date where camp_id = $id and active = 1 GROUP BY emp_non_id order by id desc"; $Q= $this->db->query($sql); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_emp_site_info($id) { $data = array(); $sql = "SELECT tt.*,employee_non_main.*,batch.*, CONCAT(`employee_non_main`.`emp_non_no_old`,',', GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no FROM site_allotment tt INNER JOIN employee_non_main on employee_non_main.emp_non_id=tt.employee_id JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` INNER JOIN batch on employee_non_main.batch_id=batch.id INNER JOIN (SELECT employee_id, MAX(site_allotment_date) AS alloted_date FROM site_allotment GROUP BY employee_id) groupedtt ON tt.employee_id = groupedtt.employee_id AND tt.site_allotment_date = groupedtt.alloted_date where site_id = $id and active = 1 GROUP BY emp_non_id order by id desc"; $Q = $this->db->query($sql); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_all_employees_batch($batch_id) { $data = array(); $sql = "select employee_non_main.emp_non_id, emp_non_full_name, emp_non_date_joining, batch_code, trade_name, CONCAT(`employee_non_main`.`emp_non_no_old`,',' ,GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no from employee_non_main JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` inner join emp_non_personal on emp_non_personal.emp_non_id=employee_non_main.emp_non_id inner join batch on id=batch_id inner join trade on emp_non_trade_id=trade_id"; $sql.= " where active =1 and batch_id = '$batch_id' GROUP BY emp_non_id order by batch_code, emp_non_full_name"; $Q = $this->db->query($sql); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function insert_camp_allotment_alert($postdata) { $data=array(); $this->db->trans_begin(); $camp_allotment_date= $this->mastermodel->convertdateformat($postdata['camp_allotment_date']); $tblValues=array( 'camp_id'=>$postdata['camp_id'], 'camp_allotment_date'=>$camp_allotment_date, 'employee_id'=>$postdata['employee_id']); $this->db->insert('camp_allotment', $tblValues); $this->mastermodel->mark_completed($postdata['alert_id']); $data['resfunction'] = 'return_page'; $data['alert_id'] = $postdata['alert_id']; 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']='Employee alloted to camp'; return $data; } } function insert_site_allotment_alert($postdata) { $data=array(); $this->db->trans_begin(); $site_allotment_date= $this->mastermodel->convertdateformat($postdata['site_allotment_date']); $tblValues=array( 'site_id'=>$postdata['site_id'], 'site_allotment_date'=>$site_allotment_date, 'employee_id'=>$postdata['employee_id']); $this->db->insert('site_allotment', $tblValues); $this->mastermodel->mark_completed($postdata['alert_id']); $data['resfunction'] = 'return_page'; $data['alert_id'] = $postdata['alert_id']; 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']='Employee alloted to site'; return $data; } } function getemployeevacationdetailsbyemployeeid($employee_id) { $query = "SELECT `exit`.`exit_date` , `leave_type`.`leave_type_name` FROM `exit` INNER JOIN `leave` ON (`exit`.`leave_id` = `leave`.`leave_id`) INNER JOIN `leave_type` ON (`leave`.`leave_type_id` = `leave_type`.`leave_type_id`) WHERE leave.employee_id = $employee_id"; return $this->db->query($query); } function getemployeerejoindatebyemployeeid($employee_id,$date) { $date= $this->mastermodel->convertdateformat($date); $query = "SELECT `effective_date` FROM `employee_status` WHERE employee_id=$employee_id AND `effective_date`> '$date' ORDER BY `effective_date` LIMIT 1"; $data=$this->db->query($query); $result= $data->row(); if($result) { return $result->effective_date; } else { return ""; } } }