?
Current Path : /home1/savoy/public_html/savoyglobal.net/sgms/application/controllers/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sgms/application/controllers/timesheet.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Timesheet extends MY_Controller { public function __construct() { parent::__construct(); $this->load->model('mastermodel'); $this->load->model('timesheetmodel'); $this->load->model('onboardingmodel'); $this->load->model('administrationmodel'); $this->load->library('Fpaginate'); $this->load->helper('to_pdf'); } function get_post_values() { $data = array(); foreach ($_POST as $key => $value) { if($key != "submit") { $data[$key] = $this->input->post($key); } } return $data; } /* common function loading pages through jquery load method . * Usages:-used for displaying addform. */ function addformdisplay($page,$directory,$table="",$pagenum="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $this->load->view(''.$directory.'/'.$page.''); } } function deletedata($table,$id,$field) { $data=array(); $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],2); if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $data=$this->mastermodel->deletedata($table,$id,$field); $data['msg']=$data['msg']; if($data['res']==1) { $this->load->view('message',$data); } else { $this->load->view('message',$data); } } } function checkexistence($table,$field,$value) { if($this->mastermodel->checkexistence($table,$field,$value)>0) { echo 1; } } function checkexistencearray($table,$field,$value) { if($this->mastermodel->checkexistencearray($table,$field,$value)>0) { echo 1; } } function addintimesheet($modelfunction,$page) { $postdata=$this->get_post_values(); $path = './assets/uploads'; if(isset($_FILES['purchase_order_document_doc']) && $_FILES['purchase_order_document_doc']['name'] != "") { $_FILES["purchase_order_document_doc"]["name"]=date("y-m-d-H-i-s").$_FILES["purchase_order_document_doc"]["name"]; if (!is_file("$path/".$_FILES["purchase_order_document_doc"]["name"])) { (move_uploaded_file($_FILES["purchase_order_document_doc"]["tmp_name"],$path."/".$_FILES["purchase_order_document_doc"]["name"])); $postdata['purchase_order_document_doc']=$_FILES["purchase_order_document_doc"]["name"]; } } else if(isset($postdata['purchase_order_document_name'])) { $postdata['purchase_order_document_doc']=""; } if(isset($_FILES['internal_job_document_doc']) && $_FILES['internal_job_document_doc']['name'] != "") { $_FILES["internal_job_document_doc"]["name"]=date("y-m-d-H-i-s").$_FILES["internal_job_document_doc"]["name"]; if (!is_file("$path/".$_FILES["internal_job_document_doc"]["name"])) { (move_uploaded_file($_FILES["internal_job_document_doc"]["tmp_name"],$path."/".$_FILES["internal_job_document_doc"]["name"])); $postdata['internal_job_document_doc']=$_FILES["internal_job_document_doc"]["name"]; } } else if(isset($postdata['internal_job_document_name'])) { $postdata['internal_job_document_doc']=""; } if(isset($_FILES['client_timesheet_document']) && $_FILES['client_timesheet_document']['name'] != "") { $_FILES["client_timesheet_document"]["name"]=date("y-m-d-H-i-s").$_FILES["client_timesheet_document"]["name"]; if (!is_file("$path/".$_FILES["client_timesheet_document"]["name"])) { (move_uploaded_file($_FILES["client_timesheet_document"]["tmp_name"],$path."/".$_FILES["client_timesheet_document"]["name"])); $postdata['client_timesheet_document']=$_FILES["client_timesheet_document"]["name"]; } } else if(isset($postdata['client_timesheet_remarks'])) { $postdata['client_timesheet_document']=""; } if(isset($_FILES['manpower_timesheet_document']) && $_FILES['manpower_timesheet_document']['name'] != "") { $_FILES["manpower_timesheet_document"]["name"]=date("y-m-d-H-i-s").$_FILES["manpower_timesheet_document"]["name"]; if (!is_file("$path/".$_FILES["manpower_timesheet_document"]["name"])) { (move_uploaded_file($_FILES["manpower_timesheet_document"]["tmp_name"],$path."/".$_FILES["manpower_timesheet_document"]["name"])); $postdata['manpower_timesheet_document']=$_FILES["manpower_timesheet_document"]["name"]; } } else if(isset($postdata['manpower_timesheet_remarks'])) { $postdata['manpower_timesheet_document']=""; } if(isset($_FILES['invoice_document']) && $_FILES['invoice_document']['name'] != "") { $_FILES["invoice_document"]["name"]=date("y-m-d-H-i-s").$_FILES["invoice_document"]["name"]; if (!is_file("$path/".$_FILES["invoice_document"]["name"])) { (move_uploaded_file($_FILES["invoice_document"]["tmp_name"],$path."/".$_FILES["internal_job_document_doc"]["name"])); $postdata['invoice_document']=$_FILES["invoice_document"]["name"]; } } else if(isset($postdata['invoice_status'])) { $postdata['invoice_document']=""; } $data=$this->timesheetmodel->$modelfunction($postdata); $data['msg']=$data['msg']; if($data['res']==1) { if(isset($data['batch_id'])) { $batch_id = $data['batch_id']; $batch_date = $data['batch_date']; $this->newaddpage($batch_id,$batch_date,'add_employee_joining'); } else if(isset($data['alert_id'])) { $alert_id = $data['alert_id']; $this->returntoalert($alert_id); } else { $this->viewintimesheetsearch($data['resfunction'],$page,'1'); } $this->load->view('message',$data); } else { $this->viewintimesheetsearch($data['resfunction'],$page,'1'); $this->load->view('message',$data); } } function viewintimesheetsearch($modelfunction,$page,$pagenum) { /*<---------------- For pagination purpose------------>*/ $perpage= $this->config->item('perpage'); $_SESSION['pagenum']=$pagenum; $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } if(isset($_POST['tab_name'])) { $postdata =""; } else { $postdata=$this->get_post_values(); } if(!empty ($postdata)) $_SESSION['searchdata']=$postdata; else if(!isset($_SESSION['searchdata'])) $_SESSION['searchdata']=""; /*<---------------- For pagination purpose------------> */ $output=$this->timesheetmodel->$modelfunction($pagenum); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['viewinfo']=$output['results']; $this->load->view('Timesheet/'.$page.'',$data); } function edit_page($id,$table,$field,$page,$alert_id='') { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); } else { $perm=1; } if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $data['viewinfo']=$this->mastermodel->get_data_srow($table,$id,$field); $data['id']=$id; $data['alert_id']=$alert_id; $this->load->view('Timesheet/'.$page,$data); } } function single_page($id,$table,$field,$page,$alert_id='') { if($_SESSION['current_mode']!="") { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],0); } else { $perm=1; } if(!$perm) { $data['msg']="Permission Denied"; $this->load->view('message',$data); } else { $data['viewinfo']=$this->mastermodel->get_data_srow($table,$id,$field); $data['id']=$id; $data['alert_id']=$alert_id; $this->load->view('Timesheet/'.$page,$data); } } function all_external_job() { $q = strtolower($_POST["q"]); if (!$q) return; $job_list=$this->timesheetmodel->get_external_job_info(); foreach ($job_list as $job) { $customer_purchase_order_no = $job['customer_purchase_order_no']; $customer_name= $job['customer_name']; $purchase_order_id=$job['purchase_order_id']; if (strpos(strtolower($customer_name), $q) !== false) { echo ''.$customer_name.'-'.$customer_purchase_order_no."#$purchase_order_id#"; echo "\n"; } else if (strpos(strtolower($customer_purchase_order_no), $q) !== false) { echo ''.$customer_name.'-'.$customer_purchase_order_no."#$purchase_order_id#"; echo "\n"; } } } function get_external_job_info($page,$customer_purchase_order_id) { $data=array(); $data['viewinfo']=$this->timesheetmodel->get_job_info_single($customer_purchase_order_id); $this->load->view('Timesheet/'.$page,$data); } function enter_client_timesheet($client_timesheet_id) { $data=array(); $data['viewinfo']=$this->onboardingmodel->get_joined_info_single('payroll_client_timesheet',$client_timesheet_id,'client_timesheet_id','payroll_purchase_order','purchase_order_id'); $this->load->view('Timesheet/enter_client_timesheet',$data); } function employees_not_marked($client_timesheet_id) { $q = strtolower($_POST["q"]); if (!$q) return; $employee_list=$this->timesheetmodel->get_employees_not_marked($client_timesheet_id); foreach ($employee_list as $items) { $name = $items['emp_non_full_name']; $emp_non_no= $items['emp_non_no']; $employee_id= $items['emp_non_id']; if($emp_non_no[0]==',') { $emp_non_no=substr($emp_non_no, 1); } $emp_non_no = str_replace(',',', ', $emp_non_no); if (strpos(strtolower($name), $q) !== false) { echo '"'.$name.'" - '.$emp_non_no." #$employee_id~$items[0]#"; echo "\n"; } else if (strpos(strtolower($emp_non_no), $q) !== false) { echo '"'.$name.'" - '.$emp_non_no." #$employee_id~$items[0]#"; echo "\n"; } } } function get_employee_trade($employee_id) { $employee=explode('~', $employee_id); if($employee[1]==0) { $trade_id=$this->mastermodel->getSingleFieldValue('employee_non_main','emp_non_trade_id','emp_non_id',$employee[0]); echo $this->mastermodel->getSingleFieldValue('trade','trade_name','trade_id',$trade_id); } else { $trade_id=$this->mastermodel->getSingleFieldValue('payroll_manpower_hiring_employee','manpower_hiring_employee_trade_id','manpower_hiring_employee_id',$employee[0]); echo $this->mastermodel->getSingleFieldValue('trade','trade_name','trade_id',$trade_id); } } function get_employee_no($employee_id) { $employee=explode('~', $employee_id); if($employee[1]==0) { echo $this->mastermodel->getSingleFieldValue('employee_non_main','emp_non_no','emp_non_id',$employee[0]); } else { echo $this->mastermodel->getSingleFieldValue('payroll_manpower_hiring_employee','manpower_hiring_employee_no','manpower_hiring_employee_id',$employee[0]); } } function get_employee_company($employee_id) { $employee=explode('~', $employee_id); if($employee[1]==0) { echo "Horeitia~0"; } else { $company_id = $this->mastermodel->getSingleFieldValue('payroll_manpower_hiring_employee','manpower_hiring_employee_company_id','manpower_hiring_employee_id',$employee[0]); echo $this->mastermodel->getSingleFieldValue('payroll_manpower_hiring','company_name','company_id',$company_id)."~".$company_id; } } function get_rates_po($employee_id,$po_id) { $employee=explode('~', $employee_id); if($employee[1]==0) { $trade_id=$this->mastermodel->getSingleFieldValue('employee_non_main','emp_non_trade_id','emp_non_id',$employee[0]); } else { $trade_id=$this->mastermodel->getSingleFieldValue('payroll_manpower_hiring_employee','manpower_hiring_employee_trade_id','manpower_hiring_employee_id',$employee[0]); } $rates = $this->timesheetmodel->get_rates_po($trade_id,$po_id); echo $rates->purchase_order_rate.'~'.$rates->purchase_order_ot_type.'~'.$rates->purchase_order_ot_rate.'~'.$rates->purchase_order_hot_rate; } function loadtimesheeetvalues() { $data['info']=$_POST; $this->load->view('Timesheet/load_timesheet_values',$data); } function enter_client_timesheet_details() { $postdata=$this->get_post_values(); $data=$this->timesheetmodel->enter_client_timesheet_details($postdata); $data['msg']="Timesheet updated successfully"; $data['return_function']='search_client_timesheet'; $data['return_page']='view_client_timesheet'; $this->load->view('message',$data); $this->load->view('Timesheet/after_timesheet_entry',$data); } function display_client_timesheet($client_timesheet_id) { $data=array(); $data['viewinfo']=$this->onboardingmodel->get_joined_info_single('payroll_client_timesheet',$client_timesheet_id,'client_timesheet_id','payroll_purchase_order','purchase_order_id'); $this->load->view('Timesheet/display_client_timesheet',$data); } function all_internal_job() { $q = strtolower($_POST["q"]); if (!$q) return; $job_list=$this->mastermodel->get_data('payroll_internal_job','Active','internal_job_status'); foreach ($job_list as $job) { $internal_job_id=$job['internal_job_id']; if (strpos(strtolower($job['internal_job_code']), $q) !== false) { echo '"'.$job['internal_job_subject'].'"-'.$job['internal_job_code']."#$internal_job_id#"; echo "\n"; } else if (strpos(strtolower($job['internal_job_subject']), $q) !== false) { echo '"'.$job['internal_job_subject'].'"-'.$job['internal_job_code']."#$internal_job_id#"; echo "\n"; } } } function get_internal_job_info($page,$internal_job_id) { $data=array(); $data['viewinfo']=$this->mastermodel->get_data_srow('payroll_internal_job',$internal_job_id,'internal_job_id'); $this->load->view('Timesheet/'.$page,$data); } function enter_internal_timesheet($internal_timesheet_id) { $data=array(); $data['viewinfo']=$this->onboardingmodel->get_joined_info_single('payroll_internal_timesheet',$internal_timesheet_id,'internal_timesheet_id','payroll_internal_job','internal_job_id'); $this->load->view('Timesheet/enter_internal_timesheet',$data); } function employees_not_marked_internal($client_timesheet_id) { $q = strtolower($_POST["q"]); if (!$q) return; $employee_list=$this->timesheetmodel->get_employees_not_marked_internal($client_timesheet_id); foreach ($employee_list as $items) { $name = $items['emp_non_full_name']; $emp_non_no= $items['emp_non_no']; $employee_id= $items['emp_non_id']; if($emp_non_no[0]==',') { $emp_non_no=substr($emp_non_no, 1); } $emp_non_no = str_replace(',',', ', $emp_non_no); if (strpos(strtolower($name), $q) !== false) { echo '"'.$name.'" - '.$emp_non_no."#$employee_id#"; echo "\n"; } else if (strpos(strtolower($emp_non_no), $q) !== false) { echo '"'.$name.'" - '.$emp_non_no."#$employee_id#"; echo "\n"; } } } function enter_internal_timesheet_details() { $postdata=$this->get_post_values(); $data=$this->timesheetmodel->enter_internal_timesheet_details($postdata); $data['msg']="Timesheet updated successfully"; $data['return_function']='search_internal_timesheet'; $data['return_page']='view_internal_timesheet'; $this->load->view('message',$data); $this->load->view('Timesheet/after_timesheet_entry',$data); } function display_internal_timesheet($internal_timesheet_id) { $data=array(); $data['viewinfo']=$this->onboardingmodel->get_joined_info_single('payroll_internal_timesheet',$internal_timesheet_id,'internal_timesheet_id','payroll_internal_job','internal_job_id'); $this->load->view('Timesheet/display_internal_timesheet',$data); } function enter_manpower_timesheet($manpower_timesheet_id) { $data=array(); $data['viewinfo']=$this->onboardingmodel->get_joined_info_single('payroll_manpower_timesheet',$manpower_timesheet_id,'manpower_timesheet_id','payroll_purchase_order','purchase_order_id'); $this->load->view('Timesheet/enter_manpower_timesheet',$data); } function employees_not_marked_manpower($manpower_timesheet_id) { $q = strtolower($_POST["q"]); if (!$q) return; $employee_list=$this->timesheetmodel->get_employees_not_marked_manpower($manpower_timesheet_id); foreach ($employee_list as $items) { $name = $items['manpower_hiring_employee_name']; $emp_non_no= $items['manpower_hiring_employee_no']; $employee_id= $items['manpower_hiring_employee_id']; if($emp_non_no[0]==',') { $emp_non_no=substr($emp_non_no, 1); } $emp_non_no = str_replace(',',', ', $emp_non_no); if (strpos(strtolower($name), $q) !== false) { echo '"'.$name.'" - '.$emp_non_no."#$employee_id#"; echo "\n"; } else if (strpos(strtolower($emp_non_no), $q) !== false) { echo '"'.$name.'" - '.$emp_non_no."#$employee_id#"; echo "\n"; } } } function get_employee_trade_manpower($employee_id) { $trade_id=$this->mastermodel->getSingleFieldValue('payroll_manpower_hiring_employee','manpower_hiring_employee_trade_id','manpower_hiring_employee_id',$employee_id); echo $this->mastermodel->getSingleFieldValue('trade','trade_name','trade_id',$trade_id); } function get_employee_no_manpower($employee_id) { echo $this->mastermodel->getSingleFieldValue('payroll_manpower_hiring_employee','manpower_hiring_employee_no','manpower_hiring_employee_id',$employee_id); } function enter_manpower_timesheet_details() { $postdata=$this->get_post_values(); $data=$this->timesheetmodel->enter_manpower_timesheet_details($postdata); $data['msg']="Timesheet updated successfully"; $data['return_function']='search_manpower_timesheet'; $data['return_page']='view_manpower_timesheet'; $this->load->view('message',$data); $this->load->view('Timesheet/after_timesheet_entry',$data); } function display_manpower_timesheet($manpower_timesheet_id) { $data=array(); $data['viewinfo']=$this->onboardingmodel->get_joined_info_single('payroll_manpower_timesheet',$manpower_timesheet_id,'manpower_timesheet_id','payroll_purchase_order','purchase_order_id'); $this->load->view('Timesheet/display_manpower_timesheet',$data); } function get_timesheet_invoice_info($po_id,$timesheet_start_date,$timesheet_end_date) { $data=array(); $data['viewinfo']=$this->timesheetmodel->get_job_info_single($po_id); $data['client_timesheet']=$this->timesheetmodel->get_client_timesheet_invoice_info($po_id,$timesheet_start_date,$timesheet_end_date); $data['manpower_timesheet']=$this->timesheetmodel->get_manpower_timesheet_invoice_info($po_id,$timesheet_start_date,$timesheet_end_date); $this->load->view('Timesheet/timesheet_invoice_info',$data); } function getpurchaseorderreport($modelfunction,$page) { $postdata=$this->get_post_values(); $data['postdata']=$postdata; $output=$this->timesheetmodel->$modelfunction($postdata); if(!empty ($output)) { $data['report']=$output; $page=$postdata['report_type'].$page; $this->load->view('Timesheet/'.$page.'',$data); } else { redirect('master/index/'.$_SESSION['current_mode'].'/9'); } } function getinvoicereport($modelfunction,$page) { $postdata=$this->get_post_values(); $data['postdata']=$postdata; $output=$this->timesheetmodel->$modelfunction($postdata); if(!empty ($output)) { $data['report']=$output; $page=$postdata['report_type'].$page; $this->load->view('Timesheet/'.$page.'',$data); } else { redirect('master/index/'.$_SESSION['current_mode'].'/9'); } } } /* End of file timesheet.php */ /* Location: ./application/controllers/timesheet.php */