Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function instructorschedAction()
- {
- if (!$this->can('sub-ps')) {
- return $this->view->pick('error/restricted');
- }
- $navs = ControllerBase::NAVIGATIONS();
- echo $navs;
- $this->view->Reports = 'true';
- $this->view->Print = 'true';
- $this->view->grade = null;
- $this->view->grade = array();
- $acad_year = ControllerBase::query("SELECT Count(*),academicyear from tblacademicyear group by academicyear");
- $this->view->acad_year = $acad_year;
- $inst = Instructor::find(
- ["deleted = 0",
- "Order" => "inst_lname",
- ]
- );
- if ($inst) {
- $resultInst = $inst->toArray();
- foreach ($inst as $key => $value) {
- if ($value->getdepartment()) {
- $resultInst[$key]['department'] = $value->getdepartment()->toArray();
- }
- }
- }
- $this->view->inst = $resultInst;
- $request = new Request();
- $imp = $request->getPost('days') ? implode('-', $request->getPost('days')) : null;
- $instructor = $request->getPost('instructor');
- $acadyear = $request->getPost('acadyear');
- $semester = $request->getPost('semester');
- $time_end = $request->getPost('time_end');
- $time_start = $request->getPost('time_start');
- $dayimp = $imp;
- if (isset($_POST['submit']) || isset($_POST['print'])) {
- if ($instructor == "ALL") {
- $grade = ControllerBase::query("SELECT classes.instructor_id,
- instructor.inst_lname,
- instructor.inst_fname,
- instructor.inst_mname,
- instructor.inst_sname,
- instructor.instructorid
- from classes
- INNER JOIN instructor ON classes.instructor_id = instructor.id
- INNER JOIN room ON classes.room_id = room.id
- INNER JOIN subject ON classes.subjectcode = subject.entryno
- WHERE classes.acadyear ='" . $acadyear . "' AND classes.semester ='" . $semester . "' GROUP BY instructor.instructorid ORDER BY instructor.inst_lname ");
- if ($grade) {
- $this->view->grade = $grade;
- } else {
- $this->view->show = 'hidden';
- $this->flash->error("Sorry, no records were found. Please try again.");
- }
- } else {
- $grade = ControllerBase::query("SELECT classes.instructor_id,
- instructor.inst_lname,
- instructor.inst_fname,
- instructor.inst_mname,
- instructor.inst_sname,
- instructor.instructorid from classes
- INNER JOIN instructor ON classes.instructor_id = instructor.id
- INNER JOIN room ON classes.room_id = room.id
- INNER JOIN subject ON classes.subjectcode = subject.entryno
- WHERE classes.acadyear ='" . $acadyear . "' AND classes.semester ='" . $semester . "' AND instructor.inst_fname = '" . $instructor . "' GROUP BY instructor.instructorid ORDER BY instructor.inst_lname ");
- if ($grade) {
- $this->view->grade = $grade;
- }
- }
- // hindi ko na ginamit si $days, pinalit ko sa $dayss sa query below
- $dayss = "";
- $postdays = $request->getPost('days');
- if ($postdays !== null) {
- $dayss = ' AND ';
- foreach ($postdays as $key => $value) {
- if($key == 0) {
- $dayss .= "(classes.days LIKE '%" . $value . "%' AND classes.time_start >= '".$time_start."') OR (classes.days LIKE '" . $value . "%' AND classes.time_start >= '".$time_start."') OR (classes.days LIKE '%" . $value . "' AND classes.time_start >= '".$time_start."')";
- }
- else {
- $dayss .= " OR (classes.days LIKE '%" . $value . "%' AND classes.time_start >= '".$time_start."') ";
- }
- }
- }
- $times = "";
- /* if ($time_start != '' and $time_end != '') {
- $times = "AND (classes.time_start BETWEEN '" . $time_start . "' AND '" . $time_end . "') AND (classes.time_end BETWEEN '" . $time_start . "' AND '" . $time_end . "')";
- }
- elseif($time_start != '') {
- $times = "AND classes.time_start >= '".$time_start."'";
- }
- elseif($time_start != '' && $time_end != '') {
- $times = " AND classes.time_start <= '".$time_start."' AND classes.time_end >= '".$time_end."'";
- }*/
- /*if($time_start != '' && $time_end == '') {
- $times = "AND classes.time_start >= '".$time_start."'";
- }
- elseif($time_start != '' && $time_end != '') {
- $times = "AND classes.time_start >= '".$time_start."' AND classes.time_end <= '".$time_end."' OR classes.time_start BETWEEN '".$time_start."' AND '".$time_end."'";
- }*/
- $sched = ControllerBase::query("SELECT * from classes
- INNER JOIN instructor ON classes.instructor_id = instructor.id
- INNER JOIN room ON classes.room_id = room.id
- INNER JOIN subject ON classes.subjectcode = subject.entryno
- WHERE classes.acadyear ='" . $acadyear . "'
- AND classes.semester ='" . $semester . "'
- $dayss
- ORDER BY subject.code ");
- if ($sched) {
- $this->view->sched = $sched;
- }
- $this->view->postback = $this->request->getPost('days');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement