Geen omschrijving

TransformativeAction.php 2.9KB

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