Advertisement
geroneee

Untitled

Oct 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. public function instructorschedAction()
  2. {
  3. if (!$this->can('sub-ps')) {
  4. return $this->view->pick('error/restricted');
  5. }
  6.  
  7. $navs = ControllerBase::NAVIGATIONS();
  8. echo $navs;
  9. $this->view->Reports = 'true';
  10. $this->view->Print = 'true';
  11.  
  12. $this->view->grade = null;
  13. $this->view->grade = array();
  14.  
  15. $acad_year = ControllerBase::query("SELECT Count(*),academicyear from tblacademicyear group by academicyear");
  16. $this->view->acad_year = $acad_year;
  17.  
  18. $inst = Instructor::find(
  19. ["deleted = 0",
  20. "Order" => "inst_lname",
  21. ]
  22. );
  23.  
  24. if ($inst) {
  25. $resultInst = $inst->toArray();
  26. foreach ($inst as $key => $value) {
  27. if ($value->getdepartment()) {
  28. $resultInst[$key]['department'] = $value->getdepartment()->toArray();
  29. }
  30. }
  31. }
  32. $this->view->inst = $resultInst;
  33.  
  34. $request = new Request();
  35.  
  36. $imp = $request->getPost('days') ? implode('-', $request->getPost('days')) : null;
  37.  
  38. $instructor = $request->getPost('instructor');
  39. $acadyear = $request->getPost('acadyear');
  40. $semester = $request->getPost('semester');
  41.  
  42. $time_end = $request->getPost('time_end');
  43. $time_start = $request->getPost('time_start');
  44. $dayimp = $imp;
  45.  
  46. if (isset($_POST['submit']) || isset($_POST['print'])) {
  47.  
  48. if ($instructor == "ALL") {
  49. $grade = ControllerBase::query("SELECT classes.instructor_id,
  50. instructor.inst_lname,
  51. instructor.inst_fname,
  52. instructor.inst_mname,
  53. instructor.inst_sname,
  54. instructor.instructorid
  55. from classes
  56. INNER JOIN instructor ON classes.instructor_id = instructor.id
  57. INNER JOIN room ON classes.room_id = room.id
  58. INNER JOIN subject ON classes.subjectcode = subject.entryno
  59. WHERE classes.acadyear ='" . $acadyear . "' AND classes.semester ='" . $semester . "' GROUP BY instructor.instructorid ORDER BY instructor.inst_lname ");
  60. if ($grade) {
  61. $this->view->grade = $grade;
  62. } else {
  63. $this->view->show = 'hidden';
  64. $this->flash->error("Sorry, no records were found. Please try again.");
  65. }
  66.  
  67. } else {
  68.  
  69. $grade = ControllerBase::query("SELECT classes.instructor_id,
  70. instructor.inst_lname,
  71. instructor.inst_fname,
  72. instructor.inst_mname,
  73. instructor.inst_sname,
  74. instructor.instructorid from classes
  75. INNER JOIN instructor ON classes.instructor_id = instructor.id
  76. INNER JOIN room ON classes.room_id = room.id
  77. INNER JOIN subject ON classes.subjectcode = subject.entryno
  78. WHERE classes.acadyear ='" . $acadyear . "' AND classes.semester ='" . $semester . "' AND instructor.inst_fname = '" . $instructor . "' GROUP BY instructor.instructorid ORDER BY instructor.inst_lname ");
  79. if ($grade) {
  80. $this->view->grade = $grade;
  81. }
  82. }
  83.  
  84. // hindi ko na ginamit si $days, pinalit ko sa $dayss sa query below
  85. $dayss = "";
  86. $postdays = $request->getPost('days');
  87.  
  88. if ($postdays !== null) {
  89. $dayss = ' AND ';
  90. foreach ($postdays as $key => $value) {
  91. if($key == 0) {
  92. $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."')";
  93. }
  94. else {
  95. $dayss .= " OR (classes.days LIKE '%" . $value . "%' AND classes.time_start >= '".$time_start."') ";
  96. }
  97. }
  98. }
  99.  
  100. $times = "";
  101. /* if ($time_start != '' and $time_end != '') {
  102. $times = "AND (classes.time_start BETWEEN '" . $time_start . "' AND '" . $time_end . "') AND (classes.time_end BETWEEN '" . $time_start . "' AND '" . $time_end . "')";
  103. }
  104. elseif($time_start != '') {
  105. $times = "AND classes.time_start >= '".$time_start."'";
  106. }
  107. elseif($time_start != '' && $time_end != '') {
  108. $times = " AND classes.time_start <= '".$time_start."' AND classes.time_end >= '".$time_end."'";
  109. }*/
  110.  
  111. /*if($time_start != '' && $time_end == '') {
  112. $times = "AND classes.time_start >= '".$time_start."'";
  113. }
  114. elseif($time_start != '' && $time_end != '') {
  115. $times = "AND classes.time_start >= '".$time_start."' AND classes.time_end <= '".$time_end."' OR classes.time_start BETWEEN '".$time_start."' AND '".$time_end."'";
  116. }*/
  117.  
  118.  
  119. $sched = ControllerBase::query("SELECT * from classes
  120. INNER JOIN instructor ON classes.instructor_id = instructor.id
  121. INNER JOIN room ON classes.room_id = room.id
  122. INNER JOIN subject ON classes.subjectcode = subject.entryno
  123. WHERE classes.acadyear ='" . $acadyear . "'
  124. AND classes.semester ='" . $semester . "'
  125. $dayss
  126. ORDER BY subject.code ");
  127.  
  128. if ($sched) {
  129.  
  130. $this->view->sched = $sched;
  131. }
  132.  
  133. $this->view->postback = $this->request->getPost('days');
  134. }
  135. }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement