Browse Source

Fix three year amen

parent
commit
9758ce148b

+ 11
- 29
app/controllers/ThreeYearPlanController.php View File

11
       DB::beginTransaction();
11
       DB::beginTransaction();
12
       $yearStart = Input::get('years') + 0;
12
       $yearStart = Input::get('years') + 0;
13
       $yearEnd = $yearStart + 3;
13
       $yearEnd = $yearStart + 3;
14
+      $program_id = Input::get('program_id');
14
       DB::insert("insert into three_year_plan (`year_start`, `year_end`) values ({$yearStart}, {$yearEnd})");
15
       DB::insert("insert into three_year_plan (`year_start`, `year_end`) values ({$yearStart}, {$yearEnd})");
15
 
16
 
16
       $typ = DB::table('three_year_plan')->where('year_start', '=', $yearStart)
17
       $typ = DB::table('three_year_plan')->where('year_start', '=', $yearStart)
30
       DB::commit();
31
       DB::commit();
31
       Session::flash('status', 'success');
32
       Session::flash('status', 'success');
32
       Session::flash('message', '<p> Cycle created.</p>');
33
       Session::flash('message', '<p> Cycle created.</p>');
33
-      return Redirect::to('three-years-plan');
34
+      return Redirect::to("three-years-plan/{$program_id}");
34
     } catch (Exception $e) {
35
     } catch (Exception $e) {
35
       Session::flash('status', 'danger');
36
       Session::flash('status', 'danger');
36
       Session::flash('message', "<p>Could not create cycle</p>");
37
       Session::flash('message', "<p>Could not create cycle</p>");
37
       Log::info($e);
38
       Log::info($e);
38
       DB::rollback();
39
       DB::rollback();
39
-      return Redirect::to('three-years-plan');;
40
+      return Redirect::to("three-years-plan/{$program_id}");
40
     }
41
     }
41
   }
42
   }
42
   // load the Three year Plan page
43
   // load the Three year Plan page
105
     $typ_id = Input::get('typ_id');
106
     $typ_id = Input::get('typ_id');
106
 
107
 
107
     $user_id = auth::user()->id;
108
     $user_id = auth::user()->id;
108
-    $program_id = DB::table('program_user')
109
-      ->where('user_id', $user_id)
110
-      ->select('program_id')
111
-      ->get();
112
-    $program_id = $program_id[0]->program_id;
109
+    $program_id = Input::get('program_id');
113
 
110
 
114
 
111
 
115
     $result = DB::table('typ_program')
112
     $result = DB::table('typ_program')
242
     $semester_id = Input::get('semester_id');
239
     $semester_id = Input::get('semester_id');
243
     $previous_objective_id = Input::get('previous_objective_id');
240
     $previous_objective_id = Input::get('previous_objective_id');
244
     $new_objective_id = Input::get('new_objective_id');
241
     $new_objective_id = Input::get('new_objective_id');
242
+    $program_id = Input::get('program_id');
245
 
243
 
246
     // get program_id
244
     // get program_id
247
     $user_id = auth::user()->id;
245
     $user_id = auth::user()->id;
248
-    $program_id = DB::table('program_user')
249
-      ->where('user_id', $user_id)
250
-      ->select('program_id')
251
-      ->get();
252
-    $program_id = $program_id[0]->program_id;
246
+
253
 
247
 
254
     // get typ_program_id
248
     // get typ_program_id
255
     $result = DB::table('typ_program')
249
     $result = DB::table('typ_program')
