Procházet zdrojové kódy

Merge branch 'oniel-progreso' into Merge_gabriel_mayo

Gabriel Santiago Plaza před 3 roky
rodič
revize
f406955d48
23 změnil soubory, kde provedl 3930 přidání a 159 odebrání
  1. 2
    0
      .gitignore
  2. 2
    2
      app/config/app.php
  3. 11
    0
      app/controllers/CriteriaController.php
  4. 224
    155
      app/controllers/OutcomesController.php
  5. 555
    0
      app/controllers/ThreeYearPlanController.php
  6. 928
    0
      app/controllers/TransformativeActionsController.php
  7. 33
    0
      app/database/migrations/2021_01_31_165057_fix_objectives_table_2.php
  8. 31
    0
      app/database/migrations/2021_01_31_171210_fix_criterion_scale.php
  9. 39
    0
      app/database/migrations/2021_02_17_205601_create_cycles_table.php
  10. 50
    0
      app/database/migrations/2021_02_17_205659_create_cycles_semesters_table.php
  11. 50
    0
      app/database/migrations/2021_02_17_205734_create_three_year_plans_table.php
  12. 48
    0
      app/database/migrations/2021_02_17_205809_create_typ_parts_table.php
  13. 63
    0
      app/database/migrations/2021_02_17_205850_create_typ_part_outcomes_table.php
  14. 50
    0
      app/database/migrations/2021_02_25_181424_typ_semesters.php
  15. 1
    0
      app/database/migrations/2021_03_29_151147_create_Transformative_Actions.php
  16. 51
    0
      app/database/migrations/2021_03_29_151542_create_annual_report_transformative.php
  17. 44
    0
      app/database/migrations/2021_04_25_194120_create_ta_course_table.php
  18. 49
    2
      app/routes.php
  19. 803
    0
      app/views/global/view-three-year-plan.blade.php
  20. 2
    0
      app/views/local/managers/admins/_navigation.blade.php
  21. 891
    0
      app/views/local/managers/admins/transformativeAction.blade.php
  22. 2
    0
      app/views/local/managers/pCoords/_navigation.blade.php
  23. 1
    0
      app/views/local/professors/_navigation.blade.php

+ 2
- 0
.gitignore Zobrazit soubor

@@ -8,3 +8,5 @@ composer.lock
8 8
 Thumbs.db
9 9
 app/database/csv/*
10 10
 app/config/local/*
11
+app/config/app.php
12
+app/config/database.php

+ 2
- 2
app/config/app.php Zobrazit soubor

@@ -27,7 +27,7 @@ return array(
27 27
 	|
28 28
 	*/ //$_ENV['APP_URL'] ?:
29 29
 
30
-	'url' =>  'https://localhost',
30
+	'url' =>  'http://localhost',
31 31
 
