?
Current Path : /home1/savoy/public_html/savoyglobal.net/sgms/draft/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/public_html/savoyglobal.net/sgms/draft/application/models/administrationmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Administrationmodel 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*/ /*Search function ends here*/ function search_attendance($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_salary($pagenum) { $data=array(); $this->db->from('salary'); $this->db->join('employee_non_main','salary.employee_id=employee_non_main.emp_non_id'); $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 salary_increment,salary_id,salary_increment_date,emp_non_full_name,trade_name,emp_non_id, 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 (`salary`) JOIN `employee_non_main` ON `emp_non_id`=`employee_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_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 == 'salary_increment_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY salary_id ORDER BY `salary_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_training($pagenum) { $data=array(); $this->db->from('employee_training'); $this->db->join('employee_non_main','employee_training.employee_id=employee_non_main.emp_non_id'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('training_module','training_module_id=training_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 trade_name,employee_training_id,emp_non_full_name,training_type, 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_training`) JOIN `employee_non_main` ON `emp_non_id`=`employee_training`.`employee_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_id` JOIN `training_module` ON `training_module_id`=`training_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']; $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY employee_training_id ORDER BY `employee_training_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_visa_processing($pagenum) { $data=array(); $this->db->from('visa_processing'); $this->db->join('employee_non_main','visa_processing.employee_id=employee_non_main.emp_non_id'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('visa_type','visa_processing.visa_type_id=visa_type.visa_type_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 visa_type_name,trade_name,visa_processing_id,emp_non_full_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 (`visa_processing`) JOIN `employee_non_main` ON `emp_non_id`=`employee_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_id` JOIN visa_type ON visa_processing.visa_type_id=visa_type.visa_type_id where active = '1'"); if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY visa_processing_id ORDER BY `visa_processing_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_passport_processing($pagenum) { $data=array(); $this->db->from('passport_processing'); $this->db->join('employee_non_main','passport_processing.employee_id=employee_non_main.emp_non_id'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('visa_processing','visa_processing.employee_id = employee_non_main.emp_non_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 *, 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 (`passport_processing`) JOIN `employee_non_main` ON `emp_non_id`=`employee_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_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']; $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY passport_processing_id ORDER BY `passport_processing_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_camp_shifting($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_shifting($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_reissue($pagenum) { $data=array(); $this->db->from('item_tool_allotment'); $this->db->join('employee_non_main','employee_non_main.emp_non_id=item_tool_allotment.employee_id'); $this->db->join('trade','trade_id=emp_non_trade_id'); $this->db->join('master','master_id=emp_non_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 allotment_id,item_tool_allotment_date,emp_non_full_name,trade_name,emp_non_date_joining,emp_non_id, 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 (`item_tool_allotment`) JOIN `employee_non_main` ON `employee_non_main`.`emp_non_id`=`item_tool_allotment`.`employee_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade_id`=`emp_non_trade_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 == 'item_tool_allotment_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY allotment_id ORDER BY `item_tool_allotment`.`allotment_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function insert_item_reissue($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_reissue'; 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); if(!isset($postdata['alert_id'])) { $alerts=$this->administrationmodel->gettoolalerts($tool,$postdata['employee_id']); foreach ($alerts as $alertitem) { $this->db->where('alert_id',$alertitem['alert_id']); $this->db->delete('alert'); } } $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); if(!isset($postdata['alert_id'])) { $alerts=$this->administrationmodel->getitemalerts($item,$postdata['employee_id']); foreach ($alerts as $alertitem) { $this->db->where('alert_id',$alertitem['alert_id']); $this->db->delete('alert'); } } $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++; } if(isset($postdata['alert_id'])!="") { $this->mastermodel->mark_completed($postdata['alert_id']); $data['alert_id'] = $postdata['alert_id']; $data['resfunction'] = 'return_page'; } 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; } } function update_item_reissue($postdata) { $data=array(); $this->db->trans_begin(); $allotment_id = $postdata['allotment_id']; $tblValues=array( 'item_tool_allotment_date'=>$this->mastermodel->convertdateformat($postdata['item_tool_allotment_date']), 'tool_remarks'=>$postdata['tool_remarks'], 'item_remarks'=>$postdata['item_remarks']); $this->db->where('allotment_id', $allotment_id); $this->db->update('item_tool_allotment', $tblValues); $this->db->where('allotment_id',$allotment_id); $this->db->delete('tool_allotment'); $this->db->where('allotment_id',$allotment_id); $this->db->delete('item_allotment'); $i=1; $data['resfunction']='search_item_reissue'; 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); $alerts=$this->administrationmodel->gettoolalerts($tool,$postdata['employee_id']); foreach ($alerts as $alertitem) { $this->db->where('alert_id',$alertitem['alert_id']); $this->db->delete('alert'); } $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); $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); } $tblValues=array( 'alert_id'=>$alert_id, 'tool_id'=>$tool, ); $this->db->insert('alert_tool', $tblValues); } } $i++; } $i=1; while (isset($postdata['item_id_'.$i])) { if(isset($postdata['select_item_'.$i])) { $item = $postdata['item_id_'.$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); $alerts=$this->administrationmodel->getitemalerts($item,$postdata['employee_id']); foreach ($alerts as $alertitem) { $this->db->where('alert_id',$alertitem['alert_id']); $this->db->delete('alert'); } $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); $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); } $tblValues=array( 'alert_id'=>$alert_id, 'item_id'=>$item, ); $this->db->insert('alert_item', $tblValues); } } $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 items allocated to employee'; return $data; } } function search_trade_change($pagenum) { $data=array(); $this->db->from('trade_change'); $this->db->join('employee_non_main','trade_change.employee_id=employee_non_main.emp_non_id'); $this->db->join('master','master_id=emp_non_id'); $this->db->join('trade','trade_change.trade_id=trade.trade_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 trade_name,emp_non_full_name,trade_change_date,remarks,trade_change_id, 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 (`trade_change`) JOIN `employee_non_main` ON `emp_non_id`=`employee_id` JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade`.`trade_id`=`emp_non_trade_id` where active = '1'"); if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY trade_change_id ORDER BY `trade_change_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_cir($pagenum) { $data=array(); $this->db->from('cir'); $this->db->join('employee_non_main','cir.employee_id=employee_non_main.emp_non_id'); $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 == 'cir_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 == 'cir_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $sql =("SELECT trade_name,emp_non_full_name,cir_id,cir_date, 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 (`cir`) JOIN `employee_non_main` ON `emp_non_id`=`employee_id` JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade`.`trade_id`=`emp_non_trade_id` where active = '1'"); if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'cir_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY cir_id ORDER BY `cir_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } function search_missing($pagenum) { $data=array(); $this->db->from('missing'); $this->db->join('employee_non_main','missing.employee_id=employee_non_main.emp_non_id'); $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 == 'wef_date' || $searchfield == 'exit_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 == 'wef_date' || $searchfield == 'exit_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $sql =("SELECT trade_name,emp_non_full_name,missing_id,wef_date,exit_date,missing_type, 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 (`missing`) JOIN `employee_non_main` ON `emp_non_id`=`employee_id` JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_id` JOIN `master` ON `master_id`=`emp_non_id` JOIN `trade` ON `trade`.`trade_id`=`emp_non_trade_id` where active = '1'"); if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'wef_date' || $searchfield == 'exit_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $sql.=" and $searchfield like '%$searchtext%'"; } $sql.=" GROUP BY missing_id ORDER BY `missing_id` DESC limit $start, $perpage"; $data['results']=$this->db->query($sql); return $data; } /*Add function starts here*/ function insert_camp_shifting($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['shift_to'], 'camp_allotment_date'=>$camp_allotment_date, 'employee_id'=>$employee); $this->db->insert('camp_allotment', $tblValues); } $i++; } $data['resfunction']='search_camp_shifting'; 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 shifted to camp'; return $data; } } function insert_site_shifting($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['shift_to'], 'site_allotment_date'=>$site_allotment_date, 'employee_id'=>$employee); $this->db->insert('site_allotment', $tblValues); } $i++; } $data['resfunction']='search_site_shifting'; 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 shifted to Site'; return $data; } } function insert_attendance($postdata) { $data=array(); $this->db->trans_begin(); $attendance_date= $this->mastermodel->convertdateformat($postdata['attendance_date']); $i=1; while (isset($postdata['employee_id_'.$i])) { if(isset($postdata['select_employee_'.$i])) { $employee = $postdata['employee_id_'.$i]; $tblValues=array( 'attendance_reason_id'=>$postdata['attendance_reason_id_'.$i], 'attendance_date'=>$attendance_date, 'employee_id'=>$employee); $this->db->insert('employee_absent', $tblValues); } $i++; } $data['resfunction']='search_attendance'; 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']='Employees Marked as Absent'; return $data; } } function insert_salary($postdata) { $data=array(); $this->db->trans_begin(); $salary_increment_date= $this->mastermodel->convertdateformat($postdata['salary_increment_date']); if(isset($postdata['employee_id']) == "") { $emp_num_array = explode(',', $postdata['employee_name']); $num=count($emp_num_array); $employee_number = $emp_num_array[$num-1]; $employee_number = trim($employee_number," "); $employee_id = $this->mastermodel->getSingleFieldValue('employee_non_main','emp_non_id','emp_non_no',$employee_number); } else $employee_id = $postdata['employee_id']; $tblValues=array( 'salary_increment'=>$postdata['salary_increment'], 'salary_increment_date'=>$salary_increment_date, 'remarks'=>$postdata['remarks'], 'employee_id'=>$employee_id); $this->db->insert('salary', $tblValues); $i=1; $salary_id=mysql_insert_id(); while (isset($postdata['allowance_id_'.$i])) { if(isset($postdata['select_allowance_'.$i])) { $allowance_id = $postdata['allowance_id_'.$i]; $allowance_amount= $postdata['allowance_amount_'.$i]; $tblValues=array( 'salary_id'=>$salary_id, 'allowance_id'=>$allowance_id, 'allowance_amount'=>$allowance_amount); $this->db->insert('salary_allowance', $tblValues); } $i++; } $i=1; while (isset($postdata['deduction_id_'.$i])) { if(isset($postdata['select_deduction_'.$i])) { $deduction_id = $postdata['deduction_id_'.$i]; $deduction_amount= $postdata['deduction_amount_'.$i]; $tblValues=array( 'salary_id'=>$salary_id, 'deduction_id'=>$deduction_id, 'deduction_amount'=>$deduction_amount); $this->db->insert('salary_deduction', $tblValues); } $i++; } $data['resfunction']='search_salary'; 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 Salary inserted Successfully'; return $data; } } function insert_training($postdata) { $data=array(); $this->db->trans_begin(); $training_date_start= $this->mastermodel->convertdateformat($postdata['training_date_start']); $training_date_end= $this->mastermodel->convertdateformat($postdata['training_date_end']); $first_attempt_date= $this->mastermodel->convertdateformat($postdata['first_attempt_date']); $second_attempt_date= $this->mastermodel->convertdateformat($postdata['second_attempt_date']); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'training_id'=>$postdata['training_id'], 'training_date_start'=>$training_date_start, 'training_date_end'=>$training_date_end, 'first_attempt_date'=>$first_attempt_date, 'second_attempt_date'=>$second_attempt_date, 'first_attempt_result'=>$postdata['first_attempt_result'], 'second_attempt_result'=>$postdata['second_attempt_result'], 'remarks'=>$postdata['remarks'],); $this->db->insert('employee_training', $tblValues); if(isset($postdata['alert_id'])=="") { $this->mastermodel->mark_completed_emp($postdata['employee_id'],'18'); $data['resfunction']='search_training'; } 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']='Employee Training Details inserted Successfully'; return $data; } } function insert_trade_change($postdata) { $data=array(); $this->db->trans_begin(); $trade_change_date= $this->mastermodel->convertdateformat($postdata['trade_change_date']); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'trade_id'=>$postdata['trade_id'], 'trade_change_date'=>$trade_change_date); $this->db->insert('trade_change', $tblValues); $tblValues=array('emp_non_trade_id'=>$postdata['trade_id']); $this->db->where('emp_non_id', $postdata['employee_id']); $this->db->update('employee_non_main', $tblValues); $i=1; while (isset($postdata['tool_id_'.$i])) { if(isset($postdata['select_tool_'.$i])) { $tool = $postdata['tool_id_'.$i]; $tblValues=array('returned'=>0); $this->db->where('tool_id',$tool); $this->db->where('employee_id',$postdata['employee_id']); $this->db->update('tool_allotment', $tblValues); } $i++; } $i=1; while (isset($postdata['1tool_id_'.$i])) { if(isset($postdata['1select_tool_'.$i])) { $tool_allotment_expiry= $this->mastermodel->convertdateformat($postdata['1tool_expiry_date_'.$i]); $tool = $postdata['1tool_id_'.$i]; $tblValues=array( 'tool_id'=>$tool, 'tool_allotment_date'=>$trade_change_date, 'employee_id'=>$postdata['employee_id'], 'tool_allotment_expiry'=>$tool_allotment_expiry, 'tool_remind_before'=>$postdata['1tool_remind_before_'.$i]); $this->db->insert('tool_allotment', $tblValues); } $i++; } $data['resfunction']='search_trade_change'; 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 Trade changed Successfully'; return $data; } } function insert_visa_processing($postdata) { $data=array(); $this->db->trans_begin(); $num_rows_emp_no=0; $visa_issue_date= $this->mastermodel->convertdateformat($postdata['visa_issue_date']); $visa_expiry_date= $this->mastermodel->convertdateformat($postdata['visa_expiry_date']); $emp_non_details = $this->mastermodel->get_data_srow('employee_non_main',$postdata['employee_id'],'emp_non_id'); $visa_code = $this->mastermodel->getSingleFieldValue('visa_type','visa_code','visa_type_id',$postdata['visa_type_id']); if(($visa_code== 0 && $postdata['visa_code'] != 0) || $postdata['sponsor_id'] != $emp_non_details->emp_non_sponsor_id) { $num_rows_emp = $this->mastermodel->number_rows('employee_non_main','emp_non_visa_type_id',$postdata['visa_type_id'],'emp_non_sponsor_id',$emp_non_details->emp_non_sponsor_id,'emp_non_nationality_id',$emp_non_details->emp_non_nationality_id); $nationality_code = $this->mastermodel->getSingleFieldValue('nationality','nationality_code','nationality_id',$emp_non_details->emp_non_nationality_id); $sponsor_code= $this->mastermodel->getSingleFieldValue('sponsor','sponsor_code','sponsor_id',$postdata['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); $sponsor_id = $postdata['sponsor_id']; } else { $emp_non_no = $emp_non_details->emp_non_no; $sponsor_id = $emp_non_details->emp_non_sponsor_id; } $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'visa_type_id'=>$postdata['visa_type_id'], 'visa_issue_date'=>$visa_issue_date, 'visa_expiry_date'=>$visa_expiry_date, 'visa_remind_before'=>$postdata['visa_remind_before'], 'visa_no'=>$postdata['visa_no'], 'medical'=>$postdata['medical'], 'blood_group'=>$postdata['blood_group'], 'id_card_no'=>$postdata['id_card_no'], 'health_card_no'=>$postdata['health_card_no'], 'fingerprint'=>$postdata['fingerprint'], 'sponsor_id'=>$sponsor_id, 'employee_no'=>$emp_non_no); $this->db->insert('visa_processing', $tblValues); $tblValues=array('emp_non_visa_type_id'=>$postdata['visa_type_id'], 'emp_non_sponsor_id'=>$sponsor_id, 'emp_non_date_visa_issue'=>$visa_issue_date, 'emp_non_date_visa_expiry'=>$visa_expiry_date, 'emp_non_visa_no'=>$postdata['visa_no'], 'emp_non_no'=>$emp_non_no, 'emp_non_visa_remind_before'=>$postdata['visa_remind_before']); $this->db->where('emp_non_id', $postdata['employee_id']); $this->db->update('employee_non_main', $tblValues); if(isset($postdata['alert_id'])) { $this->mastermodel->mark_completed($postdata['alert_id']); $data['resfunction'] = 'return_page'; $data['alert_id'] = $postdata['alert_id']; } else { $this->mastermodel->mark_completed_emp($postdata['employee_id'],'2'); $this->mastermodel->mark_completed_emp($postdata['employee_id'],'28'); $data['resfunction']='search_visa_processing'; } if($postdata['visa_code']!="0") { $i=1; $remind_before = $postdata['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['employee_id'],$alert_date); 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++; } } else { if($postdata['visa_expiry_date']!='') { $i=1; $remind_before = $postdata['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('28',$postdata['employee_id'],$alert_date); 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 ($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']='Visa Processing completed Successfully'; return $data; } } function insert_passport_processing($postdata) { $data=array(); $this->db->trans_begin(); $num_rows_emp_no=0; $passport_issue_date= $this->mastermodel->convertdateformat($postdata['passport_issue_date']); $passport_expiry_date= $this->mastermodel->convertdateformat($postdata['passport_expiry_date']); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'passport_no'=>$postdata['passport_no'], 'passport_issue_date'=>$passport_issue_date, 'passport_expiry_date'=>$passport_expiry_date, 'passport_remind_before'=>$postdata['passport_remind_before']); $this->db->insert('passport_processing', $tblValues); $tblValues=array( 'emp_non_passport_no'=>$postdata['passport_no'], 'emp_non_date_passport_issue'=>$passport_issue_date, 'emp_non_date_passport_expiry'=>$passport_expiry_date, 'emp_non_passport_remind_before'=>$postdata['passport_remind_before']); $this->db->where('emp_non_id', $postdata['employee_id']); $this->db->update('employee_non_main', $tblValues); $data['resfunction']='search_passport_processing'; if(isset($postdata['alert_id'])) { $this->mastermodel->mark_completed($postdata['alert_id']); $data['resfunction'] = 'return_page'; $data['alert_id'] = $postdata['alert_id']; } else { $this->mastermodel->mark_completed_emp($postdata['employee_id'],'29'); } $remind_before = $postdata['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['employee_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); } 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']='Passport Processing completed Successfully'; return $data; } } function insert_cir($postdata) { $data=array(); $this->db->trans_begin(); $cir_date= $this->mastermodel->convertdateformat($postdata['cir_date']); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'cir_date'=>$cir_date, 'comments'=>$postdata['comments'], 'cir_document_name'=>$postdata['cir_document_name'], 'cir_document_file'=>$postdata['cir_document_file'],); $this->db->insert('cir', $tblValues); $data['resfunction']='search_cir'; 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']='CIR Details inserted Successfully'; return $data; } } function insert_missing($postdata) { $data=array(); $this->db->trans_begin(); $wef_date= $this->mastermodel->convertdateformat($postdata['wef_date']); $exit_date= $this->mastermodel->convertdateformat($postdata['exit_date']); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'wef_date'=>$wef_date, 'remarks'=>$postdata['remarks'], 'exit_date'=>$exit_date, 'missing_type'=>$postdata['missing_type'],); $this->db->insert('missing', $tblValues); $missing_id=mysql_insert_id(); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'leave_type_id'=>'4', 'leave_reason'=>'Missing / Absconding', 'missing_id'=>$missing_id); $this->db->insert('leave', $tblValues); $data['resfunction']='search_missing'; 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']='Missing Details inserted Successfully'; return $data; } } /*Add function ends here*/ function update_salary($postdata) { $data=array(); $this->db->trans_begin(); $salary_increment_date= $this->mastermodel->convertdateformat($postdata['salary_increment_date']); $tblValues=array( 'salary_increment'=>$postdata['salary_increment'], 'salary_increment_date'=>$salary_increment_date, 'remarks'=>$postdata['remarks']); $this->db->where('salary_id', $postdata['salary_id']); $this->db->update('salary', $tblValues); $this->db->where('salary_id',$postdata['salary_id']); $this->db->delete('salary_allowance'); $this->db->where('salary_id',$postdata['salary_id']); $this->db->delete('salary_deduction'); $salary_id = $postdata['salary_id']; $i=1; while (isset($postdata['allowance_id_'.$i])) { if(isset($postdata['select_allowance_'.$i])) { $allowance_id = $postdata['allowance_id_'.$i]; $allowance_amount= $postdata['allowance_amount_'.$i]; $tblValues=array( 'salary_id'=>$salary_id, 'allowance_id'=>$allowance_id, 'allowance_amount'=>$allowance_amount); $this->db->insert('salary_allowance', $tblValues); } $i++; } $i=1; while (isset($postdata['deduction_id_'.$i])) { if(isset($postdata['select_deduction_'.$i])) { $deduction_id = $postdata['deduction_id_'.$i]; $deduction_amount= $postdata['deduction_amount_'.$i]; $tblValues=array( 'salary_id'=>$salary_id, 'deduction_id'=>$deduction_id, 'deduction_amount'=>$deduction_amount); $this->db->insert('salary_deduction', $tblValues); } $i++; } $data['resfunction']='search_salary'; 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 Salary inserted Successfully'; return $data; } } function update_attendance($postdata) { $data=array(); $this->db->trans_begin(); $attendance_date= $this->mastermodel->convertdateformat($postdata['attendance_date']); $i=1; while (isset($postdata['employee_id_'.$i])) { $employee = $postdata['employee_id_'.$i]; $tblValues=array( 'attendance_reason_id'=>$postdata['attendance_reason_id_'.$i], 'attendance_date'=>$attendance_date, 'employee_id'=>$employee); $this->db->where('employee_id',$employee); $this->db->where('attendance_date',$attendance_date); $this->db->delete('employee_absent'); $i++; } $i=1; while (isset($postdata['employee_id_'.$i])) { if(isset($postdata['select_employee_'.$i])) { $employee = $postdata['employee_id_'.$i]; $tblValues=array( 'attendance_reason_id'=>$postdata['attendance_reason_id_'.$i], 'attendance_date'=>$attendance_date, 'employee_id'=>$employee); $this->db->insert('employee_absent', $tblValues); } $i++; } $data['resfunction']='search_attendance'; 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']='Employees Marked as Absent'; return $data; } } function update_training($postdata) { $data=array(); $this->db->trans_begin(); $training_date_start= $this->mastermodel->convertdateformat($postdata['training_date_start']); $training_date_end= $this->mastermodel->convertdateformat($postdata['training_date_end']); $first_attempt_date= $this->mastermodel->convertdateformat($postdata['first_attempt_date']); $second_attempt_date= $this->mastermodel->convertdateformat($postdata['second_attempt_date']); $tblValues=array( 'training_id'=>$postdata['training_id'], 'training_date_start'=>$training_date_start, 'training_date_end'=>$training_date_end, 'first_attempt_date'=>$first_attempt_date, 'second_attempt_date'=>$second_attempt_date, 'first_attempt_result'=>$postdata['first_attempt_result'], 'second_attempt_result'=>$postdata['second_attempt_result'], 'remarks'=>$postdata['remarks'],); $this->db->where('employee_training_id', $postdata['employee_training_id']); $this->db->update('employee_training', $tblValues); $data['resfunction']='search_training'; 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 Training Details inserted Successfully'; return $data; } } function update_trade_change($postdata) { $data=array(); $this->db->trans_begin(); $trade_change_date= $this->mastermodel->convertdateformat($postdata['trade_change_date']); $tblValues=array( 'trade_change_date'=>$trade_change_date, 'remarks'=>$postdata['remarks']); $this->db->where('trade_change_id', $postdata['trade_change_id']); $this->db->update('trade_change', $tblValues); $orig_trade_id = $this->mastermodel->getSingleFieldValue('employee_non_main','emp_non_trade_id','emp_non_id',$postdata['employee_id']); $data['resfunction']='search_trade_change'; 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_visa_processing($postdata) { $data=array(); $this->db->trans_begin(); $visa_issue_date= $this->mastermodel->convertdateformat($postdata['visa_issue_date']); $visa_expiry_date= $this->mastermodel->convertdateformat($postdata['visa_expiry_date']); $old_details = $this->mastermodel->get_data_srow('visa_processing',$postdata['visa_processing_id'],'visa_processing_id'); $tblValues=array( 'visa_issue_date'=>$visa_issue_date, 'visa_expiry_date'=>$visa_expiry_date, 'visa_remind_before'=>$postdata['visa_remind_before'], 'visa_no'=>$postdata['visa_no'], 'medical'=>$postdata['medical'], 'blood_group'=>$postdata['blood_group'], 'id_card_no'=>$postdata['id_card_no'], 'health_card_no'=>$postdata['health_card_no'], 'fingerprint'=>$postdata['fingerprint']); $this->db->where('visa_processing_id', $postdata['visa_processing_id']); $this->db->update('visa_processing', $tblValues); $this->db->select_max('visa_processing_id'); $this->db->where('employee_id',$postdata['employee_id']); $query = $this->db->get('visa_processing'); $row=$query->row(); if($row->visa_processing_id==$postdata['visa_processing_id']) { $tblValues=array( 'emp_non_date_visa_issue'=>$visa_issue_date, 'emp_non_date_visa_expiry'=>$visa_expiry_date, 'emp_non_visa_remind_before'=>$postdata['visa_remind_before'], 'emp_non_visa_no'=>$postdata['visa_no'], ); $this->db->where('emp_non_id', $postdata['employee_id']); $this->db->update('employee_non_main', $tblValues); } if($postdata['visa_code']!=0) { $old_alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($old_details->visa_expiry_date)) . " -$old_details->visa_remind_before day")); $remind_before = $postdata['visa_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($visa_expiry_date)) . " -$remind_before day")); $this->db->select('alert_id'); $this->db->where('employee_id',$postdata['employee_id']); $this->db->where('alert_date',$old_alert_date); $this->db->where('alert_master_id','2'); $query = $this->db->get('alert'); $row=$query->row(); $tblValues=array( 'alert_date'=>$alert_date, ); $this->db->where('alert_id',$row->alert_id); $this->db->update('alert', $tblValues); } else { $old_alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($old_details->visa_expiry_date)) . " -$old_details->visa_remind_before day")); $remind_before = $postdata['visa_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($visa_expiry_date)) . " -$remind_before day")); $this->db->select('alert_id'); $this->db->where('employee_id',$postdata['employee_id']); $this->db->where('alert_date',$old_alert_date); $this->db->where('alert_master_id','2'); $query = $this->db->get('alert'); $row=$query->row(); if(isset($row->alert_id)!="") { $tblValues=array( 'alert_date'=>$alert_date, ); $this->db->where('alert_id',$row->alert_id); $this->db->update('alert', $tblValues); } if($postdata['visa_expiry_date']!="") { $old_alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($old_details->visa_expiry_date)) . " -$old_details->visa_remind_before day")); $remind_before = $postdata['visa_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($visa_expiry_date)) . " -$remind_before day")); $this->db->select('alert_id'); $this->db->where('employee_id',$postdata['employee_id']); $this->db->where('alert_date',$old_alert_date); $this->db->where('alert_master_id','28'); $query = $this->db->get('alert'); $row=$query->row(); if(isset($row->alert_id)!="") { $tblValues=array( 'alert_date'=>$alert_date, ); $this->db->where('alert_id',$row->alert_id); $this->db->update('alert', $tblValues); } else { $remind_before = $postdata['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('28',$postdata['employee_id'],$alert_date); $user_list = $this->mastermodel->get_alert_users('28'); foreach ($user_list as $user) { $tblValues=array( 'alert_id'=>$alert_id, 'user_id'=>$user['id']); $this->db->insert('alert_user', $tblValues); } } } else { $old_alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($old_details->visa_expiry_date)) . " -$old_details->visa_remind_before day")); $this->db->select('alert_id'); $this->db->where('employee_id',$postdata['employee_id']); $this->db->where('alert_date',$old_alert_date); $this->db->where('alert_master_id','28'); $query = $this->db->get('alert'); $row=$query->row(); if(isset($row->alert_id)!="") { $this->db->where('alert_id',$row->alert_id); $this->db->delete('alert'); } else { $this->db->where('employee_id',$postdata['employee_id']); $this->db->where('alert_master_id','28'); $this->db->delete('alert'); } } } $data['resfunction']='search_visa_processing'; 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']='Visa details changed Successfully'; return $data; } } function update_passport_processing($postdata) { $data=array(); $this->db->trans_begin(); $num_rows_emp_no=0; $passport_issue_date= $this->mastermodel->convertdateformat($postdata['passport_issue_date']); $passport_expiry_date= $this->mastermodel->convertdateformat($postdata['passport_expiry_date']); $old_details = $this->mastermodel->get_data_srow('passport_processing',$postdata['passport_processing_id'],'passport_processing_id'); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'passport_no'=>$postdata['passport_no'], 'passport_issue_date'=>$passport_issue_date, 'passport_expiry_date'=>$passport_expiry_date, 'passport_remind_before'=>$postdata['passport_remind_before']); $this->db->where('passport_processing_id', $postdata['passport_processing_id']); $this->db->update('passport_processing', $tblValues); $this->db->select_max('passport_processing_id'); $this->db->where('employee_id',$postdata['employee_id']); $query = $this->db->get('passport_processing'); $row=$query->row(); if($row->passport_processing_id==$postdata['passport_processing_id']) { $tblValues=array( 'emp_non_passport_no'=>$postdata['passport_no'], 'emp_non_date_passport_issue'=>$passport_issue_date, 'emp_non_date_passport_expiry'=>$passport_expiry_date, 'emp_non_passport_remind_before'=>$postdata['passport_remind_before']); $this->db->where('emp_non_id', $postdata['employee_id']); $this->db->update('employee_non_main', $tblValues); } $old_alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($old_details->passport_expiry_date)) . " -$old_details->passport_remind_before day")); $remind_before = $postdata['passport_remind_before']; $alert_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($passport_expiry_date)) . " -$remind_before day")); $this->db->select('alert_id'); $this->db->where('employee_id',$postdata['employee_id']); $this->db->where('alert_date',$old_alert_date); $this->db->where('alert_master_id','29'); $query = $this->db->get('alert'); $row=$query->row(); $tblValues=array( 'alert_date'=>$alert_date, ); $this->db->where('alert_id',$row->alert_id); $this->db->update('alert', $tblValues); $data['resfunction']='search_passport_processing'; 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']='Passport Processing completed Successfully'; return $data; } } function update_cir($postdata) { $data=array(); $this->db->trans_begin(); $cir_date= $this->mastermodel->convertdateformat($postdata['cir_date']); $tblValues=array( 'employee_id'=>$postdata['employee_id'], 'cir_date'=>$cir_date, 'comments'=>$postdata['comments'], 'cir_document_name'=>$postdata['cir_document_name']); $this->db->where('cir_id', $postdata['cir_id']); $this->db->update('cir', $tblValues); if($postdata['cir_document_file']!='') { $tblValues=array( 'cir_document_file'=>$postdata['cir_document_file']); $this->db->where('cir_id', $postdata['cir_id']); $this->db->update('cir', $tblValues); } $data['resfunction']='search_cir'; 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']='CIR Details updated Successfully'; return $data; } } function update_missing($postdata) { $data=array(); $this->db->trans_begin(); $wef_date= $this->mastermodel->convertdateformat($postdata['wef_date']); $exit_date= $this->mastermodel->convertdateformat($postdata['exit_date']); $tblValues=array( 'wef_date'=>$wef_date, 'remarks'=>$postdata['remarks'], 'exit_date'=>$exit_date, 'missing_type'=>$postdata['missing_type']); $this->db->where('missing_id', $postdata['missing_id']); $this->db->update('missing', $tblValues); $data['resfunction']='search_missing'; 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']='Missing Details updated Successfully'; return $data; } } function get_alloted_employees_camp_empno($value,$batch_code='',$employee_no='',$attendance_date="") { $data = array(); $sql = "SELECT tt.*,employee_non_main.*,batch.*,trade.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 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 trade on employee_non_main.emp_non_trade_id=trade.trade_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 = $value "; if($batch_code != "") { $sql.=" and batch_code like '$batch_code%'"; } if($employee_no != "") { $sql.=" and emp_non_no = '$employee_no'"; } if($attendance_date != "") { $attendance_date= $this->mastermodel->convertdateformat($attendance_date); $sql.=" and alloted_date <= '$attendance_date'"; $sql.= " and tt.employee_id not in (select employee_id from temp_employee)"; } $sql.= " GROUP BY emp_non_id order by emp_non_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_alloted_employees_camp($value,$batch_code='',$employee_name='',$attendance_date="") { $data = array(); $sql = "SELECT tt.*,employee_non_main.*,batch.*,trade.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 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 trade on employee_non_main.emp_non_trade_id=trade.trade_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 = $value "; if($batch_code != "") { $sql.=" and batch_code like '$batch_code%'"; } if($employee_name != "") { $sql.=" and (emp_non_full_name like '%$employee_name%' || emp_non_no like '%$employee_name%' || emp_non_no_old like '%$employee_name%')"; } if($attendance_date != "") { $attendance_date= $this->mastermodel->convertdateformat($attendance_date); $sql.=" and alloted_date <= '$attendance_date'"; $sql.=" and tt.employee_id not in (select employee_id from temp_employee)"; } $sql.=" GROUP BY emp_non_id order by emp_non_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_alloted_employees_site_empno($value,$batch_code='',$employee_no='') { $data = array(); $sql = "SELECT tt.*,employee_non_main.*,batch.*,trade.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 site_allotment tt INNER JOIN employee_non_main on employee_non_main.emp_non_id=tt.employee_id INNER JOIN trade on employee_non_main.emp_non_trade_id=trade.trade_id INNER JOIN batch on employee_non_main.batch_id=batch.id JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_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 = $value "; if($batch_code != "") { $sql.=" and batch_code like '$batch_code%'"; } if($employee_no != "") { $sql.=" and emp_non_no like '$employee_no%'"; } $sql.= " GROUP BY emp_non_id order by emp_non_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_alloted_employees_site($value,$batch_code='',$employee_name='') { $data = array(); $sql = "SELECT tt.*,employee_non_main.*,batch.*,trade.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 site_allotment tt INNER JOIN employee_non_main on employee_non_main.emp_non_id=tt.employee_id INNER JOIN trade on employee_non_main.emp_non_trade_id=trade.trade_id INNER JOIN batch on employee_non_main.batch_id=batch.id JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_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 = $value "; if($batch_code != "") { $sql.=" and batch_code like '$batch_code%'"; } if($employee_name != "") { $sql.=" and (emp_non_full_name like '%$employee_name%' || emp_non_no like '%$employee_name%' || emp_non_no_old like '%$employee_name%')"; } $sql.= " GROUP BY emp_non_id order by emp_non_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_employee_site($employee_id) { $sql = "SELECT tt.*,site_name FROM site_allotment tt INNER JOIN site on tt.site_id=site.site_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 tt.employee_id = '$employee_id' "; $data=$this->db->query($sql); $result= $data->row(); if($result) { return $result->site_name; } else { return ""; } } function get_all_employees() { $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 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 get_all_employees_camp($camp_id,$attendance_date='') { $data = array(); $sql = "SELECT tt.*,employee_non_main.emp_non_full_name,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 INNER JOIN batch on employee_non_main.batch_id=batch.id INNER JOIN visa_processing ON `visa_processing`.`employee_id` = `employee_non_main`.`emp_non_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 = $camp_id and active = 1"; if($attendance_date != "") { $attendance_date= $this->mastermodel->convertdateformat($attendance_date); $sql.=" and alloted_date <= '$attendance_date'"; } $sql .= " GROUP BY emp_non_id order by emp_non_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_alloted_employees_all($employee_name) { $pos = strpos($employee_name, "<"); if($pos===false) { $flag=0; } else { $flag=1; $emp_num_array = explode('<', $employee_name); $employee_number = trim($emp_num_array[1],">"); } $data = array(); $sql = "SELECT employee_non_main.*,batch.*,trade.trade_name FROM employee_non_main INNER JOIN trade on employee_non_main.emp_non_trade_id=trade.trade_id INNER JOIN batch on employee_non_main.batch_id=batch.id"; if($flag==1) $sql .= " where employee_non_main.emp_non_no = '$employee_number'"; else $sql .= " where emp_non_full_name like '$employee_name%'"; $sql.= " order by emp_non_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_info($employee_id) { $sql =("SELECT emp_non_full_name,emp_non_visa_type_id,trade_name,trade_id,nationality_name,emp_non_date_joining,emp_non_id,batch_code,emp_non_visa_type_id,emp_non_sponsor_id, 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 employee_non_main.emp_non_id = '$employee_id'"); $sql.=" GROUP BY emp_non_id"; $Q=$this->db->query($sql); $row=$Q->row(); return $row; } function get_emp_info_newempno($employee_id) { $sql =("SELECT emp_non_full_name,emp_non_visa_type_id,trade_name,trade_id,nationality_name,emp_non_date_joining,emp_non_id,batch_code,emp_non_visa_type_id,emp_non_sponsor_id,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 employee_non_main.emp_non_id = '$employee_id'"); $sql.=" GROUP BY emp_non_id"; $Q=$this->db->query($sql); $row=$Q->row(); return $row; } function get_employee_info_training($employee_number) { $sql =("SELECT emp_non_full_name,trade_name,trade_id,nationality_name,emp_non_date_joining,emp_non_id,batch_code, emp_non_visa_type_id,emp_non_visa_no,emp_non_date_visa_issue,emp_non_date_visa_expiry,emp_non_visa_remind_before,emp_non_sponsor_id, CONCAT(`employee_non_main`.`emp_non_no_old`,',',GROUP_CONCAT(DISTINCT(`visa_processing`.`employee_no`) order by visa_processing_id)) AS emp_non_no,visa_processing.* 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' and employee_non_main.emp_non_no = '$employee_number'"); $sql.=" GROUP BY emp_non_id"; $Q=$this->db->query($sql); $row=$Q->row(); return $row; } function get_data_salary_allowance_info($salary_id) { $data = array(); $this->db->select('*'); $this->db->from('salary_allowance'); $this->db->join('salary','salary.salary_id=salary_allowance.salary_id'); $this->db->join('allowance','allowance.allowance_id=salary_allowance.allowance_id'); $this->db->where('salary_allowance.salary_id',$salary_id); $this->db->order_by('salary_allowance_id','desc'); $Q= $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_data_salary_deduction_info($salary_id) { $data = array(); $this->db->select('*'); $this->db->from('salary_deduction'); $this->db->join('salary','salary.salary_id=salary_deduction.salary_id'); $this->db->join('deduction','deduction.deduction_id=salary_deduction.deduction_id'); $this->db->where('salary_deduction.salary_id',$salary_id); $this->db->order_by('salary_deduction_id','desc'); $Q= $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_employee_salary_info($employee_id) { $data = array(); $sql = "SELECT `salary`.`salary_increment` , `salary`.`salary_increment_date` , `salary`.`employee_id` ,REPLACE(REPLACE(GROUP_CONCAT(DISTINCT(CONCAT(`allowance`.`allowance_name`,'~', `salary_allowance`.`allowance_amount`))),'@',''),',','~') AS allowance ,REPLACE(REPLACE(GROUP_CONCAT(DISTINCT(CONCAT(`deduction`.`deduction_name` ,'~',`salary_deduction`.`deduction_amount`))),'@',''),',','~') AS deduction FROM `salary` LEFT JOIN `salary_allowance` ON (`salary_allowance`.`salary_id` = `salary`.`salary_id`) LEFT JOIN `salary_deduction` ON (`salary_deduction`.`salary_id` = `salary`.`salary_id`) LEFT JOIN `deduction` ON (`deduction`.`deduction_id` = `salary_deduction`.`deduction_id`) LEFT JOIN `allowance` ON (`allowance`.`allowance_id` = `salary_allowance`.`allowance_id`) where salary.employee_id = '$employee_id' GROUP BY salary.salary_id,salary.salary_increment_date order by salary_increment_date 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_employee_settlement_info($employee_id) { $data = array(); $sql = "(SELECT `settlement`.`settlement_id`,`settlement`.`basic_salary`,`settlement`.`final_amount`,`settlement`.`date` ,REPLACE(REPLACE(GROUP_CONCAT(DISTINCT(CONCAT(`allowance`.`allowance_name`,'~', `settlement_allowance`.`allowance_amount`))),'@',''),',','~') AS allowance ,REPLACE(REPLACE(GROUP_CONCAT(DISTINCT(CONCAT(`deduction`.`deduction_name` ,'~',`settlement_deduction`.`deduction_amount`))),'@',''),',','~') AS deduction FROM `settlement` JOIN `leave` on (`leave`.`leave_id`=`settlement`.`leave_id`) LEFT JOIN `settlement_allowance` ON (`settlement_allowance`.`settlement_id` = `settlement`.`settlement_id`) LEFT JOIN `settlement_deduction` ON (`settlement_deduction`.`settlement_id` = `settlement`.`settlement_id`) LEFT JOIN `deduction` ON (`deduction`.`deduction_id` = `settlement_deduction`.`deduction_id`) LEFT JOIN `allowance` ON (`allowance`.`allowance_id` = `settlement_allowance`.`allowance_id`) where `leave`.`employee_id` = '$employee_id' GROUP BY settlement.settlement_id order by settlement_id desc) UNION (SELECT `settlement_direct`.`settlement_direct_id`,`settlement_direct`.`basic_salary`,`settlement_direct`.`final_amount`,`settlement_direct`.`date` ,REPLACE(REPLACE(GROUP_CONCAT(DISTINCT(CONCAT(`allowance`.`allowance_name`,'~', `settlement_direct_allowance`.`allowance_amount`))),'@',''),',','~') AS allowance ,REPLACE(REPLACE(GROUP_CONCAT(DISTINCT(CONCAT(`deduction`.`deduction_name` ,'~',`settlement_direct_deduction`.`deduction_amount`))),'@',''),',','~') AS deduction FROM `settlement_direct` LEFT JOIN `settlement_direct_allowance` ON (`settlement_direct_allowance`.`settlement_direct_id` = `settlement_direct`.`settlement_direct_id`) LEFT JOIN `settlement_direct_deduction` ON (`settlement_direct_deduction`.`settlement_direct_id` = `settlement_direct`.`settlement_direct_id`) LEFT JOIN `deduction` ON (`deduction`.`deduction_id` = `settlement_direct_deduction`.`deduction_id`) LEFT JOIN `allowance` ON (`allowance`.`allowance_id` = `settlement_direct_allowance`.`allowance_id`) where `settlement_direct`.`employee_id` = '$employee_id' GROUP BY settlement_direct.settlement_direct_id order by settlement_direct_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_alloted_employees_camp_attendance_edit($camp_id,$date) { $data = array(); $attendance_date = $this->mastermodel->convertdateformat($date); $sql = "SELECT tt.*,employee_non_main.*,batch.*,trade.trade_name, employee_absent.attendance_date,employee_absent.attendance_reason_id,attendance_list_reason, 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 INNER JOIN employee_absent on employee_absent.employee_id=tt.employee_id INNER JOIN attendance_list on employee_absent.attendance_reason_id=attendance_list.attendance_list_id INNER JOIN trade on employee_non_main.emp_non_trade_id=trade.trade_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 JOIN visa_processing ON visa_processing.employee_id = employee_non_main.emp_non_id where camp_id = '$camp_id' and employee_absent.attendance_date = '$attendance_date'"; $sql.= " GROUP BY employee_non_main.emp_non_id order by employee_non_main.emp_non_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 insert_temp_employee($employee_id) { $tblValues=array( 'employee_id'=>$employee_id); $this->db->insert('temp_employee', $tblValues); } function delete_temp_employee($employee_id) { $this->db->where('employee_id', $employee_id); $this->db->delete('temp_employee', $tblValues); } function get_last_tool_detail($employee_id,$tool_id) { $sql = "select * from tool_allotment inner join item_tool_allotment on item_tool_allotment.allotment_id=tool_allotment.allotment_id where tool_id=$tool_id and employee_id=$employee_id order by item_tool_allotment_date desc limit 1"; $Q= $this->db->query($sql); $row=$Q->row(); return $row; } function get_last_item_detail($employee_id,$item_id) { $sql = "select * from item_allotment inner join item_tool_allotment on item_tool_allotment.allotment_id=item_allotment.allotment_id where item_id=$item_id and employee_id=$employee_id order by item_tool_allotment_date desc limit 1"; $Q= $this->db->query($sql); $row=$Q->row(); return $row; } function get_item_list($allotment_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.allotment_id",$allotment_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_list($allotment_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.allotment_id",$allotment_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 getitemalerts($item_id,$employee_id) { $data = array(); $this->db->select('alert.alert_id as alert_id'); $this->db->join('alert_item','alert_item.alert_id=alert.alert_id'); $this->db->where('alert_item.item_id',$item_id); $this->db->where('alert.employee_id',$employee_id); $Q= $this->db->get('alert'); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function gettoolalerts($tool_id,$employee_id) { $data = array(); $this->db->select('alert.alert_id as alert_id'); $this->db->join('alert_tool','alert_tool.alert_id=alert.alert_id'); $this->db->where('alert_tool.tool_id',$tool_id); $this->db->where('alert.employee_id',$employee_id); $Q= $this->db->get('alert'); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } }