Нет описания

ThreeYearPlanController.php 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <?php
  2. use Illuminate\Database\Eloquent\Collection;
  3. class ThreeYearPlanController extends \BaseController
  4. {
  5. public function create()
  6. {
  7. try {
  8. DB::beginTransaction();
  9. $yearStart = Input::get('years') + 0;
  10. $yearEnd = $yearStart + 3;
  11. $program_id = Input::get('program_id');
  12. DB::insert("insert into three_year_plan (`year_start`, `year_end`) values ({$yearStart}, {$yearEnd})");
  13. $typ = DB::table('three_year_plan')->where('year_start', '=', $yearStart)
  14. ->where('year_end', '=', $yearEnd)
  15. ->first();
  16. for ($i = $yearStart; $i < $yearEnd; $i++) {
  17. $string = 'First Semester ' . $i . '-' . ($i + 1);
  18. $string2 = 'Second Semester ' . $i . '-' . ($i + 1);
  19. $Firstsemester = DB::table('semesters')->where('name', '=', $string)->first();
  20. $secondSemester = DB::table('semesters')->where('name', '=', $string2)->first();
  21. Log::info($Firstsemester->id);
  22. Log::info($secondSemester->id);
  23. Log::info($typ->id);
  24. DB::insert("insert into typ_semesters (typ_id, semester_id) values ({$typ->id}, {$Firstsemester->id}), ({$typ->id}, {$secondSemester->id})");
  25. }
  26. DB::commit();
  27. Session::flash('status', 'success');
  28. Session::flash('message', '<p> Cycle created.</p>');
  29. return Redirect::to("three-years-plan/{$program_id}");
  30. } catch (Exception $e) {
  31. Session::flash('status', 'danger');
  32. Session::flash('message', "<p>Could not create cycle</p>");
  33. Log::info($e);
  34. DB::rollback();
  35. return Redirect::to("three-years-plan/{$program_id}");
  36. }
  37. }
  38. // load the Three year Plan page
  39. public function threeYearsReport($program_id)
  40. {
  41. $user_id = Auth::user()->id;
  42. $last_year = DB::table('three_year_plan')->select('year_end')
  43. ->orderBy('year_end', 'desc')->first();
  44. if (!$last_year) {
  45. // $last_year = date('Y');
  46. $last_year = 2019;
  47. } else {
  48. $last_year = $last_year->year_end;
  49. }
  50. // el ID de los semestres que el usuario tiene seleccionado.
  51. $semesters_ids = Session::get('semesters_ids');
  52. // buscar informacion de los semestres seleccionados
  53. $semesters = Semester::whereIn('id', $semesters_ids)->get();
  54. $title = "Three Year Plans";
  55. $typs = DB::table('three_year_plan')
  56. ->orderBy('year_start', 'asc')
  57. ->get();
  58. $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
  59. /* $program_id = DB::table('program_user')
  60. ->where('user_id', $user_id)
  61. ->select('program_id')
  62. ->get();
  63. $program_id = $program_id[0]->program_id;*/
  64. $outcomes = DB::table('outcomes')->where('deactivation_date', '=', null)->orderBy('name', 'ASC')->get();
  65. // se annadio la nueva variable
  66. return View::make('global.view-three-year-plan', compact('title', 'last_year', 'outcomes', 'typs', 'criteria', 'semesters', 'program_id'));
  67. }
  68. //when the user select a three year period from the left column, load the corresponding info
  69. public function fetchThreeYears()
  70. {
  71. $id = Input::get('id');
  72. $semesters = DB::table('typ_semesters')
  73. ->join('semesters', 'semesters.id', '=', 'typ_semesters.semester_id')
  74. ->where('typ_semesters.typ_id', $id)
  75. ->orderBy('typ_semesters.semester_id', 'asc')
  76. ->get();
  77. $typs = DB::table('three_year_plan')
  78. ->where('id', $id)
  79. ->orderBy('year_start', 'asc')
  80. ->get();
  81. $typs = $typs[0];
  82. $typs->semesters = $semesters;
  83. return array(
  84. 'typ' => $typs,
  85. );
  86. }
  87. // add or remove a semester associated with an outcome when a user selects a checkbox
  88. public function update_typ_outcomes_semesters()
  89. {
  90. $outcomeSemesterArray = json_decode(Input::get('outcomeSemesterArray'), true);
  91. $typ_id = Input::get('typ_id');
  92. $user_id = auth::user()->id;
  93. $program_id = Input::get('program_id');
  94. $result = DB::table('typ_program')
  95. ->where('three_year_plan_id', $typ_id)
  96. ->where('program_id', $program_id)
  97. ->get();
  98. // create the relation if it doesnt exist
  99. if (count($result) == 0) {
  100. $typ_program_id = DB::table('typ_program')->insertGetId(
  101. array(
  102. 'three_year_plan_id' => $typ_id,
  103. 'program_id' => $program_id
  104. )
  105. );
  106. } else {
  107. $typ_program_id = $result[0]->id;
  108. }
  109. //go through array
  110. foreach ($outcomeSemesterArray as $outcome_semester) {
  111. // foreach of the 6 semesters
  112. foreach ($outcome_semester["semesters"] as $semester) {
  113. $insert = $semester[1];
  114. $outcome_id = explode("-sem", $semester[0])[0];
  115. $semester_code = explode("-sem", $semester[0])[1];
  116. $result = DB::table('semesters')
  117. ->where('code', $semester_code)
  118. ->select('id')
  119. ->get();
  120. if (count($result) == 0) {
  121. continue;
  122. }
  123. $semester_id = $result[0]->id;
  124. // verify if it exists
  125. $result = DB::table('typ_semester_outcome')
  126. ->where('typ_program_id', $typ_program_id)
  127. ->where('semester_id', $semester_id)
  128. ->where('outcome_id', $outcome_id)
  129. ->get();
  130. // if true, it should get inserted
  131. if ($insert == true) {
  132. // if == 0, then insert
  133. if (count($result) == 0) {
  134. $_ = DB::table('typ_semester_outcome')->insertGetId(
  135. array(
  136. 'typ_program_id' => $typ_program_id,
  137. 'semester_id' => $semester_id,
  138. 'outcome_id' => $outcome_id
  139. )
  140. );
  141. }
  142. //if exists, then do nothing
  143. }
  144. // if false, it should get deleted
  145. else { //value == false
  146. // if == 0, it doesnt exist. we do nothing
  147. if (count($result) == 0) {
  148. //pass
  149. }
  150. //if exists, then do nothing
  151. else {
  152. DB::table('typ_semester_outcome')
  153. ->where('typ_program_id', $typ_program_id)
  154. ->where('semester_id', $semester_id)
  155. ->where('outcome_id', $outcome_id)
  156. ->delete();
  157. }
  158. }
  159. }
  160. }
  161. return;
  162. }
  163. // load semesters asociated with the outcomes if previously selected
  164. public function lookup_typ_semester_outcome()
  165. {
  166. $box_value = array();
  167. $info = Input::get('info');
  168. foreach ($info as $values) {
  169. $outcome_id = $values[0];
  170. $semester_code = $values[1];
  171. $program_id = $values[2];
  172. $box_id = $values[3];
  173. $typ_id = $values[4];
  174. //buscar id del typ
  175. $result = DB::table('typ_program')
  176. ->where('three_year_plan_id', $typ_id)
  177. ->where('program_id', $program_id)
  178. ->get();
  179. $typ_program_id = $result[0]->id;
  180. // buscar si existe el outcome_semester
  181. $result = DB::table('typ_semester_outcome')
  182. ->join('semesters', 'semesters.id', '=', 'typ_semester_outcome.semester_id')
  183. ->where('typ_program_id', $typ_program_id)
  184. ->where('semesters.code', $semester_code)
  185. ->where('outcome_id', $outcome_id)
  186. ->get();
  187. // if it doesnt exist
  188. if (count($result) == 0) {
  189. array_push($box_value, array($box_id, 0));
  190. } else {
  191. array_push($box_value, array($box_id, 1));
  192. }
  193. }
  194. return array(
  195. 'box_value' => ($box_value)
  196. );
  197. }
  198. // save or delete Objectives associated with the outcomes and semsters
  199. public function section2_on_change()
  200. {
  201. $typ_id = Input::get('typ_id');
  202. $outcome_id = Input::get('outcome_id');
  203. $semester_id = Input::get('semester_id');
  204. $previous_objective_id = Input::get('previous_objective_id');
  205. $new_objective_id = Input::get('new_objective_id');
  206. $program_id = Input::get('program_id');
  207. // get program_id
  208. $user_id = auth::user()->id;
  209. // get typ_program_id
  210. $result = DB::table('typ_program')
  211. ->where('three_year_plan_id', $typ_id)
  212. ->where('program_id', $program_id)
  213. ->get();
  214. $typ_program_id = $result[0]->id;
  215. // get typ_semester_outcome_id
  216. $result = DB::table('typ_semester_outcome')
  217. ->where('typ_program_id', $typ_program_id)
  218. ->where('semester_id', $semester_id)
  219. ->where('outcome_id', $outcome_id)
  220. ->get();
  221. $typ_semester_outcome_id = $result[0]->id;
  222. //delete old objective relation if it exists
  223. if ($previous_objective_id != 'nothing_selected') {
  224. $result = DB::table('typ_semester_objectives')
  225. ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
  226. ->where('objective_id', $previous_objective_id)
  227. ->get();
  228. if (count($result) != 0) {
  229. DB::table('typ_semester_objectives')
  230. ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
  231. ->where('objective_id', $previous_objective_id)
  232. ->delete();
  233. }
  234. }
  235. //create new objective relation
  236. if ($new_objective_id != 'nothing_selected') {
  237. $result = DB::table('typ_semester_objectives')
  238. ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
  239. ->where('objective_id', $new_objective_id)
  240. ->get();
  241. if (count($result) == 0) {
  242. $_ = DB::table('typ_semester_objectives')->insertGetId(
  243. array(
  244. 'typ_semester_outcome_id' => $typ_semester_outcome_id,
  245. 'objective_id' => $new_objective_id
  246. )
  247. );
  248. }
  249. }
  250. return 'update was succes';
  251. }
  252. // load the corresponding info after associating semesters with outcomes
  253. public function section2_arrive()
  254. {
  255. // get program_id
  256. $user_id = auth::user()->id;
  257. $program_id = Input::get('program_id');
  258. // get typ_program_id
  259. $typ_id = Input::get('typ_id');
  260. $result = DB::table('typ_program')
  261. ->where('three_year_plan_id', $typ_id)
  262. ->where('program_id', $program_id)
  263. ->get();
  264. $typ_program_id = $result[0]->id;
  265. //search selected outcomes,semesters and get their objectives
  266. $selected_outcomes = DB::table('typ_semester_outcome')
  267. ->join('outcomes', 'outcomes.id', '=', 'typ_semester_outcome.outcome_id')
  268. ->where('typ_semester_outcome.typ_program_id', $typ_program_id)
  269. ->distinct('typ_semester_outcome.outcome_id')
  270. ->select('typ_semester_outcome.outcome_id')
  271. ->orderBy('outcomes.name', 'asc')
  272. ->get();
  273. $selected_objectives_array = array();
  274. $outcomes_info_array = array();
  275. // $objectives_info_array = array();
  276. $semesters_array = array();
  277. $info = array();
  278. foreach ($selected_outcomes as $outcome) {
  279. $outcome_id = $outcome->outcome_id;
  280. $result_outcomes = DB::table('outcomes')
  281. ->where('outcomes.id', $outcome_id)
  282. ->orderBy('outcomes.name', 'asc')
  283. ->get();
  284. foreach ($result_outcomes as $outcome_) {
  285. $result_semesters = DB::table('typ_semester_outcome')
  286. ->join('semesters', 'semesters.id', '=', 'typ_semester_outcome.semester_id')
  287. ->where('typ_semester_outcome.typ_program_id', $typ_program_id)
  288. ->where('typ_semester_outcome.outcome_id', $outcome_->id)
  289. ->select('typ_semester_outcome.id', 'typ_semester_outcome.semester_id', 'semesters.code', 'semesters.name')
  290. ->get();
  291. // buscar info sobre selected_semsters
  292. $outcome_->selected_semesters = array();
  293. foreach ($result_semesters as $semesters_) {
  294. $typ_semester_outcome_id = $semesters_->id;
  295. // lookup previusly selected objectives
  296. $result_objectives = DB::table('typ_semester_objectives')
  297. ->join('objectives', 'objectives.id', '=', 'typ_semester_objectives.objective_id')
  298. ->where('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome_id)
  299. ->orderBy('typ_semester_objectives.id', 'asc')
  300. ->get();
  301. $semesters_->selected_objectives = array();
  302. foreach ($result_objectives as $objectives_) {
  303. array_push($semesters_->selected_objectives, $objectives_);
  304. }
  305. // lookup available objectives
  306. $result_objectives = DB::table('objective_outcome')
  307. ->join('outcomes', 'outcomes.id', '=', 'objective_outcome.outcome_id')
  308. ->join('objectives', 'objectives.id', '=', 'objective_outcome.objective_id')
  309. ->join('objective_program', 'objective_program.objective_id', '=', 'objectives.id')
  310. ->where('objective_program.program_id', $program_id)
  311. ->where('objective_outcome.outcome_id', $outcome_id)
  312. ->select('objectives.id', 'objectives.text', 'outcomes.name as outcome_name')
  313. ->orderBy('objectives.text', 'asc')
  314. ->get();
  315. $semesters_->available_objectives = array();
  316. foreach ($result_objectives as $objectives_) {
  317. array_push($semesters_->available_objectives, $objectives_);
  318. }
  319. array_push($outcome_->selected_semesters, $semesters_);
  320. }
  321. array_push($info, $outcome_);
  322. }
  323. }
  324. return $info;
  325. }
  326. // load the corresponding info after associating objectives to semesters outcomes
  327. public function section3_arrive()
  328. {
  329. // get program_id
  330. $user_id = auth::user()->id;
  331. $program_id = Input::get('program_id');
  332. // get typ_program_id
  333. $typ_id = Input::get('typ_id');
  334. $result = DB::table('typ_program')
  335. ->where('three_year_plan_id', $typ_id)
  336. ->where('program_id', $program_id)
  337. ->get();
  338. $typ_program_id = $result[0]->id;
  339. //search selected outcomes,semesters and get their objectives
  340. $selected_outcomes = DB::table('typ_semester_outcome')
  341. ->join('outcomes', 'outcomes.id', '=', 'typ_semester_outcome.outcome_id')
  342. ->where('typ_semester_outcome.typ_program_id', $typ_program_id)
  343. ->distinct('typ_semester_outcome.outcome_id')
  344. ->select('typ_semester_outcome.outcome_id')
  345. ->orderBy('outcomes.name', 'asc')
  346. ->get();
  347. $selected_objectives_array = array();
  348. $outcomes_info_array = array();
  349. // $objectives_info_array = array();
  350. $semesters_array = array();
  351. $info = array();
  352. foreach ($selected_outcomes as $outcome) {
  353. $outcome_id = $outcome->outcome_id;
  354. $result_outcomes = DB::table('outcomes')
  355. ->where('outcomes.id', $outcome_id)
  356. ->get();
  357. foreach ($result_outcomes as $outcome_) {
  358. $result_semesters = DB::table('typ_semester_outcome')
  359. ->join('semesters', 'semesters.id', '=', 'typ_semester_outcome.semester_id')
  360. ->where('typ_semester_outcome.typ_program_id', $typ_program_id)
  361. ->where('typ_semester_outcome.outcome_id', $outcome_->id)
  362. ->select('typ_semester_outcome.id', 'typ_semester_outcome.semester_id', 'semesters.code', 'semesters.name')
  363. ->get();
  364. // buscar info sobre selected_semsters
  365. $outcome_->selected_semesters = array();
  366. foreach ($result_semesters as $semesters_) {
  367. $typ_semester_outcome_id = $semesters_->id;
  368. $result_objectives = DB::table('typ_semester_objectives')
  369. ->join('objectives', 'objectives.id', '=', 'typ_semester_objectives.objective_id')
  370. ->where('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome_id)
  371. ->select('typ_semester_objectives.id as typ_semester_objectives_id', 'objectives.*', 'typ_semester_objectives.*')
  372. ->orderBy('typ_semester_objectives.id', 'asc')
  373. ->get();
  374. $semesters_->selected_objectives = array();
  375. foreach ($result_objectives as $objectives_) {
  376. $result_courses = DB::table('courses')
  377. ->where('courses.program_id', $program_id)
  378. ->select('courses.id as course_id', 'courses.name', 'courses.code', 'courses.program_id')
  379. ->orderBy('courses.name', 'asc')
  380. ->groupBy('courses.name', 'courses.code')
  381. ->get();
  382. #los cursos resultantes creo que deberian ser: todos los que se estan dando en mi programa
  383. $objectives_->available_courses = array();
  384. foreach ($result_courses as $courses_) {
  385. array_push($objectives_->available_courses, $courses_);
  386. }
  387. // search for previusly selected courses
  388. $typ_semester_objective_id = $objectives_->typ_semester_objectives_id;
  389. $result_courses = DB::table('typ_semester_courses')
  390. ->join('courses', 'courses.id', '=', 'typ_semester_courses.course_id')
  391. ->where('typ_semester_courses.typ_semester_objective_id', $typ_semester_objective_id)
  392. ->select('courses.id as course_id', 'courses.*', 'typ_semester_courses.*')
  393. ->orderBy('courses.name', 'asc')
  394. ->get();
  395. $objectives_->selected_courses = array();
  396. foreach ($result_courses as $courses_) {
  397. array_push($objectives_->selected_courses, $courses_);
  398. }
  399. array_push($semesters_->selected_objectives, $objectives_);
  400. }
  401. array_push($outcome_->selected_semesters, $semesters_);
  402. }
  403. array_push($info, $outcome_);
  404. }
  405. }
  406. return $info;
  407. }
  408. // save or delete courses associated with objectives
  409. public function section3_on_change()
  410. {
  411. $typ_id = Input::get('typ_id');
  412. $outcome_id = Input::get('outcome_id');
  413. $semester_id = Input::get('semester_id');
  414. $objective_id = Input::get('objective_id');
  415. $previous_course_id = Input::get('previous_course_id');
  416. $new_course_id = Input::get('new_course_id');
  417. // get program_id
  418. $program_id = Input::get('program_id');
  419. // get typ_program_id
  420. $result = DB::table('typ_program')
  421. ->where('three_year_plan_id', $typ_id)
  422. ->where('program_id', $program_id)
  423. ->get();
  424. $typ_program_id = $result[0]->id;
  425. // get typ_semester_outcome_id
  426. $result = DB::table('typ_semester_outcome')
  427. ->where('typ_program_id', $typ_program_id)
  428. ->where('semester_id', $semester_id)
  429. ->where('outcome_id', $outcome_id)
  430. ->get();
  431. $typ_semester_outcome_id = $result[0]->id;
  432. // get typ_semester_objective_id
  433. $result = DB::table('typ_semester_objectives')
  434. ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
  435. ->where('objective_id', $objective_id)
  436. ->get();
  437. $typ_semester_objective_id = $result[0]->id;
  438. //delete old objective relation if it exists
  439. if ($previous_course_id != 'nothing_selected') {
  440. $result = DB::table('typ_semester_courses')
  441. ->where('typ_semester_objective_id', $typ_semester_objective_id)
  442. ->where('course_id', $previous_course_id)
  443. ->get();
  444. if (count($result) != 0) {
  445. DB::table('typ_semester_courses')
  446. ->where('typ_semester_objective_id', $typ_semester_objective_id)
  447. ->where('course_id', $previous_course_id)
  448. ->delete();
  449. }
  450. }
  451. //create new objective relation
  452. if ($new_course_id != 'nothing_selected') {
  453. $result = DB::table('typ_semester_courses')
  454. ->where('typ_semester_objective_id', $typ_semester_objective_id)
  455. ->where('course_id', $new_course_id)
  456. ->get();
  457. if (count($result) == 0) {
  458. $_ = DB::table('typ_semester_courses')->insertGetId(
  459. array(
  460. 'typ_semester_objective_id' => $typ_semester_objective_id,
  461. 'course_id' => $new_course_id
  462. )
  463. );
  464. }
  465. }
  466. return 'update succes?';
  467. }
  468. public function createAnnualPlan($program_id)
  469. {
  470. $input_id = Input::get('typ_id');
  471. $current_typ = DB::select("select * from three_year_plan where id = {$input_id}")[0];
  472. $count = 0;
  473. $yearStartPlusOne = $current_typ->year_start + 1;
  474. $yearStart = $current_typ->year_start;
  475. Log::info($yearStart);
  476. Log::info($yearStartPlusOne);
  477. while ($count < 3) {
  478. $firstSemester = DB::select("select * from semesters where name like 'First Semester {$yearStart}-{$yearStartPlusOne}'");
  479. $secondSemester = DB::select("select * from semesters where name like 'Second Semester {$yearStart}-{$yearStartPlusOne}'");
  480. if (count($firstSemester) && count($secondSemester)) {
  481. Log::info($firstSemester);
  482. Log::info($secondSemester);
  483. $query = DB::select("select * from annual_cycle where semester_start ={$firstSemester[0]->id} and semester_end ={$secondSemester[0]->id} ");
  484. if (!count($query)) {
  485. DB::insert("insert into annual_cycle (academic_year, semester_start, semester_end) values ('{$yearStart}-{$yearStartPlusOne}', {$firstSemester[0]->id}, {$secondSemester[0]->id})");
  486. }
  487. $an_cycle = DB::table('annual_cycle')->where('semester_start', '=', $firstSemester[0]->id)
  488. ->where('semester_end', '=', $secondSemester[0]->id)
  489. ->first();
  490. $query = DB::table('annual_plans')->where("annual_cycle_id", '=', $an_cycle->id)
  491. ->where('program_id', '=', $program_id)->first();
  492. if (!$query) {
  493. DB::insert("insert into annual_plans (`annual_cycle_id`, `program_id`) values ({$an_cycle->id}, {$program_id})");
  494. }
  495. }
  496. $count++;
  497. $yearStart++;
  498. $yearStartPlusOne++;
  499. }
  500. }
  501. public function printPlan($program_id, $typ)
  502. {
  503. $program = DB::table('programs')->where('id', $program_id)->first();
  504. $three_year_plan = DB::table('three_year_plan')->where('id', $typ)->first();
  505. $typ_program_id = DB::table('typ_program')->where('three_year_plan_id', $three_year_plan->id)
  506. ->where('program_id', $program->id)
  507. ->first()->id;
  508. $typ_semesters = DB::table('semesters')
  509. ->join('typ_semesters', 'semesters.id', '=', 'typ_semesters.semester_id')
  510. ->where('typ_id', $three_year_plan->id)
  511. ->orderBy('semester_id')
  512. ->get();
  513. foreach ($typ_semesters as $semester) {
  514. $typ_semester_outcome[$semester->semester_id] = DB::table('typ_semester_outcome')
  515. ->join('outcomes', 'outcomes.id', '=', 'typ_semester_outcome.outcome_id')
  516. ->where('typ_program_id', $typ_program_id)
  517. ->where('semester_id', $semester->semester_id)
  518. ->select('typ_semester_outcome.id as typ_id')
  519. ->addSelect('outcomes.id as outcome_id', 'outcomes.name')
  520. ->get();
  521. foreach ($typ_semester_outcome[$semester->semester_id] as $outcome) {
  522. $outcome->objectives = DB::table('typ_semester_objectives')
  523. ->join('objectives', 'objectives.id', '=', 'typ_semester_objectives.objective_id')
  524. ->where('typ_semester_outcome_id', $outcome->typ_id)
  525. ->select('typ_semester_objectives.id as typ_obj_id')
  526. ->addSelect('objectives.text', 'objectives.id as objective_id')
  527. ->get();
  528. foreach ($outcome->objectives as $objective) {
  529. $objective->courses = DB::table('typ_semester_courses')
  530. ->join('courses', 'courses.id', '=', 'typ_semester_courses.course_id')
  531. ->where('typ_semester_objective_id', $objective->typ_obj_id)
  532. ->get();
  533. }
  534. }
  535. }
  536. Log::info($typ_semester_outcome);
  537. return View::make('global.print_three_year_plan', compact('typ_semesters', 'program', 'three_year_plan', 'typ_semesters', 'typ_semester_outcome'));
  538. }
  539. }