No Description

TransformativeAction.php 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. class TransformativeAction extends Eloquent
  3. {
  4. protected $table = 'transformative_actions';
  5. public function scopeStatus($query, $semester_id)
  6. {
  7. return $query->join('transformative_action_status')
  8. ->where('trans_id', $this->id)
  9. ->where('semester_id', $semester_id)
  10. ->first();
  11. }
  12. public static function getTypCoursesWithSemesters($trans_id)
  13. {
  14. return DB::table('transformative_actions')
  15. ->join('annual_plan_transformative', 'annual_plan_transformative.trans_id', '=', 'transformative_actions.id')
  16. ->join('typ_semester_courses', 'typ_semester_courses.id', '=', 'annual_plan_transformative.typ_semester_course_id')
  17. ->join('typ_semester_objectives', 'typ_semester_objectives.id', '=', 'typ_semester_courses.typ_semester_objective_id')
  18. ->join('typ_semester_outcome', 'typ_semester_outcome.id', '=', 'typ_semester_objectives.typ_semester_outcome_id')
  19. ->join('semesters', 'semesters.id', '=', 'typ_semester_outcome.semester_id')
  20. ->where('transformative_actions.id', $trans_id)
  21. ->select(
  22. 'transformative_actions.*',
  23. 'transformative_actions.id as trans_id',
  24. 'semesters.id',
  25. 'semesters.code',
  26. 'typ_semester_course_id as typ_future_course_id'
  27. )
  28. ->get();
  29. }
  30. public static function getCategoriesHtml($program_id)
  31. {
  32. $categories = "<option value='0'>Nothing Selected</option>";
  33. $types = DB::table('transformative_actions')
  34. ->select('type_of_TA', 'is_custom')
  35. ->where('type_of_TA', '<>', '')
  36. ->where(function ($query) use (&$program_id) {
  37. $query->whereNull('program_id')
  38. ->orWhere('program_id', $program_id);
  39. })
  40. ->where('by_professor', 0)
  41. ->groupBy('type_of_TA')
  42. ->get();
  43. $optGroupGeneral = "<optgroup label='General Transformative Actions'>";
  44. $optGroupCustom = "<optgroup label ='Program Custom Actions' id = 'program_custom_action'>";
  45. foreach ($types as $type) {
  46. if ($type->is_custom) {
  47. $optGroupCustom .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '1'>" . $type->type_of_TA . "</option>";
  48. } else {
  49. $optGroupGeneral .= "<option value = '" . $type->type_of_TA . "' data-is-custom = '0'>" . $type->type_of_TA . "</option>";
  50. }
  51. }
  52. $categories .= $optGroupGeneral . '</optgroup>';
  53. $categories .= $optGroupCustom . '</optgroup>';
  54. $categories .= '<option value ="new"> New Type of Transformative Action</option>';
  55. return $categories;
  56. }
  57. }