32 32
 	/*
33 33
 	|--------------------------------------------------------------------------
@@ -125,7 +125,7 @@ return array(
125 125
 		'Illuminate\Workbench\WorkbenchServiceProvider',
126 126
 		'Way\Generators\GeneratorsServiceProvider',
127 127
 		'Barryvdh\DomPDF\ServiceProvider',
128
-		//'Cornford\Backup\Providers\BackupServiceProvider',
128
+		// 'Cornford\Backup\Providers\BackupServiceProvider',
129 129
 		'Zizaco\Entrust\EntrustServiceProvider'
130 130
 
131 131
 	),

+ 11
- 0
app/controllers/CriteriaController.php Zobrazit soubor

@@ -572,13 +572,24 @@ class CriteriaController extends \BaseController
572 572
 
573 573
         $title = "Learning Outcomes and Criteria";
574 574
         $outcomes = Outcome::orderBy('name', 'ASC')->get();
575
+        // $outcomes = DB::table('outcomes')
576
+        //     ->orderBy('name', 'asc')
577
+        //     ->get();
575 578
         $schools = School::orderBy('name', 'ASC')->get();
579
+        // $schools = DB::table('schools')
580
+        //     ->orderBy('name', 'asc')
581
+        //     ->get();
576 582
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
583
+        // $criteria = DB::table('criteria')
584
+        //     ->orderBy('name', 'asc')
585
+        //     ->get();
577 586
 
578 587
         // se annadio la nueva variable
579 588
         return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'criteria', 'semesters'));
589
+
580 590
     }
581 591
 
592
+
582 593
     // copie index() y lo edite
583 594
     public function objectivesIndex()
584 595
     {

+ 224
- 155
app/controllers/OutcomesController.php Zobrazit soubor

@@ -43,164 +43,169 @@ class OutcomesController extends \BaseController
43 43
         $undergradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
44 44
         $gradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
45 45
         foreach ($programs as $program_id) {
46
-            //        	var_dump($program_id);
47
-            //         	exit();
48
-            $program = Program::where('id', '=', $program_id->id)->first();
49
-            $school = School::where('id', '=', $program->school_id)->first();
50
-            if ($program->is_graduate) {
51
-                $gradResults['names'][] = $program->name;
52
-                $gradResults['schools'][] = $school->name;
53
-                $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
54
-                $gradResults['attempted'][] = $attempted;
55
-                $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
56
-                $gradResults['achieved'][] = $achieved;
57
-                $gradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
58
-            } else {
59
-                $undergradResults['names'][] = $program->name;
60
-                $undergradResults['schools'][] = $school->name;
61
-                $attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
62
-                $undergradResults['attempted'][] = $attempted;
63
-                $achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
64
-                $undergradResults['achieved'][] = $achieved;
65
-                $undergradResults['successRate'][] = sprintf("%.2f", 100 * $achieved / $attempted);
66
-            }
46
+ //        	var_dump($program_id);
47
+//         	exit();
48
+        	$program = Program::where('id', '=', $program_id->id)->first();
49
+        	$school = School::where('id', '=', $program->school_id)->first();
50
+        	if($program->is_graduate)
51
+        	{
52
+        		$gradResults['names'][] = $program->name;
53
+        		$gradResults['schools'][] = $school->name;
54
+        		$attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
55
+        		$gradResults['attempted'][] = $attempted;
56
+        		$achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
57
+        		$gradResults['achieved'][] = $achieved;
58
+        		$gradResults['successRate'][] = sprintf("%.2f",100*$achieved/$attempted);
59
+
60
+        	}
61
+        	else
62
+        	{
63
+        		$undergradResults['names'][] = $program->name;
64
+        		$undergradResults['schools'][] = $school->name;
65
+        		$attempted = $program->attempted_criteria_by_outcome($id,$selected_semesters);
66
+        		$undergradResults['attempted'][] = $attempted;
67
+        		$achieved = $program->achieved_criteria_by_outcome($id,$selected_semesters);
68
+        		$undergradResults['achieved'][] = $achieved;
69
+        		$undergradResults['successRate'][] = sprintf("%.2f",100*$achieved/$attempted);
70
+        	}
71
+
67 72
         }
68 73
 
69
-        $title = "Outcome Results: " . $outcome->name;
74
+	   	$title = "Outcome Results: ".$outcome->name;
70 75
 
71 76
 
72
-        //  		$undergradResults["successRate"]
77
+//  		$undergradResults["successRate"]
73 78
 
74 79
         return View::make('local.managers.admins.learning-outcome_new', compact('title', 'outcome', 'undergradResults', 'gradResults'));
75 80
     }
76 81
 
77
-    //     public function show($id)
78
-    //     {
79
-    //         DB::disableQueryLog();
80
-    //         $outcome = Outcome::find($id);
81
-    // 
82
-    //         $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
83
-    //         $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
84
-    // 
85
-    //         //Calculate performance for this outcome for each undergrad program
86
-    //         $undergradPrograms = Program::where('is_graduate','=', 0)
87
-    //             ->where(function($query)
88
-    //             {
89
-    //                 if(Auth::user()->school_id)
90
-    //                 {
91
-    //                     $query->where('school_id', Auth::user()->school_id);
92
-    //                 }
93
-    //             })
94
-    //             ->with('courses')
95
-    //             ->orderBy('name', 'asc')->get();
96
-    // 
97
-    //         foreach($undergradPrograms as $program)
98
-    //         {
99
-    //             $undergradResults["names"][$program->id]=$program->name;
100
-    //             $undergradResults["schools"][$program->id]=$program->school->name;
101
-    //             $programAssessed=false;
102
-    // 
103
-    //             $undergradResults["attempted"][$program->id]=0;
104
-    //             $undergradResults["achieved"][$program->id]=0;
105
-    // 
106
-    //             foreach($program->courses as $course)
107
-    //             {
108
-    //                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
109
-    //                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
110
-    // 
111
-    //                 $attemptedCriteriaCount=0;
112
-    //                 $achievedCriteriaCount=0;
113
-    // 
114
-    //                 // If this outcome was evaluated
115
-    //                 if(
116
-    //                     $course_outcomes_attempted
117
-    //                     && array_key_exists($outcome->id, $course_outcomes_attempted)
118
-    //                     && $course_outcomes_attempted[$outcome->id]!=0)
119
-    //                 {
120
-    //                     // Count +1 for attempted and achieved in the program
121
-    //                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
122
-    //                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
123
-    //                     $programAssessed=true;
124
-    // 
125
-    //                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
126
-    //                     {
127
-    //                         $undergradResults["achieved"][$program->id]+=1;
128
-    //                     }
129
-    //                     $undergradResults["attempted"][$program->id]+=1;
130
-    //                 }
131
-    //             }
132
-    // 
133
-    //             // Calculate success rate for this program
134
-    //             if($programAssessed && $undergradResults["attempted"][$program->id]>0)
135
-    //                 $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
136
-    //             else
137
-    //                 $undergradResults["successRate"][$program->id]= 'N/M';
138
-    //         }
139
-    // 
140
-    // 
141
-    //         //Calculate performance for this outcome for each grad program
142
-    //         $gradPrograms = Program::where('is_graduate','=', 1)
143
-    //             ->where(function($query)
144
-    //             {
145
-    //                 if(Auth::user()->school_id)
146
-    //                 {
147
-    //                     $query->where('school_id', Auth::user()->school_id);
148
-    //                 }
149
-    //             })
150
-    //             ->with(array('courses'=>function($query)
151
-    //             {
152
-    //                 $query->whereNotNull('outcomes_attempted');
153
-    //             }))
154
-    //             ->orderBy('name', 'asc')->get();
155
-    // 
156
-    //         foreach($gradPrograms as $program)
157
-    //         {
158
-    //             $gradResults["names"][$program->id]=$program->name;
159
-    //             $gradResults["schools"][$program->id]=$program->school->name;
160
-    // 
161
-    //             $programAssessed=false;
162
-    // 
163
-    //             $gradResults["attempted"][$program->id]=0;
164
-    //             $gradResults["achieved"][$program->id]=0;
165
-    // 
166
-    //             foreach($program->courses as $course)
167
-    //             {
168
-    //                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
169
-    //                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
170
-    // 
171
-    //                 $attemptedCriteriaCount=0;
172
-    //                 $achievedCriteriaCount=0;
173
-    // 
174
-    //                 // If this outcome was evaluated
175
-    //                 if(
176
-    //                     $course_outcomes_attempted
177
-    //                     && array_key_exists($outcome->id, $course_outcomes_attempted)
178
-    //                     && $course_outcomes_attempted[$outcome->id]!=0)
179
-    //                 {
180
-    //                     // Count +1 for attempted and achieved in the program
181
-    //                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
182
-    //                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
183
-    //                     $programAssessed=true;
184
-    // 
185
-    //                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
186
-    //                     {
187
-    //                         $gradResults["achieved"][$program->id]+=1;
188
-    //                     }
189
-    //                     $gradResults["attempted"][$program->id]+=1;
190
-    //                 }
191
-    //             }
192
-    // 
193
-    //             // Calculate success rate for this program
194
-    //             if($programAssessed && $gradResults["attempted"][$program->id]>0)
195
-    //                 $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
196
-    //             else
197
-    //                 $gradResults["successRate"][$program->id]= 'N/M';
198
-    //         }
199
-    // 
200
-    //         $title = "Outcome Results: ".$outcome->name;
201
-    // 
202
-    //         return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
203
-    //     }
82
+//     public function show($id)
83
+//     {
84
+//         DB::disableQueryLog();
85
+//         $outcome = Outcome::find($id);
86
+//
87
+//         $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
88
+//         $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
89
+//
90
+//         //Calculate performance for this outcome for each undergrad program
91
+//         $undergradPrograms = Program::where('is_graduate','=', 0)
92
+//             ->where(function($query)
93
+//             {
94
+//                 if(Auth::user()->school_id)
95
+//                 {
96
+//                     $query->where('school_id', Auth::user()->school_id);
97
+//                 }
98
+//             })
99
+//             ->with('courses')
100
+//             ->orderBy('name', 'asc')->get();
101
+//
102
+//         foreach($undergradPrograms as $program)
103
+//         {
104
+//             $undergradResults["names"][$program->id]=$program->name;
105
+//             $undergradResults["schools"][$program->id]=$program->school->name;
106
+//             $programAssessed=false;
107
+//
108
+//             $undergradResults["attempted"][$program->id]=0;
109
+//             $undergradResults["achieved"][$program->id]=0;
110
+//
111
+//             foreach($program->courses as $course)
112
+//             {
113
+//                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
114
+//                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
115
+//
116
+//                 $attemptedCriteriaCount=0;
117
+//                 $achievedCriteriaCount=0;
118
+//
119
+//                 // If this outcome was evaluated
120
+//                 if(
121
+//                     $course_outcomes_attempted
122
+//                     && array_key_exists($outcome->id, $course_outcomes_attempted)
123
+//                     && $course_outcomes_attempted[$outcome->id]!=0)
124
+//                 {
125
+//                     // Count +1 for attempted and achieved in the program
126
+//                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
127
+//                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
128
+//                     $programAssessed=true;
129
+//
130
+//                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
131
+//                     {
132
+//                         $undergradResults["achieved"][$program->id]+=1;
133
+//                     }
134
+//                     $undergradResults["attempted"][$program->id]+=1;
135
+//                 }
136
+//             }
137
+//
138
+//             // Calculate success rate for this program
139
+//             if($programAssessed && $undergradResults["attempted"][$program->id]>0)
140
+//                 $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
141
+//             else
142
+//                 $undergradResults["successRate"][$program->id]= 'N/M';
143
+//         }
144
+//
145
+//
146
+//         //Calculate performance for this outcome for each grad program
147
+//         $gradPrograms = Program::where('is_graduate','=', 1)
148
+//             ->where(function($query)
149
+//             {
150
+//                 if(Auth::user()->school_id)
151
+//                 {
152
+//                     $query->where('school_id', Auth::user()->school_id);
153
+//                 }
154
+//             })
155
+//             ->with(array('courses'=>function($query)
156
+//             {
157
+//                 $query->whereNotNull('outcomes_attempted');
158
+//             }))
159
+//             ->orderBy('name', 'asc')->get();
160
+//
161
+//         foreach($gradPrograms as $program)
162
+//         {
163
+//             $gradResults["names"][$program->id]=$program->name;
164
+//             $gradResults["schools"][$program->id]=$program->school->name;
165
+//
166
+//             $programAssessed=false;
167
+//
168
+//             $gradResults["attempted"][$program->id]=0;
169
+//             $gradResults["achieved"][$program->id]=0;
170
+//
171
+//             foreach($program->courses as $course)
172
+//             {
173
+//                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
174
+//                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
175
+//
176
+//                 $attemptedCriteriaCount=0;
177
+//                 $achievedCriteriaCount=0;
178
+//
179
+//                 // If this outcome was evaluated
180
+//                 if(
181
+//                     $course_outcomes_attempted
182
+//                     && array_key_exists($outcome->id, $course_outcomes_attempted)
183
+//                     && $course_outcomes_attempted[$outcome->id]!=0)
184
+//                 {
185
+//                     // Count +1 for attempted and achieved in the program
186
+//                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
187
+//                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
188
+//                     $programAssessed=true;
189
+//
190
+//                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
191
+//                     {
192
+//                         $gradResults["achieved"][$program->id]+=1;
193
+//                     }
194
+//                     $gradResults["attempted"][$program->id]+=1;
195
+//                 }
196
+//             }
197
+//
198
+//             // Calculate success rate for this program
199
+//             if($programAssessed && $gradResults["attempted"][$program->id]>0)
200
+//                 $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
201
+//             else
202
+//                 $gradResults["successRate"][$program->id]= 'N/M';
203
+//         }
204
+//
205
+//         $title = "Outcome Results: ".$outcome->name;
206
+//
207
+//         return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
208
+//     }
204 209
 
205 210
     // TODO: Clean up and verify relationships are correct
206 211
     public function newShow($id)
@@ -513,14 +518,78 @@ class OutcomesController extends \BaseController
513 518
 
514 519
     public function fetchOutcome()
515 520
     {
516
-        $id = Input::get('id');
521
+        // original code using models
522
+        // TODO: models have to be updated because of the database update
517 523
 
518
-        $outcome = Outcome::find($id);
524
+        $id = Input::get('id');
519 525
 
520
-        $outcome->criteria;
526
+        $outcome_info = DB::table('outcomes')
527
+            ->where('outcomes.id', $id)
528
+            ->get();
529
+        $outcome = $outcome_info[0];
530
+
531
+        $diferent_levels = DB::table('criterion_objective_outcome')
532
+            ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
533
+            ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
534
+            ->where('criterion_objective_outcome.outcome_id', $id)
535
+            ->distinct('new_criteria.number_of_scales')
536
+            ->select('new_criteria.number_of_scales as levels')
537
+            ->orderBy('new_criteria.number_of_scales', 'asc')
538
+            ->get();
521 539
 
522
-        return array(
523
-            'outcome' => $outcome
540
+        $criteria_array = array();
541
+
542
+        $outcome->criteria = array();
543
+        foreach ($diferent_levels as $level) {
544
+          $level = $level->levels;
545
+
546
+          // buscar todos los criterios con el level y ponerlos en un array
547
+          $outcome_criterias = DB::table('criterion_objective_outcome')
548
+              ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
549
+              ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
550
+              ->where('criterion_objective_outcome.outcome_id', $id)
551
+              ->where('new_criteria.number_of_scales', $level)
552
+              ->whereNull('new_criteria.deleted_at')
553
+              ->select('new_criteria.id','new_criteria.name')
554
+              ->orderBy('new_criteria.name', 'asc')
555
+              ->get();
556
+          $outcome_criterias = $outcome_criterias;
557
+
558
+          foreach ($outcome_criterias as $criteria_id) {
559
+
560
+            $scales =
561
+              DB::select(
562
+                  DB::raw("
563
+                  SELECT *
564
+                  FROM (
565
+                    SELECT new_criteria.id as criterion_id,
566
+                      ROW_NUMBER() OVER(PARTITION BY scales.id) rn,
567
+                      scales.position,
568
+                      scales.title, scales.description,
569
+                      criterion_objective_outcome.outcome_id,criterion_objective_outcome.objective_id,
570
+                      criterion_scale.scale_id
571
+                    FROM new_criteria,criterion_scale,scales, criterion_objective_outcome, objectives
572
+                    where new_criteria.id=criterion_scale.criterion_id
573
+                      and scales.id = criterion_scale.scale_id
574
+                      and new_criteria.id = criterion_objective_outcome.criterion_id
575
+                      and objectives.id = criterion_objective_outcome.objective_id
576
+                      and criterion_objective_outcome.outcome_id = $id
577
+                      and new_criteria.id = $criteria_id->id
578
+                    ORDER BY new_criteria.name ASC) a
579
+                  WHERE rn = 1
580
+                  ORDER BY `a`.`position` ASC
581
+                      ")
582
+              );
583
+              // insertar la informacion de los criterios con N niveles en el arreglo de arreglos
584
+              $criteria_id->scales = $scales;
585
+              // $i++;
586
+            }//ends foreach criteria_id
587
+            array_push($outcome->criteria, array($outcome_criterias,'amount_of_levels'=>$level));
588
+        }//ends foreach level
589
+
590
+        return array
591
+        (
592
+            'outcome' => $outcome,
524 593
         );
525 594
     }
526 595
 

+ 555
- 0
app/controllers/ThreeYearPlanController.php Zobrazit soubor

@@ -0,0 +1,555 @@
1
+<?php
2
+
3
+use Illuminate\Database\Eloquent\Collection;
4
+
5
+class ThreeYearPlanController extends \BaseController
6
+{
7
+
8
+  public function threeYearsReport()
9
+  {
10
+      $user_id = auth::user()->id;
11
+
12
+      // el ID de los semestres que el usuario tiene seleccionado.
13
+      $semesters_ids = Session::get('semesters_ids');
14
+      // buscar informacion de los semestres seleccionados
15
+      $semesters = Semester::whereIn('id',$semesters_ids)->get();
16
+
17
+      $title = "Three Year Plans Planning";
18
+      $outcomes = Outcome::orderBy('name', 'ASC')
19
+          ->where('deactivation_date','=','0000-00-00')
20
+          ->orWhereNull('deactivation_date')
21
+          ->get();
22
+      // $outcomes = DB::table('outcomes')
23
+      //     ->orderBy('name', 'asc')
24
+      //     ->get();
25
+      $typs = DB::table('three_year_plan')
26
+          ->orderBy('year_start', 'asc')
27
+          ->get();
28
+      $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
29
+      // $criteria = DB::table('criteria')
30
+      //     ->orderBy('name', 'asc')
31
+      //     ->get();
32
+      $program_id = DB::table('program_user')
33
+      ->where('user_id',$user_id)
34
+      // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
35
+      ->select('program_id')
36
+      ->get();
37
+      $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
38
+
39
+      // se annadio la nueva variable
40
+      return View::make('global.view-three-year-plan', compact('title', 'outcomes', 'typs', 'criteria', 'semesters', 'program_id'));
41
+
42
+  }
43
+
44
+
45
+  public function fetchThreeYears()
46
+  {
47
+      $id = Input::get('id');
48
+
49
+      $semesters = DB::table('typ_semesters')
50
+          ->join('semesters','semesters.id','=','typ_semesters.semester_id')
51
+          ->where('typ_semesters.typ_id',$id)
52
+          // ->select('semesters.*')
53
+          ->orderBy('typ_semesters.semester_id', 'asc')
54
+          ->get();
55
+      $typs = DB::table('three_year_plan')
56
+          ->where('id',$id)
57
+          ->orderBy('year_start', 'asc')
58
+          ->get();
59
+
60
+      $typs  = $typs[0];
61
+      $typs->semesters = $semesters;
62
+
63
+      return array
64
+      (
65
+          'typ' => $typs,
66
+      );
67
+  }
68
+
69
+  public function update_typ_outcomes_semesters()
70
+  {
71
+    $outcomeSemesterArray = json_decode(Input::get('outcomeSemesterArray'), true);
72
+    $typ_id = Input::get('typ_id');
73
+
74
+    $user_id = auth::user()->id; //ya, tester es 60
75
+    $program_id = DB::table('program_user')
76
+    ->where('user_id',$user_id)
77
+    // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
78
+    ->select('program_id')
79
+    ->get();
80
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
81
+
82
+
83
+    $result = DB::table('typ_program')
84
+        ->where('three_year_plan_id',$typ_id)
85
+        ->where('program_id',$program_id)
86
+        ->get();
87
+
88
+    // create the relation if it doesnt exist
89
+    if(count($result) == 0){
90
+      $typ_program_id = DB::table('typ_program')->insertGetId(
91
+          array('three_year_plan_id' => $typ_id,
92
+                'program_id' => $program_id)
93
+      );
94
+    } else {
95
+      $typ_program_id = $result[0]->id;
96
+    }
97
+
98
+
99
+
100
+    //go through array
101
+    foreach ($outcomeSemesterArray as $outcome_semester) {
102
+
103
+      // foreach of the 6 semesters
104
+      foreach ($outcome_semester["semesters"] as $semester) {
105
+        $insert = $semester[1];
106
+
107
+        $outcome_id = explode("-sem",$semester[0])[0];
108
+
109
+        $semester_code = explode("-sem",$semester[0])[1];
110
+        $result = DB::table('semesters')
111
+            ->where('code',$semester_code)
112
+            ->select('id')
113
+            ->get();
114
+        if(count($result) == 0){
115
+          continue;
116
+        }
117
+        $semester_id = $result[0]->id;
118
+
119
+        // verify if it exists
120
+        $result = DB::table('typ_semester_outcome')
121
+            ->where('typ_program_id',$typ_program_id)
122
+            ->where('semester_id',$semester_id)
123
+            ->where('outcome_id',$outcome_id)
124
+            ->get();
125
+
126
+        // if true, it should get inserted
127
+        if ($insert == true) {
128
+          // if == 0, then insert
129
+          if(count($result) == 0){
130
+            $_ = DB::table('typ_semester_outcome')->insertGetId(
131
+                array('typ_program_id' => $typ_program_id,
132
+                      'semester_id' => $semester_id,
133
+                      'outcome_id' => $outcome_id)
134
+            );
135
+
136
+          }
137
+          //if exists, then do nothing
138
+
139
+        }
140
+        // if false, it should get deleted
141
+        else { //value == false
142
+
143
+          // if == 0, it doesnt exist. we do nothing
144
+          if(count($result) == 0){
145
+            //pass
146
+          }
147
+          //if exists, then do nothing
148
+          else {
149
+            DB::table('typ_semester_outcome')
150
+                ->where('typ_program_id', $typ_program_id)
151
+                ->where('semester_id', $semester_id)
152
+                ->where('outcome_id', $outcome_id)
153
+                ->delete();
154
+          }
155
+        }
156
+      }
157
+    }
158
+    return;
159
+  }
160
+
161
+  public function lookup_typ_semester_outcome()
162
+  {
163
+    $box_value = array();
164
+
165
+    $info = Input::get('info');
166
+
167
+    foreach ($info as $values) {
168
+      $outcome_id = $values[0];
169
+      $semester_code = $values[1];
170
+      $program_id = $values[2];
171
+      $box_id = $values[3];
172
+      $typ_id = $values[4];
173
+
174
+      //buscar id del typ
175
+      $result = DB::table('typ_program')
176
+          ->where('three_year_plan_id',$typ_id)
177
+          ->where('program_id',$program_id)
178
+          ->get();
179
+      $typ_program_id = $result[0]->id;
180
+
181
+      // buscar si existe el outcome_semester
182
+      $result = DB::table('typ_semester_outcome')
183
+          ->join('semesters','semesters.id','=','typ_semester_outcome.semester_id')
184
+          ->where('typ_program_id',$typ_program_id)
185
+          ->where('semesters.code',$semester_code)
186
+          ->where('outcome_id',$outcome_id)
187
+          ->get();
188
+
189
+      // if it doesnt exist
190
+      if (count($result)==0){
191
+        array_push($box_value,array($box_id,0));
192
+      } else {
193
+        array_push($box_value,array($box_id,1));
194
+      }
195
+
196
+    }
197
+    return array
198
+    (
199
+      'box_value' => ($box_value)
200
+    );
201
+  }
202
+
203
+  public function section2_on_change()
204
+  {
205
+    $typ_id = Input::get('typ_id');
206
+    // typ_id: (typ_id),
207
+    $outcome_id = Input::get('outcome_id');
208
+    // outcome_id: (outcome_id),
209
+    $semester_id = Input::get('semester_id');
210
+    // semester_id: (semester_id),
211
+    $previous_objective_id = Input::get('previous_objective_id');
212
+    // previous_objective_id: (previous_objective_id),
213
+    $new_objective_id = Input::get('new_objective_id');
214
+    // new_objective_id: (new_objective_id)
215
+
216
+    // get program_id
217
+    $user_id = auth::user()->id; //ya, tester es 60
218
+    $program_id = DB::table('program_user')
219
+        ->where('user_id',$user_id)
220
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
221
+        ->select('program_id')
222
+        ->get();
223
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
224
+
225
+    // get typ_program_id
226
+    $result = DB::table('typ_program')
227
+        ->where('three_year_plan_id',$typ_id)
228
+        ->where('program_id',$program_id)
229
+        ->get();
230
+    $typ_program_id = $result[0]->id;
231
+
232
+    // get typ_semester_outcome_id
233
+    $result = DB::table('typ_semester_outcome')
234
+        ->where('typ_program_id',$typ_program_id)
235
+        ->where('semester_id',$semester_id)
236
+        ->where('outcome_id',$outcome_id)
237
+        ->get();
238
+    $typ_semester_outcome_id = $result[0]->id;
239
+
240
+    //delete old objective relation if it exists
241
+    if ($previous_objective_id != 'nothing_selected') {
242
+      $result = DB::table('typ_semester_objectives')
243
+          ->where('typ_semester_outcome_id',$typ_semester_outcome_id)
244
+          ->where('objective_id',$previous_objective_id)
245
+          ->get();
246
+      if (count($result) != 0) {
247
+        DB::table('typ_semester_objectives')
248
+            ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
249
+            ->where('objective_id', $previous_objective_id)
250
+            ->delete();
251
+      }
252
+    }
253
+
254
+    //create new objective relation
255
+    if ($new_objective_id != 'nothing_selected') {
256
+      $result = DB::table('typ_semester_objectives')
257
+          ->where('typ_semester_outcome_id',$typ_semester_outcome_id)
258
+          ->where('objective_id',$new_objective_id)
259
+          ->get();
260
+      if (count($result) == 0) {
261
+        $_ = DB::table('typ_semester_objectives')->insertGetId(
262
+            array(
263
+              'typ_semester_outcome_id' => $typ_semester_outcome_id,
264
+              'objective_id' => $new_objective_id)
265
+        );
266
+      }
267
+    }
268
+    return 'update was succes';
269
+  }
270
+
271
+  public function section2_arrive()
272
+  {
273
+    // get program_id
274
+    $user_id = auth::user()->id; //ya, tester es 60
275
+    $program_id = DB::table('program_user')
276
+        ->where('user_id',$user_id)
277
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
278
+        ->select('program_id')
279
+        ->get();
280
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
281
+
282
+    // get typ_program_id
283
+    $typ_id = Input::get('typ_id');
284
+    $result = DB::table('typ_program')
285
+        ->where('three_year_plan_id',$typ_id)
286
+        ->where('program_id',$program_id)
287
+        ->get();
288
+    $typ_program_id = $result[0]->id;
289
+
290
+
291
+    //search selected outcomes,semesters and get their objectives
292
+    $selected_outcomes = DB::table('typ_semester_outcome')
293
+        ->join('outcomes','outcomes.id','=','typ_semester_outcome.outcome_id')
294
+        ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
295
+        ->distinct('typ_semester_outcome.outcome_id')
296
+        ->select('typ_semester_outcome.outcome_id')
297
+        ->orderBy('outcomes.name', 'asc')
298
+        ->get();
299
+
300
+    $selected_objectives_array = array();
301
+    $outcomes_info_array = array();
302
+    // $objectives_info_array = array();
303
+    $semesters_array = array();
304
+
305
+    $info = array();
306
+    foreach ($selected_outcomes as $outcome) {
307
+
308
+
309
+      $outcome_id = $outcome->outcome_id;
310
+      $result_outcomes = DB::table('outcomes')
311
+          ->where('outcomes.id',$outcome_id)
312
+          ->orderBy('outcomes.name', 'asc')
313
+          ->get();
314
+
315
+      foreach ($result_outcomes as $outcome_) {
316
+
317
+        $result_semesters = DB::table('typ_semester_outcome')
318
+            ->join('semesters','semesters.id','=','typ_semester_outcome.semester_id')
319
+            ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
320
+            ->where('typ_semester_outcome.outcome_id',$outcome_->id)
321
+            ->select('typ_semester_outcome.id','typ_semester_outcome.semester_id','semesters.code','semesters.name')
322
+            ->get();
323
+        // buscar info sobre selected_semsters
324
+        $outcome_->selected_semesters = array();
325
+        foreach ($result_semesters as $semesters_) {
326
+          $typ_semester_outcome_id = $semesters_->id;
327
+
328
+          // lookup previusly selected objectives
329
+          $result_objectives = DB::table('typ_semester_objectives')
330
+              ->join('objectives','objectives.id','=','typ_semester_objectives.objective_id')
331
+              ->where('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome_id)
332
+              ->orderBy('typ_semester_objectives.id', 'asc')
333
+              ->get();
334
+
335
+          $semesters_->selected_objectives = array();
336
+          foreach ($result_objectives as $objectives_) {
337
+
338
+            array_push($semesters_->selected_objectives, $objectives_);
339
+          }
340
+
341
+          // lookup available objectives
342
+          $result_objectives = DB::table('criterion_objective_outcome')
343
+              ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
344
+              ->join('objectives','objectives.id','=','criterion_objective_outcome.objective_id')
345
+              ->join('objective_program','objective_program.objective_id','=','objectives.id')
346
+              ->where('objective_program.program_id',$program_id)
347
+              ->where('criterion_objective_outcome.outcome_id',$outcome_id)
348
+              ->select('objectives.id','objectives.text','outcomes.name as outcome_name')
349
+              ->orderBy('objectives.text', 'asc')
350
+              ->get();
351
+
352
+          $semesters_->available_objectives = array();
353
+          foreach ($result_objectives as $objectives_) {
354
+
355
+            array_push($semesters_->available_objectives, $objectives_);
356
+          }
357
+
358
+          array_push($outcome_->selected_semesters, $semesters_);
359
+        }
360
+        array_push($info, $outcome_);
361
+      }
362
+    }
363
+    return $info;
364
+  }
365
+
366
+  public function section3_arrive()
367
+  {
368
+    // get program_id
369
+    $user_id = auth::user()->id; //ya, tester es 60
370
+    $program_id = DB::table('program_user')
371
+        ->where('user_id',$user_id)
372
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
373
+        ->select('program_id')
374
+        ->get();
375
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
376
+
377
+    // get typ_program_id
378
+    $typ_id = Input::get('typ_id');
379
+    $result = DB::table('typ_program')
380
+        ->where('three_year_plan_id',$typ_id)
381
+        ->where('program_id',$program_id)
382
+        ->get();
383
+    $typ_program_id = $result[0]->id;
384
+
385
+
386
+    //search selected outcomes,semesters and get their objectives
387
+    $selected_outcomes = DB::table('typ_semester_outcome')
388
+        ->join('outcomes','outcomes.id','=','typ_semester_outcome.outcome_id')
389
+        ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
390
+        ->distinct('typ_semester_outcome.outcome_id')
391
+        ->select('typ_semester_outcome.outcome_id')
392
+        ->orderBy('outcomes.name', 'asc')
393
+        ->get();
394
+
395
+    $selected_objectives_array = array();
396
+    $outcomes_info_array = array();
397
+    // $objectives_info_array = array();
398
+    $semesters_array = array();
399
+
400
+    $info = array();
401
+    foreach ($selected_outcomes as $outcome) {
402
+
403
+
404
+      $outcome_id = $outcome->outcome_id;
405
+      $result_outcomes = DB::table('outcomes')
406
+          ->where('outcomes.id',$outcome_id)
407
+          ->get();
408
+
409
+      foreach ($result_outcomes as $outcome_) {
410
+
411
+        $result_semesters = DB::table('typ_semester_outcome')
412
+            ->join('semesters','semesters.id','=','typ_semester_outcome.semester_id')
413
+            ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
414
+            ->where('typ_semester_outcome.outcome_id',$outcome_->id)
415
+            ->select('typ_semester_outcome.id','typ_semester_outcome.semester_id','semesters.code','semesters.name')
416
+            ->get();
417
+        // buscar info sobre selected_semsters
418
+        $outcome_->selected_semesters = array();
419
+        foreach ($result_semesters as $semesters_) {
420
+          $semester_id = $semesters_->semester_id;
421
+
422
+          $typ_semester_outcome_id = $semesters_->id;
423
+          $result_objectives = DB::table('typ_semester_objectives')
424
+              ->join('objectives','objectives.id','=','typ_semester_objectives.objective_id')
425
+              ->where('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome_id)
426
+              ->select('typ_semester_objectives.id as typ_semester_objectives_id','objectives.*','typ_semester_objectives.*')
427
+              ->orderBy('typ_semester_objectives.id', 'asc')
428
+              ->get();
429
+
430
+          $semesters_->selected_objectives = array();
431
+          foreach ($result_objectives as $objectives_) {
432
+            $objective_id = $objectives_->objective_id;
433
+            $program_id = $objectives_->program_id;
434
+            $result_courses = DB::table('objective_program')
435
+                ->join('objectives','objectives.id','=','objective_program.objective_id')
436
+                ->join('courses','courses.program_id','=','objective_program.program_id')
437
+                ->where('objective_program.objective_id', $objective_id)
438
+                ->where('objective_program.program_id', $program_id)
439
+                ->where('courses.semester_id', $semester_id)
440
+                ->distinct('courses.name','courses.code')
441
+                ->select('courses.id as course_id','courses.name','courses.code','objective_program.objective_id','objective_program.program_id')
442
+                ->orderBy('courses.name', 'asc')
443
+                ->groupBy('courses.name','courses.code')
444
+                ->get();
445
+
446
+            $objectives_->available_courses = array();
447
+            foreach ($result_courses as $courses_) {
448
+              array_push($objectives_->available_courses, $courses_);
449
+            }
450
+
451
+            // search for previusly selected courses
452
+            $typ_semester_objective_id = $objectives_->typ_semester_objectives_id;
453
+            $result_courses = DB::table('typ_semester_courses')
454
+                ->join('courses','courses.id','=','typ_semester_courses.course_id')
455
+                ->where('typ_semester_courses.typ_semester_objective_id', $typ_semester_objective_id)
456
+                ->select('courses.id as course_id','courses.*','typ_semester_courses.*')
457
+                ->orderBy('courses.name', 'asc')
458
+                ->get();
459
+
460
+            $objectives_->selected_courses = array();
461
+            foreach ($result_courses as $courses_) {
462
+              array_push($objectives_->selected_courses, $courses_);
463
+            }
464
+
465
+            array_push($semesters_->selected_objectives, $objectives_);
466
+          }
467
+
468
+          array_push($outcome_->selected_semesters, $semesters_);
469
+        }
470
+        array_push($info, $outcome_);
471
+      }
472
+    }
473
+    return $info;
474
+  }
475
+
476
+
477
+  public function section3_on_change()
478
+  {
479
+    $typ_id = Input::get('typ_id');
480
+    // typ_id: (typ_id),
481
+    $outcome_id = Input::get('outcome_id');
482
+    // outcome_id: (outcome_id),
483
+    $semester_id = Input::get('semester_id');
484
+    // semester_id: (semester_id),
485
+    $objective_id = Input::get('objective_id');
486
+    // objective_id: (objective_id),
487
+    $previous_course_id = Input::get('previous_course_id');
488
+    // previous_course_id: (previous_course_id),
489
+    $new_course_id = Input::get('new_course_id');
490
+    // new_course_id: (new_course_id)
491
+
492
+    // get program_id
493
+    $user_id = auth::user()->id; //ya, tester es 60
494
+    $program_id = DB::table('program_user')
495
+        ->where('user_id',$user_id)
496
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
497
+        ->select('program_id')
498
+        ->get();
499
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
500
+
501
+    // get typ_program_id
502
+    $result = DB::table('typ_program')
503
+        ->where('three_year_plan_id',$typ_id)
504
+        ->where('program_id',$program_id)
505
+        ->get();
506
+    $typ_program_id = $result[0]->id;
507
+
508
+    // get typ_semester_outcome_id
509
+    $result = DB::table('typ_semester_outcome')
510
+        ->where('typ_program_id',$typ_program_id)
511
+        ->where('semester_id',$semester_id)
512
+        ->where('outcome_id',$outcome_id)
513
+        ->get();
514
+    $typ_semester_outcome_id = $result[0]->id;
515
+
516
+    // get typ_semester_objective_id
517
+    $result = DB::table('typ_semester_objectives')
518
+        ->where('typ_semester_outcome_id',$typ_semester_outcome_id)
519
+        ->where('objective_id',$objective_id)
520
+        ->get();
521
+    $typ_semester_objective_id = $result[0]->id;
522
+
523
+    //delete old objective relation if it exists
524
+    if ($previous_course_id != 'nothing_selected') {
525
+      $result = DB::table('typ_semester_courses')
526
+          ->where('typ_semester_objective_id',$typ_semester_objective_id)
527
+          ->where('course_id',$previous_course_id)
528
+          ->get();
529
+      if (count($result) != 0) {
530
+        DB::table('typ_semester_courses')
531
+            ->where('typ_semester_objective_id', $typ_semester_objective_id)
532
+            ->where('course_id', $previous_course_id)
533
+            ->delete();
534
+      }
535
+    }
536
+
537
+    //create new objective relation
538
+    if ($new_course_id != 'nothing_selected') {
539
+      $result = DB::table('typ_semester_courses')
540
+          ->where('typ_semester_objective_id',$typ_semester_objective_id)
541
+          ->where('course_id',$new_course_id)
542
+          ->get();
543
+      if (count($result) == 0) {
544
+        $_ = DB::table('typ_semester_courses')->insertGetId(
545
+            array(
546
+              'typ_semester_objective_id' => $typ_semester_objective_id,
547
+              'course_id' => $new_course_id)
548
+        );
549
+      }
550
+    }
551
+    return 'update succes?';
552
+  }
553
+
554
+
555
+}

+ 928
- 0
app/controllers/TransformativeActionsController.php Zobrazit soubor

@@ -0,0 +1,928 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Input;
4
+
5
+class TransformativeActionsController extends \BaseController
6
+{
7
+
8
+    public function editTA()
9
+    {
10
+        $title = "Transformative Action";
11
+        $role = Auth::user()['role'];
12
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
13
+
14
+        $schools = School::orderBy('name', 'ASC')->get();
15
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
16
+        $programs = Program::orderBy('name', 'ASC')->get();
17
+        $user_id = auth::user()->id;
18
+
19
+        $program_id = DB::table('program_user')
20
+            ->where('user_id',$user_id)
21
+            ->select('program_id')
22
+            ->get();
23
+        $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
24
+        $outcomes = Outcome::orderBy('name', 'ASC')
25
+                    ->where('deactivation_date','=','0000-00-00')
26
+                    ->orWhereNull('deactivation_date')
27
+                    ->get();
28
+        $objectives = array();
29
+
30
+        // if user is program coordinator
31
+        if ($role == 3){
32
+          //1 edit panel: load the TA that
33
+          //    are custom ('transformative_actions.by_professor' == 0)
34
+          //    were approved in past ('transformative_actions.is_custom' == 1)
35
+          $ta_edit_panel = DB::table('transformative_actions')
36
+                          ->where('transformative_actions.is_custom', 1)
37
+                          ->where('transformative_actions.program_id', $program_id)
38
+                          ->where('transformative_actions.by_professor', 0)
39
+                          ->orderBy('at_text', 'ASC')
40
+                          ->get();
41
+          //2 approve panel: load TAs that
42
+          //    can be approved ('transformative_actions.by_professor' == 1)
43
+          $ta_approval_panel = DB::table('transformative_actions')
44
+                            ->where('transformative_actions.is_custom', 1)
45
+                            ->where('transformative_actions.program_id', $program_id)
46
+                            ->where('transformative_actions.by_professor',1)
47
+                            ->orderBy('at_text', 'ASC')
48
+                            ->get();
49
+          //2.1 approve panel: load the filter options.
50
+          // the "->where()" should be the same from $ta_approval_panel,
51
+          //  but with aditional joins and different select
52
+          //
53
+          // get the names of the professors
54
+          $professor_filter_approvePanel = DB::table('transformative_actions')
55
+                            ->join('users','users.id','=','transformative_actions.user_id')
56
+                            ->where('transformative_actions.is_custom', 1)
57
+                            ->where('transformative_actions.program_id', $program_id)
58
+                            ->where('transformative_actions.by_professor', 1)
59
+                            ->select('users.*')
60
+                            ->groupby('transformative_actions.user_id')
61
+                            ->orderBy('users.first_name', 'ASC')
62
+                            ->get();
63
+          // get the courses from asociated with a TA
64
+          $course_filter_approvePanel = DB::table('ta_course')
65
+                            ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
66
+                            ->join('courses','courses.id','=','ta_course.course_id')
67
+                            ->where('transformative_actions.is_custom', 1)
68
+                            ->where('transformative_actions.program_id', $program_id)
69
+                            ->where('transformative_actions.by_professor', 1)
70
+                            ->select('courses.*')
71
+                            ->groupBy('courses.name','courses.code')
72
+                            ->orderBy('courses.name', 'ASC')
73
+                            ->orderBy('courses.code', 'ASC')
74
+                            ->get();
75
+          // get the outcome asociated with a TA
76
+          $outcome_filter_approvePanel = DB::table('transformative_actions')
77
+                            ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
78
+                            ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
79
+                            ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
80
+                            ->where('transformative_actions.is_custom', 1)
81
+                            ->where('transformative_actions.program_id', $program_id)
82
+                            ->where('transformative_actions.by_professor', 1)
83
+                            ->select('outcomes.*')
84
+                            ->groupBy('outcomes.id')
85
+                            ->orderBy('outcomes.name', 'ASC')
86
+                            ->get();
87
+          //3 edit panel: load the filter options.
88
+          // the "->where()" should be the same from $ta_edit_panel,
89
+          //  but with aditional joins and different select
90
+          //
91
+          $professor_filter_editPanel = DB::table('transformative_actions')
92
+                            ->join('users','users.id','=','transformative_actions.user_id')
93
+                            ->where('transformative_actions.is_custom', 1)
94
+                            ->where('transformative_actions.program_id', $program_id)
95
+                            ->where('transformative_actions.by_professor', 0)
96
+                            ->select('users.*')
97
+                            ->groupby('transformative_actions.user_id')
98
+                            ->orderBy('users.first_name', 'ASC')
99
+                            ->get();
100
+          $course_filter_editPanel =  DB::table('ta_course')
101
+                            ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
102
+                            ->join('courses','courses.id','=','ta_course.course_id')
103
+                            ->where('transformative_actions.is_custom', 1)
104
+                            ->where('transformative_actions.program_id', $program_id)
105
+                            ->where('transformative_actions.by_professor', 0)
106
+                            ->select('courses.*')
107
+                            ->groupBy('courses.name','courses.code')
108
+                            ->orderBy('courses.name', 'ASC')
109
+                            ->orderBy('courses.code', 'ASC')
110
+                            ->get();
111
+          $outcome_filter_editPanel = DB::table('transformative_actions')
112
+                            ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
113
+                            ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
114
+                            ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
115
+                            ->where('transformative_actions.is_custom', 1)
116
+                            ->where('transformative_actions.program_id', $program_id)
117
+                            ->where('transformative_actions.by_professor', 0)
118
+                            ->select('outcomes.*')
119
+                            ->groupBy('outcomes.id')
120
+                            ->orderBy('outcomes.name', 'ASC')
121
+                            ->get();
122
+          // 4 create panel: search all courses
123
+          $courses_create = DB::table('courses')
124
+                            ->where('courses.program_id',$program_id)
125
+                            ->select('courses.*')
126
+                            ->groupBy('courses.name','courses.code')
127
+                            ->orderBy('courses.name', 'ASC')
128
+                            ->orderBy('courses.code', 'ASC')
129
+                            ->get();
130
+        }
131
+        // if user is profesor
132
+        elseif ($role == 4){
133
+          // 1 the user can only edit TA that need approval and has been submited by the same user
134
+          $ta_edit_panel = DB::table('transformative_actions')
135
+                          ->where('transformative_actions.is_custom', 1)
136
+                          ->where('transformative_actions.program_id',$program_id)
137
+                          ->where('transformative_actions.user_id', Auth::user()->id)
138
+                          ->where('transformative_actions.by_professor',1)
139
+                          ->select('transformative_actions.*')
140
+                          ->orderBy('at_text', 'ASC')
141
+                          ->get();
142
+          // 2 approve panel: dont load TA since professors cant approve them
143
+          $ta_approval_panel = array();
144
+          // 3 edit panel: load professor filter for his courses
145
+          $professor_filter_editPanel = array();
146
+          $course_filter_editPanel =  DB::table('ta_course')
147
+                            ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
148
+                            ->join('courses','courses.id','=','ta_course.course_id')
149
+                            ->where('transformative_actions.is_custom', 1)
150
+                            ->where('transformative_actions.user_id', Auth::user()->id)
151
+                            ->where('transformative_actions.program_id', $program_id)
152
+                            ->where('transformative_actions.by_professor', 1)
153
+                            ->select('courses.*')
154
+                            ->groupBy('courses.name','courses.code')
155
+                            ->orderBy('courses.name', 'ASC')
156
+                            ->orderBy('courses.code', 'ASC')
157
+                            ->get();
158
+          $outcome_filter_editPanel = DB::table('transformative_actions')
159
+                            ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
160
+                            ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
161
+                            ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
162
+                            ->where('transformative_actions.is_custom', 1)
163
+                            ->where('transformative_actions.user_id', Auth::user()->id)
164
+                            ->where('transformative_actions.program_id',$program_id)
165
+                            ->where('transformative_actions.by_professor', 1)
166
+                            ->select('outcomes.*')
167
+                            ->groupBy('outcomes.id')
168
+                            ->orderBy('outcomes.name', 'ASC')
169
+                            ->get();
170
+          // these arent used by professors
171
+          $professor_filter_approvePanel = array();
172
+          $course_filter_approvePanel = array();
173
+          $outcome_filter_approvePanel = array();
174
+
175
+          // 4 create panel: search courses given by the professor
176
+          $courses_create = DB::table('courses')
177
+                            ->where('courses.program_id',$program_id)
178
+                            ->where('courses.user_id', Auth::user()->id)
179
+                            ->select('courses.*')
180
+                            ->groupBy('courses.name','courses.code')
181
+                            ->orderBy('courses.name', 'ASC')
182
+                            ->orderBy('courses.code', 'ASC')
183
+                            ->get();
184
+        }
185
+
186
+        return View::make('local.managers.admins.transformativeAction', compact('title','role', 'outcomes', 'schools', 'criteria', 'programs', 'outcomes', 'objectives',
187
+        'ta_edit_panel','ta_approval_panel','courses_create',
188
+        'professor_filter_approvePanel', 'course_filter_approvePanel', 'outcome_filter_approvePanel',
189
+        'professor_filter_editPanel', 'outcome_filter_editPanel', 'course_filter_editPanel'
190
+      ));
191
+    }
192
+
193
+
194
+    private function cleanInput()
195
+    {
196
+        $clean_input = array();
197
+
198
+
199
+        $trimmed = trim(preg_replace('/\t+/', '', Input::get('text')));
200
+
201
+        Log::info('trimmed 1 -->' . $trimmed . '<--');
202
+
203
+        // if ($trimmed == '') {
204
+        //     $trimmed = NULL;
205
+        // } else {
206
+        //     $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
207
+        // }
208
+
209
+        Log::info('trimmed 2 -->' . $trimmed . '<--');
210
+
211
+
212
+        $clean_input['text'] = $trimmed;
213
+
214
+        //////
215
+        $trimmed = trim(preg_replace('/\t+/', '', Input::get('description')));
216
+
217
+        Log::info('trimmed 3 -->' . $trimmed . '<--');
218
+
219
+        // if ($trimmed == '') {
220
+        //     $trimmed = NULL;
221
+        // } else {
222
+        //     $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
223
+        // }
224
+
225
+        Log::info('trimmed 4 -->' . $trimmed . '<--');
226
+
227
+
228
+        $clean_input['description'] = $trimmed;
229
+
230
+
231
+
232
+        $clean_input['objectiveid'] = Input::get('objectiveid');
233
+        $clean_input['courseid'] = Input::get('courseid');
234
+        $clean_input['approval'] = Input::get('approval');
235
+        $clean_input['ta_id'] = Input::get('ta_id');
236
+
237
+        return $clean_input;
238
+    }
239
+
240
+    private function makeValidator($clean_input)
241
+    {
242
+
243
+      /** Validation rules */
244
+      return Validator::make(
245
+            array(
246
+                'text' => $clean_input['text'],
247
+                'description' => $clean_input['description'],
248
+                'objectiveid' => $clean_input['objectiveid'],
249
+                'courseid' => $clean_input['courseid'],
250
+                'approval' => $clean_input['approval'],
251
+                'ta_id' => $clean_input['ta_id'],
252
+            ),
253
+            array(
254
+                'text' => 'required|string',
255
+                'description' => 'required|string',
256
+                'objectiveid' => 'required|array',
257
+                'courseid' => 'required|array',
258
+                'approval' => 'integer',
259
+                'ta_id' => 'integer',
260
+            )
261
+        );
262
+    }
263
+
264
+
265
+    /**
266
+     * Create a new transformative action.
267
+     *
268
+     * @return Redirect Redirect back to form page
269
+     */
270
+    public function createTA()
271
+    {
272
+        $clean_input = $this->cleanInput();
273
+
274
+        /** Validation rules */
275
+        $validator = $this->makeValidator($clean_input);
276
+
277
+        /** If validation fails */
278
+        if ($validator->fails()) {
279
+            /** Prepare error message */
280
+            $message = '<p>Error(s) creating a new Transformative Action:</p><ul>';
281
+
282
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
283
+                $message .= $validationError;
284
+            }
285
+
286
+            $message .= '</ul>';
287
+
288
+            /** Send error message and old data */
289
+            Session::flash('status', 'danger');
290
+            Session::flash('message', $message);
291
+            $role = Auth::user()['role'];
292
+            return Redirect::to('transformativeAction')->withInput();
293
+        } else {
294
+
295
+          $user_id = auth::user()->id;
296
+          $program_id = DB::table('program_user')
297
+              ->where('user_id',$user_id)
298
+              ->select('program_id')
299
+              ->get();
300
+          $program_id = $program_id[0]->program_id;
301
+          $role = Auth::user()['role'];
302
+          $by_professor = 1;
303
+          if($role == 3){
304
+            $by_professor = 0;
305
+          }
306
+
307
+          // $by_professor = $clean_input['approval'];
308
+
309
+          $current_timestamp = date('Y/m/d H:i:s', time());
310
+          // insert the TA
311
+          $ta_id = DB::table('transformative_actions')->insertGetId(
312
+              array('at_text' => $clean_input['text'],
313
+                    'description' => $clean_input['description'],
314
+                    'is_custom' => 1,
315
+                    'user_id' => $user_id,
316
+                    'program_id' => $program_id,
317
+                    'created_at' => $current_timestamp,
318
+                    'by_professor' => $by_professor,
319
+                  )
320
+          );
321
+
322
+          //
323
+          // // insert the multiple TA_objective_program
324
+          foreach ($clean_input['objectiveid'] as $objective_id) {
325
+            DB::table('transformative_objective_program')->insert(
326
+                array(
327
+                  'ta_id' => $ta_id,
328
+                  'objective_id' => $objective_id,
329
+                  'program_id' => $program_id,
330
+                  'created_at' => $current_timestamp,
331
+                  )
332
+            );
333
+          }
334
+
335
+          //
336
+          // // insert the multiple TA_course
337
+          foreach ($clean_input['courseid'] as $course_id) {
338
+            DB::table('TA_course')->insert(
339
+                array(
340
+                  'ta_id' => $ta_id,
341
+                  'course_id' => $course_id,
342
+                  )
343
+            );
344
+          }
345
+
346
+          Session::flash('status', 'success');
347
+          Session::flash('message', 'Transformative Action created: "' . $clean_input['text'] . '".');
348
+          $role = Auth::user()['role'];
349
+          return Redirect::to('transformativeAction')->withInput();
350
+        }
351
+    }
352
+
353
+
354
+    public function approveTA()
355
+    {
356
+      $role = Auth::user()['role'];
357
+      if($role != 3){
358
+        $message = 'Only Program Coordinators can approve a TA';
359
+        Session::flash('status', 'danger');
360
+        Session::flash('message', $message);
361
+        return Redirect::to('transformativeAction')->withInput();
362
+      }
363
+
364
+      $ta_id = Input::get('ta_id');
365
+      $text = Input::get('at_text');
366
+
367
+      if($ta_id == 0){
368
+        $message = 'Please select a Transformative Action</p>';
369
+
370
+        Session::flash('status', 'danger');
371
+        Session::flash('message', $message);
372
+
373
+        $role = Auth::user()['role'];
374
+        return Redirect::to('transformativeAction')->withInput();
375
+      }
376
+
377
+      $current_timestamp = date('Y/m/d H:i:s', time());
378
+
379
+      // edit the TA
380
+      DB::table('transformative_actions')
381
+                  ->where('id', $ta_id)
382
+                  ->update([
383
+                        'by_professor' => 0,
384
+                        'updated_at' => $current_timestamp,
385
+                    ]);
386
+
387
+      Session::flash('status', 'success');
388
+      Session::flash('message', 'Approved the Transformative Action: "' . $text . '".');
389
+      $role = Auth::user()['role'];
390
+      return Redirect::to('transformativeAction')->withInput();
391
+    }
392
+
393
+
394
+
395
+
396
+
397
+
398
+    public function updateTA()
399
+    {
400
+      $clean_input = $this->cleanInput();
401
+
402
+      /** Validation rules */
403
+      $validator = $this->makeValidator($clean_input);
404
+
405
+      /** If validation fails */
406
+      if ($validator->fails()) {
407
+          /** Prepare error message */
408
+          $message = 'Error(s) updating the Transformative Action: <ul>';
409
+
410
+          foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
411
+              $message .= $validationError;
412
+          }
413
+
414
+          $message .= '</ul>';
415
+
416
+          /** Send error message and old data */
417
+          Session::flash('status', 'danger');
418
+          Session::flash('message', $message);
419
+          $role = Auth::user()['role'];
420
+          return Redirect::to('transformativeAction')->withInput();
421
+      } else {
422
+
423
+          $user_id = auth::user()->id;
424
+          $program_id = DB::table('program_user')
425
+              ->where('user_id',$user_id)
426
+              ->select('program_id')
427
+              ->get();
428
+          $program_id = $program_id[0]->program_id;
429
+          $role = Auth::user()['role'];
430
+          $by_professor = $clean_input['approval'];
431
+          if($role == 4){
432
+            $by_professor = 1;
433
+          }
434
+
435
+          // $by_professor = $clean_input['approval'];
436
+
437
+          $current_timestamp = date('Y/m/d H:i:s', time());
438
+          // edit the TA
439
+          DB::table('transformative_actions')
440
+                      ->where('id', $clean_input['ta_id'])
441
+                      ->update([
442
+                            'by_professor' => $by_professor,
443
+                            'at_text' => $clean_input['text'],
444
+                            'description' => $clean_input['description'],
445
+                            'updated_at' => $current_timestamp,
446
+                        ]);
447
+
448
+
449
+          $ta_id = $clean_input['ta_id'];
450
+          $new_objective_id = $clean_input['objectiveid'];
451
+          $old_objective_id = DB::table('transformative_objective_program')
452
+                      ->where('ta_id',$ta_id)
453
+                      ->select('objective_id')
454
+                      ->lists('objective_id');
455
+
456
+          //delete existing objective_id if it isnt in new_ids array
457
+          foreach ($old_objective_id as $old_id) {
458
+            if(in_array($old_id,$new_objective_id)){
459
+              //do nothing if a new id is already in atble
460
+            }
461
+            else {
462
+              //if old id not in new id, delete
463
+              DB::table('transformative_objective_program')
464
+                ->where('ta_id',$ta_id)
465
+                ->where('objective_id', $old_id)
466
+                ->delete();
467
+            }
468
+          }
469
+
470
+          //
471
+          foreach ($new_objective_id as $new_id) {
472
+            $result = DB::table('transformative_objective_program')
473
+                        ->where('objective_id',$new_id)
474
+                        ->select('objective_id')
475
+                        ->lists('objective_id');
476
+
477
+            if(count($result) == 0){
478
+              //if the new_id does not exists, do nothing
479
+              DB::table('transformative_objective_program')->insert(
480
+                array(
481
+                  'ta_id' => $ta_id,
482
+                  'objective_id' => $new_id,
483
+                  'program_id' => $program_id,
484
+                  'created_at' => $current_timestamp,
485
+                )
486
+              );
487
+            }
488
+            else {
489
+              //if the new_id already exists, do nothing
490
+            }
491
+          }
492
+
493
+
494
+          $new_course_id = $clean_input['courseid'];
495
+          $old_course_id = DB::table('ta_course')
496
+                      ->where('ta_id',$ta_id)
497
+                      ->select('course_id')
498
+                      ->lists('course_id');
499
+
500
+          //delete existing course_id if it isnt in new_ids array
501
+          foreach ($old_course_id as $old_id) {
502
+            if(in_array($old_id,$new_course_id)){
503
+              //do nothing if a new id is already in atble
504
+            }
505
+            else {
506
+              //if old id not in new id, delete
507
+              DB::table('ta_course')
508
+                ->where('ta_id',$ta_id)
509
+                ->where('course_id', $old_id)
510
+                ->delete();
511
+            }
512
+          }
513
+          //add course_id if it isnt already inserted
514
+          foreach ($new_course_id as $new_id) {
515
+            $result = DB::table('ta_course')
516
+                        ->where('ta_id',$ta_id)
517
+                        ->where('course_id',$new_id)
518
+                        ->select('course_id')
519
+                        ->lists('course_id');
520
+
521
+            if(count($result) == 0){
522
+              //if the new_id does not exists, do nothing
523
+              DB::table('ta_course')->insert(
524
+                array(
525
+                  'ta_id' => $ta_id,
526
+                  'course_id' => $new_id,
527
+                )
528
+              );
529
+            }
530
+            else {
531
+              //if the new_id already exists, do nothing
532
+            }
533
+          }
534
+
535
+          Session::flash('status', 'success');
536
+          Session::flash('message', 'Updated Transformative Action: "' . $clean_input['text'] . '".');
537
+          $role = Auth::user()['role'];
538
+          return Redirect::to('transformativeAction')->withInput();
539
+      }
540
+    }
541
+
542
+
543
+    public function deleteTA()
544
+    {
545
+      $ta_id = array(Input::get('ta_id'));
546
+
547
+      // si envia id 0, el backend se queja en la linea: $ta = $ta[0];
548
+      // nunca deberia ocurrir, pero es un safity measure.
549
+      if($ta_id == 0){
550
+        $message = 'Please select a Transformative Action</p>';
551
+
552
+        Session::flash('status', 'danger');
553
+        Session::flash('message', $message);
554
+
555
+        $role = Auth::user()['role'];
556
+        return Redirect::to('transformativeAction')->withInput();
557
+      }
558
+
559
+      $ta = DB::table('transformative_actions')
560
+          ->where('transformative_actions.is_custom', 1)
561
+          ->where('id',$ta_id)
562
+          ->get();
563
+      $ta = $ta[0];
564
+
565
+      $used = DB::table('annual_plan_transformative')
566
+              ->where('id',$ta_id)
567
+              ->get();
568
+
569
+      $recommended = $ta->by_professor;
570
+      // the TA can only be deleted if error if the TA is not currently as "Recommended"
571
+      // and isnt used in an anual plan
572
+      if ($recommended == 1 && count($used) == 0) {
573
+        // delete the TA if it qualifies
574
+        DB::delete("delete from transformative_actions where id = ?", $ta_id);
575
+
576
+        $name = $ta->at_text;
577
+
578
+        $message = 'The Transformative Action has been deleted:</p><ul>';
579
+        $message .= '<li> '.$name.' </li>';
580
+        $message .= '</ul>';
581
+
582
+        Session::flash('status', 'success');
583
+        Session::flash('message', $message);
584
+        $role = Auth::user()['role'];
585
+        return Redirect::to('transformativeAction')->withInput();
586
+      }
587
+
588
+
589
+      $message = 'Transformative Actions can only be deleted if:</p><ul>';
590
+      $message .= '<li> It has a status of "Recommended"</li>';
591
+      $message .= '<li> It is not currently used in a plan</li>';
592
+      $message .= '</ul>';
593
+
594
+      Session::flash('status', 'danger');
595
+      Session::flash('message', $message);
596
+
597
+      $role = Auth::user()['role'];
598
+      return Redirect::to('transformativeAction')->withInput();
599
+    }
600
+
601
+
602
+
603
+
604
+
605
+    public function selectTA()
606
+    {
607
+      $ta_id = Input::get("ta_id");
608
+      $user_id = Auth::user()->id;
609
+      $program_id = DB::table('program_user')
610
+          ->where('user_id',$user_id)
611
+          ->select('program_id')
612
+          ->get();
613
+      $program_id = $program_id[0]->program_id;
614
+
615
+      $objectives = DB::table('transformative_actions')
616
+                        ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
617
+                        ->join('objectives','objectives.id','=','transformative_objective_program.objective_id')
618
+                        ->where('transformative_actions.id',$ta_id)
619
+                        ->select('objectives.text as text', 'objectives.id as id')
620
+                        ->orderBy('objectives.text', 'ASC')
621
+                        ->get();
622
+
623
+      $an_objective = $objectives[0]->id;
624
+      $outcome_id = DB::table('criterion_objective_outcome')
625
+                    ->where('criterion_objective_outcome.objective_id',$an_objective)
626
+                    ->select('criterion_objective_outcome.outcome_id')
627
+                    ->get();
628
+      $outcome_id = $outcome_id[0]->outcome_id;
629
+
630
+
631
+      $objectives_from_outcome = DB::table('objectives')
632
+                    ->join('objective_program','objective_program.objective_id','=','objectives.id')
633
+                    ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','objectives.id')
634
+                    ->where('criterion_objective_outcome.outcome_id',$outcome_id)
635
+                    ->where('objective_program.program_id',$program_id)
636
+                    ->orderBy('objectives.text', 'ASC')
637
+                    ->select('objectives.text as text', 'objectives.id as id')
638
+                    ->get();
639
+      $selected_courses = DB::table('ta_course')
640
+                    ->join('courses','courses.id','=','ta_course.course_id')
641
+                    ->where('ta_id',$ta_id)
642
+                    ->orderBy('courses.name', 'ASC')
643
+                    ->orderBy('courses.code', 'ASC')
644
+                    ->select('courses.*')
645
+                    ->get();
646
+      $name = DB::table('transformative_actions')
647
+                  ->where('id',$ta_id)
648
+                  ->select('at_text as name')
649
+                  ->lists('name');
650
+      $description = DB::table('transformative_actions')
651
+                  ->where('id',$ta_id)
652
+                  ->select('description')
653
+                  ->lists('description');
654
+      $status = DB::table('transformative_actions')
655
+                  ->where('id',$ta_id)
656
+                  ->select('by_professor as status')
657
+                  ->lists('status');
658
+      $status = $status[0];
659
+      $plans_count = DB::table('annual_plan_transformative')
660
+                  ->where('id',$ta_id)
661
+                  ->get();
662
+      $plans_count = count($plans_count);
663
+      $can_be_deleted = false;
664
+      if($plans_count == 0 && $status == 1){
665
+        $can_be_deleted = true;
666
+      }
667
+      return array(
668
+        'objectives' => $objectives,
669
+        'objectives_from_outcome' => $objectives_from_outcome,
670
+        'selected_courses' => $selected_courses,
671
+        'name' => $name,
672
+        'description' => $description,
673
+        'status' => $status,
674
+        'can_be_deleted' => $can_be_deleted,
675
+        'plans_count' => $plans_count,
676
+      );
677
+    }
678
+
679
+    public function objectivesFromOutcome()
680
+    {
681
+      $user_id = Auth::user()->id;
682
+      $program_id = DB::table('program_user')
683
+          ->where('user_id',$user_id)
684
+          ->select('program_id')
685
+          ->get();
686
+      $program_id = $program_id[0]->program_id;
687
+      $ta_id = Input::get("ta_id");
688
+      $outcome_id = Input::get("outcome_id");
689
+
690
+      $objectives = DB::table('objectives')
691
+                    ->join('objective_program','objective_program.objective_id','=','objectives.id')
692
+                    ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','objectives.id')
693
+                    ->where('criterion_objective_outcome.outcome_id',$outcome_id)
694
+                    ->where('objective_program.program_id',$program_id)
695
+                    ->orderBy('objectives.text', 'ASC')
696
+                    ->select('objectives.text as text', 'objectives.id as id')
697
+                    ->get();
698
+
699
+      return array(
700
+        'objectives' => $objectives,
701
+      );
702
+    }
703
+
704
+    // return TA filtered by the user on the approve or edit panel
705
+    public function filterTA()
706
+    {
707
+      $user_id = Auth::user()->id;
708
+      $role = Auth::user()['role'];
709
+      $professor_id = Input::get('professor_id');
710
+      $course_id = Input::get('course_id');
711
+      $outcome_id = Input::get('outcome_id');
712
+      $panel_id = Input::get('panel_id');
713
+      $program_id = DB::table('program_user')
714
+          ->where('user_id',$user_id)
715
+          ->select('program_id')
716
+          ->get();
717
+      $program_id = $program_id[0]->program_id;
718
+
719
+      // if the user is a coordinator filtering the approvePanel
720
+      if ($role == '3' && $panel_id == 'approvePanel'){
721
+
722
+        // if professor isnt a desired filter, search all professors
723
+        if ($professor_id == 0){
724
+          $all_ta_users = DB::table('transformative_actions')
725
+                        ->where('transformative_actions.is_custom', 1)
726
+                        ->where('transformative_actions.program_id', $program_id)
727
+                        ->where('transformative_actions.by_professor',1)
728
+                        ->select('transformative_actions.user_id')
729
+                        ->get();
730
+          $professor_id = array();
731
+          foreach ($all_ta_users as $key => $user) {
732
+            array_push($professor_id, $user->user_id);
733
+          }
734
+        }else{
735
+          $professor_id = array($professor_id);
736
+        }
737
+        // if course isnt a desired filter, search all courses
738
+        if ($course_id == 0){
739
+          $courses =  DB::table('ta_course')
740
+                    ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
741
+                    ->join('courses','courses.id','=','ta_course.course_id')
742
+                    ->where('transformative_actions.is_custom', 1)
743
+                    ->where('transformative_actions.program_id', $program_id)
744
+                    ->where('transformative_actions.by_professor', 1)
745
+                    ->select('courses.id')
746
+                    ->get();
747
+
748
+          $course_id = array();
749
+          foreach ($courses as $key => $course) {
750
+            array_push($course_id, $course->id);
751
+          }
752
+        }else{
753
+          $course_id = array($course_id);
754
+        }
755
+        // if outcome isnt a desired filter, search all outcomes
756
+        if ($outcome_id == 0){
757
+          $outcomes = DB::table('transformative_actions')
758
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
759
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
760
+                      ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
761
+                      ->where('transformative_actions.is_custom', 1)
762
+                      ->where('transformative_actions.program_id', $program_id)
763
+                      ->where('transformative_actions.by_professor', 1)
764
+                      ->select('outcomes.id')
765
+                      ->groupBy('outcomes.id')
766
+                      ->get();
767
+          $outcome_id = array();
768
+          foreach ($outcomes as $key => $outcome) {
769
+            array_push($outcome_id, $outcome->id);
770
+          }
771
+        }else{
772
+          $outcome_id = array($outcome_id);
773
+        }
774
+
775
+        // search TA with filters
776
+        $filtered_at = DB::table('transformative_actions')
777
+                      ->join('ta_course','ta_course.ta_id','=','transformative_actions.id')
778
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
779
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
780
+                      ->where('transformative_actions.is_custom', 1)
781
+                      ->where('transformative_actions.program_id',$program_id)
782
+                      ->where('transformative_actions.by_professor',1)
783
+                      ->whereIn('transformative_actions.user_id',$professor_id)
784
+                      ->whereIn('criterion_objective_outcome.outcome_id',$outcome_id)
785
+                      ->whereIn('ta_course.course_id',$course_id)
786
+                      ->select('transformative_actions.*')
787
+                      ->groupBy('transformative_actions.id')
788
+                      ->orderBy('transformative_actions.at_text', 'ASC')
789
+                      ->get();
790
+        return $filtered_at;
791
+      }
792
+      // if the user is a coordinator filtering the editPanel
793
+      elseif($role == '3' && $panel_id == 'editPanel'){
794
+
795
+        // if professor isnt a desired filter, search all professors
796
+        if ($professor_id == 0){
797
+          $all_ta_users = DB::table('transformative_actions')
798
+                        ->where('transformative_actions.is_custom', 1)
799
+                        ->where('transformative_actions.program_id', $program_id)
800
+                        ->where('transformative_actions.by_professor',0)
801
+                        ->select('transformative_actions.user_id')
802
+                        ->get();
803
+          $professor_id = array();
804
+          foreach ($all_ta_users as $key => $user) {
805
+            array_push($professor_id, $user->user_id);
806
+          }
807
+        }else{
808
+          $professor_id = array($professor_id);
809
+        }
810
+        // if course isnt a desired filter, search all courses
811
+        if ($course_id == 0){
812
+          $courses =  DB::table('ta_course')
813
+                    ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
814
+                    ->join('courses','courses.id','=','ta_course.course_id')
815
+                    ->where('transformative_actions.is_custom', 1)
816
+                    ->where('transformative_actions.program_id', $program_id)
817
+                    ->where('transformative_actions.by_professor', 0)
818
+                    ->select('courses.id')
819
+                    ->get();
820
+
821
+          $course_id = array();
822
+          foreach ($courses as $key => $course) {
823
+            array_push($course_id, $course->id);
824
+          }
825
+        }else{
826
+          $course_id = array($course_id);
827
+        }
828
+        // if outcome isnt a desired filter, search all outcomes
829
+        if ($outcome_id == 0){
830
+          $outcomes = DB::table('transformative_actions')
831
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
832
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
833
+                      ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
834
+                      ->where('transformative_actions.is_custom', 1)
835
+                      ->where('transformative_actions.program_id', $program_id)
836
+                      ->where('transformative_actions.by_professor', 0)
837
+                      ->select('outcomes.id')
838
+                      ->groupBy('outcomes.id')
839
+                      ->get();
840
+          $outcome_id = array();
841
+          foreach ($outcomes as $key => $outcome) {
842
+            array_push($outcome_id, $outcome->id);
843
+          }
844
+        }else{
845
+          $outcome_id = array($outcome_id);
846
+        }
847
+
848
+        // search TA with filters
849
+        $filtered_at = DB::table('transformative_actions')
850
+                      ->join('ta_course','ta_course.ta_id','=','transformative_actions.id')
851
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
852
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
853
+                      ->where('transformative_actions.is_custom', 1)
854
+                      ->where('transformative_actions.program_id',$program_id)
855
+                      ->where('transformative_actions.by_professor',0)
856
+                      ->whereIn('transformative_actions.user_id',$professor_id)
857
+                      ->whereIn('criterion_objective_outcome.outcome_id',$outcome_id)
858
+                      ->whereIn('ta_course.course_id',$course_id)
859
+                      ->select('transformative_actions.*')
860
+                      ->groupBy('transformative_actions.id')
861
+                      ->orderBy('transformative_actions.at_text', 'ASC')
862
+                      ->get();
863
+        return $filtered_at;
864
+      }
865
+      // if the user is a professor filtering the editPanel
866
+      elseif($role == '4' && $panel_id == 'editPanel'){
867
+
868
+        // if course isnt a desired filter, search all courses
869
+        if ($course_id == 0){
870
+          $courses = DB::table('ta_course')
871
+                    ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
872
+                    ->join('courses','courses.id','=','ta_course.course_id')
873
+                    ->where('transformative_actions.user_id', Auth::user()->id)
874
+                    ->where('transformative_actions.is_custom', 1)
875
+                    ->where('transformative_actions.program_id', $program_id)
876
+                    ->where('transformative_actions.by_professor', 1)
877
+                    ->select('courses.id')
878
+                    ->get();
879
+
880
+          $course_id = array();
881
+          foreach ($courses as $key => $course) {
882
+            array_push($course_id, $course->id);
883
+          }
884
+        }else{
885
+          $course_id = array($course_id);
886
+        }
887
+        // if outcome isnt a desired filter, search all outcomes
888
+        if ($outcome_id == 0){
889
+          $outcomes = DB::table('transformative_actions')
890
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
891
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
892
+                      ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
893
+                      ->where('transformative_actions.user_id', Auth::user()->id)
894
+                      ->where('transformative_actions.is_custom', 1)
895
+                      ->where('transformative_actions.program_id', $program_id)
896
+                      ->where('transformative_actions.by_professor', 1)
897
+                      ->select('outcomes.id')
898
+                      ->groupBy('outcomes.id')
899
+                      ->get();
900
+          $outcome_id = array();
901
+          foreach ($outcomes as $key => $outcome) {
902
+            array_push($outcome_id, $outcome->id);
903
+          }
904
+        }else{
905
+          $outcome_id = array($outcome_id);
906
+        }
907
+
908
+        // search TA with filters
909
+        $filtered_at = DB::table('transformative_actions')
910
+                      ->join('ta_course','ta_course.ta_id','=','transformative_actions.id')
911
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
912
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
913
+                      ->where('transformative_actions.user_id', Auth::user()->id)
914
+                      ->where('transformative_actions.is_custom', 1)
915
+                      ->where('transformative_actions.program_id',$program_id)
916
+                      ->where('transformative_actions.by_professor',1)
917
+                      ->whereIn('criterion_objective_outcome.outcome_id',$outcome_id)
918
+                      ->whereIn('ta_course.course_id',$course_id)
919
+                      ->select('transformative_actions.*')
920
+                      ->groupBy('transformative_actions.id')
921
+                      ->orderBy('transformative_actions.at_text', 'ASC')
922
+                      ->get();
923
+        return $filtered_at;
924
+      }
925
+      return 'ilegal';
926
+    }
927
+
928
+}

