parent
commit
187b9bcd2e
2 changed files with 37 additions and 5 deletions
  1. 1
    1
      app/controllers/AnnualPlansController.php
  2. 36
    4
      app/controllers/CriteriaController.php

+ 1
- 1
app/controllers/AnnualPlansController.php View File

@@ -322,7 +322,7 @@ class AnnualPlansController extends \BaseController
322 322
 
323 323
       $typ_info['courses'][$objective->id] = DB::select("select c.id, c.number, c.name, 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')));
324 324
 
325
-      $typ_info['criteria'][$objective->id] = DB::select("select * from criteria where deleted_at IS NULL and id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
325
+      $typ_info['criteria'][$objective->id] = DB::select("select * from criteria where deleted_at IS NULL and id in (select criterion_id from criterion_objective_outcome join program_criterion_objective_outcome on program_criterion_objective_outcome.cri_obj_out_id = criterion_objective_outcome.id where outcome_id = ? and program_id {$program_id} and objective_id = {$objective->id})", array(Input::get('id')));
326 326
       Log::info($typ_info['criteria'][$objective->id]);
327 327
       $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')));
328 328
       Log::info($typ_info['typ_objective_id'][$objective->id]);

+ 36
- 4
app/controllers/CriteriaController.php View File

@@ -95,7 +95,7 @@ class CriteriaController extends \BaseController
95 95
         $program_id = Input::get('program_fetch');
96 96
         $outcome_id = Input::get('outcome_fetch');
97 97
         $json = array();
98
-        $json['criterion'] = DB::select("SELECT * FROM `criteria` where id in (select criterion_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select criterion_id from program_criterion where program_id = {$program_id})");
98
+        $json['criterion'] = DB::select("SELECT * FROM `criteria` where id in (select criterion_id from criterion_objective_outcome join program_criterion_objective_outcome on program_criterion_objective_outcome.cri_obj_out = criterion_objective_outcome.id where outcome_id ={$outcome_id} and program_id = {$program_id}) ");
99 99
 
100 100
         return json_encode($json);
101 101
     }
@@ -544,7 +544,22 @@ class CriteriaController extends \BaseController
544 544
                     $outcome_objective = str_replace($parentesis, '', $objective_id);
545 545
 
546 546
                     $outcome_objective = explode(',', $outcome_objective);
547
-                    DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$outcome_objective[1]},{$outcome_objective[0]}, {$criterionId})");
547
+                    $cobo_id = DB::table('criterion_objective_outcome')
548
+                        ->insertGetId(array(
549
+                            "objective_id" => $outcome_objective[1],
550
+                            "outcome_id" => $outcome_objective[0],
551
+                            "criterion_id" => $criterionId
552
+                        ));
553
+
554
+                    foreach ($clean_input['program_id'] as $program_id) {
555
+                        DB::table('program_criterion_objective_outcome')
556
+                            ->insert(array(
557
+                                'program_id' => $program_id,
558
+                                'cri_obj_out_id' => $cobo_id
559
+                            ));
560
+                    }
561
+                    //DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$outcome_objective[1]},{$outcome_objective[0]}, {$criterionId})");
562
+
548 563
                 }
549 564
 
550 565
 
@@ -855,7 +870,11 @@ class CriteriaController extends \BaseController
855 870
             $parentesis = array('(', ')');
856 871
             if ($criterion->save()) {
857 872
                 $criterionId = $criterion->id;
858
-                DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
873
+                DB::table('criterion_objective_outcome as cobo')
874
+                    ->join('program_criterion_objective_outcome as poco', 'poco.cri_obj_out_id', '=', 'cobo.id')
875
+                    ->where($criterionId)
876
+                    ->delete();
877
+                // DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
859 878
                 DB::delete("delete from `program_criterion` where `criterion_id` ={$criterionId}");
860 879
 
861 880
                 foreach ($clean_input['objective_id'] as $objective_id) {
@@ -863,7 +882,20 @@ class CriteriaController extends \BaseController
863 882
                     $outcome_objective = str_replace($parentesis, '', $objective_id);
864 883
 
865 884
                     $outcome_objective = explode(',', $outcome_objective);
866
-                    DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$outcome_objective[1]},{$outcome_objective[0]}, {$criterionId})");
885
+                    $cobo_id = DB::table('criterion_objective_outcome')
886
+                        ->insertGetId(array(
887
+                            "objective_id" => $outcome_objective[1],
888
+                            "outcome_id" => $outcome_objective[0],
889
+                            "criterion_id" => $criterionId
890
+                        ));
891
+
892
+                    foreach ($clean_input['program_id'] as $program_id) {
893
+                        DB::table('program_criterion_objective_outcome')
894
+                            ->insert(array(
895
+                                'program_id' => $program_id,
896
+                                'cri_obj_out_id' => $cobo_id
897
+                            ));
898
+                    }
867 899
                 }
868 900
 
869 901
                 /*DB::delete("delete from `scales` where id in (select scale_id id from criterion_scale where criterion_id = {$criterionId})");