|
@@ -788,44 +788,86 @@ class AnnualPlansController extends \BaseController
|
788
|
788
|
$objective_id = Input::get('objective_id');
|
789
|
789
|
$course_code = Input::get('course_code');
|
790
|
790
|
$course_number = Input::get('course_number');
|
791
|
|
-
|
792
|
|
- $newTransId = DB::table('transformative_actions')
|
793
|
|
- ->insertGetId(array(
|
794
|
|
- 'is_custom' => $is_custom,
|
795
|
|
- 'at_text' => $at_text,
|
796
|
|
- 'description' => $description,
|
797
|
|
- 'type_of_TA' => $type_of_ta,
|
798
|
|
- 'user_id' => Auth::user()->id,
|
799
|
|
- 'program_id' => $program_id,
|
800
|
|
- 'by_professor' => 0,
|
801
|
|
- 'created_at' => date('Y-m-d H:i:s'),
|
802
|
|
- 'updated_at' => date('Y-m-d H:i:s')
|
803
|
|
- ));
|
804
|
|
- DB::table('ta_course')->insert(array(
|
805
|
|
- 'ta_id' => $newTransId,
|
806
|
|
- 'course_number' => $course_number,
|
807
|
|
- 'course_code' => $course_code
|
808
|
|
- ));
|
809
|
|
- DB::table('transformative_objective')->insert(array(
|
810
|
|
- 'ta_id' => $newTransId,
|
811
|
|
- 'objective_id' => $objective_id
|
812
|
|
- ));
|
813
|
|
- foreach ($future_typ_course_id as $index => $typ_future_course_id) {
|
814
|
|
- $annual_plan = DB::table('annual_cycle')
|
815
|
|
- ->join('annual_plans', 'annual_plans.annual_cycle_id', '=', 'annual_cycle.id')
|
816
|
|
- ->where('program_id', $program_id)
|
817
|
|
- ->where(function ($query) use (&$future_semesters, &$index) {
|
818
|
|
- $query->where('semester_start', $future_semesters[$index])
|
819
|
|
- ->orWhere('semester_end', $future_semesters[$index]);
|
820
|
|
- })->first();
|
|
791
|
+ $edit_ta_id = Input::get('edit_ta_id');
|
|
792
|
+
|
|
793
|
+ if ($edit_ta_id) {
|
|
794
|
+ DB::table('transformative_actions')
|
|
795
|
+ ->where('id', $edit_ta_id)->update(array(
|
|
796
|
+ 'is_custom' => $is_custom,
|
|
797
|
+ 'at_text' => $at_text,
|
|
798
|
+ 'description' => $description,
|
|
799
|
+ 'type_of_TA' => $type_of_ta,
|
|
800
|
+ 'user_id' => Auth::user()->id,
|
|
801
|
+ 'program_id' => $program_id,
|
|
802
|
+ //'by_professor' => 0,
|
|
803
|
+ //'created_at' => date('Y-m-d H:i:s'),
|
|
804
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
805
|
+ ));
|
821
|
806
|
DB::table('annual_plan_transformative')
|
822
|
|
- ->insert(array(
|
823
|
|
- 'annual_plan_id' => $annual_plan->id,
|
824
|
|
- 'trans_id' => $newTransId,
|
825
|
|
- 'typ_semester_course_id' => $typ_future_course_id,
|
826
|
|
- 'proposing_coordinator_id' => Auth::user()->id,
|
827
|
|
- 'proposed_date' => date('Y-m-d H:i:s')
|
|
807
|
+ ->where('trans_id', $edit_ta_id)
|
|
808
|
+ ->delete();
|
|
809
|
+ foreach ($future_typ_course_id as $index => $typ_future_course_id) {
|
|
810
|
+ $annual_plan = DB::table('annual_cycle')
|
|
811
|
+ ->join('annual_plans', 'annual_plans.annual_cycle_id', '=', 'annual_cycle.id')
|
|
812
|
+ ->where('program_id', $program_id)
|
|
813
|
+ ->where(function ($query) use (&$future_semesters, &$index) {
|
|
814
|
+ $query->where('semester_start', $future_semesters[$index])
|
|
815
|
+ ->orWhere('semester_end', $future_semesters[$index]);
|
|
816
|
+ })->first();
|
|
817
|
+ DB::table('annual_plan_transformative')
|
|
818
|
+ ->insert(array(
|
|
819
|
+ 'annual_plan_id' => $annual_plan->id,
|
|
820
|
+ 'trans_id' => $edit_ta_id,
|
|
821
|
+ 'typ_semester_course_id' => $typ_future_course_id,
|
|
822
|
+ 'proposing_coordinator_id' => Auth::user()->id,
|
|
823
|
+ 'proposed_date' => date('Y-m-d H:i:s')
|
|
824
|
+ ));
|
|
825
|
+ }
|
|
826
|
+ $transformative_action = TransformativeAction::getTypCoursesWithSemesters($edit_ta_id);
|
|
827
|
+ $transformative_action[0]->updated = 1;
|
|
828
|
+ return $transformative_action;
|
|
829
|
+ } else {
|
|
830
|
+ $newTransId = DB::table('transformative_actions')
|
|
831
|
+ ->insertGetId(array(
|
|
832
|
+ 'is_custom' => $is_custom,
|
|
833
|
+ 'at_text' => $at_text,
|
|
834
|
+ 'description' => $description,
|
|
835
|
+ 'type_of_TA' => $type_of_ta,
|
|
836
|
+ 'user_id' => Auth::user()->id,
|
|
837
|
+ 'program_id' => $program_id,
|
|
838
|
+ 'by_professor' => 0,
|
|
839
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
840
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
828
|
841
|
));
|
|
842
|
+ DB::table('ta_course')->insert(array(
|
|
843
|
+ 'ta_id' => $newTransId,
|
|
844
|
+ 'course_number' => $course_number,
|
|
845
|
+ 'course_code' => $course_code
|
|
846
|
+ ));
|
|
847
|
+ DB::table('transformative_objective')->insert(array(
|
|
848
|
+ 'ta_id' => $newTransId,
|
|
849
|
+ 'objective_id' => $objective_id
|
|
850
|
+ ));
|
|
851
|
+ foreach ($future_typ_course_id as $index => $typ_future_course_id) {
|
|
852
|
+ $annual_plan = DB::table('annual_cycle')
|
|
853
|
+ ->join('annual_plans', 'annual_plans.annual_cycle_id', '=', 'annual_cycle.id')
|
|
854
|
+ ->where('program_id', $program_id)
|
|
855
|
+ ->where(function ($query) use (&$future_semesters, &$index) {
|
|
856
|
+ $query->where('semester_start', $future_semesters[$index])
|
|
857
|
+ ->orWhere('semester_end', $future_semesters[$index]);
|
|
858
|
+ })->first();
|
|
859
|
+ DB::table('annual_plan_transformative')
|
|
860
|
+ ->insert(array(
|
|
861
|
+ 'annual_plan_id' => $annual_plan->id,
|
|
862
|
+ 'trans_id' => $newTransId,
|
|
863
|
+ 'typ_semester_course_id' => $typ_future_course_id,
|
|
864
|
+ 'proposing_coordinator_id' => Auth::user()->id,
|
|
865
|
+ 'proposed_date' => date('Y-m-d H:i:s')
|
|
866
|
+ ));
|
|
867
|
+ }
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+ return TransformativeAction::getTypCoursesWithSemesters($newTransId);
|
829
|
871
|
}
|
830
|
872
|
}
|
831
|
873
|
|