+ 33
- 0
app/database/migrations/2021_01_31_165057_fix_objectives_table_2.php Zobrazit soubor

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class FixObjectivesTable2 extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	 public function up()
14
+ 	{
15
+ 		Schema::table('objectives', function (Blueprint $table) {
16
+
17
+ 			$table->dropForeign('objectives_program_id_foreign');
18
+ 			//$table->dropColumn('program_id');
19
+ 			//$table->dropColumn('outcome_id');
20
+ 		});
21
+ 	}
22
+
23
+	/**
24
+	 * Reverse the migrations.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function down()
29
+	{
30
+		//
31
+	}
32
+
33
+}

+ 31
- 0
app/database/migrations/2021_01_31_171210_fix_criterion_scale.php Zobrazit soubor

@@ -0,0 +1,31 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class FixCriterionScale extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::table('criterion_scale', function (Blueprint $table) {
16
+ 			$table->dropForeign('criterion_scale_criterion_id_foreign');
17
+ 		});
18
+
19
+	}
20
+
21
+	/**
22
+	 * Reverse the migrations.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public function down()
27
+	{
28
+		//
29
+	}
30
+
31
+}

+ 39
- 0
app/database/migrations/2021_02_17_205601_create_cycles_table.php Zobrazit soubor

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateCyclesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	 public function up()
14
+ 	{
15
+ 		Schema::create('cycles', function(Blueprint $table)
16
+ 		{
17
+			// 		id unico
18
+ 			$table->increments('id')->unsigned();
19
+			// 		cuando a~nos tiene el ciclo('3')
20
+			$table->integer('years_in_cycle');
21
+			// 		cuando comienza el ciclo ('2019')
22
+			$table->integer('start');
23
+			// 		cuando termina  el ciclo ('2022')
24
+			$table->integer('end');
25
+ 			$table->timestamps();
26
+ 		});
27
+ 	}
28
+
29
+ 	/**
30
+ 	 * Reverse the migrations.
31
+ 	 *
32
+ 	 * @return void
33
+ 	 */
34
+ 	public function down()
35
+ 	{
36
+ 		Schema::drop('cycles');
37
+ 	}
38
+
39
+}

