Açıklama Yok

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