123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <?php
-
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Input;
-
- class AnnualPlansController extends \BaseController
- {
-
- /**
- * Checks whether a user has permission to view a page in this controller
- *
- * @var User $user Authenticated user
- */
- private function userHasAccess($program_id)
- {
- $user = Auth::user();
-
- switch ($user->role) {
- case '3':
- $programs = $user->programs->lists('id');
-
- // If program does not belong to user, show 403
- if (!in_array($program_id, $programs))
- return false;
-
- break;
-
- case '2':
- $programs = Program::where('school_id', $user->school_id)->lists('id');
-
- // If program is not in user's school, show 403
- if (!in_array($program_id, $programs))
- return false;
-
- break;
- case '4':
- return false;
- }
-
- return true;
- }
-
- public function viewAllPlans($program_id)
- {
- $title = "Annual Plans";
- $annual_plans = DB::select("select * from annual_plans order by id desc");
-
-
- return View::make('local.managers.sCoords.view-annual-plans', compact('title', 'program_id', 'annual_plans'));
- }
-
- /**
- * Lists annual plans by year and program
- * @var string $title Title for page
- * @var Program $programs Collection of programs user has access to
- * @var User $user Authenticated user
- * @var Quinquennium $quinquenniums All current or past quinquenniums
- * @var Quinquennium $current_quinquennium Current quinquennium
- */
-
- public function postReport()
- {
- $program_id = Input::get('program_id') + 0;
- $realized = Input::get('realized');
- $logrado = Input::get('logrado');
- $continued = Input::get('continued');
- $semester = Input::get('semester');
- $typ_objective = Input::get('typ_objective');
- $transformative = Input::get('transformative');
- $annual_id = Input::get("annual_id") + 0;
- $id = Auth::user()['id'];
-
- for ($i = 0; $i < count($semester); $i++) {
- $real = $realized[$i] + 0;
- $logr = $logrado[$i] + 0;
- $cont = $continued[$i] + 0;
- $obj = $typ_objective[$i] + 0;
- $trans = $transformative[$i] + 0;
- $sem = $semester[$i] + 0;
-
- //if it was continued
- if ($real == 1) $real = 2;
- else $real = 1;
- if ($cont == 1) $cont = $sem + 1;
- else $cont = "NULL";
- $annual_trans_id = DB::select("select id from annual_plan_transformative where annual_plan_id ={$annual_id} and trans_id = {$trans} and typ_semester_objective_id = {$obj}")[0]->id;
-
-
- $queryUpdate = DB::select("select * from annual_report_transformative where annual_trans_id = {$annual_trans_id}");
- if (!count($queryUpdate)) {
- DB::insert("insert into annual_report_transformative (accomplished, cycle_of_life, semester_used, semester_continue, annual_trans_id, supervised_coordinator_id) values ({$logr},{$real},{$sem},{$cont},{$annual_trans_id}, {$id})");
- } else {
- DB::update("update annual_report_transformative set accomplished = {$logr}, cycle_of_life ={$real}, semester_used ={$sem}, semester_continue={$cont}, supervised_coordinator_id={$id} where annual_trans_id ={$annual_trans_id}");
- }
- }
- return;
- }
- public function index()
- {
- $title = 'Annual Plans';
- $user = Auth::user();
- $quinquenniums = Quinquennium::where('start_date', '<=', date('Y-m-d'))->get();
- $current_quinquennium = Quinquennium::where('start_date', '<=', date('Y-m-d'))
- ->where('end_date', '>=', date('Y-m-d'))
- ->first();
-
- switch ($user->role) {
- case '1':
- $programs = Program::all();
- break;
- case '2':
- $programs = Program::where('school_id', $user->school_id)->get();
- break;
- case 3:
- $programs = $user->programs;
- break;
- default:
- App::abort('404');
- break;
- }
-
- return View::make('local.managers.shared.index_annual_plans', compact('title', 'quinquenniums', 'programs', 'current_quinquennium'));
- }
- public function adminIndex($school_id)
- {
- $title = "Annual Plans";
- $programs = Program::where("school_id", $school_id)->get();
-
- return View::make('local.managers.admins.appraisal-program', compact('title', 'programs'));
- }
-
- public function showPlan($program_id, $typ_id = null)
- {
- $title = "Annual Plans";
- //$typ_parts = DB::select("select * from typ_parts");
- if (!$typ_id) {
- $current_typ = DB::select("select * from three_year_plan where year_start <=" . date('Y') . " and year_end >=" . date('Y'))[0]->id;
- } else {
- $current_typ = DB::select("select * from three_year_plan where id ={$typ_id}")[0]->id;
- }
- Log::info($current_typ);
-
- $program = Program::where('id', '=', $program_id)->first();
- $annual_plans = DB::select("select * from annual_plans where program_id = {$program_id} order by id desc limit 5");
- Log::info($annual_plans);
- $outcomes = array();
- $allSemesterOrder = array();
- foreach ($annual_plans as $an_plan) {
- Log::info($an_plan->id);
- $outcomes[$an_plan->id]["first"] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id = {$an_plan->semester_start} and typ_program_id in (select id from typ_program where program_id ={$an_plan->program_id} and three_year_plan_id ={$current_typ} ))");
- $allSemesterOrder[$an_plan->id]["first"] = DB::select("select * from semesters where id = {$an_plan->semester_start}")[0];
- $outcomes[$an_plan->id]["second"] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id ={$an_plan->semester_end} and typ_program_id in (select id from typ_program where program_id ={$an_plan->program_id} and three_year_plan_id = {$current_typ} ))");
- $allSemesterOrder[$an_plan->id]["second"] = DB::select("select * from semesters where id = {$an_plan->semester_end}")[0];
- }
- $alltyp = DB::select('select * from three_year_plan order by id desc');
-
- return View::make('local.managers.sCoords.annual-plans', compact('title', 'annual_plans', 'current_typ', 'program', 'outcomes', 'allSemesterOrder', 'alltyp'));
- }
-
- /**
- * Page to create a new plan for the current quinquennium
- * @var string $title Title for page
- * @var Program $programs Collection of programs user has access to
- * @var Outcome $outcomes List of outcomes ordered by name
- * @var User $user Currently logged user
- * @var Course $courses Courses for a particular program
- */
- public function fetchTYP($program_id)
- {
- $typ_info = array();
- $semester = DB::select("select * from semesters where id=?", array(Input::get('semester')))[0];
-
-
- //$typ_info['courses'] = DB::select("select * from courses where id in (select course_id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id} )and outcome_id = ?))", array(Input::get('id')));
- //foreach ($typ_info['courses'] as $course) {
- // $typ_info['courses_objective'][$course->id] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_course_id in (select id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id = {$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id}))and course_id ={$course->id}))");
- // foreach ($typ_info['courses_objective'][$course->id] as $objective) {
- // $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
- // }
- //}
- //$typ_info['courses'] = DB::select("select * from courses where id in (select course_id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where typ_semester_outcome_id in (select id from type_semester_outcome where semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id} )and outcome_id = ?)))", array(Input::get('id')));
- //$typ_info['unique_objective'] = DB::select("select * from objectives where id in (select distinct objective_id from typ_semester_objectives where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id = {$semester->id} and outcome_id =? and typ_program_id in (select id from typ_program where program_id ={$program_id})))", array(Input::get('id')));
- //foreach ($typ_info['unique_objective'] as $objective) {
- // $typ_info['courses_objective'][$objective->id] = DB::select("select * from courses where id in (SELECT course_id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id={$semester->id} and outcome_id =? and typ_program_id in (select id from typ_program where program_id = {$program_id})) and id in (select typ_semester_course_id from typ_semester_objectives where objective_id = {$objective->id}))", array(Input::get('id')));
- // $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
- //}
- $annual_plan = DB::select("select id from annual_plans where (semester_start = {$semester->id} or semester_end ={$semester->id}) and program_id ={$program_id}")[0];
- $typ_info['objectives'] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = ? and semester_id = {$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id})))", array(Input::get('id')));
- $typ_info['transformative_actions'] = DB::select("select * from transformative_actions where by_professor =0 and is_custom=0");
- foreach ($typ_info['objectives'] as $objective) {
-
- $typ_info['courses'][$objective->id] = DB::select("select c.id, c.number, c.code, typ.id typ_course_id from courses c, typ_semester_courses typ, (select course_id, id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id =? and semester_id ={$semester->id} and typ_program_id in(select id from typ_program where program_id ={$program_id})))) rel where typ.course_id =c.id and rel.course_id = c.id and typ.id = rel.id ", array(Input::get('id')));
-
- $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
- Log::info($typ_info['criteria'][$objective->id]);
- $typ_info['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id =? and semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id}))", array(Input::get('id')));
- Log::info($typ_info['typ_objective_id'][$objective->id]);
- $typ_info['typ_objective_id'][$objective->id] = $typ_info['typ_objective_id'][$objective->id][0];
-
- Log::info($typ_info['typ_objective_id'][$objective->id]->id);
- Log::info($annual_plan->id);
- $typ_info['annual_plans_transformative'][$objective->id] = DB::select("select trans_id from annual_plan_transformative where annual_plan_id={$annual_plan->id} and typ_semester_objective_id ={$typ_info['typ_objective_id'][$objective->id]->id}");
- foreach ($typ_info['courses'][$objective->id] as $course) {
- $typ_info['selected_criteria'][$objective->id][$course->id] = DB::select("select criteria_id, typ_semester_course_id typ_course_id from annual_plan_objective where annual_plan_id ={$annual_plan->id} and typ_semester_course_id ={$course->typ_course_id} ");
- }
-
-
- $typ_info['custom_transformative'][$objective->id] = DB::select("select * from transformative_actions where is_custom =1 and by_professor=0 and id in (select ta_id from transformative_objective_program where objective_id = {$objective->id})");
- }
- $typ_info['annual_plan'] = $annual_plan;
- Log::info($typ_info);
-
- return json_encode($typ_info);
- }
- public function deleteTA()
- {
- $annual_id = Input::get('annual_id') + 0;
- $typ_id = Input::get('typ_id') + 0;
- $trans_id = Input::get('TA_id') + 0;
-
- DB::delete("delete from `annual_plan_transformative` where annual_plan_id ={$annual_id} and typ_semester_objective_id ={$typ_id} and trans_id={$trans_id}");
- return;
- }
-
- public function postTA()
- {
- $annual_id = Input::get('annual_id') + 0;
- $TA_id = Input::get('TA_id') + 0;
- $typ_id = Input::get('typ_id') + 0;
- $old_ta = Input::get('old_ta') + 0;
- $id = Auth::user()['id'];
- $date = date('Y-m-d');
- $date = strtotime($date);
-
-
- $query = DB::select("select * from annual_plan_transformative where annual_plan_id ={$annual_id} and trans_id ={$old_ta} and typ_semester_objective_id ={$typ_id}");
-
- if (!count($query)) {
- DB::insert("insert into `annual_plan_transformative` (`annual_plan_id`,`trans_id`, `typ_semester_objective_id`, `proposing_coordinator_id`, `proposed_date`) values({$annual_id},{$TA_id},{$typ_id}, {$id}, now() ) ");
- return "Insert Successful";
- } else {
- if ($TA_id == 0) {
- DB::delete("delete from annual_plan_transformative where trans_id={$TA_id} and annual_plan_id ={$annual_id} and typ_semester_objective_id ={$typ_id}");
- return "deleted";
- } else {
- DB::update("update annual_plan_transformative set trans_id = {$TA_id}, proposing_coordinator_id = {$id}, proposed_date = now() where trans_id={$old_ta} and annual_plan_id ={$annual_id} and typ_semester_objective_id ={$typ_id}");
- return "updated";
- }
- }
- }
- public function transformativeReport()
- {
- $json_to_send = array();
- $annual_id = Input::get('an_id');
- $transformative_action_info = DB::select("select * from transformative_actions where id in (select distinct trans_id from annual_plan_transformative where annual_plan_id = {$annual_id}) ");
- foreach ($transformative_action_info as $trans) {
- $json_to_send['Trans_act'][$trans->id] = $trans;
- $json_to_send['outcomes'][$trans->id] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where id in(select typ_semester_outcome_id from typ_semester_objectives where id in (select typ_semester_objective_id from annual_plan_transformative where trans_id ={$trans->id} and annual_plan_id = {$annual_id})))");
- $json_to_send['typ_objective'][$trans->id] = DB::select("select * from typ_semester_objectives where id in (select typ_semester_objective_id from annual_plan_transformative where annual_plan_id ={$annual_id} and trans_id = {$trans->id})");
- foreach ($json_to_send['typ_objective'][$trans->id] as $typ) {
- $json_to_send['objective'][$typ->id][$trans->id] = DB::select("select * from objectives where id = {$typ->objective_id}");
- $json_to_send['coordinator'][$typ->id][$trans->id] = DB::select("select * from users where id in (select proposing_coordinator_id from annual_plan_transformative where typ_semester_objective_id = {$typ->id} and annual_plan_id = {$annual_id} and trans_id = {$trans->id})");
- $json_to_send['proposed_date'][$typ->id][$trans->id] = DB::select("select proposed_date from annual_plan_transformative where typ_semester_objective_id = {$typ->id} and annual_plan_id = {$annual_id} and trans_id = {$trans->id} ");
- $json_to_send['all_info_report'][$typ->id][$trans->id] = DB::select("select art.accomplished, art.cycle_of_life, semesters.name, art.semester_continue, art.annual_trans_id, art.supervised_coordinator_id from annual_report_transformative art, (select id from annual_plan_transformative where typ_semester_objective_id = {$typ->id} and annual_plan_id = {$annual_id} and trans_id = {$trans->id} ) apt, semesters where art.annual_trans_id = apt.id and semesters.id = art.semester_used");
- }
-
- if ($trans->user_id) {
- $json_to_send['suggested'][$trans->id] = DB::select("select * from users where id = {$trans->user_id}");
- }
- }
- return json_encode($json_to_send);
- }
-
- public function deleteCriteria()
- {
- $criteria = Input::get('criteria') + 0;
- $typ_course_id = Input::get('typ_course_id') + 0;
- $annual_plan = Input::get('annual_plan') + 0;
- $old_criteria = Input::get('old_criteria') + 0;
- $message = '';
-
- DB::delete("delete from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id ={$typ_course_id} and criteria_id={$criteria}");
- return;
- }
-
- public function fetchAllTables()
- {
- $annual_plan = array();
- $an_id = Input::get('id');
- $program_id = Input::get('program_id');
-
- $an_semesters = DB::select("select semester_start, semester_end, program_id from annual_plans where id ={$an_id} and program_id ={$program_id}")[0];
-
- $annual_plan['first']['outcomes'] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id = {$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))");
-
- $annual_plan['second']['outcomes'] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id = {$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))");
-
- $annual_plan['first']['semester'] = array('id' => $an_semesters->semester_start);
- $annual_plan['second']['semester'] = array('id' => $an_semesters->semester_end);
- foreach ($annual_plan['first']['outcomes'] as $outcomes) {
-
- $annual_plan['first']['objectives'][$outcomes->id] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = {$outcomes->id} and semester_id = {$an_semesters->semester_start} and typ_program_id in (select id from typ_program where program_id ={$an_semesters->program_id})))");
-
- foreach ($annual_plan['first']['objectives'][$outcomes->id] as $objective) {
- $annual_plan['first']['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})) ")[0];
- $annual_plan['first']['courses'][$objective->id] = DB::select("select typ.id typ_id, typ.course_id, c.code, c.number from (select course_id, id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})))) typ, courses c where c.id = typ.course_id");
- foreach ($annual_plan['first']['courses'][$objective->id] as $course) {
- $annual_plan['first']['criteria'][$objective->id][$course->course_id] = DB::select("select * from new_criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id = {$course->typ_id} )");
- }
-
- $annual_plan['first']['trans_actions'][$objective->id] = DB::select("select * from transformative_actions where id in (select trans_id from annual_plan_transformative where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))))");
- foreach ($annual_plan['first']['trans_actions'][$objective->id] as $trans) {
- $annual_plan['fill_info'][$annual_plan['first']['typ_objective_id'][$objective->id]->id][$trans->id] = DB::select("select * from annual_report_transformative where annual_trans_id in (select id from annual_plan_transformative where trans_id = {$trans->id} and typ_semester_objective_id ={$annual_plan['first']['typ_objective_id'][$objective->id]->id} and annual_plan_id = {$an_id} )")[0];
- }
- }
- }
- foreach ($annual_plan['second']['outcomes'] as $outcomes) {
- $annual_plan['second']['objectives'][$outcomes->id] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = {$outcomes->id} and semester_id = {$an_semesters->semester_end} and typ_program_id in (select id from typ_program where program_id ={$an_semesters->program_id})))");
- foreach ($annual_plan['second']['objectives'][$outcomes->id] as $objective) {
- $annual_plan['second']['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})) ")[0];
-
- $annual_plan['second']['courses'][$objective->id] = DB::select("select typ.id typ_id, typ.course_id, c.code, c.number from (select course_id, id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})))) typ, courses c where c.id = typ.course_id");
- foreach ($annual_plan['second']['courses'][$objective->id] as $course) {
- $annual_plan['second']['criteria'][$objective->id][$course->course_id] = DB::select("select * from new_criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id ={$course->typ_id})");
- }
-
- $annual_plan['second']['trans_actions'][$objective->id] = DB::select("select * from transformative_actions where id in (select trans_id from annual_plan_transformative where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))))");
- Log::info($annual_plan['second']['typ_objective_id'][$objective->id]->id);
- foreach ($annual_plan['second']['trans_actions'][$objective->id] as $trans) {
- $annual_plan['fill_info'][$annual_plan['second']['typ_objective_id'][$objective->id]->id][$trans->id] = DB::select("select * from annual_report_transformative where annual_trans_id in (select id from annual_plan_transformative where trans_id = {$trans->id} and typ_semester_objective_id ={$annual_plan['second']['typ_objective_id'][$objective->id]->id} and annual_plan_id = {$an_id} )")[0];
- }
- }
- }
-
- return json_encode($annual_plan);
- }
-
- public function postAnnualPlan()
- {
- $criteria = Input::get('criteria') + 0;
- $typ_course_id = Input::get('typ_course_id') + 0;
- $annual_plan = Input::get('annual_plan') + 0;
- $old_criteria = Input::get('old_criteria') + 0;
- $message = '';
- $query = DB::select("select * from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id = {$typ_course_id} and criteria_id ={$old_criteria}");
- if (!count($query)) {
- $query = DB::select("select * from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id = {$typ_course_id} and criteria_id ={$criteria}");
-
- if (!count($query)) {
-
- DB::insert("insert into `annual_plan_objective` (`annual_plan_id`, `typ_semester_course_id`, `criteria_id`) values ({$annual_plan}, {$typ_course_id}, {$criteria})");
- $message = "inserting was a success";
- } else {
- $message = "Duplicate entry, please choose another criteria.";
- }
- } else {
- $query = DB::select("select * from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id = {$typ_course_id} and criteria_id ={$criteria}");
-
- if (!count($query)) {
- DB::update("update `annual_plan_objective` set criteria_id = {$criteria} where annual_plan_id = {$annual_plan} and typ_semester_course_id ={$typ_course_id} and criteria_id = {$old_criteria} ");
- $message = "Updating was a success";
- } else {
- $message = "Duplicate entry, please choose another criteria.";
- }
- }
- return $message;
- }
- public function create(Program $program)
- {
- $title = 'New Annual Plan for ' . $program->name;
- $user = Auth::user();
- $outcomes = Outcome::orderBy('name')->get();
-
- $current_quinquennium = Quinquennium::where('start_date', '<=', date('Y-m-d'))
- ->where('end_date', '>=', date('Y-m-d'))
- ->first();
-
- $courses = Course::select('id', 'code', 'number', 'name')
- ->where('program_id', $program->id)
- ->groupBy('name')
- ->orderBy('code', 'ASC')
- ->orderBy('number', 'ASC')
- ->orderBy('name', 'ASC')
- ->get();
-
- // Check if user can create a plan
- if (!$this->userHasAccess($program->id)) {
- return View::make('global.403');
- }
-
- return View::make('local.managers.shared.create_annual_plan', compact('title', 'program', 'current_quinquennium', 'outcomes', 'courses'));
- }
- }
|