+ 50
- 0
app/database/migrations/2021_02_17_205659_create_cycles_semesters_table.php Zobrazit soubor

@@ -0,0 +1,50 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateCyclesSemestersTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('cycles_semesters', function(Blueprint $table)
16
+		{
17
+			// id unico
18
+			$table->increments('id')->unsigned();
19
+			// id del ciclo que pertenece
20
+			$table->integer('cycle_id')->unsigned();
21
+			// semestre n
22
+			$table->integer('semester_id')->unsigned();
23
+			$table
24
+				->foreign('cycle_id')
25
+				->references('id')
26
+				->on('cycles')
27
+				->onDelete('cascade')
28
+				->onUpdate('cascade');
29
+			$table
30
+				->foreign('semester_id')
31
+				->references('id')
32
+				->on('semesters')
33
+				->onDelete('cascade')
34
+				->onUpdate('cascade');
35
+			$table->timestamps();
36
+		});
37
+	}
38
+
39
+	/**
40
+	 * Reverse the migrations.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public function down()
45
+	{
46
+		//
47
+		Schema::drop('cycles_semesters');
48
+	}
49
+
50
+}

+ 50
- 0
app/database/migrations/2021_02_17_205734_create_three_year_plans_table.php Zobrazit soubor

@@ -0,0 +1,50 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateThreeYearPlansTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+			Schema::create('three_year_plans', function(Blueprint $table)
16
+			{
17
+					$table->increments('id')->unsigned();
18
+					$table->integer('cycle_id')->unsigned();
19
+					$table
20
+							->foreign('cycle_id')
21
+							->references('id')
22
+							->on('cycles')
23
+							->onDelete('cascade')
24
+							->onUpdate('cascade');
25
+					$table->integer('program_id')->unsigned();
26
+					$table
27
+							->foreign('program_id')
28
+							->references('id')
29
+							->on('programs')
30
+							->onDelete('cascade')
31
+							->onUpdate('cascade');
32
+					$table->boolean('is_submitted')->default(0);
33
+					$table->dateTime('submitted_on')->nullable();
34
+					$table->timestamps();
35
+			});
36
+	}
37
+
38
+
39
+
40
+	/**
41
+	 * Reverse the migrations.
42
+	 *
43
+	 * @return void
44
+	 */
45
+	public function down()
46
+	{
47
+			Schema::drop('three_year_plans');
48
+	}
49
+
50
+}

