public function generateAttendanceEmployee($empID, $month, $year)
 {
     $attendance = array();
     $start_date = new DateTime("{$year}-{$month}-01");
     $end_date = new DateTime($start_date->format('Y-m-t'));
     $attendance = Attendance_model::getAttendance($empID, $start_date->format('Y-m-d'), $end_date->format('Y-m-d'));
     /*
     		$end_date = $end_date->modify('+1 day'); 
     		$period = new DatePeriod($start_date, new DateInterval('P1D'), $end_date);
     		foreach($period as $date){
     			//$row = $this->view_attendance($empID, $date->format("m/d/Y"));
     			
     			$this->db->select('time_in, time_out, man_hours, tardiness, overtime');
     			$this->db->where('emp_id',$empID);
     			$this->db->where('logdate',$date->format("m/d/Y"));
     			$this->db->order_by('logdate');
     			$result = $this->db->get('view_attendance');
     			$row = $result->row();
     		
     			$time_in = "";
     			$time_out = "";
     			$man_hours = 0;
     			$tardiness = 0;
     			$overtime = 0;
     			if(count($row)!=0){
     				$time_in = $row->time_in;
     				$time_out = $row->time_out;
     				$man_hours = $row->man_hours; 
     				$tardiness = $row->tardiness;
     				$overtime = $row->overtime;
     			}
     			array_push($attendance, array(
     				"emp_id"=>$empID,
     				"datevalue"=>$date->format("Y-m-d"), 
     				"datelog"=>$date->format("M d, Y"), 
     				"weekday"=>$date->format("D"), 
     				"time_in"=>$time_in, 
     				"time_out"=>$time_out,
     				"man_hours"=>$man_hours, 
     				"tardiness"=>$tardiness,
     				"overtime"=>$overtime));
     		}*/
     return $attendance;
 }
Пример #2
0
 public function attendance_upload()
 {
     $config = array('allowed_types' => 'csv', 'upload_path' => 'assets/csv/', 'overwrite' => TRUE);
     $this->load->library('csvreader');
     $this->load->library('upload', $config);
     $data['post'] = $this->input->post();
     if ($data['post']) {
         if (isset($data['post']['btnUpload'])) {
             if (!$this->upload->do_upload()) {
                 $data['error'] = $this->upload->display_errors();
             }
             $data['csv'] = $this->upload->data();
             $result = $this->csvreader->parse_file($data['csv']['full_path']);
             $data['csvData'] = $result;
         } else {
             if (isset($data['post']['btnSave'])) {
                 $result = $this->csvreader->parse_file($data['post']['hidPath']);
                 Attendance_model::upload_attendance($result);
                 $this->session->set_userdata('added', 1);
                 redirect('payroll/attendance');
             }
         }
     }
     $data['pageTitle'] = 'Upload Attendance - MSInc.';
     $data['content'] = 'attendance/attendance_upload';
     $this->load->view($this->master_layout, $data);
     $this->display_notif();
 }