Browse Source

Created Three Years Plan page

onielm 3 years ago
parent
commit
af26bd8660

+ 555
- 0
app/controllers/ThreeYearPlanController.php View File

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
+}

+ 39
- 0
app/database/migrations/2021_02_17_205601_create_cycles_table.php View File

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 View File

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 View File

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 View File

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 View File

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
+}

+ 33
- 0
app/database/migrations/2021_02_25_180526_three_year_plan.php View File

1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class ThreeYearPlan extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('three_year_plan', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->timestamps();
19
+			$table->integer('year_start')->unsigned();
20
+			$table->integer('year_end')->unsigned();
21
+		});
22
+	}
23
+
24
+	/**
25
+	 * Reverse the migrations.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function down()
30
+	{
31
+		Schema::drop('three_year_plan');
32
+	}
33
+}

+ 50
- 0
app/database/migrations/2021_02_25_181424_typ_semesters.php View File

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
+}

+ 43
- 0
app/database/migrations/2021_02_25_181544_typ_program.php View File

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

+ 50
- 0
app/database/migrations/2021_02_25_181623_typ_semester_outcome.php View File

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

+ 46
- 0
app/database/migrations/2021_02_25_181644_typ_semester_objectives.php View File

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

+ 49
- 0
app/database/migrations/2021_02_25_181655_typ_semester_courses.php View File

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

+ 803
- 0
app/views/global/view-three-year-plan.blade.php View File

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

+ 1
- 0
app/views/local/managers/admins/_navigation.blade.php View File

3
 
3
 
4
     <ul class="nav navbar-nav navbar-right">
4
     <ul class="nav navbar-nav navbar-right">
5
       <li>{{ HTML::linkAction('AdministratorsController@overview', 'Overview') }}</li>
5
       <li>{{ HTML::linkAction('AdministratorsController@overview', 'Overview') }}</li>
6
+      <li>{{ HTML::linkAction('ThreeYearPlanController@threeYearsReport', 'Three Years Plan') }}</li>
6
       <li>{{ HTML::linkAction('TransformativeActionsController@editTA', 'Transformative Actions') }}</li>
7
       <li>{{ HTML::linkAction('TransformativeActionsController@editTA', 'Transformative Actions') }}</li>
7
 
8
 
8
       <li class="dropdown">
9
       <li class="dropdown">

+ 1
- 0
app/views/local/managers/pCoords/_navigation.blade.php View File

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