浏览代码

Fix three year amen

父节点
当前提交
9758ce148b
共有 2 个文件被更改,包括 27 次插入35 次删除
  1. 11
    29
      app/controllers/ThreeYearPlanController.php
  2. 16
    6
      app/views/global/view-three-year-plan.blade.php

+ 11
- 29
app/controllers/ThreeYearPlanController.php 查看文件

@@ -11,6 +11,7 @@ class ThreeYearPlanController extends \BaseController
11 11
       DB::beginTransaction();
12 12
       $yearStart = Input::get('years') + 0;
13 13
       $yearEnd = $yearStart + 3;
14
+      $program_id = Input::get('program_id');
14 15
       DB::insert("insert into three_year_plan (`year_start`, `year_end`) values ({$yearStart}, {$yearEnd})");
15 16
 
16 17
       $typ = DB::table('three_year_plan')->where('year_start', '=', $yearStart)
@@ -30,13 +31,13 @@ class ThreeYearPlanController extends \BaseController
30 31
       DB::commit();
31 32
       Session::flash('status', 'success');
32 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 35
     } catch (Exception $e) {
35 36
       Session::flash('status', 'danger');
36 37
       Session::flash('message', "<p>Could not create cycle</p>");
37 38
       Log::info($e);
38 39
       DB::rollback();
39
-      return Redirect::to('three-years-plan');;
40
+      return Redirect::to("three-years-plan/{$program_id}");
40 41
     }
41 42
   }
42 43
   // load the Three year Plan page
@@ -105,11 +106,7 @@ class ThreeYearPlanController extends \BaseController
105 106
     $typ_id = Input::get('typ_id');
106 107
 
107 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 112
     $result = DB::table('typ_program')
@@ -242,14 +239,11 @@ class ThreeYearPlanController extends \BaseController
242 239
     $semester_id = Input::get('semester_id');
243 240
     $previous_objective_id = Input::get('previous_objective_id');
244 241
     $new_objective_id = Input::get('new_objective_id');
242
+    $program_id = Input::get('program_id');
245 243
 
246 244
     // get program_id
247 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 248
     // get typ_program_id
255 249
     $result = DB::table('typ_program')
@@ -303,11 +297,7 @@ class ThreeYearPlanController extends \BaseController
303 297
   {
304 298
     // get program_id
305 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 302
     // get typ_program_id
313 303
     $typ_id = Input::get('typ_id');
@@ -398,11 +388,7 @@ class ThreeYearPlanController extends \BaseController
398 388
   {
399 389
     // get program_id
400 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 393
     // get typ_program_id
408 394
     $typ_id = Input::get('typ_id');
@@ -506,12 +492,7 @@ class ThreeYearPlanController extends \BaseController
506 492
     $new_course_id = Input::get('new_course_id');
507 493
 
508 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 497
     // get typ_program_id
517 498
     $result = DB::table('typ_program')
@@ -568,7 +549,8 @@ class ThreeYearPlanController extends \BaseController
568 549
   }
569 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 554
     $count = 0;
573 555
     $yearStartPlusOne = $current_typ->year_start + 1;
574 556
     $yearStart = $current_typ->year_start;

+ 16
- 6
app/views/global/view-three-year-plan.blade.php 查看文件

@@ -80,7 +80,8 @@
80 80
           "{{ URL::action('ThreeYearPlanController@update_typ_outcomes_semesters') }}",
81 81
           {
82 82
             outcomeSemesterArray : JSON.stringify(outcomeSemesterArray),
83
-            typ_id: (id)
83
+            typ_id: (id),
84
+            program_id: {{$program_id}}
84 85
           },
85 86
           function(data)
86 87
           {
@@ -117,6 +118,7 @@
117 118
       <div class="modal-body">
118 119
         {{ Form::open(array('action' => 'ThreeYearPlanController@create' )) }}
119 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 122
         <select name = 'years' class="form-control selectpicker">
121 123
           
122 124
           
@@ -322,7 +324,9 @@ $(document).ready(function()
322 324
           previous_objective_id: (previous_objective_id),
323 325
           outcome_id: (outcome_id),
324 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 331
         function(data)
328 332
         {
@@ -358,7 +362,8 @@ $(document).ready(function()
358 362
           outcome_id: (outcome_id),
359 363
           semester_id: (semester_id),
360 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 368
         function(data)
364 369
         {
@@ -378,7 +383,10 @@ $(document).ready(function()
378 383
 
379 384
 $('.go-to-temp').on('click', function(){
380 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 390
     window.location.href = "{{URL::action('AnnualPlansController@showPlan',array($program_id))}}";
383 391
 
384 392
   });
@@ -551,7 +559,8 @@ $('.go-to-temp').on('click', function(){
551 559
     $.post(
552 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 565
         function(data)
557 566
         {
@@ -677,7 +686,8 @@ $('.go-to-temp').on('click', function(){
677 686
     $.post(
678 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 692
         function(data)
683 693
         {