303
   {
297
   {
304
     // get program_id
298
     // get program_id
305
     $user_id = auth::user()->id;
299
     $user_id = auth::user()->id;
306
-    $program_id = DB::table('program_user')
307
-      ->where('user_id', $user_id)
308
-      ->select('program_id')
309
-      ->get();
310
-    $program_id = $program_id[0]->program_id;
300
+    $program_id = Input::get('program_id');
311
 
301
 
312
     // get typ_program_id
302
     // get typ_program_id
313
     $typ_id = Input::get('typ_id');
303
     $typ_id = Input::get('typ_id');
398
   {
388
   {
399
     // get program_id
389
     // get program_id
400
     $user_id = auth::user()->id;
390
     $user_id = auth::user()->id;
401
-    $program_id = DB::table('program_user')
402
-      ->where('user_id', $user_id)
403
-      ->select('program_id')
404
-      ->get();
405
-    $program_id = $program_id[0]->program_id;
391
+    $program_id = Input::get('program_id');
406
 
392
 
407
     // get typ_program_id
393
     // get typ_program_id
408
     $typ_id = Input::get('typ_id');
394
     $typ_id = Input::get('typ_id');
506
     $new_course_id = Input::get('new_course_id');
492
     $new_course_id = Input::get('new_course_id');
507
 
493
 
508
     // get program_id
494
     // get program_id
509
-    $user_id = auth::user()->id;
510
-    $program_id = DB::table('program_user')
511
-      ->where('user_id', $user_id)
512
-      ->select('program_id')
513
-      ->get();
514
-    $program_id = $program_id[0]->program_id;
495
+    $program_id = Input::get('program_id');
515
 
496
 
516
     // get typ_program_id
497
     // get typ_program_id
517
     $result = DB::table('typ_program')
498
     $result = DB::table('typ_program')
568
   }
549
   }
569
   public function createAnnualPlan($program_id)
550
   public function createAnnualPlan($program_id)
570
   {
551
   {
571
-    $current_typ = DB::select("select * from three_year_plan where year_start <=" . date('Y') . " and year_end >=" . date('Y'))[0];
552
+    $input_id =  Input::get('typ_id');
553
+    $current_typ = DB::select("select * from three_year_plan where id  = {$input_id}")[0];
572
     $count = 0;
554
     $count = 0;
573
     $yearStartPlusOne = $current_typ->year_start + 1;
555
     $yearStartPlusOne = $current_typ->year_start + 1;
574
     $yearStart = $current_typ->year_start;
556
     $yearStart = $current_typ->year_start;

+ 16
- 6
app/views/global/view-three-year-plan.blade.php View File

80
           "{{ URL::action('ThreeYearPlanController@update_typ_outcomes_semesters') }}",
80
           "{{ URL::action('ThreeYearPlanController@update_typ_outcomes_semesters') }}",
81
           {
81
           {
82
             outcomeSemesterArray : JSON.stringify(outcomeSemesterArray),
82
             outcomeSemesterArray : JSON.stringify(outcomeSemesterArray),
83
-            typ_id: (id)
83
+            typ_id: (id),
84
+            program_id: {{$program_id}}
84
           },
85
           },
85
           function(data)
86
           function(data)
86
           {
87
           {
117
       <div class="modal-body">
118
       <div class="modal-body">
118
         {{ Form::open(array('action' => 'ThreeYearPlanController@create' )) }}
119
         {{ Form::open(array('action' => 'ThreeYearPlanController@create' )) }}
119
         <p>Select a new cycle. You cannot choose a cycle that has been created before</p>
120
         <p>Select a new cycle. You cannot choose a cycle that has been created before</p>
121
+        <input type ='hidden' name = 'program_id' value = '{{$program_id}}'>
120
         <select name = 'years' class="form-control selectpicker">
122
         <select name = 'years' class="form-control selectpicker">
121
           
123
           
122
           
124
           
322
           previous_objective_id: (previous_objective_id),
324
           previous_objective_id: (previous_objective_id),
323
           outcome_id: (outcome_id),
325
           outcome_id: (outcome_id),
324
           semester_id: (semester_id),
326
           semester_id: (semester_id),
325
-          new_objective_id: (new_objective_id)
327
+          new_objective_id: (new_objective_id),
328
+          program_id: {{$program_id}}
329
+
326
         },
330
         },
327
         function(data)
331
         function(data)
328
         {
332
         {
358
           outcome_id: (outcome_id),
362
           outcome_id: (outcome_id),
359
           semester_id: (semester_id),
363
           semester_id: (semester_id),
360
           objective_id: (objective_id),
364
           objective_id: (objective_id),
361
-          new_course_id: (new_course_id)
365
+          new_course_id: (new_course_id),
366
+          program_id: {{$program_id}}
362
         },
367
         },
363
         function(data)
368
         function(data)
364
         {
369
         {
378
 
383
 
379
 $('.go-to-temp').on('click', function(){
384
 $('.go-to-temp').on('click', function(){
380
   $.post(
385
   $.post(
381
-    "{{ URL::action('ThreeYearPlanController@createAnnualPlan', array($program_id))}}");
386
+    "{{ URL::action('ThreeYearPlanController@createAnnualPlan', array($program_id))}}",
387
+    {
388
+      typ_id: $('#table-cycles').data('typ-id')
389
+    });
382
     window.location.href = "{{URL::action('AnnualPlansController@showPlan',array($program_id))}}";
390
     window.location.href = "{{URL::action('AnnualPlansController@showPlan',array($program_id))}}";
383
 
391
 
384
   });
392
   });
551
     $.post(
559
     $.post(
552
         "{{ URL::action('ThreeYearPlanController@section2_arrive') }}",
560
         "{{ URL::action('ThreeYearPlanController@section2_arrive') }}",
553
         {
561
         {
554
-          typ_id: (typ_id)
562
+          typ_id: (typ_id),
563
+          program_id: {{$program_id}}
555
         },
564
         },
556
         function(data)
565
         function(data)
557
         {
566
         {
677
     $.post(
686
     $.post(
678
         "{{ URL::action('ThreeYearPlanController@section3_arrive') }}",
687
         "{{ URL::action('ThreeYearPlanController@section3_arrive') }}",
679
         {
688
         {
680
-          typ_id: (typ_id)
689
+          typ_id: (typ_id),
690
+          program_id : {{$program_id}}
681
         },
691
         },
682
         function(data)
692
         function(data)
683
         {
693
         {