+ 48
- 0
app/database/migrations/2021_02_17_205809_create_typ_parts_table.php Zobrazit soubor

@@ -0,0 +1,48 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateTypPartsTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('typ_parts', function(Blueprint $table)
16
+		{
17
+			$table->increments('id')->unsigned();
18
+			$table->integer('three_year_plan_id')->unsigned();
19
+			$table
20
+				->foreign('three_year_plan_id')
21
+				->references('id')
22
+				->on('three_year_plans')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+			$table->integer('semester_id')->unsigned();
26
+			$table
27
+					->foreign('semester_id')
28
+					->references('id')
29
+					->on('semesters')
30
+					->onDelete('cascade')
31
+					->onUpdate('cascade');
32
+			$table->timestamps();
33
+		});
34
+
35
+		// DB::statement("ALTER TABLE `typ_parts` comment 'Annual plans that are part of a three-year plan'");
36
+	}
37
+
38
+	/**
39
+	 * Reverse the migrations.
40
+	 *
41
+	 * @return void
42
+	 */
43
+	public function down()
44
+	{
45
+		Schema::drop('typ_parts');
46
+	}
47
+
48
+}

+ 63
- 0
app/database/migrations/2021_02_17_205850_create_typ_part_outcomes_table.php Zobrazit soubor

@@ -0,0 +1,63 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateTypPartOutcomesTable extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('typ_part_outcomes', function (Blueprint $table) {
17
+
18
+			$table->increments('id')->unsigned();
19
+			$table->integer('typ_part_id')->unsigned();
20
+			$table
21
+				->foreign('typ_part_id')
22
+				->references('id')
23
+				->on('typ_parts')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table->integer('outcome_id')->unsigned();
27
+			$table
28
+				->foreign('outcome_id')
29
+				->references('id')
30
+				->on('outcomes')
31
+				->onDelete('cascade')
32
+				->onUpdate('cascade');
33
+			$table->integer('objective_id')->unsigned()->nullable();
34
+			$table
35
+				->foreign('objective_id')
36
+				->references('id')
37
+				->on('objectives')
38
+				->onDelete('cascade')
39
+				->onUpdate('cascade');
40
+			$table->integer('course_id')->unsigned()->nullable();
41
+			$table
42
+				->foreign('course_id')
43
+				->references('id')
44
+				->on('courses')
45
+				->onDelete('cascade')
46
+				->onUpdate('cascade');
47
+			$table->tinyInteger('display_order');
48
+			$table->timestamps();
49
+		});
50
+
51
+		// DB::statement("ALTER TABLE typ_part_outcomes comment 'Outcomes for the annual plans of the three year plans'");
52
+	}
53
+
54
+	/**
55
+	 * Reverse the migrations.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function down()
60
+	{
61
+		Schema::drop('typ_part_outcomes');
62
+	}
63
+}

+ 50
- 0
app/database/migrations/2021_02_25_181424_typ_semesters.php Zobrazit soubor

@@ -0,0 +1,50 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class TypSemesters extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('typ_semesters', function(Blueprint $table)
16
+		{
17
+			// id unico
18
+			$table->increments('id')->unsigned();
19
+			// id del ciclo que pertenece
20
+			$table->integer('typ_id')->unsigned();
21
+			// semestre n
22
+			$table->integer('semester_id')->unsigned();
23
+			$table
24
+				->foreign('typ_id')
25
+				->references('id')
26
+				->on('three_year_plan')
27
+				->onDelete('cascade')
28
+				->onUpdate('cascade');
29
+			$table
30
+				->foreign('semester_id')
31
+				->references('id')
32
+				->on('semesters')
33
+				->onDelete('cascade')
34
+				->onUpdate('cascade');
35
+			$table->timestamps();
36
+		});
37
+	}
38
+
39
+	/**
40
+	 * Reverse the migrations.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public function down()
45
+	{
46
+		//
47
+		Schema::drop('typ_semesters');
48
+	}
49
+
50
+}

+ 1
- 0
app/database/migrations/2021_03_29_151147_create_Transformative_Actions.php Zobrazit soubor

@@ -22,6 +22,7 @@ class CreateTransformativeActions extends Migration
22 22
 			$table->integer('user_id')->unsigned()->nullable();
23 23
 			$table->integer('program_id')->unsigned()->nullable();
24 24
 			$table->text('at_text');
25
+			$table->text('description');
25 26
 			$table->boolean('by_professor');
26 27
 
27 28
 			$table->foreign('user_id')

+ 51
- 0
app/database/migrations/2021_03_29_151542_create_annual_report_transformative.php Zobrazit soubor

@@ -0,0 +1,51 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class CreateAnnualReportTransformative extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::create('annual_report_transformative', function (Blueprint $table) {
18
+			$table->increments('id');
19
+			$table->boolean('accomplished');
20
+			$table->integer('cycle_of_life');
21
+			$table->integer("semester_used")->unsigned();
22
+			$table->integer('semester_continue')->unsigned()->nullable();
23
+			$table->integer('trans_op_id')->unsigned();
24
+			$table->foreign('trans_op_id')
25
+				->references('id')
26
+				->on('transformative_objective_program')
27
+				->onDelete('cascade')
28
+				->onUpdate('cascade');
29
+			$table->foreign('semester_used')
30
+				->references('id')
31
+				->on('semesters')
32
+				->onDelete('cascade')
33
+				->onUpdate('cascade');
34
+			$table->foreign('semester_continue')
35
+				->references('id')
36
+				->on('semesters')
37
+				->onDelete('cascade')
38
+				->onUpdate('cascade');
39
+		});
40
+	}
41
+
42
+	/**
43
+	 * Reverse the migrations.
44
+	 *
45
+	 * @return void
46
+	 */
47
+	public function down()
48
+	{
49
+		Schema::drop('annual_report_transformative');
50
+	}
51
+}

+ 44
- 0
app/database/migrations/2021_04_25_194120_create_ta_course_table.php Zobrazit soubor

@@ -0,0 +1,44 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateTaCourseTable extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('ta_course', function (Blueprint $table) {
17
+			$table->increments('id');
18
+
19
+			$table->integer('ta_id')->unsigned();
20
+			$table->foreign('ta_id')
21
+				->references('id')
22
+				->on('transformative_actions')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+
26
+			$table->integer('course_id')->unsigned();
27
+			$table->foreign('course_id')
28
+				->references('id')
29
+				->on('courses')
30
+				->onDelete('cascade')
31
+				->onUpdate('cascade');
32
+		});
33
+	}
34
+
35
+	/**
36
+	 * Reverse the migrations.
37
+	 *
38
+	 * @return void
39
+	 */
40
+	public function down()
41
+	{
42
+		Schema::drop('ta_course');
43
+	}
44
+}

+ 49
- 2
app/routes.php Zobrazit soubor

@@ -53,7 +53,8 @@ View::composer(array(
53 53
     'local.managers.shared.program',
54 54
     'local.managers.shared.rubrics',
55 55
     'global.view-learning-outcomes-criteria',
56
-    'global.view-learning-outcomes-criteria'
56
+    'global.view-learning-outcomes-criteria',
57
+    'global.view-three-year-plan'
57 58
 ), function ($view) {
58 59
     $view->with('role', Auth::user()->role);
59 60
 });
@@ -186,6 +187,10 @@ Route::group(array('before' => 'auth|has_access'), function () {
186 187
         'as' => 'delete',
187 188
         'uses' => 'CriteriaController@delete'
188 189
     ));
190
+    Route::post('delete', array(
191
+        'as' => 'delete',
192
+        'uses' => 'TransformativeActionsController@deleteTA'
193
+    ));
189 194
     // Fetch a criterion for a rubric
