function __construct() {
parent::__construct();
$this->load->model('db/l_student_reserve_change_model', 'student_reserve');
$this->load->model('db/m_course_model', 'course');
$this->load->model('db/m_class_model', 'class');
$this->load->model('db/m_grade_model', 'grade');
$this->load->model('db/reschedule_model', 'reschedule');
$this->load->library("pagination");
}
public function index() {
try {
$data = $this->make_data();
$data['today'] = date("Ymd");
admin_layout_view('attend_index', $data);
} catch (Exception $e) {
$this->_show_error($e->getMessage(), $e->getTraceAsString());
}
}
public function make_data() {
try {
$data['course_list'] = $this->course->get_list();
$data['class_alphabet'] = array("M", "A", "B", "C", "D", "E", "F");
$data['grade_info'] = $this->base->get_grade();
$this->today = date('Y-m-d 00-00-00');
$start = $this->input->post('start_date') ? $this->input->post('start_date') : $this->today;
$end = $this->input->post('end_date') ? $this->input->post('end_date') : $this->today;
$data['btn_kind'] = $this->input->post('sub_btn');
$list = [];
switch ($data['btn_kind']) {
case 1:
$list = $this->reschedule->get_past_rest_list($start, $end, $student_id = false);
break;
case 2:
$list = $this->reschedule->get_no_contact_absence_list($student_id = false, $start, $end);
break;
case 3:
$list = $this->reschedule->get_past_attend_list($start, $student_id = false);
break;
case 4:
$list = $this->reschedule->get_past_attend_transfer_list($start, $student_id = false);
break;
case 5:
$list = $this->reschedule->get_schedule_list($end, $student_id = false, false);
break;
case 6:
$list = $this->reschedule->get_tranfer_list($end, $student_id = false, $start);
break;
case 7:
$list = $this->reschedule->get_rest_list($start, $end, $student_id = false);
break;
}
$data["list"] = [];
foreach ($list as &$schedule_class) {
$student = $this->base->get_student_now_info($schedule_class["student_id"]);
if ($this->input->post('freeword')) {
if (
strpos($student["id"], $this->input->post('freeword')) === false &&
strpos($student["name"], $this->input->post('freeword')) === false &&
strpos($student["name_kana"], $this->input->post('freeword')) === false
) {
continue;
}
}
$schedule_class = array_merge($schedule_class, $student);
if ($this->input->post('course')) {
if (!in_array($student["course"]["id"], $this->input->post('course'))) {
continue;
}
}
if ($this->input->post('class')) {
$base_class_signs = [];
$match = false;
foreach ($schedule_class["class"] as $class) {
if (in_array($class["base_class_sign"], $this->input->post('class'))) {
$match = true;
}
}
if (!$match) {
continue;
}
}
if ($this->input->post('grade')) {
if (!in_array($student["grade_id"], $this->input->post('grade'))) {
continue;
}
}
$data["list"][] = $schedule_class;
}
if ($data['btn_kind'] == 4 || $data['btn_kind'] == 6) {
foreach ($data["list"] as &$r) {
$r["source"] = $this->db->select('*')
->from('schedule_class')
->where('id', $r["source_schedule_class_id"])
->get()
->row_array();
$r["source_class"] = $this->reschedule->get_class_info($r["source_schedule_class_id"]);
$r["transfer_class"] = $this->db->select()
->from('m_class')
->where('id', $r['student_class_id'])
->get()
->row_array();
$r["bus"] = $this->base->get_student_bus($r["student_id"]);
}
}
$data["today_date"] = date("Ymd");
return $data;
} catch (Exception $e) {
$this->_show_error($e->getMessage(), $e->getTraceAsString());
}
}