Browse Source

Update AnnualPlansController.php

parent
commit
75a3429132
1 changed files with 10 additions and 11 deletions
  1. 10
    11
      app/controllers/AnnualPlansController.php

+ 10
- 11
app/controllers/AnnualPlansController.php View File

160
       annual_plans.id as id 
160
       annual_plans.id as id 
161
     from annual_plans 
161
     from annual_plans 
162
     join annual_cycle on annual_cycle_id = annual_cycle.id 
162
     join annual_cycle on annual_cycle_id = annual_cycle.id 
163
-    where program_id = 110 
163
+    where program_id = {$program_id} 
164
     and(
164
     and(
165
       semester_start in(
165
       semester_start in(
166
         select semester_id 
166
         select semester_id 
178
     // Log::info($annual_plans);
178
     // Log::info($annual_plans);
179
     $outcomes = array();
179
     $outcomes = array();
180
     $allSemesterOrder = array();
180
     $allSemesterOrder = array();
181
+    Log::info($annual_plans);
181
     /*foreach ($annual_plans as $an_plan) {
182
     /*foreach ($annual_plans as $an_plan) {
182
       Log::info($an_plan->id);
183
       Log::info($an_plan->id);
183
       $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->id} ))");
184
       $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->id} ))");
330
     }
331
     }
331
   }
332
   }
332
 
333
 
333
-  public function CreateOrEdit($program_id){
334
+  public function CreateOrEdit($program_id)
335
+  {
334
 
336
 
335
     $semester_id = Input::get('semester_id');
337
     $semester_id = Input::get('semester_id');
336
     $expected_target = Input::get('expected_target');
338
     $expected_target = Input::get('expected_target');
337
-    
339
+
338
     $exist = DB::select("select * from target_outcomes_program where program_id = {$program_id} and semester_id = {$semester_id}");
340
     $exist = DB::select("select * from target_outcomes_program where program_id = {$program_id} and semester_id = {$semester_id}");
339
-    
340
-    
341
-    if($exist){
342
-      //update
343
-      DB::update("update target_outcomes_program set expected_target = {$expected_target}, updated_at = now() where program_id = {$program_id} and semester_id = {$semester_id}");
344
-    }
345
 
341
 
346
 
342
 
347
-    else{
343
+    if ($exist) {
344
+      //update
345
+      DB::update("update target_outcomes_program set expected_target = {$expected_target}, updated_at = now() where program_id = {$program_id} and semester_id = {$semester_id}");
346
+    } else {
348
       //create a new one
347
       //create a new one
349
       DB::insert("insert into target_outcomes_program (program_id, semester_id, expected_target, created_at, updated_at) values({$program_id}, {$semester_id}, '{$expected_target}', '{now()}', '{now()}')");
348
       DB::insert("insert into target_outcomes_program (program_id, semester_id, expected_target, created_at, updated_at) values({$program_id}, {$semester_id}, '{$expected_target}', '{now()}', '{now()}')");
350
     }
349
     }
619
 
618
 
620
     return $outcome;
619
     return $outcome;
621
   }
620
   }
622
-}
621
+}