190 195
     Route::post('fetchCriterionWithTrashed', array(
191 196
         'as' => 'fetchCriterionWithTrashed',
@@ -238,6 +243,14 @@ Route::group(array('before' => 'auth|has_access'), function () {
238 243
     Route::get('my-assessment-reports', 'OutcomesController@professorAssessmentReports');
239 244
     Route::post('objectives/fetch', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetch'));
240 245
 
246
+    // Transformative Actions for p-coordinators and professors
247
+    Route::get('transformativeAction', array('uses' => 'TransformativeActionsController@editTA'));
248
+    Route::post('transformativeAction/createTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@createTA'));
249
+    Route::post('transformativeAction/selectTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@selectTA'));
250
+    Route::post('transformativeAction/updateTA', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@updateTA'));
251
+    Route::post('transformativeAction/filterTA', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@filterTA'));
252
+    Route::post('transformativeAction/objectivesFromOutcome', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@objectivesFromOutcome'));
253
+
241 254
     /**
242 255
      * Administrator Routes
243 256
      */
@@ -258,7 +271,6 @@ Route::group(array('before' => 'auth|has_access'), function () {
258 271
 
259 272
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
260 273
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@update'));
261
-        Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
262 274
         Route::post('crtiteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));
263 275
         Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses' => 'CriteriaController@destroy'));
264 276
 
@@ -295,6 +307,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
295 307
         Route::get('school/{id}', 'SchoolsController@show');
296 308
         Route::get('program/{id}', 'ProgramsController@show');
297 309
         Route::post('programs/report', 'ProgramsController@showReport');
310
+        // Route::post('storeTypInfo', 'OutcomesController@storeCycleInfo'); //TODO: where is this route supposed to be placed?
298 311
         Route::get('programs', 'ProgramsController@index');
299 312
         Route::get('template-list', 'TemplatesController@schoolCoordinatorIndex');
300 313
         Route::post('deleteObjective', 'Objective2Controller@delete');
@@ -309,6 +322,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
309 322
         Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
310 323
         Route::get('school-objective', 'Objective2Controller@editSchool');
311 324
         Route::get('school-criteria', 'CriteriaController@editSchool');
325
+        //Show users annual plan
312 326
         Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
313 327
         Route::post('annual-plan-fetchTYP/{program_id}/{typ_id}', 'AnnualPlansController@fetchTYP');
314 328
         Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
@@ -319,6 +333,20 @@ Route::group(array('before' => 'auth|has_access'), function () {
319 333
         Route::post('annual-report-post', 'AnnualPlansController@postReport');
320 334
         Route::post('annual-plan-deleteTA', 'AnnualPlansController@deleteTA');
321 335
         Route::post('annual-plan-trans-report', 'AnnualPlansController@transformativeReport');
336
+
337
+
338
+        // Show users plan de tres a~nos
339
+        Route::get('three-years-plan', 'ThreeYearPlanController@threeYearsReport');
340
+        Route::post('fetchThreeYears', array('before' => 'csrf', 'uses'=>'ThreeYearPlanController@fetchThreeYears'));
341
+        Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
342
+        Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));
343
+        Route::post('section2_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_on_change'));
344
+        Route::post('section3_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_arrive'));
345
+        Route::post('section3_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_on_change'));
346
+        Route::post('typ/getObjectives', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@getObjectivesForTYP'));
347
+        Route::post('typ/updateOutcomeSemsters', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@typ_update_outcomes_semesters'));
348
+        Route::post('typ/update', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@update_typ_outcomes_semesters'));
349
+
322 350
     });
323 351
 
324 352
 
@@ -391,6 +419,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
391 419
         Route::get('new-report/{id}', 'OutcomesController@newReport');
392 420
         Route::get('new-report-all', 'OutcomesController@newReportAll');
393 421
         Route::get('courses/{id}', 'CoursesController@newShow');
422
+
394 423
         Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
395 424
         Route::post('annual-plan-fetchTYP/{program_id}', 'AnnualPlansController@fetchTYP');
396 425
         Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
@@ -408,6 +437,24 @@ Route::group(array('before' => 'auth|has_access'), function () {
408 437
         Route::post('annual-report-post', 'AnnualPlansController@postReport');
409 438
         Route::post('annual-plan-deleteTA', 'AnnualPlansController@deleteTA');
410 439
         Route::post('annual-plan-trans-report', 'AnnualPlansController@transformativeReport');
440
+
441
+
442
+        // Transformative Actions
443
+        Route::post('transformativeAction/approveTA', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@approveTA'));
444
+
445
+        // Show users plan de tres a~nos
446
+        Route::get('three-years-plan', 'ThreeYearPlanController@threeYearsReport');
447
+        Route::post('fetchThreeYears', array('before' => 'csrf', 'uses'=>'ThreeYearPlanController@fetchThreeYears'));
448
+        Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
449
+        Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));
450
+        Route::post('section2_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_on_change'));
451
+        Route::post('section3_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_arrive'));
452
+        Route::post('section3_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_on_change'));
453
+        Route::post('typ/getObjectives', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@getObjectivesForTYP'));
454
+        Route::post('typ/updateOutcomeSemsters', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@typ_update_outcomes_semesters'));
455
+        Route::post('typ/update', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@update_typ_outcomes_semesters'));
456
+
457
+
411 458
     });
412 459
 
413 460
 

+ 803
- 0
app/views/global/view-three-year-plan.blade.php Zobrazit soubor

@@ -0,0 +1,803 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if(Auth::user()->role==2)
5
+      @include('local.managers.sCoords._navigation')
6
+    @elseif(Auth::user()->role==3)
7
+      @include('local.managers.pCoords._navigation')
8
+    @endif
9
+@stop
10
+
11
+@section('main')
12
+  {{-- TODO: look where to place this script.
13
+          if placed inside .ready() or before it,
14
+            an error that the function is not defined occurs. --}}
15
+  {{-- TODO: no reconoce acentos --}}
16
+  <script type="text/javascript">
17
+    function filterCycles() {
18
+      // Declare variables
19
+      var input, filter, div, li, i, cycleText;
20
+      input = document.getElementById('userInput');
21
+      filter = input.value.toUpperCase();
22
+      div = document.getElementById("list");
23
+      li = div.getElementsByTagName('li');
24
+
25
+      // Loop through all list items, and hide those who don't match the search query
26
+      for (i = 0; i < li.length; i++) {
27
+        cycleText = li[i].textContent;
28
+        if (cycleText.toUpperCase().indexOf(filter) > -1) {
29
+          li[i].style.display = "";
30
+        } else {
31
+          li[i].style.display = "none";
32
+        }
33
+      }
34
+    }
35
+
36
+    // onChange, update selected outcomes-semesters
37
+    function update_outcome_semesters() {
38
+      var outcomeSemesterArray= new Array();
39
+      // For each learning outcome, get selected boxes and put it into an array
40
+      $('#outcome-semesters-body tr').each(function( index )
41
+      {
42
+          var outcomeObject = new Object();
43
+          outcomeObject.id= $(this).data('id');
44
+          var semesters = new Array();
45
+          var temp = new Array();
46
+          temp.push($(this).children(".sem1-box").find("input").attr('name'));
47
+          temp.push($(this).children(".sem1-box").find("input").prop("checked"));
48
+          semesters.push(temp);
49
+
50
+          temp = new Array();
51
+          temp.push($(this).children(".sem2-box").find("input").attr('name'));
52
+          temp.push($(this).children(".sem2-box").find("input").prop("checked"));
53
+          semesters.push(temp);
54
+
55
+          temp = new Array();
56
+          temp.push($(this).children(".sem3-box").find("input").attr('name'));
57
+          temp.push($(this).children(".sem3-box").find("input").prop("checked"));
58
+          semesters.push(temp);
59
+
60
+          temp = new Array();
61
+          temp.push($(this).children(".sem4-box").find("input").attr('name'));
62
+          temp.push($(this).children(".sem4-box").find("input").prop("checked"));
63
+          semesters.push(temp);
64
+
65
+          temp = new Array();
66
+          temp.push($(this).children(".sem5-box").find("input").attr('name'));
67
+          temp.push($(this).children(".sem5-box").find("input").prop("checked"));
68
+          semesters.push(temp);
69
+
70
+          temp = new Array();
71
+          temp.push($(this).children(".sem6-box").find("input").attr('name'));
72
+          temp.push($(this).children(".sem6-box").find("input").prop("checked"));
73
+          semesters.push(temp);
74
+
75
+          outcomeObject.semesters= semesters;
76
+
77
+          var clone = jQuery.extend({}, outcomeObject);
78
+          outcomeSemesterArray.push(clone);
79
+      });
80
+
81
+      var id = $('#table-cycles').data('typ-id');
82
+
83
+      $.post(
84
+          "{{ URL::action('ThreeYearPlanController@update_typ_outcomes_semesters') }}",
85
+          {
86
+            outcomeSemesterArray : JSON.stringify(outcomeSemesterArray),
87
+            typ_id: (id)
88
+          },
89
+          function(data)
90
+          {
91
+              //;
92
+          }
93
+      );
94
+    }
95
+
96
+  </script>
97
+
98
+  <div class="row">
99
+    <div class="col-md-3">
100
+      <input class="form-control" type="text" id="userInput" onkeyup="filterCycles()" placeholder="Search for Cycles..">
101
+      <div class="list-group" id='list'>
102
+        @foreach ($typs as $typ)
103
+          <li data-cycle-id="{{$typ->id}}" class="list-group-item">{{$typ->year_start}}-{{$typ->year_end}}</li>
104
+        @endforeach
105
+      </div>
106
+    </div>
107
+
108
+    <div class="col-md-9">
109
+      <div id="cycle-display" class="panel panel-default">
110
+        <div class="panel-heading">
111
+          <h4 class=" panel-title" style="cursor:auto!important;">
112
+          </h4>
113
+        </div>
114
+        <div class="panel-body" id="section1">
115
+          <p class="section1-description">Select two or more Semesters that will be evaluated by an Outcome.</p>
116
+            <div class="table-responsive">
117
+              {{-- <table class="table table-striped table-condensed datatable"> --}}
118
+              <table data-typ-id="0" class="table table-striped table-condensed" id="table-cycles">
119
+                <style media="screen">
120
+                  input[type=checkbox] {transform: scale(2);}
121
+                </style>
122
+                <thead>
123
+                  <tr style="background-color:#FDD8B5;">
124
+                    {{-- <th rowspan="0" style="background-color:#F5DEDD;" class="text-center">Dominios de aprendizaje</th> --}}
125
+                    <th rowspan="0" style="background-color:#F5DEDD;" class="text-center">Learning Outcomes</th>
126
+                    <th colspan="2" class="text-center" id="cycle1"></th>
127
+                    <th colspan="2" class="text-center" id="cycle2"></th>
128
+                    <th colspan="2" class="text-center" id="cycle3"></th>
129
+                  </tr>
130
+                  <tr class="">
131
+                    <th class="text-center">1er sem</th>
132
+                    <th class="text-center">2do sem</th>
133
+                    <th class="text-center">1er sem</th>
134
+                    <th class="text-center">2do sem</th>
135
+                    <th class="text-center">1er sem</th>
136
+                    <th class="text-center">2do sem</th>
137
+                  </tr>
138
+                </thead>
139
+                <tfoot>
140
+                </tfoot>
141
+                <input type="text" id="cycle_id" name="cycle_id" value="getsReplacedWithJS" hidden>
142
+                      {{-- <label for="profesores">Profesores (pares)</label> --}}
143
+                <tbody id="outcome-semesters-body" onchange="update_outcome_semesters()">
144
+                  @foreach ($outcomes as $outcome)
145
+                    <tr data-id="{{$outcome->id}}">
146
+                      <th>{{$outcome->name}}</th>
147
+                      <th class="text-center sem1-box"><input type="checkbox" id="{{$outcome->id}}-sem1" name="{{$outcome->id}}-sem1" value="checked" /></th>
148
+                      <th class="text-center sem2-box"><input type="checkbox" id="{{$outcome->id}}-sem2" name="{{$outcome->id}}-sem2" value="checked" /></th>
149
+                      <th class="text-center sem3-box"><input type="checkbox" id="{{$outcome->id}}-sem3" name="{{$outcome->id}}-sem3" value="checked" /></th>
150
+                      <th class="text-center sem4-box"><input type="checkbox" id="{{$outcome->id}}-sem4" name="{{$outcome->id}}-sem4" value="checked" /></th>
151
+                      <th class="text-center sem5-box"><input type="checkbox" id="{{$outcome->id}}-sem5" name="{{$outcome->id}}-sem5" value="checked" /></th>
152
+                      <th class="text-center sem6-box"><input type="checkbox" id="{{$outcome->id}}-sem6" name="{{$outcome->id}}-sem6" value="checked" /></th>
153
+                    </tr>
154
+                  @endforeach
155
+                </tbody>
156
+              </table>
157
+              <hr>
158
+              <div class="">
159
+                <button class="btn-lg btn-primary pull-right go-to-2" style="margin:5px;">Select Objectives</button>
160
+              </div>
161
+            </div>
162
+        </div>
163
+        <div class="panel-body" id="section2">
164
+          <p class="section2-description">Select one or more Objectives that will be evaluated in a given Semester.</p>
165
+            <div>
166
+              <div class="objectives-section-0">
167
+              </div>
168
+              <div class="objectives-section">
169
+              </div>
170
+            <hr>
171
+            <div class="">
172
+              <button class="btn-lg btn-primary pull-right go-to-3" style="margin:5px;">Go to Objectives Selection</button>
173
+              <button class="btn-lg btn-primary pull-right back-to-1" style="margin:5px;">Back to Semester Selection</button>
174
+            </div>
175
+            </div>
176
+        </div>
177
+        <div class="panel-body" id="section3">
178
+          <p class="section3-description">Select one or more Courses that will be evaluated by an Objective in a given Semester.</p>
179
+            <div>
180
+              <div class="courses-main-clone-0" hidden>
181
+                <div class="title-course-selection-0">
182
+                  <button class="btn btn-md btn-secondary pull-right hide-course-selection"><span class="glyphicon glyphicon-minus"></span> Hide Outcome Options</button>
183
+                  <button class="btn btn-md btn-secondary pull-right show-course-selection"><span class="glyphicon glyphicon-plus"></span> Show Outcome Options</button>
184
+                  <p class="h3" style="width:100%;max-width:80%;"><b>Outcome: example</b></p>
185
+                </div>
186
+                <div class="semester-course-selection-0" style="margin-left:30px;">
187
+                  <label class="semester-label-course-selection-0" for="">First Semester of 2000-2000</label>
188
+                  <div class="select-course-selection-0" style="margin-left:30px;">
189
+                    <div class="objective-selector-0">
190
+                      <label for="">OBJECTIVE TEMP</label>
191
+                      <select class="select-0" name="" style="width:100%;max-width:55%;">
192
+                        <option class="default-option" value="nothing_selected">Select a course</option>
193
+                      </select>
194
+                      <button class="btn btn-md btn-danger delete-selection-0" style="margin:5px;"><span class="glyphicon glyphicon-minus"></span> remove</button>
195
+                    </div>
196
+                    <div class="clone-objective-course-select-0">
197
+                      <button class="btn btn-md btn-secondary add-objective-course" style="margin:5px;"><span class="glyphicon glyphicon-plus"></span> Choose more Courses</button>
198
+                    </div>
199
+                  </div>
200
+                </div>
201
+                <div class="footer-course-selection-0" style="margin-left:30px;" hidden>
202
+                  <p><b>Course selection for this Outcome is currently hidden</b></p>
203
+                </div>
204
+              </div>
205
+              <div class="courses-section-0">
206
+              </div>
207
+              <div class="courses-section">
208
+              </div>
209
+            <hr>
210
+            <div class="">
211
+              <button class="btn-lg btn-primary pull-right go-to-temp" style="margin:5px;">Go to TYP evaluation page</button>
212
+              <button class="btn-lg btn-primary pull-right back-to-2" style="margin:5px;">Back to Objective Selection</button>
213
+            </div>
214
+            </div>
215
+        </div>
216
+      </div>
217
+    </div>
218
+    <div class="col-md-9">
219
+      <div class="no-cycle alert alert-info">
220
+        <p>Select a Three year cycle to start</p>
221
+      </div>
222
+    </div>
223
+
224
+  </div>
225
+@stop
226
+
227
+@section('included-js')
228
+    @include('global._datatables_js')
229
+@stop
230
+
231
+@section('javascript')
232
+
233
+$(document).ready(function()
234
+{
235
+  // --------------------------------------------------------------------------
236
+  // Page load
237
+  // --------------------------------------------------------------------------
238
+
239
+  // Hide accordion panel contents by default
240
+  var outcomes = {{json_encode($outcomes)}};
241
+
242
+  $('.panel-group .panel-body').hide();
243
+
244
+  $('#cycle-display').parent().hide();
245
+
246
+  $("#clonedOutcome0").hide();;
247
+
248
+  $('.show-course-selection').hide();
249
+
250
+  // --------------------------------------------------------------------------
251
+  // Functions
252
+  // --------------------------------------------------------------------------
253
+
254
+
255
+
256
+(function () {
257
+    var previous;
258
+    $("select").on('focus', function () {
259
+        // Store the current value on focus and on change
260
+        previous = this.value;
261
+    }).change(function() {
262
+
263
+      //comienzo
264
+      var options_values = $(this).parent().find('select').val().split('-');
265
+
266
+      //ifs
267
+      if (options_values.length == 3){
268
+
269
+        var typ_id = $('#table-cycles').data('typ-id');
270
+        var previous_objective_id = previous.split('-')[2];
271
+
272
+        var options_values =this.value.split('-');
273
+        var outcome_id = options_values[0];
274
+        var semester_id = options_values[1];
275
+        var new_objective_id = options_values[2];
276
+
277
+        if (new_objective_id == 'n'){
278
+          new_objective_id = 'nothing_selected';
279
+        }
280
+        if (previous_objective_id == 'n'){
281
+          previous_objective_id = 'nothing_selected';
282
+        }
283
+
284
+        $.post(
285
+        "{{ URL::action('ThreeYearPlanController@section2_on_change') }}",
286
+        {
287
+          typ_id: (typ_id),
288
+          previous_objective_id: (previous_objective_id),
289
+          outcome_id: (outcome_id),
290
+          semester_id: (semester_id),
291
+          new_objective_id: (new_objective_id)
292
+        },
293
+        function(data)
294
+        {
295
+          //
296
+        }
297
+        );
298
+        previous = this.value;
299
+
300
+      }
301
+      else if (options_values.length == 4){
302
+
303
+        var typ_id = $('#table-cycles').data('typ-id');
304
+        var previous_course_id = previous.split('-')[3];
305
+
306
+        var options_values =this.value.split('-');
307
+        var outcome_id = options_values[0];
308
+        var semester_id = options_values[1];
309
+        var objective_id = options_values[2];
310
+        var new_course_id = options_values[3];
311
+
312
+        if (new_course_id == 'n'){
313
+          new_course_id = 'nothing_selected';
314
+        }
315
+        if (previous_course_id == 'n'){
316
+          previous_course_id = 'nothing_selected';
317
+        }
318
+
319
+        $.post(
320
+        "{{ URL::action('ThreeYearPlanController@section3_on_change') }}",
321
+        {
322
+          typ_id: (typ_id),
323
+          previous_course_id: (previous_course_id),
324
+          outcome_id: (outcome_id),
325
+          semester_id: (semester_id),
326
+          objective_id: (objective_id),
327
+          new_course_id: (new_course_id)
328
+        },
329
+        function(data)
330
+        {
331
+          //
332
+        }
333
+        );
334
+        previous = this.value;
335
+
336
+      }
337
+    });
338
+})();
339
+
340
+
341
+  // --------------------------------------------------------------------------
342
+  // Events
343
+  // --------------------------------------------------------------------------
344
+
345
+
346
+
347
+    // When list item is clicked, load corresponding info
348
+    //section 1
349
+    $('.list-group-item').on('click', function()
350
+    {
351
+      var id = $(this).data('cycle-id');
352
+      $('#table-cycles').data('typ-id',id);
353
+      $('#section1').show();
354
+      $('#section2').hide();
355
+      $('#section3').hide();
356
+
357
+      var outcome_id_semester_code_program_id_box_id_typ_id = new Object();
358
+      var outcome_id_semester_code_program_id_box_id_typ_id = Array();
359
+
360
+      $.post(
361
+      "{{ URL::action('ThreeYearPlanController@fetchThreeYears') }}",
362
+      { id: id },
363
+      function(json)
364
+      {
365
+
366
+
367
+          // Retrieve datatable instance
368
+          var table = $('#table-cycles');
369
+
370
+          var typ = json.typ;
371
+          var year_start = json.typ.year_start;
372
+          var year_end = json.typ.year_end;
373
+          var semesters = json.typ.semesters;
374
+          var program_id = {{$program_id}};
375
+          //  var outcomes = already defined
376
+
377
+          $('#cycle-display').parent().show();
378
+          $('.no-cycle').parent().hide();
379
+
380
+          //Display title and definition
381
+          $('#cycle-display .panel-title').html('Planning for the years of ' + year_start + '-' + year_end);
382
+          $('#cycle-display .cycle-definition').html("Select the semesters which you would like to review an outcome in the three year plan of " + year_start + '-' + year_end+".");
383
+
384
+          //Empty table
385
+          //table.clear();
386
+
387
+          // Add new semesters
388
+          //if(typ.length>0)
389
+          //{
390
+          $('table').show();
391
+          $('#cycle1').html((year_start)+"-"+(year_start+1));
392
+          $('#cycle2').html((year_start+1)+"-"+(year_end-1));
393
+          $('#cycle3').html((year_end-1)+"-"+(year_end));
394
+
395
+          $('#cycle_id').val(typ.id);
396
+
397
+          //resets the checkboxes' name, clears marked, and disables them by default.
398
+          $.each(outcomes, function(index, outcome)
399
+          {
400
+            $.each([1,2,3,4,5,6], function(index, semester)
401
+            {
402
+              var id = outcome.id+"-sem"+semester;
403
+              var new_name = id;
404
+              document.getElementById(id).setAttribute("name", new_name);
405
+              $("#"+id).attr("disabled", true);
406
+              $("#"+id).prop("checked", false);
407
+            });
408
+          });
409
+
410
+
411
+          var i = 1;
412
+          $.each(outcomes, function(index, outcome)
413
+          {
414
+            $.each(semesters, function(index, semester)
415
+            {
416
+              var id = outcome.id+"-sem"+i;
417
+              var new_name = outcome.id+"-sem"+semester.code;
418
+
419
+              var checkbox = document.getElementById(id);
420
+              checkbox.setAttribute("name", new_name);
421
+
422
+              //enable the check box
423
+              $("#"+id).removeAttr("disabled");
424
+
425
+              //store checkboxes info in an array to later lookup which are marked
426
+              var temp = Array(outcome.id,semester.code,program_id, id, typ.id);
427
+              outcome_id_semester_code_program_id_box_id_typ_id.push(temp);
428
+              i++;
429
+            });
430
+            i = 1;
431
+          });
432
+
433
+          //search which boxes are marked in the data-base
434
+          $.post(
435
+            "{{ URL::action('ThreeYearPlanController@lookup_typ_semester_outcome'  ) }}",
436
+            {
437
+              info : (outcome_id_semester_code_program_id_box_id_typ_id)
438
+            },
439
+            function(data)
440
+            {
441
+              $.each(data.box_value, function(index, box_id_value)
442
+              {
443
+                var box_id = box_id_value[0];
444
+                var value = box_id_value[1];
445
+                if (1 == value) {
446
+                  $("#"+box_id).prop("checked", true);
447
+                }
448
+              });
449
+            }
450
+          );
451
+      },
452
+      'json'
453
+      );
454
+
455
+
456
+    });
457
+
458
+
459
+  });
460
+
461
+
462
+    // go back to section 1
463
+    $('.back-to-1').on('click', function(e)
464
+    {
465
+      window.scrollTo(0, 0);
466
+      $(".panel-body").hide();
467
+      $("#section1").show();
468
+    });
469
+
470
+
471
+    // go back to section 2
472
+    $('.back-to-2').on('click', function(e)
473
+    {
474
+      window.scrollTo(0, 0);
475
+      $(".panel-body").hide();
476
+      $("#section2").show();
477
+    });
478
+
479
+
480
+  // go to section 2
481
+  $('.go-to-2').on('click', function(e)
482
+  {
483
+    var not_enough = false;
484
+    var i = 0;
485
+    $('#table-cycles tbody tr').each(function() {
486
+      $(this).find('th').each(function() {
487
+        if ($(this).find('input').is(':checked')){
488
+          i = i + 1;
489
+        }
490
+      });
491
+
492
+      if (i < 2){
493
+        not_enough = true;
494
+      }
495
+      i = 0;
496
+    });
497
+
498
+    if (not_enough == true){
499
+      alert("Each Outcome must be evaluated in at least 2 semesters.");
500
+      return true;
501
+    }
502
+
503
+    $(".panel-body").hide();;
504
+    $("#section2").show();;
505
+
506
+    var typ_id = $('#table-cycles').data('typ-id');
507
+    $.post(
508
+        "{{ URL::action('ThreeYearPlanController@section2_arrive') }}",
509
+        {
510
+          typ_id: (typ_id)
511
+        },
512
+        function(data)
513
+        {
514
+          $('.objectives-section').empty();
515
+
516
+          $.each(data, function(index, outcome)
517
+          {
518
+            var outcome_name = outcome.name;
519
+            var outcome_id = outcome.id;
520
+            $('.objectives-section').append('<hr>');
521
+
522
+            var area = $('.courses-section-0').clone(true);
523
+            area.attr('class','');
524
+
525
+            var title = 'Outcome: ' + outcome_name;
526
+            var title_area = $('.title-course-selection-0').clone(true);
527
+            title_area.attr('class','title-course-selection h3');
528
+            title_area.find('p').html(title);
529
+
530
+            area.append(title_area);
531
+
532
+            $.each(outcome.selected_semesters, function(index, semester)
533
+            {
534
+                var semester_name = semester.name;
535
+                var semester_id = semester.semester_id;
536
+
537
+                var select_area = $('.semester-course-selection-0').clone(true);
538
+                select_area.attr('class','semester-course-selection');
539
+                select_area.attr('style',' ');
540
+                select_area.find('.semester-label-course-selection-0').html(semester_name+"'s Objectives");
541
+                var no_option = outcome_id+'-'+semester_id+'-n';
542
+                select_area.find('option').val(no_option).html('Select an Objective');
543
+                select_area.find('.add-objective-course').html('<span class="glyphicon glyphicon-plus"></span> Choose more Objectives');
544
+
545
+                if (semester.available_objectives.length != 0){
546
+                  select_area.find('.objective-selector-0 label').hide();
547
+                  $.each(semester.available_objectives, function(index, objective)
548
+                  {
549
+                    var objective_id = objective.id;
550
+                    var option_value = outcome_id+'-'+semester_id+'-'+objective_id;
551
+
552
+                    var option_name = objective.text;
553
+                    var new_option = select_area.find('.default-option').clone(true);
554
+                    new_option.html(option_name);
555
+                    new_option.val(option_value);
556
+                    new_option.attr('class','select_objective');
557
+
558
+                    select_area.find('select').append(new_option);
559
+                  });
560
+                }
561
+                if (semester.available_objectives.length == 0){
562
+                  select_area.find('select').prop('disabled', 'disabled');
563
+                  select_area.find('.objective-selector-0 label').html('There are no Objectives available for this Outcome and Semester combination');
564
+                  select_area.find('.objective-selector-0 select').hide();
565
+                  select_area.find('button').prop('disabled', 'disabled');
566
+                }
567
+                $.each(semester.selected_objectives, function(index, objective)
568
+                {
569
+                  select_area.find('.objective-selector-0').hide();
570
+                  //si hay objetivos previamente seleccionados, escribirlos
571
+                  var objective_id = objective.id;
572
+                  var option_value = outcome_id+'-'+semester_id+'-'+objective_id;
573
+                  var new_select = select_area.find('.objective-selector-0').clone(true);
574
+                  new_select.attr('class','objective-selector');
575
+                  new_select.find('select').val(option_value);
576
+                  select_area.find('.clone-objective-course-select-0').before(new_select);
577
+                  select_area.find('.objective-selector').show();
578
+                });
579
+                area.append(select_area);
580
+            });
581
+            var footer = $('.footer-course-selection-0').clone(true);
582
+            footer.attr('class','footer-course-selection');
583
+            footer.find('p').html('<b>Objective selection for this Outcome is currently hidden.</b>');
584
+            area.append(footer);
585
+
586
+            area.append('<br>');
587
+            area.show(true);
588
+            $('.objectives-section').append(area);
589
+          });
590
+        }
591
+    );
592
+  });
593
+
594
+
595
+
596
+    // hide the options of an outcome in section 2 and 3
597
+    $('.hide-course-selection').on('click', function(e)
598
+    {
599
+      $(this).parent().find('.show-course-selection').show();;
600
+      $(this).hide();;
601
+      $(this).parent().parent().find('.semester-course-selection').hide(333);
602
+      $(this).parent().parent().find('.footer-course-selection').show(333);
603
+    });
604
+
605
+    // show the options of an outcome in section 2 and 3
606
+    $('.show-course-selection').on('click', function(e)
607
+    {
608
+      $(this).parent().find('.hide-course-selection').show();
609
+      $(this).hide();
610
+      $(this).parent().parent().find('.semester-course-selection').show(333);
611
+      $(this).parent().parent().find('.footer-course-selection').hide(333);
612
+    });
613
+
614
+
615
+    // in section 2 and 3, add selects for choosing more objectives and courses, respectively
616
+    $('.add-objective-course').on('click', function(e)
617
+    {
618
+      var new_select = $(this).parent().parent().find('.objective-selector-0').clone(true);
619
+      new_select.attr('class','objective-selector');
620
+      new_select.show();
621
+      $(this).parent().before(new_select);
622
+    });
623
+
624
+
625
+  // go to section 3
626
+  $('.go-to-3').on('click', function(e)
627
+  {
628
+    window.scrollTo(0, 0);
629
+    $(".panel-body").hide();;
630
+    $("#section3").show();;
631
+
632
+    var typ_id = $('#table-cycles').data('typ-id');
633
+    $.post(
634
+        "{{ URL::action('ThreeYearPlanController@section3_arrive') }}",
635
+        {
636
+          typ_id: (typ_id)
637
+        },
638
+        function(data)
639
+        {
640
+          $('.courses-section').empty();
641
+
642
+          $.each(data, function(index, outcome)
643
+          {
644
+            var outcome_name = outcome.name;
645
+            var outcome_id = outcome.id;
646
+            $('.courses-section').append('<hr>');
647
+
648
+            var area = $('.courses-section-0').clone(true);
649
+            area.attr('class','');
650
+
651
+            var title = 'Outcome: ' + outcome_name;
652
+            var title_area = $('.title-course-selection-0').clone(true);
653
+            title_area.attr('class','title-course-selection h3');
654
+            title_area.find('p').html(title);
655
+
656
+            area.append(title_area);
657
+
658
+            $.each(outcome.selected_semesters, function(index, semester)
659
+            {
660
+                var semester_name = semester.name;
661
+                var semester_id = semester.semester_id;
662
+
663
+                var select_area = $('.semester-course-selection-0').clone(true);
664
+                select_area.attr('class','semester-course-selection');
665
+                select_area.attr('style',' ');
666
+                select_area.find('.semester-label-course-selection-0').html(semester_name);
667
+
668
+
669
+                $.each(semester.selected_objectives, function(index, objective)
670
+                {
671
+                    var objective_id = objective.objective_id;
672
+                    var objective_text = objective.text;
673
+                    var new_select = select_area.find('.select-course-selection-0').clone(true);
674
+                    new_select.attr('class','select-course-selection');
675
+                    new_select.find('label').html('');
676
+                    new_select.find('.objective-selector-0').before('<p>Objective: <b>'+objective_text+'</b></p>');
677
+                    {{-- new_select.find('.objective-selector-0 select').attr('style','width:100%;max-width:25%;'); --}}
678
+                    $.each(objective.available_courses, function(index, course)
679
+                    {
680
+                      var course_id = course.course_id;
681
+
682
+                      var option_value = outcome_id+'-'+semester_id+'-'+objective_id+'-'+course_id;
683
+
684
+                      var option_name = '['+course.code+'] '+course.name;
685
+
686
+                      var new_option = new_select.find('.default-option').clone(true);
687
+                      new_option.html(option_name);
688
+                      new_option.val(option_value);
689
+                      new_option.attr('class','select_course');
690
+                      new_select.find('select').append(new_option);
691
+
692
+                    });
693
+                    if (objective.available_courses.length == 0){
694
+                      new_select.find('.select-course-selection-0').hide();
695
+                      new_select.find('select').prop('disabled', 'disabled');
696
+                      new_select.find('select label').html(' Objective "'+objective_text+'" has no courses available for selection');
697
+                      new_select.find('button').prop('disabled', 'disabled');
698
+                    }
699
+                    $.each(objective.selected_courses, function(index, course)
700
+                    {
701
+                      new_select.find('.objective-selector-0').hide();
702
+                      //si hay objetivos previamente seleccionados, escribirlos
703
+                      var course_id = course.course_id;
704
+                      var option_value = outcome_id+'-'+semester_id+'-'+objective_id+'-'+course_id;
705
+
706
+                      var new_selected_course = new_select.find('.objective-selector-0').clone(true);
707
+                      new_selected_course.attr('class','objective-selector');
708
+                      new_selected_course.find('select').val(option_value);
709
+                      {{-- new_selected_course.find('label').html(''); --}}
710
+                      new_selected_course.show();
711
+                      new_select.find('.clone-objective-course-select-0').before(new_selected_course);
712
+                    });
713
+                    select_area.find('.select-course-selection-0').after(new_select);
714
+                });
715
+                if (semester.selected_objectives.length != 0){
716
+                  select_area.find('.select-course-selection-0').hide();
717
+                }
718
+                else{
719
+                  select_area.find('select').prop('disabled', 'disabled');
720
+                  select_area.find('.objective-selector-0').html('There are no objectives selected for this semester');
721
+                  select_area.find('button').prop('disabled', 'disabled');
722
+                }
723
+                area.append(select_area);
724
+            });
725
+            var footer = $('.footer-course-selection-0').clone(true);
726
+            footer.attr('class','footer-course-selection');
727
+            area.append(footer);
728
+
729
+            area.append('<br>');
730
+            area.show(true);
731
+            $('.courses-section').append(area);
732
+          });
733
+        }
734
+    );
735
+  });
736
+
737
+
738
+  // remove an
739
+  $('.delete-selection-0').on('click', function(e)
740
+  {
741
+    var options_values = $(this).parent().find('select').val().split('-');
742
+
743
+    if (options_values.length == 3){
744
+      var typ_id = $('#table-cycles').data('typ-id');
745
+      var outcome_id = options_values[0];
746
+      var semester_id = options_values[1];
747
+      var new_objective_id = "nothing_selected";
748
+
749
+      var previous_objective_id = options_values[2];
750
+      if (previous_objective_id == 'n'){
751
+        previous_objective_id = "nothing_selected";
752
+        // with the next return, the post shouldnt excecute.
753
+        //  im leaving the assignment in the line before this one just in case.
754
+        $(this).parent().hide();;
755
+        return true;
756
+      }
757
+
758
+      $.post(
759
+        "{{ URL::action('ThreeYearPlanController@section2_on_change') }}",
760
+        {
761
+          typ_id: (typ_id),
762
+          previous_objective_id: (previous_objective_id),
763
+          outcome_id: (outcome_id),
764
+          semester_id: (semester_id),
765
+          new_objective_id: (new_objective_id)
766
+        },
767
+        function(data)
768
+        {
769
+          //
770
+        }
771
+      );
772
+    }
773
+    else if (options_values.length == 4){
774
+
775
+      var typ_id = $('#table-cycles').data('typ-id');
776
+      var outcome_id = options_values[0];
777
+      var semester_id = options_values[1];
778
+      var objective_id = options_values[2];
779
+      var previous_course_id = options_values[3];
780
+      var new_course_id = 'nothing_selected';
781
+
782
+      $.post(
783
+        "{{ URL::action('ThreeYearPlanController@section3_on_change') }}",
784
+        {
785
+          typ_id: (typ_id),
786
+          previous_course_id: (previous_course_id),
787
+          outcome_id: (outcome_id),
788
+          semester_id: (semester_id),
789
+          objective_id: (objective_id),
790
+          new_course_id: (new_course_id)
791
+        },
792
+        function(data)
793
+        {
794
+          //
795
+        }
796
+      );
797
+    }
798
+
799
+    $(this).parent().hide();;
800
+  });
801
+
802
+
803
+@stop

+ 2
- 0
app/views/local/managers/admins/_navigation.blade.php Zobrazit soubor

@@ -3,6 +3,8 @@
3 3
 
4 4
     <ul class="nav navbar-nav navbar-right">
5 5
       <li>{{ HTML::linkAction('AdministratorsController@overview', 'Overview') }}</li>
6
+      <li>{{ HTML::linkAction('ThreeYearPlanController@threeYearsReport', 'Three Years Plan') }}</li>
7
+      <li>{{ HTML::linkAction('TransformativeActionsController@editTA', 'Transformative Actions') }}</li>
6 8
 
7 9
       <li class="dropdown">
8 10
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Management<span class="caret"></span></a>

+ 891
- 0
app/views/local/managers/admins/transformativeAction.blade.php Zobrazit soubor

@@ -0,0 +1,891 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if($role==2)
5
+        @include('local.managers.sCoords._navigation')
6
+    @elseif($role==3)
7
+        @include('local.managers.pCoords._navigation')
8
+    @else
9
+        @include('local.professors._navigation')
10
+    @endif
11
+@stop
12
+@section('main')
13
+
14
+<div class="row">
15
+    <div class="col-md-6">
16
+        <!-- Form to add a new criterion -->
17
+        <div class="panel panel-default panel-button">
18
+            <div class="panel-heading">
19
+                Create a TA
20
+            </div>
21
+            <div class="panel-body" id="createPanel">
22
+              {{ Form::open(array('action' => 'TransformativeActionsController@createTA')) }}
23
+
24
+              <div class="form-group">
25
+                {{ Form::label('text', 'Name') }}
26
+                {{ Form::text('text', '', array('class' => 'form-control')) }}
27
+              </div>
28
+
29
+              <div class="form-group">
30
+                {{ Form::label('description', 'Description') }}
31
+                {{ Form::textarea('description', '', array('class' => 'form-control')) }}
32
+              </div>
33
+
34
+              <div class="form-group"> </div>
35
+              <div class="form-group" id='dummyApproval'>
36
+                <label>Availability</label>
37
+                <select name="approval" class="form-control">
38
+                  <option value="1">Recommended</option>
39
+                  <option value="0">To be implemented</option>
40
+                </select>
41
+              </div>
42
+
43
+              <label>Courses being Transformed by the Action</label>
44
+              <div class="" id="">
45
+                <div class="form-group col-md-11">
46
+                  <select name="courseid[]" class="form-control createCourses selectpicker">
47
+                    @foreach ($courses_create as $course)
48
+                      <option value="{{$course->id}}">{{$course->name}} [{{$course->code}}]</option>
49
+                    @endforeach
50
+                  </select>
51
+                </div>
52
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
53
+                  X
54
+                </button>
55
+              </div>
56
+              <button type="button" class='btn btn-md btn-secondary add-course'>
57
+                <span class='glyphicon glyphicon-plus'>
58
+                </span>
59
+                Add another Course
60
+              </button>
61
+              <div class="form-group"> </div>
62
+
63
+              <div class="form-group" id='createOutcome'>
64
+                <label>Outcome perteneciente</label>
65
+                <select name="outcome" class="form-control selectpicker">
66
+                  @foreach ($outcomes as $outcome)
67
+                    <option value="{{$outcome->id}}">{{$outcome->name}}</option>
68
+                  @endforeach
69
+                </select>
70
+              </div>
71
+
72
+              <label>Associated Objectives</label>
73
+              <div class="" id="">
74
+                <div class="form-group col-md-11">
75
+                  <select name="objectiveid[]" class="form-control createObjectives">
76
+                    <option value="">First, select an Outcome</option>
77
+                  </select>
78
+                </div>
79
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
80
+                  X
81
+                </button>
82
+              </div>
83
+              <button type="button" class='btn btn-md btn-secondary add-objective'>
84
+                <span class='glyphicon glyphicon-plus'>
85
+                </span>
86
+                Add another Objective
87
+              </button>
88
+              <div class="form-group"> </div>
89
+
90
+              {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
91
+              {{ Form::close() }}
92
+            </div>
93
+        </div>
94
+        <div class="panel panel-default panel-button">
95
+            <div class="panel-heading">
96
+                Approve a Recommended TA
97
+            </div>
98
+            <div class="panel-body" id="approvePanel">
99
+
100
+              <div class="">
101
+                <button class="btn btn-md btn-secondary filterButton">
102
+                  <span class="glyphicon glyphicon-plus">
103
+                  </span>
104
+                  Filters
105
+                </button>
106
+              </div>
107
+              <div class="filterSection">
108
+                <br>
109
+                <div class="">
110
+                  <div class="">
111
+                    <label>Professor that created the TA</label>
112
+                    <select class="form-control filterProfessor selectpicker">
113
+                      <option value="0">Show All</option>
114
+                      @foreach ($professor_filter_approvePanel as $ta)
115
+                        <option value="{{$ta->id}}">Prof. {{$ta->first_name}} {{$ta->surnames}}</option>
116
+                      @endforeach
117
+                    </select>
118
+                  </div>
119
+                  <br>
120
+                  <div class="">
121
+                    <label>Course evaluated by an Objective of the TA</label>
122
+                    <select class="form-control filterCourse selectpicker">
123
+                      <option value="0">Show All</option>
124
+                      @foreach ($course_filter_approvePanel as $course)
125
+                        <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
126
+                      @endforeach
127
+                    </select>
128
+                  </div>
129
+                  <br>
130
+                  <div class="">
131
+                    <label>Outcome of the TA</label>
132
+                    <select class="form-control filterOutcome selectpicker">
133
+                      <option value="0">Show All</option>
134
+                      @foreach ($outcome_filter_approvePanel as $outcome)
135
+                        <option value="{{$outcome->id}}">{{$outcome->name}}</option>
136
+                      @endforeach
137
+                    </select>
138
+                  </div>
139
+                </div>
140
+              </div>
141
+              <hr>
142
+              {{ Form::open(array('action' => 'TransformativeActionsController@approveTA')) }}
143
+
144
+              <div>
145
+                <div class="form-group col-md-11">
146
+                  <label>Select Transformative Action</label>
147
+                  <select name="ta" class="form-control SelectTA selectpicker" id='approvalSelectTA'>
148
+                    @if (count($ta_approval_panel) == 0)
149
+                      <option value="0">No TAs available</option>
150
+                    @else
151
+                    @endif
152
+                    @foreach ($ta_approval_panel as $ta)
153
+                      <option value="{{$ta->id}}">{{$ta->at_text}}</option>
154
+                   @endforeach
155
+                  </select>
156
+                </div>
157
+              </div>
158
+
159
+              <div class="form-group">
160
+                {{ Form::label('approvalDescription', 'Description') }}
161
+                {{ Form::textarea('approvalDescription', '', array('class' => 'form-control')) }}
162
+              </div>
163
+
164
+              <label>Associated Courses</label>
165
+              <div class="approveCourses">
166
+                <div class="form-group col-md-11 approveCourse">
167
+                  <select name="courseid[]" class="form-control selectpicker">
168
+                      <option value="">option</option>
169
+                  </select>
170
+                </div>
171
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
172
+                  X
173
+                </button>
174
+              </div>
175
+              <button type="button" class='btn btn-md btn-secondary add-course'>
176
+                <span class='glyphicon glyphicon-plus'>
177
+                </span>
178
+                Add another Course
179
+              </button>
180
+
181
+              <label>Associated Objectives</label>
182
+              <div class="approveObjectives">
183
+                <div class="form-group col-md-11">
184
+                  <select name="objectiveid[]" class="form-control">
185
+                    @foreach ($objectives as $id => $text)
186
+                      <option value="{{$id}}">{{$text}}</option>
187
+                    @endforeach
188
+                  </select>
189
+                </div>
190
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
191
+                  X
192
+                </button>
193
+              </div>
194
+              <button type="button" class='btn btn-md btn-secondary add-objective'>
195
+                <span class='glyphicon glyphicon-plus'>
196
+                </span>
197
+                Add another Objective
198
+              </button>
199
+
200
+              <input type='hidden' name='at_text' class="approvalText">
201
+
202
+              <input type='hidden' name='ta_id' class='updateTA'>
203
+
204
+              {{ Form::submit('Approve', array('class' => 'btn btn-primary btn-block')) }}
205
+              {{ Form::close() }}
206
+            </div>
207
+        </div>
208
+    </div>
209
+
210
+    <div class="col-md-6">
211
+        <div class="panel panel-default panel-button">
212
+            <div class="panel-heading">
213
+                Edit a TA
214
+            </div>
215
+            <div class="panel-body" id="editPanel">
216
+
217
+              <div class="">
218
+                <button class="btn btn-md btn-secondary filterButton">
219
+                  <span class="glyphicon glyphicon-plus">
220
+                  </span>
221
+                  Filters
222
+                </button>
223
+              </div>
224
+              <div class="filterSection">
225
+                <br>
226
+                <div class="">
227
+                  <div class="">
228
+                    <label>Professor that created the TA</label>
229
+                    <select class="form-control filterProfessor selectpicker">
230
+                      <option value="0">Show All</option>
231
+                      @foreach ($professor_filter_editPanel as $user)
232
+                        <option value="{{$user->id}}">Prof. {{$user->first_name}} {{$user->surnames}}</option>
233
+                      @endforeach
234
+                    </select>
235
+                  </div>
236
+                  <br>
237
+                  <div class="">
238
+                    <label>Course evaluated by an Objective of the TA</label>
239
+                    <select class="form-control filterCourse selectpicker">
240
+                      <option value="0">Show All</option>
241
+                      @foreach ($course_filter_editPanel as $course)
242
+                        <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
243
+                      @endforeach
244
+                    </select>
245
+                  </div>
246
+                  <br>
247
+                  <div class="">
248
+                    <label>Outcome of the TA</label>
249
+                    <select class="form-control filterOutcome selectpicker">
250
+                      <option value="0">Show All</option>
251
+                      @foreach ($outcome_filter_editPanel as $outcome)
252
+                        <option value="{{$outcome->id}}">{{$outcome->name}}</option>
253
+                      @endforeach
254
+                    </select>
255
+                  </div>
256
+                </div>
257
+              </div>
258
+              <hr>
259
+
260
+              {{ Form::open(array('action' => 'TransformativeActionsController@updateTA')) }}
261
+
262
+              <div>
263
+                <div class="form-group col-md-12">
264
+                  <label>Select Transformative Action</label>
265
+                  <select name="ta" class="form-control SelectTA selectpicker" id='editSelectTA'>
266
+                     @if (count($ta_edit_panel) == 0)
267
+                       <option value="0">No TAs available</option>
268
+                     @else
269
+                     @endif
270
+                     @foreach ($ta_edit_panel as $ta)
271
+                      <option value="{{$ta->id}}">{{$ta->at_text}}</option>
272
+                    @endforeach
273
+                  </select>
274
+                </div>
275
+              </div>
276
+
277
+              <div class="form-group" id="editName">
278
+                {{ Form::label('text', 'Name') }}
279
+                {{ Form::text('text', '', array('class' => 'form-control')) }}
280
+              </div>
281
+              <input type='hidden' name='ta_id' class='updateTA' value="0">
282
+
283
+              <div class="form-group">
284
+                {{ Form::label('description', 'Description') }}
285
+                {{ Form::textarea('description', '', array('class' => 'form-control')) }}
286
+              </div>
287
+
288
+              <div class="form-group"> </div>
289
+              <div class="form-group" id='editApproval'>
290
+                <label>Availability</label>
291
+                <select name="approval" class="form-control selectpicker">
292
+                    <option value="1">Recommended</option>
293
+                    <option value="0">To be implemented</option>
294
+                </select>
295
+              </div>
296
+
297
+              <label>Associated Courses</label>
298
+              <div class="editCourses">
299
+                <div class="form-group col-md-11 editCourse">
300
+                  <select name="courseid[]" class="form-control selectpicker">
301
+                    @foreach ($courses_create as $course)
302
+                      <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
303
+                    @endforeach
304
+                  </select>
305
+                </div>
306
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
307
+                  X
308
+                </button>
309
+              </div>
310
+              <button type="button" class='btn btn-md btn-secondary add-course'>
311
+                <span class='glyphicon glyphicon-plus'>
312
+                </span>
313
+                Add another Course
314
+              </button>
315
+              <div class="form-group"> </div>
316
+
317
+              <label>Associated Objectives</label>
318
+              <div class="editObjectives">
319
+                <div class="form-group col-md-11">
320
+                  {{-- <select class="form-control selectpicker"> --}}
321
+                  <select name="objectiveid[]" class="form-control">
322
+                    @foreach ($objectives as $id => $text)
323
+                      <option value="{{$id}}">{{$text}}</option>
324
+                    @endforeach
325
+                  </select>
326
+                </div>
327
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
328
+                  X
329
+                </button>
330
+              </div>
331
+              <button type="button" class='btn btn-md btn-secondary add-objective'>
332
+                <span class='glyphicon glyphicon-plus'>
333
+                </span>
334
+                Add another Objective
335
+              </button>
336
+              <div class="form-group"> </div>
337
+
338
+              {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
339
+              {{ Form::close() }}
340
+
341
+              {{ Form::open(array('action' => 'TransformativeActionsController@deleteTA')) }}
342
+              <input type='hidden' name='ta_id' id='deleteTA'>
343
+              {{Form::submit("Delete", array('class'=> 'btn btn-primary btn-block', 'id'=>"DeleteButton"))}}
344
+            </div>
345
+        </div>
346
+    </div>
347
+</div>
348
+
349
+@stop
350
+
351
+@section('javascript')
352
+
353
+// --------------------------------------------------------------------------
354
+// Page load
355
+// --------------------------------------------------------------------------
356
+
357
+// Hide accordion panel contents by default
358
+$('.panel-group .panel-body').hide();
359
+
360
+$('#outcome-display').parent().hide();
361
+
362
+$('.remove-objective').hide();
363
+$('.remove-course').hide();
364
+
365
+////createPanel
366
+// remove TA approval section if the user isnt a program coordinator
367
+var dummyApproval = $('#dummyApproval');
368
+dummyApproval.find('select').prop('disabled', 'disabled');
369
+dummyApproval.find('option').remove();
370
+
371
+
372
+var role = {{Auth::user()['role']}};
373
+if (role == 3){
374
+  dummyApproval.find('select').append('<option value="0">To be implemented</option>');
375
+  $('#approvePanel .add-course').hide();
376
+} else if (role == 4){
377
+  dummyApproval.find('select').append('<option value="1">Recommended</option>');
378
+  $('#approvePanel').parent().hide();
379
+
380
+  //hide the select for changin Availability
381
+  $('#editApproval').find('select').prop('disabled', 'disabled');
382
+  //add an input since disabled the form wont recognize it
383
+  $('#editApproval').append('<input type="text" name="approval" value="1" hidden />')
384
+
385
+  // in edit panel, hide the professor filter
386
+  $('.filterProfessor').parent().hide();
387
+  $('.filterProfessor').parent().next().hide(); // hide <br>
388
+}
389
+
390
+$('.createObjectives').prop('disabled', 'disabled');
391
+$('#createPanel .add-objective').prop('disabled', 'disabled');
392
+
393
+
394
+////editPanel
395
+// disable the buttons of the edit section if there are no TA for selection
396
+if(($('#editSelectTA').val() === "")){
397
+  $('#editPanel').find('select').prop('disabled', 'disabled');
398
+  $('#editPanel').find('button').prop('disabled', 'disabled');
399
+  $('#editPanel').find('input').prop('disabled', 'disabled');
400
+}else{
401
+  var ta_id = $('#editSelectTA').val();
402
+  if(ta_id != 0){
403
+    load_ta_info_for_edit(ta_id);
404
+  }
405
+
406
+
407
+}
408
+
409
+////approvePanel
410
+$('#approvePanel .add-objective').hide();
411
+// disable the buttons of the approval section if there are no TA for selection
412
+if(($('#approvalSelectTA').val() === "")){
413
+  $('#approvePanel').find('select').prop('disabled', 'disabled');
414
+  $('#approvePanel').find('button').prop('disabled', 'disabled');
415
+  $('#approvePanel').find('input').prop('disabled', 'disabled');
416
+  $('#approvalDescription').prop('disabled', 'disabled');
417
+}else{
418
+  var ta_id = $('#approvalSelectTA').val();
419
+  if(ta_id != 0){
420
+    load_ta_info_for_approval(ta_id);
421
+  }
422
+
423
+}
424
+
425
+//
426
+$('.filterSection').hide();
427
+
428
+// --------------------------------------------------------------------------
429
+// Functions
430
+// --------------------------------------------------------------------------
431
+
432
+function load_objectives_from_outcome(outcome_id) {
433
+  $.post(
434
+    "{{ URL::action('TransformativeActionsController@objectivesFromOutcome') }}",
435
+    {
436
+      outcome_id: (outcome_id),
437
+    },
438
+    function(data)
439
+    {
440
+      var panel = $('#createPanel');
441
+
442
+      //
443
+      var objectives = data.objectives;
444
+      //delete al current select
445
+      panel.find('.remove-objective').parent().remove();
446
+
447
+      //create select
448
+      var new_div = $('<div/>',{
449
+        'class': 'createObjectives'
450
+      });
451
+      var new_inner_div = $('<div/>',{
452
+        'class': 'form-group col-md-11'
453
+      });
454
+      var new_select = $('<select/>',{
455
+        'class': 'form-control createObjectives selectpicker',
456
+        'data-live-search': 'true',
457
+        'name': 'objectiveid[]'
458
+      });
459
+      var new_button = $('<button/>',{
460
+        'class': 'btn btn-md btn-primary col-md-1 remove-objective',
461
+        'type': 'button',
462
+        'html': 'X'
463
+      });
464
+      new_button.hide();
465
+
466
+      $.each(objectives, function(index, objective)
467
+      {
468
+        new_select.append('<option value="'+ objective.id +'">'+ objective.text +'</option>');
469
+      });
470
+
471
+      panel.find('.add-objective').before(new_div);
472
+      new_div.append(new_button);
473
+      new_div.append(new_inner_div);
474
+      new_inner_div.append(new_select);
475
+      new_select.selectpicker('refresh');
476
+
477
+      //activate the button for adding more objectives
478
+      $('#createPanel .add-objective').prop('disabled', false);
479
+    }
480
+  );
481
+}
482
+
483
+function load_ta_info_for_edit(ta_id) {
484
+  $.post(
485
+    "{{ URL::action('TransformativeActionsController@selectTA') }}",
486
+    {
487
+      ta_id: (ta_id),
488
+    },
489
+    function(data)
490
+    {
491
+      //
492
+      var selected_courses = data.selected_courses;
493
+      var objectives = data.objectives;
494
+      var objectives_from_outcome = data.objectives_from_outcome;
495
+      var status = data.status;
496
+      var name = data.name[0];
497
+      var description = data.description[0];
498
+      var can_be_deleted = data.can_be_deleted;
499
+
500
+      //add objectives button
501
+      var add_button = $('#editPanel .add-objective');
502
+
503
+      //set if the TA is approved or not
504
+      $('#editApproval select').val(status);
505
+
506
+      //delete objectives select
507
+      $('.editObjectives').remove();
508
+
509
+      //create one objective select and populate it
510
+      var panel = $('#editPanel');
511
+
512
+      //
513
+      var objectives = data.objectives;
514
+      //delete al current select
515
+      panel.find('.remove-objective').parent().remove();
516
+
517
+      //create select
518
+      var new_div = $('<div/>',{
519
+        'class': 'editObjectives'
520
+      });
521
+      var new_inner_div = $('<div/>',{
522
+        'class': 'form-group col-md-11'
523
+      });
524
+      var new_select = $('<select/>',{
525
+        'class': 'form-control editObjectives selectpicker',
526
+        'data-live-search': 'true',
527
+        'name': 'objectiveid[]'
528
+      });
529
+      var new_button = $('<button/>',{
530
+        'class': 'btn btn-md btn-primary col-md-1 remove-objective',
531
+        'type': 'button',
532
+        'html': 'X'
533
+      });
534
+      new_button.hide();
535
+
536
+      $.each(objectives_from_outcome, function(index, objective)
537
+      {
538
+        new_select.append('<option value="'+ objective.id +'">'+ objective.text +'</option>');
539
+      });
540
+
541
+      panel.find('.add-objective').before(new_div);
542
+      new_div.append(new_button);
543
+      new_div.append(new_inner_div);
544
+      new_inner_div.append(new_select);
545
+      new_select.selectpicker('refresh');
546
+
547
+
548
+      //change de value of the select
549
+
550
+      //add the other selects
551
+
552
+      var prev_select = new_div;
553
+      $.each(objectives, function(index, objective)
554
+      {
555
+        prev_select.find('select').val(objective.id);
556
+        add_objective_select(add_button);
557
+        {{-- add_button; --}}
558
+        prev_select = add_button.prev();
559
+
560
+      });
561
+      add_button.prev().remove();
562
+
563
+      //set the text box
564
+      $('#editName').find('input').val(name);
565
+      $('#editPanel #description').val(description);
566
+
567
+      //
568
+      $('#deleteTA').val(ta_id);
569
+      $('#editPanel .updateTA').val(ta_id);
570
+
571
+      if(can_be_deleted == false){
572
+        $('#DeleteButton').prop('disabled', 'disabled');
573
+      }else{
574
+        $('#DeleteButton').prop('disabled', false);
575
+      }
576
+
577
+
578
+      //locate de "add course" button on edit panel
579
+      var add_course_button = $('#editPanel .add-course')
580
+
581
+      //save current course selectpickers, add a new one, and delete old ones
582
+      var current_course_selects = $('#editPanel .editCourse');
583
+      add_course_button.click();
584
+      current_course_selects.remove();
585
+
586
+      //populate edit panel with courses previusly selected
587
+      var prev_select = add_course_button.prev();
588
+      prev_select.find('.remove-course').hide();
589
+      $.each(selected_courses, function(index, course)
590
+      {
591
+        prev_select.find('select').val(course.id);
592
+        add_course_button.click();
593
+        prev_select = add_course_button.prev();
594
+      });
595
+      prev_select.remove();
596
+
597
+    }
598
+  );
599
+}
600
+
601
+function load_ta_info_for_approval(ta_id) {
602
+  $.post(
603
+    "{{ URL::action('TransformativeActionsController@selectTA') }}",
604
+    {
605
+      ta_id: (ta_id),
606
+    },
607
+    function(data)
608
+    {
609
+      //
610
+      var selected_courses = data.selected_courses;
611
+      var objectives = data.objectives;
612
+      var status = data.status[0];
613
+      var name = data.name[0];
614
+      var description = data.description[0];
615
+
616
+      //clear the objectives of ony prevoius TA selected for approve
617
+      var add_button = $('#approvePanel .add-objective');
618
+      var select = add_button.prev().clone(true);
619
+
620
+      var first_select = select.clone(true);
621
+      first_select.find('button').hide();
622
+
623
+      $('.approveObjectives').remove();
624
+      add_button.before(first_select);
625
+
626
+      var prev_select = first_select;
627
+      $.each(objectives, function(index, objective)
628
+      {
629
+
630
+        // save the new select in a var
631
+        var new_select = select.clone(true);
632
+
633
+        // set only one option on the select
634
+        prev_select.find('option').remove();
635
+        prev_select.find('select').append('<option value="'+ objective.id +'">'+objective.text +'</option>');
636
+        prev_select = new_select;
637
+        // add the copy of the select
638
+        add_button.before(new_select);
639
+      });
640
+      // remove the last objective select, since it isnt one of the saved objectives
641
+      add_button.prev().remove();
642
+
643
+      //
644
+      $('#approvalDescription').val(description);
645
+      $('.approvalText').val(name);
646
+      $('#approvePanel .updateTA').val(ta_id);
647
+
648
+
649
+      //locate de "add course" button on approve panel
650
+      var add_course_button = $('#approvePanel .add-course')
651
+
652
+      //save current course selectpickers, add a new one, and delete old ones
653
+      var current_course_selects = $('#approvePanel .approveCourse');
654
+      add_course_button.click();
655
+      current_course_selects.remove();
656
+
657
+      //populate approve panel with courses previusly selected
658
+      var prev_select = add_course_button.prev();
659
+      prev_select.find('.remove-course').hide();
660
+      $.each(selected_courses, function(index, course)
661
+      {
662
+        var new_option = $('<option/>',{
663
+          'value': course.id,
664
+          'type': 'button',
665
+          'html': course.name+' ['+course.code+']'
666
+        });
667
+        prev_select.find('select option').remove();
668
+        prev_select.find('select').append(new_option);
669
+        prev_select.find('.remove-course').hide();
670
+        add_course_button.click();
671
+        prev_select = add_course_button.prev();
672
+      });
673
+      prev_select.remove();
674
+
675
+    }
676
+  );
677
+}
678
+
679
+function add_objective_select(element) {
680
+  var prev_select = $(element).prev();
681
+
682
+  var parent_panel = $(element).parent().parent().attr('id');
683
+  var select_class = '';
684
+  if(parent_panel == 'editPanel'){
685
+    select_class = 'editObjectives';
686
+  }else{
687
+    select_class = 'createObjectives';
688
+  }
689
+
690
+  //create select
691
+  var new_div = $('<div/>',{
692
+    'class': select_class
693
+  });
694
+  var new_inner_div = $('<div/>',{
695
+    'class': 'form-group col-md-11'
696
+  });
697
+  var new_select = $('<select/>',{
698
+    'class': 'form-control createObjectives selectpicker',
699
+    'data-live-search': 'true',
700
+    'name': 'objectiveid[]'
701
+  });
702
+  var new_button = $('<button/>',{
703
+    'class': 'btn btn-md btn-primary col-md-1 remove-objective',
704
+    'type': 'button',
705
+    'html': 'X'
706
+  });
707
+
708
+
709
+  $.each(prev_select.find('option'), function(index, option)
710
+  {
711
+    var new_option = $('<option/>',{
712
+      'value': $(option).val(),
713
+      'html': $(option).html()
714
+    });
715
+    new_select.append(new_option);
716
+  });
717
+
718
+
719
+  $(element).before(new_div);
720
+  new_div.append(new_inner_div);
721
+  new_div.append(new_button);
722
+  new_inner_div.append(new_select);
723
+  $(element).parent().find('.selectpicker').selectpicker('refresh');
724
+  new_select.selectpicker('refresh');
725
+
726
+}
727
+
728
+function add_course_select(element) {
729
+  var prev_select = $(element).prev();
730
+
731
+  var parent_panel = $(element).parent().parent().attr('id');
732
+  var select_class = '';
733
+  if(parent_panel == 'editPanel'){
734
+    select_class = 'editCourse';
735
+  }else{
736
+    select_class = 'createCourse';
737
+  }
738
+
739
+  //create select
740
+  var new_div = $('<div/>',{
741
+    'class': select_class+' approveCourse'
742
+  });
743
+  var new_inner_div = $('<div/>',{
744
+    'class': 'form-group col-md-11'
745
+  });
746
+  var new_select = $('<select/>',{
747
+    'class': 'form-control createCourses selectpicker',
748
+    'data-live-search': 'true',
749
+    'name': 'courseid[]'
750
+  });
751
+  var new_button = $('<button/>',{
752
+    'class': 'btn btn-md btn-primary col-md-1 remove-course',
753
+    'type': 'button',
754
+    'html': 'X'
755
+  });
756
+
757
+
758
+  $.each(prev_select.find('option'), function(index, option)
759
+  {
760
+    var new_option = $('<option/>',{
761
+      'value': $(option).val(),
762
+      'html': $(option).html()
763
+    });
764
+    new_select.append(new_option);
765
+  });
766
+
767
+
768
+  $(element).before(new_div);
769
+  new_div.append(new_inner_div);
770
+  new_div.append(new_button);
771
+  new_inner_div.append(new_select);
772
+  $(element).parent().find('.selectpicker').selectpicker('refresh');
773
+  new_select.selectpicker('refresh');
774
+
775
+}
776
+
777
+// --------------------------------------------------------------------------
778
+// Events
779
+// --------------------------------------------------------------------------
780
+
781
+// When a TA is selected for edit, load the TA info
782
+$('#createOutcome').on('change', function()
783
+{
784
+  var outcome_id = $(this).find('select').val();
785
+
786
+  load_objectives_from_outcome(outcome_id);
787
+});
788
+
789
+// When a TA is selected for edit, load the TA info
790
+$('#editSelectTA').parent().on('change', function()
791
+{
792
+  var ta_id = $(this).find('select').val();
793
+  if(ta_id != 0){
794
+    load_ta_info_for_edit(ta_id);
795
+  }
796
+});
797
+
798
+// When a TA is selected for approval, load the TA info
799
+$('#approvalSelectTA').parent().on('change', function()
800
+{
801
+  var ta_id = $(this).find('select').val();
802
+  if(ta_id != 0){
803
+    load_ta_info_for_approval(ta_id);
804
+    }
805
+});
806
+
807
+
808
+// Add an objective Select picker
809
+$('.add-objective').on('click', function()
810
+{
811
+  add_objective_select(this);
812
+});
813
+// Add an course Select picker
814
+$('.add-course').on('click', function()
815
+{
816
+  add_course_select(this);
817
+});
818
+
819
+// Remove an objective Select picker
820
+$('.panel').on('click', '.remove-objective', function()
821
+{
822
+  $(this).parent().remove();
823
+});
824
+// Remove an course Select picker
825
+$('.panel').on('click', '.remove-course', function()
826
+{
827
+  $(this).parent().remove();
828
+});
829
+
830
+// Remove an objective Select picker
831
+$('.filterButton').on('click', function()
832
+{
833
+  var span = $(this).find('span');
834
+  if(span.attr('class') == 'glyphicon glyphicon-plus'){
835
+    span.attr('class','glyphicon glyphicon-minus');
836
+  } else{
837
+    span.attr('class','glyphicon glyphicon-plus');
838
+  }
839
+  $(this).parent().next().toggle(533);
840
+});
841
+
842
+//
843
+$('.filterSection').on('change', function()
844
+{
845
+
846
+  var professor_id = $(this).find('.filterProfessor select').val();
847
+  var course_id = $(this).find('.filterCourse select').val();
848
+  var outcome_id = $(this).find('.filterOutcome select').val();
849
+  var panel_id = $(this).parent().attr('id');
850
+
851
+  var select = $('#'+panel_id+' .SelectTA select');
852
+
853
+
854
+  $.post(
855
+    "{{ URL::action('TransformativeActionsController@filterTA') }}",
856
+    {
857
+      professor_id: (professor_id),
858
+      course_id: (course_id),
859
+      outcome_id: (outcome_id),
860
+      panel_id: (panel_id),
861
+    },
862
+    function(data)
863
+    {
864
+      //
865
+      select.find('option').remove();
866
+      $.each(data, function(index, ta)
867
+      {
868
+        var ta_id = ta.id;
869
+        var ta_text = ta.at_text;
870
+        var new_option = '<option value="'+ ta_id +'">'+ ta_text +'</option>';
871
+        select.append(new_option);
872
+      });
873
+
874
+      select.selectpicker('refresh');
875
+
876
+      if(data.length != 0){
877
+        var ta_id = data[0].id;
878
+
879
+        if(panel_id=='editPanel'){
880
+          load_ta_info_for_edit(ta_id);
881
+        }
882
+        if(panel_id=='approvePanel'){
883
+          load_ta_info_for_approval(ta_id);
884
+        }
885
+      }
886
+    }
887
+  );
888
+
889
+});
890
+
891
+@stop

+ 2
- 0
app/views/local/managers/pCoords/_navigation.blade.php Zobrazit soubor

@@ -6,6 +6,8 @@
6 6
     <ul class="nav navbar-nav navbar-right">
7 7
       <li>{{ HTML::linkAction('ProgramCoordinatorsController@overview', 'Overview') }}</li>
8 8
       <li>{{ HTML::linkAction('TemplatesController@newTemplate', 'Rubrics') }}</li>
9
+      <li>{{ HTML::linkAction('ThreeYearPlanController@threeYearsReport', 'Three Years Plan') }}</li>
10
+      <li>{{ HTML::linkAction('TransformativeActionsController@editTA', 'Transformative Actions') }}</li>
9 11
 
10 12
       <li>{{ HTML::linkAction('Objective2Controller@editProgram', 'Objectives')}}</li>
11 13
       <li>{{ HTML::linkAction('CriteriaController@editProgram', 'Criteria') }}</li>

+ 1
- 0
app/views/local/professors/_navigation.blade.php Zobrazit soubor

@@ -8,6 +8,7 @@
8 8
       <li>{{ HTML::linkAction('ProfessorsController@overview', 'My Courses') }}</li>
9 9
       {{-- la linea siguiente comentada es lo que habia originalmente. tanto la linea como este comentario se pueden borrar --}}
10 10
       {{-- <li>{{ HTML::linkAction('CriteriaController@index', 'Learning Outcomes and Criteria') }}</li> --}}
11
+      <li>{{ HTML::linkAction('TransformativeActionsController@editTA', 'Transformative Actions') }}</li>
11 12
       <li class="dropdown">
12 13
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
13 14
         <ul class="dropdown-menu" role="menu">