5 Commits

Autor SHA1 Mensagem Data
  onielm 4df236bd00 Created new Overview page 3 anos atrás
  onielm 88f674311c Update ThreeYearPlanController.php 3 anos atrás
  onielm 8617bc32f7 Merge branch 'Merge_gabriel_mayo' into oniel-progreso 3 anos atrás
  Gabriel Santiago Plaza f406955d48 Merge branch 'oniel-progreso' into Merge_gabriel_mayo 3 anos atrás
  Gabriel Santiago Plaza 249aac5c5e CReo que esta es la que hay 3 anos atrás
29 arquivos alterados com 4352 adições e 331 exclusões
  1. 350
    35
      app/controllers/AdministratorsController.php
  2. 298
    17
      app/controllers/AnnualPlansController.php
  3. 86
    94
      app/controllers/ProgramCoordinatorsController.php
  4. 8
    16
      app/controllers/ThreeYearPlanController.php
  5. 11
    13
      app/database/migrations/2021_03_03_084851_create_annual_plans_table.php
  6. 15
    15
      app/database/migrations/2021_03_03_090217_create_annual_plan_objective_table.php
  7. 18
    5
      app/database/migrations/2021_03_29_154844_create_annual_plan_transformative.php
  8. 57
    0
      app/database/migrations/2021_03_29_155542_create_annual_report_transformative.php
  9. 55
    0
      app/database/migrations/2021_05_18_102422_create_overview_table.php
  10. 0
    0
      app/database/unusedMigrations/2021_01_28_174905_fixObjectivesTable.php
  11. 0
    0
      app/database/unusedMigrations/2021_02_16_142747_create_cycles_table.php
  12. 13
    13
      app/database/unusedMigrations/2021_02_17_190111_create_three_year_plans_table.php
  13. 48
    0
      app/database/unusedMigrations/2021_02_17_190118_create_typ_parts_table.php
  14. 63
    0
      app/database/unusedMigrations/2021_02_17_190124_create_typ_part_outcomes_table.php
  15. 37
    1
      app/routes.php
  16. 1
    1
      app/views/global/_datatables_js.blade.php
  17. 539
    0
      app/views/layouts/master-2.blade.php
  18. 4
    2
      app/views/local/managers/admins/_navigation.blade.php
  19. 30
    0
      app/views/local/managers/admins/appraisal-program.blade.php
  20. 1
    1
      app/views/local/managers/admins/new_criteria.blade.php
  21. 515
    0
      app/views/local/managers/admins/overview2.blade.php
  22. 2
    0
      app/views/local/managers/pCoords/_navigation.blade.php
  23. 7
    0
      app/views/local/managers/sCoords/_navigation.blade.php
  24. 510
    0
      app/views/local/managers/sCoords/annual-plans.blade.php
  25. 163
    0
      app/views/local/managers/sCoords/annual_plan_js.blade.php
  26. 175
    113
      app/views/local/managers/sCoords/criteria.blade.php
  27. 1
    4
      app/views/local/managers/sCoords/objectives.blade.php
  28. 1341
    0
      app/views/local/managers/sCoords/view-annual-plans.blade.php
  29. 4
    1
      composer.json

+ 350
- 35
app/controllers/AdministratorsController.php Ver arquivo

@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 
3 3
 class AdministratorsController extends \BaseController
4
-{	
4
+{
5 5
 	private function outcomes_semesters($selected_semesters, $level)
6 6
 	{
7 7
 		$min_start="9000-01-01 00:00:00";
@@ -42,14 +42,14 @@ class AdministratorsController extends \BaseController
42 42
 												   ->orWhere("level",3);
43 43
 										})
44 44
 								->count();
45
-	
45
+
46 46
 		foreach($outcomes as $outcome)
47 47
 		{
48
-			
48
+
49 49
 // 		var_dump($outcome->id);
50 50
 // 		print "<br>";
51 51
 			$outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semesters, $level);
52
-			$outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semesters, $level);	
52
+			$outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semesters, $level);
53 53
 		}
54 54
 
55 55
         $uhs_school_id = School::where('name', 'LIKE', '%UHS%')->first()->id;
@@ -91,34 +91,34 @@ class AdministratorsController extends \BaseController
91 91
 				}
92 92
 			}
93 93
 		}
94
-	
94
+
95 95
 		return array('outcomes'=>$outcomes,'outcomes_attempted'=>$outcomes_attempted, 'outcomes_achieved'=>$outcomes_achieved, 'attemptedProgramsPerOutcome'=>$attemptedProgramsPerOutcome, 'achievedProgramsPerOutcome'=>$achievedProgramsPerOutcome,'participating_programs'=>$participating_programs);
96
-	
97
-	
98
-	
96
+
97
+
98
+
99 99
 	}
100 100
     public function overview()
101 101
     {
102
-    
102
+
103 103
         $selected_semesters = Semester::find(Session::get('semesters_ids'));
104
-        
104
+
105 105
 		$subgraduado=$this->outcomes_semesters($selected_semesters,0);
106 106
         $outcomes_subgrad=$subgraduado['outcomes'];
107
-        $undergrad_outcomes_achieved=$subgraduado['outcomes_achieved']; 
108
-        $undergrad_outcomes_attempted=$subgraduado['outcomes_attempted']; 
109
-        $attemptedUndergradProgramsPerOutcome=$subgraduado['attemptedProgramsPerOutcome']; 
110
-        $achievedUndergradProgramsPerOutcome=$subgraduado['achievedProgramsPerOutcome']; 
111
-        $participating_undergrad_programs=$subgraduado['participating_programs']; 
112
-		
113
-		
107
+        $undergrad_outcomes_achieved=$subgraduado['outcomes_achieved'];
108
+        $undergrad_outcomes_attempted=$subgraduado['outcomes_attempted'];
109
+        $attemptedUndergradProgramsPerOutcome=$subgraduado['attemptedProgramsPerOutcome'];
110
+        $achievedUndergradProgramsPerOutcome=$subgraduado['achievedProgramsPerOutcome'];
111
+        $participating_undergrad_programs=$subgraduado['participating_programs'];
112
+
113
+
114 114
 		$graduado=$this->outcomes_semesters($selected_semesters,1);
115 115
         $outcomes_grad=$graduado['outcomes'];
116
-        $grad_outcomes_achieved=$graduado['outcomes_achieved']; 
117
-        $grad_outcomes_attempted=$graduado['outcomes_attempted']; 
118
-        $attemptedGradProgramsPerOutcome=$graduado['attemptedProgramsPerOutcome']; 
119
-        $achievedGradProgramsPerOutcome=$graduado['achievedProgramsPerOutcome']; 
120
-        $participating_grad_programs=$graduado['participating_programs']; 
121
-		
116
+        $grad_outcomes_achieved=$graduado['outcomes_achieved'];
117
+        $grad_outcomes_attempted=$graduado['outcomes_attempted'];
118
+        $attemptedGradProgramsPerOutcome=$graduado['attemptedProgramsPerOutcome'];
119
+        $achievedGradProgramsPerOutcome=$graduado['achievedProgramsPerOutcome'];
120
+        $participating_grad_programs=$graduado['participating_programs'];
121
+
122 122
         //Total amount of learning outcomes
123 123
 //         $outcomeCount = Outcome::withTrashed()->count();
124 124
 //         $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
@@ -147,7 +147,7 @@ class AdministratorsController extends \BaseController
147 147
 //         									    		   ->orWhere("level",3);
148 148
 //         									    })
149 149
 //         								->count();
150
-// 
150
+//
151 151
 //         $outcomes_grad = Outcome::where(function($query) use ($selected_semester){$query->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null);})->where(function($query2){$query2->where("level",2)->orWhere("level",3);})->orderBy('name', 'ASC')->get();
152 152
 //         $outcomeCount_grad = Outcome::where(function($query) use ($selected_semester){$query->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null);})->where(function($query2){$query2->where("level",2)->orWhere("level",3);})->count();
153 153
 
@@ -159,21 +159,21 @@ class AdministratorsController extends \BaseController
159 159
 
160 160
         $schools = School::where('id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get();
161 161
         $title = 'Campus Overview';
162
-        
163
-        
162
+
163
+
164 164
         /**
165 165
          * Calculate campus wide outcome performance by counting the number of students
166
-         $undergrad_outcomes_attempted will have the number of criteria that was assessed in undergradute courses during the selected semester 
167
-         $undergrad_outcomes_achieved will have the number of criteria that was assessed in undergradute courses  during the selected semester 
166
+         $undergrad_outcomes_attempted will have the number of criteria that was assessed in undergradute courses during the selected semester
167
+         $undergrad_outcomes_achieved will have the number of criteria that was assessed in undergradute courses  during the selected semester
168 168
             where the percentage of students that obtained a better or equal score than the expected_student_score established in the
169 169
             activity_criterion table is greater or equal than the expected_percentage_students_achieving also established in the
170
-            activity_criterion table         
170
+            activity_criterion table
171 171
          */
172 172
 
173 173
 // 		foreach($outcomes_subgrad as $outcome)
174 174
 // 		{
175 175
 // 			$undergrad_outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semester->id,0);
176
-// 			$undergrad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,0);	
176
+// 			$undergrad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,0);
177 177
 // 		}
178 178
 // 		var_dump($undergrad_outcomes_attempted);
179 179
 // 		print"<br>";
@@ -182,7 +182,7 @@ class AdministratorsController extends \BaseController
182 182
 // 		foreach($outcomes_grad as $outcome)
183 183
 // 		{
184 184
 // 			$grad_outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semester->id,1);
185
-// 			$grad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,1);			
185
+// 			$grad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,1);
186 186
 // 		}
187 187
 
188 188
         /**
@@ -221,7 +221,7 @@ class AdministratorsController extends \BaseController
221 221
 //             }))->where('is_graduate', 0)->where('school_id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get() as $program)
222 222
 //             {
223 223
 //             	$participating_undergrad_programs[$program->id]=(object)array('id'=>$program->id, 'name'=>$program->name, 'is_graduate'=> $program->is_graduate, 'school_id'=>$program->school_id,'semestre_id',$selected_semester);
224
-// 
224
+//
225 225
 // // 				SELECT ac.id activity_criterion_id, ac.activity_id, ac.expected_student_score, ac.expected_percentage_students_achieving, co.program_id FROM activity_criterion ac, new_criteria c, activities a, objectives o, courses co where co.id=a.course_id and co.semester_id=13 and a.id=ac.activity_id and c.id = ac.criterion_id and o.id=c.objective_id and o.outcome_id = 2 order by program_id
226 226
 // 				$program_attempted_outcome=$program->attempted_outcome($outcome->id, $selected_semester->id);
227 227
 // 				$attempted_outcomes_per_undergrad_program[$outcome->id]+=$program_attempted_outcome;
@@ -250,11 +250,11 @@ class AdministratorsController extends \BaseController
250 250
 // 		exit();
251 251
         /**
252 252
          * Calculate how many grad programs achieved and attempted each outcome
253
-         $grad_outcomes_attempted will have the number of criteria that was assessed in gradute courses during the selected semester 
254
-         $grad_outcomes_achieved will have the number of criteria that was assessed in gradute courses  during the selected semester 
253
+         $grad_outcomes_attempted will have the number of criteria that was assessed in gradute courses during the selected semester
254
+         $grad_outcomes_achieved will have the number of criteria that was assessed in gradute courses  during the selected semester
255 255
             where the percentage of students that obtained a better or equal score than the expected_student_score established in the
256 256
             activity_criterion table is greater or equal than the expected_percentage_students_achieving also established in the
257
-            activity_criterion table         
257
+            activity_criterion table
258 258
          */
259 259
 
260 260
 
@@ -303,4 +303,319 @@ class AdministratorsController extends \BaseController
303 303
 // 		exit();
304 304
         return View::make('local.managers.admins.overview', compact('title', 'schools', 'outcomes_subgrad', 'outcomes_grad', 'undergrad_outcomes_achieved', 'undergrad_outcomes_attempted', 'grad_outcomes_achieved', 'grad_outcomes_attempted', 'attemptedUndergradProgramsPerOutcome', 'participating_undergrad_programs', 'achievedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'participating_grad_programs', 'achievedGradProgramsPerOutcome'));
305 305
     }
306
+
307
+
308
+    public function overview2()
309
+    {
310
+			// '''
311
+			//stucture of outcomes array:
312
+			//
313
+			// $outcome->id
314
+			// $outcome->name
315
+			// $outcome->semesters
316
+			//
317
+			// $outcome->semesters[i]->id
318
+			// $outcome->semesters[i]->code
319
+			// $outcome->semesters[i]->name
320
+			// $outcome->semesters[i]->tested
321
+			// $outcome->semesters[i]->achievers
322
+			// '''
323
+      $selected_semesters = Semester::find(Session::get('semesters_ids'));
324
+			$title = 'Overview2';
325
+
326
+			$semesters = DB::table('overview')
327
+          ->join('semesters','semesters.id','=','overview.semester_id')
328
+          ->select('semesters.name', 'semesters.code')
329
+					->orderBy('semesters.code', 'asc')
330
+					->groupBy('semesters.id')
331
+          ->get();
332
+			$outcomes = DB::table('overview')
333
+          ->join('outcomes','outcomes.id','=','overview.outcome_id')
334
+          ->selectRaw('outcomes.name, overview.outcome_id as id, sum(overview.total_evaluated) as total_evaluated, sum(overview.total_achieved) as total_achieved')
335
+					->orderBy('outcomes.name', 'asc')
336
+					->groupBy('overview.outcome_id')
337
+          ->get();
338
+			foreach ($outcomes as $outcome) {
339
+				$outcome->semesters = DB::table('overview')
340
+	          ->join('semesters','semesters.id','=','overview.semester_id')
341
+						->where('overview.outcome_id', $outcome->id)
342
+						->selectRaw('semesters.id, semesters.name, semesters.code, sum(overview.total_evaluated) as total_evaluated, sum(overview.total_achieved) as total_achieved')
343
+						->orderBy('semesters.code', 'asc')
344
+						->groupBy('overview.outcome_id')
345
+						->groupBy('overview.semester_id')
346
+	          ->get();
347
+			}
348
+
349
+			$filters = array();
350
+			$filters['school'] = DB::table('overview')
351
+          ->join('programs','programs.id','=','overview.program_id')
352
+          ->join('schools','schools.id','=','programs.school_id')
353
+					->select('schools.id','schools.name')
354
+					->orderBy('schools.name', 'asc')
355
+					->groupBy('schools.id')
356
+          ->get();
357
+
358
+			$filters['program'] = DB::table('overview')
359
+          ->join('programs','programs.id','=','overview.program_id')
360
+					->select('programs.id','programs.name')
361
+					->orderBy('programs.name', 'asc')
362
+					->groupBy('overview.program_id')
363
+          ->get();
364
+
365
+			$filters['semester'] = DB::table('overview')
366
+          ->join('semesters','semesters.id','=','overview.semester_id')
367
+          ->select('semesters.id','semesters.name','semesters.code')
368
+					->orderBy('semesters.code', 'asc')
369
+					->groupBy('overview.semester_id')
370
+          ->get();
371
+
372
+			$filters['year'] = DB::table('overview')//
373
+          ->join('semesters','semesters.id','=','overview.semester_id')
374
+          ->select('semesters.id','semesters.start')
375
+					->orderBy('semesters.code', 'asc')
376
+					->groupBy('overview.semester_id')
377
+          ->get();
378
+
379
+			$filters['outcome'] = DB::table('overview')
380
+          ->join('outcomes','outcomes.id','=','overview.outcome_id')
381
+          ->select('outcomes.id','outcomes.name')
382
+					->orderBy('outcomes.name', 'asc')
383
+					->groupBy('overview.outcome_id')
384
+          ->get();
385
+
386
+			$target = 0.70;
387
+
388
+      return View::make('local.managers.admins.overview2', compact('title','selected_semesters','outcomes','semesters','filters','target'));
389
+    }
390
+
391
+		// this is called when filters are changed
392
+    public function overview2_filter_results()
393
+    {
394
+
395
+			// selected filter data
396
+			$schools = Input::get('schools');
397
+			$programs = Input::get('programs');
398
+			$semesters = Input::get('semesters');
399
+			$years = Input::get('years');
400
+			$outcomes = Input::get('outcomes');
401
+
402
+
403
+			// make an array id's of schools selected. if All, use All available id's
404
+			if ($schools == array("0")){
405
+				$result = DB::table('overview')
406
+						->join('programs','programs.id','=','overview.program_id')
407
+						->join('schools','schools.id','=','programs.school_id')
408
+						->select('schools.id')
409
+						->orderBy('schools.name', 'asc')
410
+						->groupBy('schools.id')
411
+						->get();
412
+				$schools_id = array();
413
+				foreach ($result as $school) {
414
+					array_push($schools_id,$school->id);
415
+				}
416
+			}else {
417
+				$schools_id = array();
418
+				foreach ($schools as $school_id) {
419
+					array_push($schools_id,intval($school_id));
420
+				}
421
+			}
422
+			// make an array id's of programs selected. if All, use All available id's
423
+			if ($programs == array("0")){
424
+				$result = DB::table('overview')
425
+	          ->join('programs','programs.id','=','overview.program_id')
426
+						->select('programs.id')
427
+						->orderBy('programs.name', 'asc')
428
+						->groupBy('overview.program_id')
429
+	          ->get();
430
+				$programs_id = array();
431
+				foreach ($result as $program) {
432
+					array_push($programs_id,$program->id);
433
+				}
434
+			}else {
435
+				$programs_id = array();
436
+				foreach ($programs as $program_id) {
437
+					array_push($programs_id,intval($program_id));
438
+				}
439
+			}
440
+			// make an array id's of semesters selected. if All, use All available id's
441
+			if ($semesters == array("0")){
442
+				$result = DB::table('overview')
443
+	          ->join('semesters','semesters.id','=','overview.semester_id')
444
+	          ->select('semesters.id')
445
+						->orderBy('semesters.code', 'asc')
446
+						->groupBy('overview.semester_id')
447
+	          ->get();
448
+				$semesters_id = array();
449
+				foreach ($result as $semester) {
450
+					array_push($semesters_id,$semester->id);
451
+				}
452
+			}else {
453
+				$semesters_id = array();
454
+				foreach ($semesters as $semester_id) {
455
+					array_push($semesters_id,intval($semester_id));
456
+				}
457
+			}
458
+			// make an array id's of years selected. if All, use All available id's
459
+			if ($years == array("0")){
460
+				$result = DB::table('overview')//
461
+	          ->join('semesters','semesters.id','=','overview.semester_id')
462
+	          ->select('semesters.id')
463
+						->orderBy('semesters.code', 'asc')
464
+						->groupBy('overview.semester_id')
465
+	          ->get();
466
+				$years_id = array();
467
+				foreach ($result as $year) {
468
+					array_push($years_id,$year->id);
469
+				}
470
+			}else {
471
+				$years_id = array();
472
+				foreach ($years as $year_id) {
473
+					array_push($years_id,intval($year_id));
474
+				}
475
+			}
476
+			// make an array id's of outcomes selected. if All, use All available id's
477
+			if ($outcomes == array("0")){
478
+				$result = DB::table('overview')
479
+	          ->join('outcomes','outcomes.id','=','overview.outcome_id')
480
+	          ->select('outcomes.id')
481
+						->orderBy('outcomes.name', 'asc')
482
+						->groupBy('overview.outcome_id')
483
+	          ->get();
484
+				$outcomes_id = array();
485
+				foreach ($result as $outcome) {
486
+					array_push($outcomes_id,$outcome->id);
487
+				}
488
+			}else {
489
+				$outcomes_id = array();
490
+				foreach ($outcomes as $outcome_id) {
491
+					array_push($outcomes_id,intval($outcome_id));
492
+				}
493
+			}
494
+
495
+
496
+			// get data for graph
497
+			$semesters = DB::table('overview')
498
+					->join('programs','programs.id','=','overview.program_id')
499
+					->join('schools','schools.id','=','programs.school_id')
500
+					->join('semesters','semesters.id','=','overview.semester_id')
501
+					->join('outcomes','outcomes.id','=','overview.outcome_id')
502
+					->whereIn('schools.id',$schools_id)
503
+					->whereIn('programs.id',$programs_id)
504
+					->whereIn('semesters.id',$semesters_id)
505
+					// ->whereIn('years.id',$years_id)
506
+					->whereIn('outcomes.id',$outcomes_id)
507
+          ->select('semesters.name', 'semesters.code')
508
+					->orderBy('semesters.code', 'asc')
509
+					->groupBy('semesters.id')
510
+					->get();
511
+			$outcomes = DB::table('overview')
512
+					->join('programs','programs.id','=','overview.program_id')
513
+					->join('schools','schools.id','=','programs.school_id')
514
+					->join('semesters','semesters.id','=','overview.semester_id')
515
+					->join('outcomes','outcomes.id','=','overview.outcome_id')
516
+					->whereIn('schools.id',$schools_id)
517
+					->whereIn('programs.id',$programs_id)
518
+					->whereIn('semesters.id',$semesters_id)
519
+					// ->whereIn('years.id',$years_id)
520
+					->whereIn('outcomes.id',$outcomes_id)
521
+          ->selectRaw('outcomes.name, overview.outcome_id as id, sum(overview.total_evaluated) as total_evaluated, sum(overview.total_achieved) as total_achieved')
522
+					->orderBy('outcomes.name', 'asc')
523
+					->groupBy('overview.outcome_id')
524
+					->get();
525
+			foreach ($outcomes as $outcome) {
526
+				$outcome->semesters = DB::table('overview')
527
+						->join('programs','programs.id','=','overview.program_id')
528
+						->join('schools','schools.id','=','programs.school_id')
529
+						->join('semesters','semesters.id','=','overview.semester_id')
530
+						->join('outcomes','outcomes.id','=','overview.outcome_id')
531
+						->whereIn('schools.id',$schools_id)
532
+						->whereIn('programs.id',$programs_id)
533
+						->whereIn('semesters.id',$semesters_id)
534
+						// ->whereIn('years.id',$years_id)
535
+						->whereIn('outcomes.id',$outcomes_id)
536
+						->where('overview.outcome_id', $outcome->id)
537
+						->selectRaw('semesters.id, semesters.name, semesters.code, sum(overview.total_evaluated) as total_evaluated, sum(overview.total_achieved) as total_achieved')
538
+						->orderBy('semesters.code', 'asc')
539
+						->groupBy('overview.outcome_id')
540
+						->groupBy('overview.semester_id')
541
+						->get();
542
+			}
543
+
544
+			// get data for filters
545
+			$filters = array();
546
+			$filters['school'] = DB::table('overview')
547
+					->join('programs','programs.id','=','overview.program_id')
548
+					->join('schools','schools.id','=','programs.school_id')
549
+					->join('semesters','semesters.id','=','overview.semester_id')
550
+					->join('outcomes','outcomes.id','=','overview.outcome_id')
551
+					->whereIn('schools.id',$schools_id)
552
+					->whereIn('programs.id',$programs_id)
553
+					->whereIn('semesters.id',$semesters_id)
554
+					// ->whereIn('years.id',$years_id)
555
+					->whereIn('outcomes.id',$outcomes_id)
556
+					->select('schools.id','schools.name')
557
+					->orderBy('schools.name', 'asc')
558
+					->groupBy('schools.id')
559
+					->get();
560
+			$filters['program'] = DB::table('overview')
561
+					->join('programs','programs.id','=','overview.program_id')
562
+					->join('schools','schools.id','=','programs.school_id')
563
+					->join('semesters','semesters.id','=','overview.semester_id')
564
+					->join('outcomes','outcomes.id','=','overview.outcome_id')
565
+					->whereIn('schools.id',$schools_id)
566
+					// ->whereIn('programs.id',$programs_id)
567
+					->whereIn('semesters.id',$semesters_id)
568
+					// ->whereIn('years.id',$years_id)
569
+					->whereIn('outcomes.id',$outcomes_id)
570
+					->select('programs.id','programs.name')
571
+					->orderBy('programs.name', 'asc')
572
+					->groupBy('overview.program_id')
573
+					->get();
574
+			$filters['semester'] = DB::table('overview')
575
+					->join('programs','programs.id','=','overview.program_id')
576
+					->join('schools','schools.id','=','programs.school_id')
577
+					->join('semesters','semesters.id','=','overview.semester_id')
578
+					->join('outcomes','outcomes.id','=','overview.outcome_id')
579
+					->whereIn('schools.id',$schools_id)
580
+					->whereIn('programs.id',$programs_id)
581
+					// ->whereIn('semesters.id',$semesters_id)
582
+					// ->whereIn('years.id',$years_id)
583
+					->whereIn('outcomes.id',$outcomes_id)
584
+					->select('semesters.id','semesters.name','semesters.code')
585
+					->orderBy('semesters.code', 'asc')
586
+					->groupBy('overview.semester_id')
587
+					->get();
588
+			$filters['year'] = DB::table('overview')////////////////////////////////////////////
589
+					->join('programs','programs.id','=','overview.program_id')
590
+					->join('schools','schools.id','=','programs.school_id')
591
+					->join('semesters','semesters.id','=','overview.semester_id')
592
+					->join('outcomes','outcomes.id','=','overview.outcome_id')
593
+					->whereIn('schools.id',$schools_id)
594
+					->whereIn('programs.id',$programs_id)
595
+					->whereIn('semesters.id',$semesters_id)
596
+					// ->whereIn('years.id',$years_id)
597
+					->whereIn('outcomes.id',$outcomes_id)
598
+
599
+					->get();
600
+			$filters['outcome'] = DB::table('overview')
601
+					->join('programs','programs.id','=','overview.program_id')
602
+					->join('schools','schools.id','=','programs.school_id')
603
+					->join('semesters','semesters.id','=','overview.semester_id')
604
+					->join('outcomes','outcomes.id','=','overview.outcome_id')
605
+					->whereIn('schools.id',$schools_id)
606
+					->whereIn('programs.id',$programs_id)
607
+					->whereIn('semesters.id',$semesters_id)
608
+					// ->whereIn('years.id',$years_id)
609
+					// ->whereIn('outcomes.id',$outcomes_id)
610
+					->select('outcomes.id','outcomes.name')
611
+					->orderBy('outcomes.name', 'asc')
612
+					->groupBy('overview.outcome_id')
613
+          ->get();
614
+
615
+			return array(
616
+				"semesters" => $semesters,
617
+				"outcomes_info" => $outcomes,
618
+				"filters" => $filters,
619
+			);
620
+    }
306 621
 }

+ 298
- 17
app/controllers/AnnualPlansController.php Ver arquivo

@@ -1,6 +1,10 @@
1 1
 <?php
2 2
 
3
-class AnnualPlansController extends \BaseController {
3
+use Illuminate\Support\Facades\Auth;
4
+use Illuminate\Support\Facades\Input;
5
+
6
+class AnnualPlansController extends \BaseController
7
+{
4 8
 
5 9
   /**
6 10
    * Checks whether a user has permission to view a page in this controller
@@ -16,7 +20,7 @@ class AnnualPlansController extends \BaseController {
16 20
         $programs = $user->programs->lists('id');
17 21
 
18 22
         // If program does not belong to user, show 403
19
-        if(!in_array($program_id, $programs))
23
+        if (!in_array($program_id, $programs))
20 24
           return false;
21 25
 
22 26
         break;
@@ -25,7 +29,7 @@ class AnnualPlansController extends \BaseController {
25 29
         $programs = Program::where('school_id', $user->school_id)->lists('id');
26 30
 
27 31
         // If program is not in user's school, show 403
28
-        if(!in_array($program_id, $programs))
32
+        if (!in_array($program_id, $programs))
29 33
           return false;
30 34
 
31 35
         break;
@@ -36,6 +40,15 @@ class AnnualPlansController extends \BaseController {
36 40
     return true;
37 41
   }
38 42
 
43
+  public function viewAllPlans($program_id)
44
+  {
45
+    $title = "Annual Plans";
46
+    $annual_plans = DB::select("select * from annual_plans order by id desc");
47
+
48
+
49
+    return View::make('local.managers.sCoords.view-annual-plans', compact('title', 'program_id', 'annual_plans'));
50
+  }
51
+
39 52
   /**
40 53
    * Lists annual plans by year and program
41 54
    * @var string $title     Title for page
@@ -44,13 +57,50 @@ class AnnualPlansController extends \BaseController {
44 57
    * @var Quinquennium $quinquenniums      All current or past quinquenniums
45 58
    * @var Quinquennium $current_quinquennium      Current quinquennium
46 59
    */
60
+
61
+  public function postReport()
62
+  {
63
+    $program_id = Input::get('program_id') + 0;
64
+    $realized = Input::get('realized');
65
+    $logrado = Input::get('logrado');
66
+    $continued = Input::get('continued');
67
+    $semester = Input::get('semester');
68
+    $typ_objective = Input::get('typ_objective');
69
+    $transformative = Input::get('transformative');
70
+    $annual_id = Input::get("annual_id") + 0;
71
+    $id = Auth::user()['id'];
72
+
73
+    for ($i = 0; $i < count($semester); $i++) {
74
+      $real = $realized[$i] + 0;
75
+      $logr = $logrado[$i] + 0;
76
+      $cont = $continued[$i] + 0;
77
+      $obj = $typ_objective[$i] + 0;
78
+      $trans = $transformative[$i] + 0;
79
+      $sem = $semester[$i] + 0;
80
+
81
+      //if it was continued
82
+      if ($real == 1) $real = 2;
83
+      else $real = 1;
84
+      if ($cont == 1) $cont = $sem + 1;
85
+      else $cont = "NULL";
86
+      $annual_trans_id = DB::select("select id from annual_plan_transformative where annual_plan_id ={$annual_id} and trans_id = {$trans} and typ_semester_objective_id = {$obj}")[0]->id;
87
+
88
+
89
+      $queryUpdate = DB::select("select * from annual_report_transformative where annual_trans_id = {$annual_trans_id}");
90
+      if (!count($queryUpdate)) {
91
+        DB::insert("insert into annual_report_transformative (accomplished, cycle_of_life, semester_used, semester_continue, annual_trans_id, supervised_coordinator_id) values ({$logr},{$real},{$sem},{$cont},{$annual_trans_id}, {$id})");
92
+      } else {
93
+        DB::update("update annual_report_transformative set accomplished = {$logr}, cycle_of_life ={$real}, semester_used ={$sem}, semester_continue={$cont}, supervised_coordinator_id={$id} where annual_trans_id ={$annual_trans_id}");
94
+      }
95
+    }
96
+    return;
97
+  }
47 98
   public function index()
48 99
   {
49 100
     $title = 'Annual Plans';
50 101
     $user = Auth::user();
51
-    $quinquenniums = Quinquennium::where('start_date','<=', date('Y-m-d'))->get();
52
-    $current_quinquennium = Quinquennium::
53
-      where('start_date', '<=', date('Y-m-d'))
102
+    $quinquenniums = Quinquennium::where('start_date', '<=', date('Y-m-d'))->get();
103
+    $current_quinquennium = Quinquennium::where('start_date', '<=', date('Y-m-d'))
54 104
       ->where('end_date', '>=', date('Y-m-d'))
55 105
       ->first();
56 106
 
@@ -71,6 +121,41 @@ class AnnualPlansController extends \BaseController {
71 121
 
72 122
     return View::make('local.managers.shared.index_annual_plans', compact('title', 'quinquenniums', 'programs', 'current_quinquennium'));
73 123
   }
124
+  public function adminIndex($school_id)
125
+  {
126
+    $title = "Annual Plans";
127
+    $programs = Program::where("school_id", $school_id)->get();
128
+
129
+    return View::make('local.managers.admins.appraisal-program', compact('title', 'programs'));
130
+  }
131
+
132
+  public function showPlan($program_id, $typ_id = null)
133
+  {
134
+    $title = "Annual Plans";
135
+    //$typ_parts = DB::select("select * from typ_parts");
136
+    if (!$typ_id) {
137
+      $current_typ = DB::select("select * from three_year_plan where year_start <=" . date('Y') . " and year_end >=" . date('Y'))[0]->id;
138
+    } else {
139
+      $current_typ = DB::select("select * from three_year_plan where id ={$typ_id}")[0]->id;
140
+    }
141
+    Log::info($current_typ);
142
+
143
+    $program = Program::where('id', '=', $program_id)->first();
144
+    $annual_plans = DB::select("select * from annual_plans where program_id = {$program_id} order by id desc limit 5");
145
+    Log::info($annual_plans);
146
+    $outcomes = array();
147
+    $allSemesterOrder = array();
148
+    foreach ($annual_plans as $an_plan) {
149
+      Log::info($an_plan->id);
150
+      $outcomes[$an_plan->id]["first"] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id = {$an_plan->semester_start} and typ_program_id in (select id from typ_program where program_id ={$an_plan->program_id} and three_year_plan_id ={$current_typ} ))");
151
+      $allSemesterOrder[$an_plan->id]["first"] = DB::select("select * from semesters where id = {$an_plan->semester_start}")[0];
152
+      $outcomes[$an_plan->id]["second"] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id ={$an_plan->semester_end} and typ_program_id in (select id from typ_program where program_id ={$an_plan->program_id} and three_year_plan_id = {$current_typ} ))");
153
+      $allSemesterOrder[$an_plan->id]["second"] = DB::select("select * from semesters where id = {$an_plan->semester_end}")[0];
154
+    }
155
+    $alltyp = DB::select('select * from three_year_plan order by id desc');
156
+
157
+    return View::make('local.managers.sCoords.annual-plans', compact('title', 'annual_plans', 'current_typ', 'program', 'outcomes', 'allSemesterOrder', 'alltyp'));
158
+  }
74 159
 
75 160
   /**
76 161
    * Page to create a new plan for the current quinquennium
@@ -80,33 +165,229 @@ class AnnualPlansController extends \BaseController {
80 165
    * @var User $user      Currently logged user
81 166
    * @var Course $courses      Courses for a particular program
82 167
    */
168
+  public function fetchTYP($program_id)
169
+  {
170
+    $typ_info = array();
171
+    $semester = DB::select("select * from semesters where id=?", array(Input::get('semester')))[0];
172
+
173
+
174
+    //$typ_info['courses'] = DB::select("select * from courses where id in (select course_id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id} )and outcome_id = ?))", array(Input::get('id')));
175
+    //foreach ($typ_info['courses'] as $course) {
176
+    //  $typ_info['courses_objective'][$course->id] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_course_id in (select id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id = {$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id}))and course_id ={$course->id}))");
177
+    //  foreach ($typ_info['courses_objective'][$course->id] as $objective) {
178
+    //    $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
179
+    //  }
180
+    //}
181
+    //$typ_info['courses'] = DB::select("select * from courses where id in (select course_id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where typ_semester_outcome_id in (select id from type_semester_outcome where semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id} )and outcome_id = ?)))", array(Input::get('id')));
182
+    //$typ_info['unique_objective'] = DB::select("select * from objectives where id in (select distinct objective_id from typ_semester_objectives where  typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id = {$semester->id} and outcome_id =? and typ_program_id in (select id from typ_program where program_id ={$program_id})))", array(Input::get('id')));
183
+    //foreach ($typ_info['unique_objective'] as $objective) {
184
+    //  $typ_info['courses_objective'][$objective->id] = DB::select("select * from courses where id in (SELECT course_id from typ_semester_courses where typ_semester_outcome_id in (select id from typ_semester_outcome where semester_id={$semester->id} and outcome_id =? and typ_program_id in (select id from typ_program where program_id = {$program_id})) and id in (select typ_semester_course_id from typ_semester_objectives where objective_id  = {$objective->id}))", array(Input::get('id')));
185
+    //  $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
186
+    //}
187
+    $annual_plan = DB::select("select id from annual_plans where (semester_start = {$semester->id} or semester_end ={$semester->id}) and program_id ={$program_id}")[0];
188
+    $typ_info['objectives'] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = ? and semester_id = {$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id})))", array(Input::get('id')));
189
+    $typ_info['transformative_actions'] = DB::select("select * from transformative_actions where by_professor =0 and is_custom=0");
190
+    foreach ($typ_info['objectives'] as $objective) {
191
+
192
+      $typ_info['courses'][$objective->id] = DB::select("select c.id, c.number, c.code, typ.id typ_course_id from courses c, typ_semester_courses typ, (select course_id, id  from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id =? and semester_id ={$semester->id} and typ_program_id in(select id from typ_program where program_id ={$program_id})))) rel where typ.course_id =c.id and rel.course_id = c.id and typ.id = rel.id ", array(Input::get('id')));
193
+
194
+      $typ_info['criteria'][$objective->id] = DB::select("select * from new_criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
195
+      Log::info($typ_info['criteria'][$objective->id]);
196
+      $typ_info['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id =? and semester_id ={$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id}))", array(Input::get('id')));
197
+      Log::info($typ_info['typ_objective_id'][$objective->id]);
198
+      $typ_info['typ_objective_id'][$objective->id] = $typ_info['typ_objective_id'][$objective->id][0];
199
+
200
+      Log::info($typ_info['typ_objective_id'][$objective->id]->id);
201
+      Log::info($annual_plan->id);
202
+      $typ_info['annual_plans_transformative'][$objective->id] = DB::select("select trans_id from annual_plan_transformative where annual_plan_id={$annual_plan->id} and typ_semester_objective_id ={$typ_info['typ_objective_id'][$objective->id]->id}");
203
+      foreach ($typ_info['courses'][$objective->id] as $course) {
204
+        $typ_info['selected_criteria'][$objective->id][$course->id] = DB::select("select criteria_id, typ_semester_course_id typ_course_id from annual_plan_objective where annual_plan_id ={$annual_plan->id} and typ_semester_course_id ={$course->typ_course_id} ");
205
+      }
206
+
207
+
208
+      $typ_info['custom_transformative'][$objective->id] = DB::select("select * from transformative_actions where is_custom =1 and by_professor=0 and id in (select ta_id from transformative_objective_program where objective_id = {$objective->id})");
209
+    }
210
+    $typ_info['annual_plan'] = $annual_plan;
211
+    Log::info($typ_info);
212
+
213
+    return json_encode($typ_info);
214
+  }
215
+  public function deleteTA()
216
+  {
217
+    $annual_id = Input::get('annual_id') + 0;
218
+    $typ_id = Input::get('typ_id') + 0;
219
+    $trans_id = Input::get('TA_id') + 0;
220
+
221
+    DB::delete("delete from `annual_plan_transformative` where annual_plan_id ={$annual_id} and typ_semester_objective_id ={$typ_id} and trans_id={$trans_id}");
222
+    return;
223
+  }
224
+
225
+  public function postTA()
226
+  {
227
+    $annual_id = Input::get('annual_id') + 0;
228
+    $TA_id = Input::get('TA_id') + 0;
229
+    $typ_id = Input::get('typ_id') + 0;
230
+    $old_ta = Input::get('old_ta') + 0;
231
+    $id = Auth::user()['id'];
232
+    $date = date('Y-m-d');
233
+    $date = strtotime($date);
234
+
235
+
236
+    $query = DB::select("select * from annual_plan_transformative where annual_plan_id ={$annual_id} and trans_id ={$old_ta} and typ_semester_objective_id ={$typ_id}");
237
+
238
+    if (!count($query)) {
239
+      DB::insert("insert into `annual_plan_transformative` (`annual_plan_id`,`trans_id`, `typ_semester_objective_id`, `proposing_coordinator_id`, `proposed_date`) values({$annual_id},{$TA_id},{$typ_id}, {$id}, now() ) ");
240
+      return "Insert Successful";
241
+    } else {
242
+      if ($TA_id == 0) {
243
+        DB::delete("delete from annual_plan_transformative where trans_id={$TA_id} and annual_plan_id ={$annual_id} and typ_semester_objective_id ={$typ_id}");
244
+        return "deleted";
245
+      } else {
246
+        DB::update("update annual_plan_transformative set trans_id = {$TA_id}, proposing_coordinator_id = {$id}, proposed_date = now() where trans_id={$old_ta} and annual_plan_id ={$annual_id} and typ_semester_objective_id ={$typ_id}");
247
+        return "updated";
248
+      }
249
+    }
250
+  }
251
+  public function transformativeReport()
252
+  {
253
+    $json_to_send = array();
254
+    $annual_id = Input::get('an_id');
255
+    $transformative_action_info = DB::select("select * from transformative_actions where id in (select distinct trans_id from annual_plan_transformative where annual_plan_id = {$annual_id}) ");
256
+    foreach ($transformative_action_info as $trans) {
257
+      $json_to_send['Trans_act'][$trans->id] = $trans;
258
+      $json_to_send['outcomes'][$trans->id] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where id in(select typ_semester_outcome_id from typ_semester_objectives where id in (select typ_semester_objective_id from annual_plan_transformative where trans_id ={$trans->id} and annual_plan_id = {$annual_id})))");
259
+      $json_to_send['typ_objective'][$trans->id] = DB::select("select * from typ_semester_objectives where id in (select typ_semester_objective_id from annual_plan_transformative where annual_plan_id ={$annual_id} and trans_id = {$trans->id})");
260
+      foreach ($json_to_send['typ_objective'][$trans->id] as $typ) {
261
+        $json_to_send['objective'][$typ->id][$trans->id] = DB::select("select * from objectives where id = {$typ->objective_id}");
262
+        $json_to_send['coordinator'][$typ->id][$trans->id] = DB::select("select * from users where id in (select proposing_coordinator_id from annual_plan_transformative where typ_semester_objective_id = {$typ->id} and annual_plan_id = {$annual_id} and trans_id = {$trans->id})");
263
+        $json_to_send['proposed_date'][$typ->id][$trans->id] = DB::select("select proposed_date from annual_plan_transformative where typ_semester_objective_id = {$typ->id} and annual_plan_id = {$annual_id} and trans_id = {$trans->id} ");
264
+        $json_to_send['all_info_report'][$typ->id][$trans->id] = DB::select("select art.accomplished, art.cycle_of_life, semesters.name, art.semester_continue,  art.annual_trans_id, art.supervised_coordinator_id  from annual_report_transformative art, (select id from annual_plan_transformative where typ_semester_objective_id = {$typ->id} and annual_plan_id = {$annual_id} and trans_id = {$trans->id} ) apt, semesters  where art.annual_trans_id = apt.id and semesters.id = art.semester_used");
265
+      }
266
+
267
+      if ($trans->user_id) {
268
+        $json_to_send['suggested'][$trans->id] = DB::select("select * from users where id = {$trans->user_id}");
269
+      }
270
+    }
271
+    return json_encode($json_to_send);
272
+  }
273
+
274
+  public function deleteCriteria()
275
+  {
276
+    $criteria = Input::get('criteria') + 0;
277
+    $typ_course_id = Input::get('typ_course_id') + 0;
278
+    $annual_plan = Input::get('annual_plan') + 0;
279
+    $old_criteria = Input::get('old_criteria') + 0;
280
+    $message = '';
281
+
282
+    DB::delete("delete from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id ={$typ_course_id} and criteria_id={$criteria}");
283
+    return;
284
+  }
285
+
286
+  public function fetchAllTables()
287
+  {
288
+    $annual_plan = array();
289
+    $an_id = Input::get('id');
290
+    $program_id = Input::get('program_id');
291
+
292
+    $an_semesters = DB::select("select semester_start, semester_end, program_id from annual_plans where id ={$an_id} and program_id ={$program_id}")[0];
293
+
294
+    $annual_plan['first']['outcomes'] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id = {$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))");
295
+
296
+    $annual_plan['second']['outcomes'] = DB::select("select * from outcomes where id in (select outcome_id from typ_semester_outcome where semester_id = {$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))");
297
+
298
+    $annual_plan['first']['semester'] = array('id' => $an_semesters->semester_start);
299
+    $annual_plan['second']['semester'] = array('id' => $an_semesters->semester_end);
300
+    foreach ($annual_plan['first']['outcomes'] as $outcomes) {
301
+
302
+      $annual_plan['first']['objectives'][$outcomes->id] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = {$outcomes->id} and semester_id = {$an_semesters->semester_start} and typ_program_id in (select id from typ_program where program_id ={$an_semesters->program_id})))");
303
+
304
+      foreach ($annual_plan['first']['objectives'][$outcomes->id] as $objective) {
305
+        $annual_plan['first']['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and  typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})) ")[0];
306
+        $annual_plan['first']['courses'][$objective->id] = DB::select("select typ.id typ_id, typ.course_id, c.code, c.number from (select course_id, id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})))) typ, courses c where c.id = typ.course_id");
307
+        foreach ($annual_plan['first']['courses'][$objective->id] as $course) {
308
+          $annual_plan['first']['criteria'][$objective->id][$course->course_id] = DB::select("select * from new_criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id = {$course->typ_id} )");
309
+        }
310
+
311
+        $annual_plan['first']['trans_actions'][$objective->id] = DB::select("select * from transformative_actions where id in (select trans_id from annual_plan_transformative where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_start} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))))");
312
+        foreach ($annual_plan['first']['trans_actions'][$objective->id] as $trans) {
313
+          $annual_plan['fill_info'][$annual_plan['first']['typ_objective_id'][$objective->id]->id][$trans->id] = DB::select("select * from annual_report_transformative where annual_trans_id in (select id from annual_plan_transformative where trans_id = {$trans->id} and typ_semester_objective_id ={$annual_plan['first']['typ_objective_id'][$objective->id]->id} and annual_plan_id = {$an_id} )")[0];
314
+        }
315
+      }
316
+    }
317
+    foreach ($annual_plan['second']['outcomes'] as $outcomes) {
318
+      $annual_plan['second']['objectives'][$outcomes->id] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = {$outcomes->id} and semester_id = {$an_semesters->semester_end} and typ_program_id in (select id from typ_program where program_id ={$an_semesters->program_id})))");
319
+      foreach ($annual_plan['second']['objectives'][$outcomes->id] as $objective) {
320
+        $annual_plan['second']['typ_objective_id'][$objective->id] = DB::select("select id from typ_semester_objectives where objective_id = {$objective->id} and  typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})) ")[0];
321
+
322
+        $annual_plan['second']['courses'][$objective->id] = DB::select("select typ.id typ_id, typ.course_id, c.code, c.number from (select course_id, id from typ_semester_courses where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id})))) typ, courses c where c.id = typ.course_id");
323
+        foreach ($annual_plan['second']['courses'][$objective->id] as $course) {
324
+          $annual_plan['second']['criteria'][$objective->id][$course->course_id] = DB::select("select * from new_criteria where id in(select criteria_id from annual_plan_objective where annual_plan_id = {$an_id} and typ_semester_course_id ={$course->typ_id})");
325
+        }
326
+
327
+        $annual_plan['second']['trans_actions'][$objective->id] = DB::select("select * from transformative_actions where id in (select trans_id from annual_plan_transformative where typ_semester_objective_id in (select id from typ_semester_objectives where objective_id ={$objective->id} and typ_semester_outcome_id in (select id from typ_semester_outcome where outcome_id ={$outcomes->id} and semester_id ={$an_semesters->semester_end} and typ_program_id in(select id from typ_program where program_id ={$an_semesters->program_id}))))");
328
+        Log::info($annual_plan['second']['typ_objective_id'][$objective->id]->id);
329
+        foreach ($annual_plan['second']['trans_actions'][$objective->id] as $trans) {
330
+          $annual_plan['fill_info'][$annual_plan['second']['typ_objective_id'][$objective->id]->id][$trans->id] = DB::select("select * from annual_report_transformative where annual_trans_id in (select id from annual_plan_transformative where trans_id = {$trans->id} and typ_semester_objective_id ={$annual_plan['second']['typ_objective_id'][$objective->id]->id} and annual_plan_id = {$an_id} )")[0];
331
+        }
332
+      }
333
+    }
334
+
335
+    return json_encode($annual_plan);
336
+  }
337
+
338
+  public function postAnnualPlan()
339
+  {
340
+    $criteria = Input::get('criteria') + 0;
341
+    $typ_course_id = Input::get('typ_course_id') + 0;
342
+    $annual_plan = Input::get('annual_plan') + 0;
343
+    $old_criteria = Input::get('old_criteria') + 0;
344
+    $message = '';
345
+    $query = DB::select("select * from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id = {$typ_course_id} and criteria_id ={$old_criteria}");
346
+    if (!count($query)) {
347
+      $query = DB::select("select * from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id = {$typ_course_id} and criteria_id ={$criteria}");
348
+
349
+      if (!count($query)) {
350
+
351
+        DB::insert("insert into `annual_plan_objective` (`annual_plan_id`, `typ_semester_course_id`, `criteria_id`) values ({$annual_plan}, {$typ_course_id}, {$criteria})");
352
+        $message = "inserting was a success";
353
+      } else {
354
+        $message = "Duplicate entry, please choose another criteria.";
355
+      }
356
+    } else {
357
+      $query = DB::select("select * from annual_plan_objective where annual_plan_id ={$annual_plan} and typ_semester_course_id = {$typ_course_id} and criteria_id ={$criteria}");
358
+
359
+      if (!count($query)) {
360
+        DB::update("update `annual_plan_objective` set criteria_id = {$criteria} where annual_plan_id = {$annual_plan} and typ_semester_course_id ={$typ_course_id} and criteria_id = {$old_criteria} ");
361
+        $message = "Updating was a success";
362
+      } else {
363
+        $message = "Duplicate entry, please choose another criteria.";
364
+      }
365
+    }
366
+    return $message;
367
+  }
83 368
   public function create(Program $program)
84 369
   {
85
-    $title = 'New Annual Plan for '.$program->name;
370
+    $title = 'New Annual Plan for ' . $program->name;
86 371
     $user = Auth::user();
87 372
     $outcomes = Outcome::orderBy('name')->get();
88 373
 
89
-    $current_quinquennium = Quinquennium::
90
-      where('start_date', '<=', date('Y-m-d'))
374
+    $current_quinquennium = Quinquennium::where('start_date', '<=', date('Y-m-d'))
91 375
       ->where('end_date', '>=', date('Y-m-d'))
92 376
       ->first();
93 377
 
94
-    $courses = Course::
95
-      select('id', 'code', 'number', 'name')
378
+    $courses = Course::select('id', 'code', 'number', 'name')
96 379
       ->where('program_id', $program->id)
97 380
       ->groupBy('name')
98
-      ->orderBy('code','ASC')
99
-      ->orderBy('number','ASC')
100
-      ->orderBy('name','ASC')
381
+      ->orderBy('code', 'ASC')
382
+      ->orderBy('number', 'ASC')
383
+      ->orderBy('name', 'ASC')
101 384
       ->get();
102 385
 
103 386
     // Check if user can create a plan
104
-    if(!$this->userHasAccess($program->id))
105
-    {
387
+    if (!$this->userHasAccess($program->id)) {
106 388
       return View::make('global.403');
107 389
     }
108 390
 
109 391
     return View::make('local.managers.shared.create_annual_plan', compact('title', 'program', 'current_quinquennium', 'outcomes', 'courses'));
110 392
   }
111
-
112 393
 }

+ 86
- 94
app/controllers/ProgramCoordinatorsController.php Ver arquivo

@@ -1,109 +1,101 @@
1 1
 <?php
2 2
 
3
-class ProgramCoordinatorsController extends \BaseController {
4
-
5
-    public function overview()
6
-    {
7
-        //TODO Find a better way to prevent non-scoords from reaching the page
8
-        switch(Auth::user()->role)
9
-        {
10
-            case 1:
11
-                return Redirect::to('administrator');
12
-                break;
13
-            case 2:
14
-                return Redirect::to('school-coordinator');
15
-                break;
16
-        }
17
-
18
-        $title = 'Program Coordinator Overview';
3
+use Illuminate\Support\Facades\Auth;
4
+use Illuminate\Support\Facades\Log;
5
+
6
+class ProgramCoordinatorsController extends \BaseController
7
+{
8
+
9
+  public function overview()
10
+  {
11
+    //TODO Find a better way to prevent non-scoords from reaching the page
12
+    switch (Auth::user()->role) {
13
+      case 1:
14
+        return Redirect::to('administrator');
15
+        break;
16
+      case 2:
17
+        return Redirect::to('school-coordinator');
18
+        break;
19
+    }
20
+    Log::info(Auth::user()->programs);
21
+    $title = 'Program Coordinator Overview';
19 22
 
20
-        $programs = Auth::user()->programs;
23
+    $programs = Auth::user()->programs;
21 24
 
22
-        $outcomes = Outcome::orderBy('name', 'asc')->get();
23
-        $outcomeCount = Outcome::all()->count();
25
+    $outcomes = Outcome::orderBy('name', 'asc')->get();
26
+    $outcomeCount = Outcome::all()->count();
24 27
 
25
-        $programs_array = array();
26
-        $programs_contact = array();
28
+    $programs_array = array();
29
+    $programs_contact = array();
27 30
 
28
-        foreach ($programs as $program)
29
-        {
30
-          $program_array = array();
31
+    foreach ($programs as $program) {
32
+      $program_array = array();
31 33
 
32
-          $program_array['program'] = $program;
34
+      $program_array['program'] = $program;
33 35
 
34
-          $program_array['outcomes_achieved'] = array_fill(1, $outcomeCount, 0);
35
-          $program_array['outcomes_attempted'] = array_fill(1, $outcomeCount, 0);
36
+      $program_array['outcomes_achieved'] = array_fill(1, $outcomeCount, 0);
37
+      $program_array['outcomes_attempted'] = array_fill(1, $outcomeCount, 0);
36 38
 
37
-          $program_array['program_courses'] = $program->courses;
38
-          $program_array['grouped_objectives'] = $program->objectives();
39
+      $program_array['program_courses'] = $program->courses;
40
+      $program_array['grouped_objectives'] = $program->objectives();
39 41
 
40
-          $program_array['assessed_courses_count']=0;
41
-          foreach ($program_array['program_courses'] as $course)
42
-          {
43
-            if($course->outcomes_achieved!=NULL)
44
-            {
45
-              $program_array['course_outcomes_achieved'] =json_decode($course->outcomes_achieved, true);
46
-              $program_array['course_outcomes_attempted'] =json_decode($course->outcomes_attempted, true);
47
-              for($i=1; $i<=count($program_array['outcomes_attempted']); $i++)
48
-              {
49
-                $program_array['outcomes_achieved'][$i]+=$program_array['course_outcomes_achieved'][$i];
50
-                $program_array['outcomes_attempted'][$i]+=$program_array['course_outcomes_attempted'][$i];
51
-              }
52
-              $program_array['assessed_courses_count']+=1;
53
-            }
42
+      $program_array['assessed_courses_count'] = 0;
43
+      foreach ($program_array['program_courses'] as $course) {
44
+        if ($course->outcomes_achieved != NULL) {
45
+          $program_array['course_outcomes_achieved'] = json_decode($course->outcomes_achieved, true);
46
+          $program_array['course_outcomes_attempted'] = json_decode($course->outcomes_attempted, true);
47
+          for ($i = 1; $i <= count($program_array['outcomes_attempted']); $i++) {
48
+            $program_array['outcomes_achieved'][$i] += $program_array['course_outcomes_achieved'][$i];
49
+            $program_array['outcomes_attempted'][$i] += $program_array['course_outcomes_attempted'][$i];
54 50
           }
55
-
56
-          /**
57
-           * List of grouped courses (grouped sections)
58
-           */
59
-
60
-          $program_array['grouped_courses'] = Course::
61
-            select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
62
-            ->with('semester')
63
-            ->with('program')
64
-            ->where('program_id', $program->id)
65
-            ->whereIn('semester_id', Session::get('semesters_ids'))
66
-            ->groupBy(array('code', 'number', 'semester_id'))
67
-            ->orderBy('code')
68
-            ->orderBy('number')
69
-            ->orderBy('semester_id')
70
-            ->get();
71
-
72
-
73
-          $programs_array[] = $program_array;
74
-
75
-
76
-          // Program contact information
77
-          $users = User::
78
-              select('users.*')
79
-              ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
80
-              ->where(function($query) use($program)
81
-              {
82
-                $query
83
-                    ->where('school_id', $program->school_id)
84
-                    ->where('role', 2);
85
-              })
86
-              ->orWhere(function($query) use($program)
87
-              {
88
-                $query
89
-                    ->where('role', 3)
90
-                    ->where('program_id', $program->id);
91
-              })
92
-              ->orWhere(function($query) use($program)
93
-              {
94
-                $query
95
-                    ->where('role', 4)
96
-                    ->where('program_id', $program->id);
97
-              })
98
-              ->get();
99
-
100
-
101
-            $programs_contact[] = $users;
102
-
51
+          $program_array['assessed_courses_count'] += 1;
103 52
         }
104
-
105
-
106
-        return View::make('local.managers.pCoords.overview', compact('title', 'programs', 'outcomes', 'programs_array', 'programs_contact'));
53
+      }
54
+
55
+      /**
56
+       * List of grouped courses (grouped sections)
57
+       */
58
+
59
+      $program_array['grouped_courses'] = Course::select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
60
+        ->with('semester')
61
+        ->with('program')
62
+        ->where('program_id', $program->id)
63
+        ->whereIn('semester_id', Session::get('semesters_ids'))
64
+        ->groupBy(array('code', 'number', 'semester_id'))
65
+        ->orderBy('code')
66
+        ->orderBy('number')
67
+        ->orderBy('semester_id')
68
+        ->get();
69
+
70
+
71
+      $programs_array[] = $program_array;
72
+
73
+
74
+      // Program contact information
75
+      $users = User::select('users.*')
76
+        ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
77
+        ->where(function ($query) use ($program) {
78
+          $query
79
+            ->where('school_id', $program->school_id)
80
+            ->where('role', 2);
81
+        })
82
+        ->orWhere(function ($query) use ($program) {
83
+          $query
84
+            ->where('role', 3)
85
+            ->where('program_id', $program->id);
86
+        })
87
+        ->orWhere(function ($query) use ($program) {
88
+          $query
89
+            ->where('role', 4)
90
+            ->where('program_id', $program->id);
91
+        })
92
+        ->get();
93
+
94
+
95
+      $programs_contact[] = $users;
107 96
     }
108 97
 
98
+
99
+    return View::make('local.managers.pCoords.overview', compact('title', 'programs', 'outcomes', 'programs_array', 'programs_contact'));
100
+  }
109 101
 }

+ 8
- 16
app/controllers/ThreeYearPlanController.php Ver arquivo

@@ -329,12 +329,12 @@ class ThreeYearPlanController extends \BaseController
329 329
           }
330 330
 
331 331
           // lookup available objectives
332
-          $result_objectives = DB::table('criterion_objective_outcome')
333
-              ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
334
-              ->join('objectives','objectives.id','=','criterion_objective_outcome.objective_id')
332
+          $result_objectives = DB::table('objective_outcome')
333
+              ->join('outcomes','outcomes.id','=','objective_outcome.outcome_id')
334
+              ->join('objectives','objectives.id','=','objective_outcome.objective_id')
335 335
               ->join('objective_program','objective_program.objective_id','=','objectives.id')
336 336
               ->where('objective_program.program_id',$program_id)
337
-              ->where('criterion_objective_outcome.outcome_id',$outcome_id)
337
+              ->where('objective_outcome.outcome_id',$outcome_id)
338 338
               ->select('objectives.id','objectives.text','outcomes.name as outcome_name')
339 339
               ->orderBy('objectives.text', 'asc')
340 340
               ->get();
@@ -407,8 +407,6 @@ class ThreeYearPlanController extends \BaseController
407 407
         // buscar info sobre selected_semsters
408 408
         $outcome_->selected_semesters = array();
409 409
         foreach ($result_semesters as $semesters_) {
410
-          $semester_id = $semesters_->semester_id;
411
-
412 410
           $typ_semester_outcome_id = $semesters_->id;
413 411
           $result_objectives = DB::table('typ_semester_objectives')
414 412
               ->join('objectives','objectives.id','=','typ_semester_objectives.objective_id')
@@ -419,19 +417,13 @@ class ThreeYearPlanController extends \BaseController
419 417
 
420 418
           $semesters_->selected_objectives = array();
421 419
           foreach ($result_objectives as $objectives_) {
422
-            $objective_id = $objectives_->objective_id;
423
-            $program_id = $objectives_->program_id;
424
-            $result_courses = DB::table('objective_program')
425
-                ->join('objectives','objectives.id','=','objective_program.objective_id')
426
-                ->join('courses','courses.program_id','=','objective_program.program_id')
427
-                ->where('objective_program.objective_id', $objective_id)
428
-                ->where('objective_program.program_id', $program_id)
429
-                ->where('courses.semester_id', $semester_id)
430
-                ->distinct('courses.name','courses.code')
431
-                ->select('courses.id as course_id','courses.name','courses.code','objective_program.objective_id','objective_program.program_id')
420
+            $result_courses = DB::table('courses')
421
+                ->where('courses.program_id', $program_id)
422
+                ->select('courses.id as course_id','courses.name','courses.code','courses.program_id')
432 423
                 ->orderBy('courses.name', 'asc')
433 424
                 ->groupBy('courses.name','courses.code')
434 425
                 ->get();
426
+            #los cursos resultantes creo que deberian ser: todos los que se estan dando en mi programa
435 427
 
436 428
             $objectives_->available_courses = array();
437 429
             foreach ($result_courses as $courses_) {

app/database/migrations/2016_07_15_084851_create_annual_plans_table.php → app/database/migrations/2021_03_03_084851_create_annual_plans_table.php Ver arquivo

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class CreateAnnualPlansTable extends Migration {
6
+class CreateAnnualPlansTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,25 +13,23 @@ class CreateAnnualPlansTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::create('annual_plans', function(Blueprint $table)
16
-		{
17
-			$table->engine = 'InnoDB';
16
+		Schema::create('annual_plans', function (Blueprint $table) {
17
+
18 18
 			$table->increments('id');
19
-			$table->integer('quinquennium_id')->unsigned();
20
-			$table
21
-				->foreign('quinquennium_id')
19
+			$table->string('academic_year');
20
+			$table->integer('semester_start')->unsigned();
21
+			$table->foreign('semester_start')
22 22
 				->references('id')
23
-				->on('quinquenniums')
23
+				->on('semesters')
24 24
 				->onDelete('cascade')
25 25
 				->onUpdate('cascade');
26
-			$table->integer('program_id')->unsigned();
27
-			$table->integer('semester_id')->unsigned();
28
-			$table
29
-				->foreign('semester_id')
26
+			$table->integer('semester_end')->unsigned();
27
+			$table->foreign('semester_end')
30 28
 				->references('id')
31 29
 				->on('semesters')
32 30
 				->onDelete('cascade')
33 31
 				->onUpdate('cascade');
32
+			$table->integer('program_id')->unsigned();
34 33
 			$table
35 34
 				->foreign('program_id')
36 35
 				->references('id')
@@ -53,5 +52,4 @@ class CreateAnnualPlansTable extends Migration {
53 52
 	{
54 53
 		Schema::drop('annual_plans');
55 54
 	}
56
-
57 55
 }

app/database/migrations/2016_07_15_090217_create_annual_plan_outcomes_table.php → app/database/migrations/2021_03_03_090217_create_annual_plan_objective_table.php Ver arquivo

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class CreateAnnualPlanOutcomesTable extends Migration {
6
+class CreateAnnualPlanObjectiveTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,9 +13,8 @@ class CreateAnnualPlanOutcomesTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::create('annual_plan_outcomes', function(Blueprint $table)
16
-		{
17
-			$table->engine = 'InnoDB';
16
+		Schema::create('annual_plan_objective', function (Blueprint $table) {
17
+
18 18
 			$table->increments('id');
19 19
 			$table->integer('annual_plan_id')->unsigned();
20 20
 			$table
@@ -23,21 +23,22 @@ class CreateAnnualPlanOutcomesTable extends Migration {
23 23
 				->on('annual_plans')
24 24
 				->onDelete('cascade')
25 25
 				->onUpdate('cascade');
26
-			$table->integer('outcome_id')->unsigned();
26
+			$table->integer('typ_semester_course_id')->unsigned();
27 27
 			$table
28
-				->foreign('outcome_id')
28
+				->foreign('typ_semester_course_id')
29 29
 				->references('id')
30
-				->on('outcomes')
30
+				->on('typ_semester_courses')
31 31
 				->onDelete('cascade')
32 32
 				->onUpdate('cascade');
33
-			$table->text('objectives')->nullable();
34
-			$table->text('courses')->nullable();
35
-			$table->text('methods')->nullable();
36
-			$table->tinyInteger('display_order');
33
+			$table->integer('criteria_id')->unsigned();
34
+			$table->foreign('criteria_id')
35
+				->references('id')
36
+				->on('new_criteria')
37
+				->onUpdate('cascade')
38
+				->onDelete('cascade');
39
+
37 40
 			$table->timestamps();
38 41
 		});
39
-
40
-		DB::statement("ALTER TABLE `fyp_part_outcomes` comment 'Outcomes for the annual plans'");
41 42
 	}
42 43
 
43 44
 
@@ -48,7 +49,6 @@ class CreateAnnualPlanOutcomesTable extends Migration {
48 49
 	 */
49 50
 	public function down()
50 51
 	{
51
-		Schema::drop('annual_plan_outcomes');
52
+		Schema::drop('annual_plan_objective');
52 53
 	}
53
-
54 54
 }

+ 18
- 5
app/database/migrations/2021_03_29_154844_create_annual_plan_transformative.php Ver arquivo

@@ -15,18 +15,31 @@ class CreateAnnualPlanTransformative extends Migration
15 15
 	{
16 16
 		Schema::create('annual_plan_transformative', function (Blueprint $table) {
17 17
 			$table->increments('id');
18
-			$table->integer('annual_plan')->unsigned();
19
-			$table->integer('trans_op_id')->unsigned();
20
-			$table->foreign('trans_op_id')
18
+			$table->integer('annual_plan_id')->unsigned();
19
+			$table->integer('trans_id')->unsigned();
20
+			$table->foreign('trans_id')
21 21
 				->references('id')
22
-				->on('transformative_objective_program')
22
+				->on('transformative_actions')
23 23
 				->onDelete('cascade')
24 24
 				->onUpdate('cascade');
25
-			$table->foreign('annual_plan')
25
+			$table->foreign('annual_plan_id')
26 26
 				->references('id')
27 27
 				->on('annual_plans')
28 28
 				->onDelete('cascade')
29 29
 				->onUpdate('cascade');
30
+			$table->integer('typ_semester_objective_id')->unsigned();
31
+			$table->foreign('typ_semester_objective_id')
32
+				->references('id')
33
+				->on('typ_semester_objectives')
34
+				->onDelete('cascade')
35
+				->onUpdate('cascade');
36
+			$table->integer('proposing_coordinator_id')->unsigned();
37
+			$table->foreign('proposing_coordinator_id')
38
+				->references('id')
39
+				->on('users')
40
+				->onDelete('restrict')
41
+				->onUpdate('restrict');
42
+			$table->dateTime('proposed_date');
30 43
 		});
31 44
 	}
32 45
 

+ 57
- 0
app/database/migrations/2021_03_29_155542_create_annual_report_transformative.php Ver arquivo

@@ -0,0 +1,57 @@
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('annual_trans_id')->unsigned();
24
+			$table->foreign('annual_trans_id')
25
+				->references('id')
26
+				->on('annual_plan_transformative')
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
+			$table->integer('supervised_coordinator_id')->unsigned();
40
+			$table->foreign('supervised_coordinator_id')
41
+				->references('id')
42
+				->on('users')
43
+				->onDelete('restrict')
44
+				->onUpdate('restrict');
45
+		});
46
+	}
47
+
48
+	/**
49
+	 * Reverse the migrations.
50
+	 *
51
+	 * @return void
52
+	 */
53
+	public function down()
54
+	{
55
+		Schema::drop('annual_report_transformative');
56
+	}
57
+}

+ 55
- 0
app/database/migrations/2021_05_18_102422_create_overview_table.php Ver arquivo

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

app/database/migrations/2021_01_28_174905_fixObjectivesTable.php → app/database/unusedMigrations/2021_01_28_174905_fixObjectivesTable.php Ver arquivo


app/database/migrations/2021_02_16_142747_create_cycles_table.php → app/database/unusedMigrations/2021_02_16_142747_create_cycles_table.php Ver arquivo


app/database/migrations/2021_02_16_142832_create_cycles_semesters_table.php → app/database/unusedMigrations/2021_02_17_190111_create_three_year_plans_table.php Ver arquivo

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

+ 48
- 0
app/database/unusedMigrations/2021_02_17_190118_create_typ_parts_table.php Ver arquivo

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

+ 63
- 0
app/database/unusedMigrations/2021_02_17_190124_create_typ_part_outcomes_table.php Ver arquivo

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

+ 37
- 1
app/routes.php Ver arquivo

@@ -256,6 +256,8 @@ Route::group(array('before' => 'auth|has_access'), function () {
256 256
      */
257 257
     Route::group(array('before' => 'admin'), function () {
258 258
         Route::get('/administrator', 'AdministratorsController@overview');
259
+        Route::get('/administrator2', 'AdministratorsController@overview2');
260
+        Route::post('/administrator2/filter', 'AdministratorsController@overview2_filter_results');
259 261
         Route::post('administrator/rubrics', array(
260 262
             'as' => 'rubrics',
261 263
             'before' => 'csrf',
@@ -315,11 +317,25 @@ Route::group(array('before' => 'auth|has_access'), function () {
315 317
         Route::get('print_school/{id}', 'SchoolsController@print_school');
316 318
 
317 319
         // Assessment reports
320
+
318 321
         Route::get('school-assessment-report/{outcome_id}', 'OutcomesController@schoolAssessmentReport');
319 322
 
320 323
         // Gabriel added this, so the school coordinator can add criterias and objectives
324
+        Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
321 325
         Route::get('school-objective', 'Objective2Controller@editSchool');
322 326
         Route::get('school-criteria', 'CriteriaController@editSchool');
327
+        //Show users annual plan
328
+        Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
329
+        Route::post('annual-plan-fetchTYP/{program_id}/{typ_id}', 'AnnualPlansController@fetchTYP');
330
+        Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
331
+        Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
332
+        Route::get('annual-plan-show/{program_id}', 'AnnualPlansController@viewAllPlans');
333
+        Route::post('fetchAllTables', 'AnnualPlansController@fetchAllTables');
334
+        Route::post('annual-plan-postTA', 'AnnualPlansController@postTA');
335
+        Route::post('annual-report-post', 'AnnualPlansController@postReport');
336
+        Route::post('annual-plan-deleteTA', 'AnnualPlansController@deleteTA');
337
+        Route::post('annual-plan-trans-report', 'AnnualPlansController@transformativeReport');
338
+
323 339
 
324 340
         // Show users plan de tres a~nos
325 341
         Route::get('three-years-plan', 'ThreeYearPlanController@threeYearsReport');
@@ -349,7 +365,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
349 365
         Route::get('course/{id}', 'CoursesController@showLimited');
350 366
         Route::get('rubrics/{template_id}/download', 'TemplatesController@download');
351 367
         Route::post('program/fetch', array('before' => 'csrf', 'uses' => 'ProgramsController@fetch'));
352
-
368
+        Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
353 369
         Route::get('printRubric/{id}', 'TemplatesController@printview');
354 370
         Route::get('rubric/{rubric_id}', 'RubricsController@show_limited');
355 371
         Route::get('grouped_course/{code}/{number}/{semester_code}', 'CoursesController@showGrouped');
@@ -406,6 +422,25 @@ Route::group(array('before' => 'auth|has_access'), function () {
406 422
         Route::get('new-report-all', 'OutcomesController@newReportAll');
407 423
         Route::get('courses/{id}', 'CoursesController@newShow');
408 424
 
425
+        Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
426
+        Route::post('annual-plan-fetchTYP/{program_id}', 'AnnualPlansController@fetchTYP');
427
+        Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
428
+        Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
429
+
430
+        //Gabriel added this
431
+
432
+        Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
433
+        Route::post('annual-plan-fetchTYP/{program_id}/{typ_id}', 'AnnualPlansController@fetchTYP');
434
+        Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
435
+        Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
436
+        Route::get('annual-plan-show/{program_id}', 'AnnualPlansController@viewAllPlans');
437
+        Route::post('fetchAllTables', 'AnnualPlansController@fetchAllTables');
438
+        Route::post('annual-plan-postTA', 'AnnualPlansController@postTA');
439
+        Route::post('annual-report-post', 'AnnualPlansController@postReport');
440
+        Route::post('annual-plan-deleteTA', 'AnnualPlansController@deleteTA');
441
+        Route::post('annual-plan-trans-report', 'AnnualPlansController@transformativeReport');
442
+
443
+
409 444
         // Transformative Actions
410 445
         Route::post('transformativeAction/approveTA', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@approveTA'));
411 446
 
@@ -421,6 +456,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
421 456
         Route::post('typ/updateOutcomeSemsters', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@typ_update_outcomes_semesters'));
422 457
         Route::post('typ/update', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@update_typ_outcomes_semesters'));
423 458
 
459
+
424 460
     });
425 461
 
426 462
 

+ 1
- 1
app/views/global/_datatables_js.blade.php Ver arquivo

@@ -8,4 +8,4 @@
8 8
 <script src="{{ asset('vendor/bower_components/datatables.net-buttons/js/buttons.html5.min.js') }}"></script>
9 9
 <script src="{{ asset('vendor/bower_components/datatables.net-buttons/js/buttons.print.min.js') }}"></script>
10 10
 <script src="{{ asset('vendor/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') }}"></script>
11
-<script src="{{ asset('vendor/bower_components/datatables.net-buttons-bs/js/buttons.bootstrap.min.js') }}"></script>
11
+<script src="{{ asset('vendor/bower_components/datatables.net-buttons-bs/js/buttons.bootstrap.min.js') }}"></script>

+ 539
- 0
app/views/layouts/master-2.blade.php
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 4
- 2
app/views/local/managers/admins/_navigation.blade.php Ver arquivo

@@ -3,8 +3,7 @@
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
+      <li>{{ HTML::linkAction('AdministratorsController@overview2', 'Overview2') }}</li>
8 7
 
9 8
       <li class="dropdown">
10 9
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Management<span class="caret"></span></a>
@@ -35,6 +34,7 @@
35 34
         </ul>
36 35
       </li>
37 36
       <li>{{ HTML::linkAction('ProgramsController@index', 'Programs') }}</li>
37
+
38 38
       @if(count(Auth::user()->courses))
39 39
       <li> {{ HTML::linkAction('ProfessorsController@overview', 'My Courses', NULL) }}</li>
40 40
       <li class="dropdown">
@@ -45,6 +45,7 @@
45 45
           @endforeach
46 46
         </ul>
47 47
       </li>
48
+
48 49
       @endif
49 50
 
50 51
       <li class="dropdown">
@@ -53,6 +54,7 @@
53 54
           <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Campus Reports') }}</li>
54 55
           @if(count(Auth::user()->courses))
55 56
           <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
57
+
56 58
           @endif
57 59
         </ul>
58 60
       </li>

+ 30
- 0
app/views/local/managers/admins/appraisal-program.blade.php Ver arquivo

@@ -0,0 +1,30 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if(Auth::user()->role==1)
5
+        @include('local.managers.admins._navigation')
6
+    @elseif(Auth::user()->role==2)
7
+        @include('local.managers.sCoords._navigation')
8
+    @elseif(Auth::user()->role==3)
9
+        @include('local.managers.pCoords._navigation')
10
+    @endif
11
+@stop
12
+
13
+@section('main')
14
+    <div class="row">
15
+        <div class="col-md-12">
16
+            <p>Click the links below to see annual appraisal plans for a specific program with assessed courses:</p>
17
+            
18
+            
19
+            <ol id="table-of-contents" class="upper-roman">
20
+            @foreach($programs as $program)
21
+                <li>
22
+                    <a href="{{ URL::action('AnnualPlansController@showPlan', array($program->id))}}">
23
+                        {{ $program->name }}
24
+                    </a>
25
+                </li>
26
+            @endforeach
27
+            </ol>
28
+        </div>
29
+    </div>
30
+@stop

+ 1
- 1
app/views/local/managers/admins/new_criteria.blade.php Ver arquivo

@@ -642,7 +642,7 @@
642 642
         $("#" + objectiveGroup + ' select').each(function() {
643 643
             var temp = {
644 644
                 id: this.attr('id'),
645
-                value: this.find(":selected").val();
645
+                value: this.val()
646 646
             }
647 647
             array_push(allObjectives, temp);
648 648
         })

+ 515
- 0
app/views/local/managers/admins/overview2.blade.php Ver arquivo

@@ -0,0 +1,515 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+@include('local.managers.admins._navigation')
5
+@stop
6
+
7
+@section('main')
8
+
9
+<div>
10
+  <div class="">
11
+    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
12
+    <script type="text/javascript">
13
+
14
+    function make_chart(outcomes_info, semesters) {
15
+      //////// Get values ready for chart
16
+      var target_line = {{$target}};
17
+      var x_label = 'Learning Outcomes';
18
+      var y_label = 'Percent of students';
19
+      var outcomes_labels = Array();
20
+      var i = 0;
21
+      outcomes_info.forEach(eachOutcome);
22
+      function eachOutcome(outcome, index) {
23
+        outcomes_labels.push({v: (index+1), f: outcome.name});
24
+        i = i + 1;
25
+      }
26
+
27
+      //
28
+      var outcomes_data = Array();
29
+
30
+      var legend = Array();
31
+      legend.push('');
32
+      legend.push('Target');
33
+      $.each(semesters, function(index, semester){
34
+        var name = semester.name;
35
+        name = name.split(' ');
36
+        var semester_number = name[0];
37
+        var semester_year = name[2];
38
+
39
+        if (semester_number == 'First'){
40
+          semester_number = '1';
41
+        }
42
+        else if (semester_number == 'Second'){
43
+          semester_number = '2';
44
+        }
45
+
46
+        name = semester_year + " Sem " + semester_number;
47
+        legend.push(name);
48
+      });
49
+      outcomes_data.push(legend);
50
+
51
+      //
52
+      var hidden_values = Array();
53
+      hidden_values.push(0);
54
+      hidden_values.push(target_line);
55
+      var k = 0;
56
+      while (k < semesters.length){
57
+        hidden_values.push(null);
58
+        k = k + 1;
59
+      }
60
+
61
+      //
62
+      outcomes_data.push(hidden_values);
63
+
64
+      $.each(outcomes_info, function(index, outcome){
65
+        var temp_outcome_grouping_info = Array();
66
+        temp_outcome_grouping_info.push({v:(index+1),f:"Students acheiving Learning Outcomes"});
67
+        temp_outcome_grouping_info.push(target_line);
68
+
69
+        var i = 0;
70
+        $.each(outcome.semesters, function(index, semester){
71
+
72
+          // if semester is not the same, insert null.
73
+          //  else, insert info from expected semester.
74
+          if(semester.name != semesters[i].name){
75
+            while(semester.name != semesters[i].name && i < semesters.length){
76
+              temp_outcome_grouping_info.push(null);
77
+              i = i + 1;
78
+            }
79
+          }
80
+          i = i + 1;
81
+
82
+          var total = semester.total_evaluated;
83
+          var achievers = semester.total_achieved;
84
+
85
+          var percentage = achievers/total;
86
+          var display_percentage = percentage*100;
87
+          temp_outcome_grouping_info.push({v:percentage,f:'\nAchieved by ' + display_percentage.toFixed(2) + '%\n(' + achievers + ' achievers and ' + total + ' participants)'});
88
+        });
89
+
90
+        var i = temp_outcome_grouping_info.length;
91
+        while(i < semesters.length+2){
92
+          temp_outcome_grouping_info.push(null);
93
+          i = i + 1;
94
+        }
95
+
96
+        outcomes_data.push(temp_outcome_grouping_info);
97
+      });
98
+      var last_hidden_values = [...hidden_values];
99
+      last_hidden_values[0] = i+1;
100
+      outcomes_data.push(last_hidden_values);
101
+
102
+      ////////
103
+      google.charts.load('current', {
104
+        packages: ['corechart']
105
+      }).then(function () {
106
+        var data = google.visualization.arrayToDataTable(outcomes_data);
107
+        // var data = google.visualization.arrayToDataTable([
108
+        //   ['', 'Target', '2020-21 Sem 2', '2021-22 Sem 1', '2021-22 Sem 2'],
109
+        //   [0, 0.80, null, null, null],
110
+        //   [{v:1,f:"Students acheiving Learning Outcomes"}, 0.80, {v:0.8275,f:82.75}, {v:0.9075,f:'\nAchieved by '+(90.75).toString()+'%\n(60 achievers and 80 participants)'}, {v:0.8475,f:84.75}],
111
+        //   [{v:2,f:"Students acheiving Learning Outcomes"}, 0.80, {v:0.7475,f:74.75}, {v:0.8775,f:87.75}, {v:0.9975,f:60.75}],
112
+        //   [{v:3,f:"Students acheiving Learning Outcomes"}, 0.80, {v:0.6875,f:68.75}, {v:0.9175,f:91.75}, {v:0.8475,f:84.75}],
113
+        //   [4, 0.80, null, null, null]
114
+        // ]);
115
+
116
+        var chartDiv = document.getElementById('chart_div');
117
+        var chart = new google.visualization.ColumnChart(chartDiv);
118
+        chart.draw(data, {
119
+          // colors: ['lime', 'magenta'],
120
+          hAxis: {
121
+            title: x_label,
122
+            ticks: outcomes_labels,
123
+            viewWindow: {
124
+              min: 0.5,
125
+              max: outcomes_info.length + 0.5 // el total de outcomes + 0.5
126
+            },
127
+            textStyle : {
128
+              fontSize: 10,
129
+              bold: true,
130
+            }
131
+          },
132
+          legend: 'right',
133
+          series: {
134
+            0: {
135
+              type: 'line'
136
+            }
137
+          },
138
+          title: ' ',
139
+          chartArea: {
140
+            width: '70%',
141
+            // top: 10,
142
+            // height: '50%'
143
+          },
144
+          vAxis: {
145
+            title: y_label,
146
+            format: 'percent',
147
+            viewWindow: {
148
+              min: 0,
149
+              max: 1
150
+            }
151
+          }
152
+        });
153
+      });
154
+    }
155
+
156
+
157
+    // labels for each outcome grouping
158
+    var outcomes_info = <?= json_encode($outcomes, JSON_HEX_TAG); ?>;
159
+    var semesters = <?= json_encode($semesters, JSON_HEX_TAG); ?>;
160
+
161
+    make_chart(outcomes_info,semesters);
162
+
163
+    </script>
164
+    <script src="https://www.gstatic.com/charts/loader.js"></script>
165
+    <div class="">
166
+      <div class="filters">
167
+        <div class="row" style="display: flex;">
168
+          <div class="category" >
169
+            <label for="school">School</label>
170
+            <div class="select">
171
+              <select multiple class="selectpicker" name="school" id="school">
172
+                <option value="0" selected="selected">All</option>
173
+                @foreach ($filters['school'] as $school)
174
+                  <option value="{{$school->id}}">{{$school->name}}</option>
175
+                @endforeach
176
+              </select>
177
+            </div>
178
+          </div>
179
+          <div class="category" >
180
+            <label for="program" >Academic Program</label>
181
+            <div class="select">
182
+              <select multiple class="selectpicker" name="program" id="program">
183
+                <option value="0" selected="selected">All</option>
184
+                @foreach ($filters['program'] as $program)
185
+                  <option value="{{$program->id}}">{{$program->name}}</option>
186
+                @endforeach
187
+              </select>
188
+            </div>
189
+          </div>
190
+        </div>
191
+        <div class="row" style="display: flex;">
192
+          <div class="category" >
193
+            <label for="semester">Semester</label>
194
+            <div class="select">
195
+              <select multiple class="selectpicker" name="semester" id="semester">
196
+                <option value="0" selected="selected">All</option>
197
+                @foreach ($filters['semester'] as $semester)
198
+                  <option value="{{$semester->id}}">{{$semester->name}}</option>
199
+                @endforeach
200
+              </select>
201
+            </div>
202
+          </div>
203
+          <div class="category" >
204
+            <label for="year">Academic Year</label>
205
+            <div class="select">
206
+              <select multiple class="selectpicker" name="year" id="year">
207
+                <option value="0" selected="selected">All</option>
208
+                @foreach ($filters['year'] as $year)
209
+                  <option value="{{$year->id}}">{{$year->start}}</option>
210
+                @endforeach
211
+              </select>
212
+            </div>
213
+          </div>
214
+          <div class="category" >
215
+            <label for="outcome">Learning Outcomes</label>
216
+            <div class="select">
217
+              <select multiple class="selectpicker" name="outcome" id="outcome">
218
+                <option value="0" selected="selected">All</option>
219
+                @foreach ($filters['outcome'] as $outcome)
220
+                  <option value="{{$outcome->id}}">{{$outcome->name}}</option>
221
+                @endforeach
222
+              </select>
223
+            </div>
224
+          </div>
225
+        </div>
226
+      </div>
227
+      <h4 class="container">
228
+        <b>Percent of Students Achieving Learning Outcomes By Academic Session</b>
229
+      </h4>
230
+      <div class="container" style="height:500px; width:1300px;" id="chart_div"></div>
231
+      <div class="" style="padding-left: 25px;">
232
+        <h5>
233
+          <b>Annotation</b>
234
+        </h5>
235
+        The target line represents the expected percent of students achieving the learning outcome({{$target*100}}%).
236
+      </div>
237
+    </div>
238
+  </div>
239
+</div>
240
+
241
+@stop
242
+
243
+@section('included-js')
244
+
245
+<!-- HighCharts -->
246
+<script src="{{ asset('vendor/highcharts/highcharts.js') }}"></script>
247
+
248
+@stop
249
+
250
+@section('javascript')
251
+
252
+
253
+$(document).ready(function()
254
+{
255
+  $("#year").parent().parent().parent().hide();
256
+
257
+
258
+
259
+  // when a filter is focused
260
+  var previous;
261
+  $(".category").find("button").focus(function() {
262
+    previous = Array();
263
+    $(this).parent().find("select option:selected").each(function() {
264
+      previous.push(this.value);
265
+    });
266
+  });
267
+
268
+  // when a filter is changed
269
+  $(".category").find("select").change(function() {
270
+    var new_value = Array();
271
+    $(this).parent().find("select option:selected").each(function() {
272
+      new_value.push(this.value);
273
+    });
274
+
275
+    //if statements so that "All" only can be selected alone and dont allow selecting no options
276
+    if(jQuery.inArray("0",new_value) !== -1 && jQuery.inArray("0",previous) === -1){
277
+      $(this).parent().find("select option:selected").each(function() {
278
+        $(this).removeAttr('selected');
279
+        $(this).parent().val(0);
280
+        //$('.selectpicker').selectpicker('refresh');
281
+        new_value = ["0"];
282
+      });
283
+    }else if(jQuery.inArray("0",new_value) !== -1 && jQuery.inArray("0",previous) !== -1 && new_value.length > previous.length){
284
+      $(this).parent().find("select option:selected").each(function() {
285
+        if(this.value == "0"){
286
+          $(this).removeAttr('selected');
287
+          //$('.selectpicker').selectpicker('refresh');
288
+          new_value = Array(new_value[1]);
289
+        }
290
+      });
291
+    }else if(new_value.length == 0){
292
+      $(this).parent().find("select").val(0);
293
+      //$('.selectpicker').selectpicker('refresh');
294
+      new_value = ["0"];
295
+    }
296
+    previous = new_value;
297
+
298
+
299
+    // get values from all selects
300
+    var schools = $("#school").val();
301
+    var programs = $("#program").val();
302
+    var semesters = $("#semester").val();
303
+    var years = $("#year").val();
304
+    var outcomes = $("#outcome").val();
305
+
306
+    // query the values and get new data for chart
307
+    $.post(
308
+        "{{ URL::action('AdministratorsController@overview2_filter_results') }}",
309
+      {
310
+        schools: (schools),
311
+        programs: (programs),
312
+        semesters: (semesters),
313
+        years: (years),
314
+        outcomes: (outcomes),
315
+      },
316
+      function(data)
317
+      {
318
+        var filters = data.filters;
319
+        var outcomes_info = data.outcomes_info;
320
+        var semesters = data.semesters;
321
+
322
+        //////// update chart
323
+        make_chart(outcomes_info,semesters);
324
+
325
+
326
+        ////////update filters
327
+        var new_all = $('<option/>',{
328
+          'value': "0",
329
+          'html': "All",
330
+        });;
331
+
332
+        {{--
333
+        //update school filter
334
+        var school_filter = $("#school");
335
+        var new_school_options = filters.school;
336
+        school_filter.find("option").remove();
337
+        school_filter.append(new_all.clone(true));
338
+        $.each(new_school_options, function(index, school)
339
+        {
340
+          var value = school.id;
341
+          var html = school.name;
342
+          var new_option = $('<option/>',{
343
+            'value': value,
344
+            'html': html,
345
+          });;
346
+          school_filter.append(new_option);
347
+        });
348
+        --}}
349
+
350
+        //update school filter
351
+        var school_filter = $("#school");
352
+        var school_selected_options = Array();
353
+        school_filter.find("option:selected").each(function() {
354
+          school_selected_options.push(this.value);
355
+        });
356
+        var new_school_options = filters.school;
357
+        school_filter.find("option").remove();
358
+        if(Array("0")[0] == school_selected_options[0]){
359
+          school_filter.append(new_all.clone(true).attr("selected","selected"));
360
+        } else{
361
+          school_filter.append(new_all.clone(true));
362
+        }
363
+        $.each(new_school_options, function(index, school)
364
+        {
365
+          var value = school.id.toString();
366
+          var html = school.name;
367
+          var new_option;
368
+          if(jQuery.inArray(value,school_selected_options) === -1){
369
+            new_option = $('<option/>',{
370
+              'value': value,
371
+              'html': html,
372
+            });;
373
+          }else{
374
+            new_option = $('<option/>',{
375
+              'value': value,
376
+              'html': html,
377
+              'selected': 'selected',
378
+            });;
379
+          }
380
+          school_filter.append(new_option);
381
+        });
382
+
383
+        //update semester filter
384
+        var semester_filter = $("#semester");
385
+        var semester_selected_options = Array();
386
+        semester_filter.find("option:selected").each(function() {
387
+          semester_selected_options.push(this.value);
388
+        });
389
+        var new_semester_options = filters.semester;
390
+        semester_filter.find("option").remove();
391
+        if(Array("0")[0] == semester_selected_options[0]){
392
+          semester_filter.append(new_all.clone(true).attr("selected","selected"));
393
+        } else{
394
+          semester_filter.append(new_all.clone(true));
395
+        }
396
+        $.each(new_semester_options, function(index, semester)
397
+        {
398
+          var value = semester.id.toString();
399
+          var html = semester.name;
400
+          var new_option;
401
+          if(jQuery.inArray(value,semester_selected_options) === -1){
402
+            new_option = $('<option/>',{
403
+              'value': value,
404
+              'html': html,
405
+            });;
406
+          }else{
407
+            new_option = $('<option/>',{
408
+              'value': value,
409
+              'html': html,
410
+              'selected': 'selected',
411
+            });;
412
+          }
413
+          semester_filter.append(new_option);
414
+        });
415
+
416
+        //update program filter
417
+        var program_filter = $("#program");
418
+        var program_selected_options = Array();
419
+        program_filter.find("option:selected").each(function() {
420
+          program_selected_options.push(this.value);
421
+        });
422
+        var new_program_options = filters.program;
423
+        program_filter.find("option").remove();
424
+        if(Array("0")[0] == program_selected_options[0]){
425
+          program_filter.append(new_all.clone(true).attr("selected","selected"));
426
+        } else{
427
+          program_filter.append(new_all.clone(true));
428
+        }
429
+        $.each(new_program_options, function(index, program)
430
+        {
431
+          var value = program.id.toString();
432
+          var html = program.name;
433
+          var new_option;
434
+          if(jQuery.inArray(value,program_selected_options) === -1){
435
+            new_option = $('<option/>',{
436
+              'value': value,
437
+              'html': html,
438
+            });;
439
+          }else{
440
+            new_option = $('<option/>',{
441
+              'value': value,
442
+              'html': html,
443
+              'selected': 'selected',
444
+            });;
445
+          }
446
+          program_filter.append(new_option);
447
+        });
448
+
449
+
450
+        //update outcome filter
451
+        var outcome_filter = $("#outcome");
452
+        var outcome_selected_options = Array();
453
+        outcome_filter.find("option:selected").each(function() {
454
+          outcome_selected_options.push(this.value);
455
+        });
456
+        var new_outcome_options = filters.outcome;
457
+        outcome_filter.find("option").remove();
458
+        if(Array("0")[0] == outcome_selected_options[0]){
459
+          outcome_filter.append(new_all.clone(true).attr("selected","selected"));
460
+        } else{
461
+          outcome_filter.append(new_all.clone(true));
462
+        }
463
+        $.each(new_outcome_options, function(index, outcome)
464
+        {
465
+          var value = outcome.id.toString();
466
+          var html = outcome.name;
467
+          var new_option;
468
+          if(jQuery.inArray(value,outcome_selected_options) === -1){
469
+            new_option = $('<option/>',{
470
+              'value': value,
471
+              'html': html,
472
+            });;
473
+          }else{
474
+            new_option = $('<option/>',{
475
+              'value': value,
476
+              'html': html,
477
+              'selected': 'selected',
478
+            });;
479
+          }
480
+          outcome_filter.append(new_option);
481
+        });
482
+
483
+
484
+        {{--
485
+        //update semester filter
486
+        var semester_filter = $("#semester");
487
+        var new_semester_options = filters.semester;
488
+        semester_filter.find("option").remove();
489
+        semester_filter.append(new_all.clone(true));
490
+        $.each(new_semester_options, function(index, semester)
491
+        {
492
+          var value = semester.id;
493
+          var html = semester.name;
494
+          var new_option = $('<option/>',{
495
+            'value': value,
496
+            'html': html,
497
+          });;
498
+          semester_filter.append(new_option);
499
+        });
500
+        --}}
501
+
502
+
503
+        $('.selectpicker').selectpicker('refresh');
504
+      }
505
+    );
506
+
507
+  });
508
+
509
+});
510
+
511
+
512
+
513
+{{-- @include('global.dummy-outcomes') --}}
514
+
515
+@stop

+ 2
- 0
app/views/local/managers/pCoords/_navigation.blade.php Ver arquivo

@@ -11,6 +11,7 @@
11 11
 
12 12
       <li>{{ HTML::linkAction('Objective2Controller@editProgram', 'Objectives')}}</li>
13 13
       <li>{{ HTML::linkAction('CriteriaController@editProgram', 'Criteria') }}</li>
14
+      <li><a href="{{ URL::action('AnnualPlansController@showPlan', Auth::user()->programs[0]->id)}}">Annual Plan</a><li>
14 15
       <li class="dropdown">
15 16
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
16 17
         <ul class="dropdown-menu" role="menu">
@@ -57,6 +58,7 @@
57 58
           <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
58 59
         </ul>
59 60
       </li>
61
+      <li>
60 62
     </ul>
61 63
   </div>
62 64
 </div>

+ 7
- 0
app/views/local/managers/sCoords/_navigation.blade.php Ver arquivo

@@ -36,6 +36,13 @@
36 36
           @endif
37 37
         </ul>
38 38
       </li>
39
+      <li class='dropdown'>
40
+        <a href ='#' class ='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded="false"> Annual Plans<span class="caret"></span></a>
41
+        <ul class ='dropdown-menu' role='menu'>
42
+          @foreach (Auth::user()->school->programs as $program)
43
+          <li><a href ="{{ URL::action('AnnualPlansController@showPlan', array($program->id))}}" >{{$program->name}}</a></li>
44
+          @endforeach
45
+        </ul></li>
39 46
 
40 47
       <li class="dropdown">
41 48
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>

+ 510
- 0
app/views/local/managers/sCoords/annual-plans.blade.php Ver arquivo

@@ -0,0 +1,510 @@
1
+@extends('layouts.master-2')
2
+
3
+@section('navigation')
4
+    @if(Auth::user()->role==1)
5
+      @include('local.managers.admins._navigation')
6
+    @elseif(Auth::user()->role==2)
7
+      @include('local.managers.sCoords._navigation')
8
+    @elseif(Auth::user()->role==3)
9
+      @include('local.managers.pCoords._navigation')
10
+    @elseif(Auth::user()->role==4)
11
+      @include('local.professors._navigation')
12
+    @endif
13
+@stop
14
+@section('main')
15
+
16
+  {{-- TODO: look where to place this script.
17
+          if placed inside .ready() or before it,
18
+            an error that the function is not defined occurs. --}}
19
+  {{-- TODO: no reconoce acentos --}}
20
+
21
+
22
+  <div class="row">
23
+    <div class="col-md-3">
24
+      <a role ="button" class="btn btn-secondary" href="{{URL::action("AnnualPlansController@viewAllPlans", array($program->id))}}">View Plans</a>
25
+
26
+
27
+      @foreach ($annual_plans as $an_plan)
28
+      <h4>Plan for {{$an_plan->academic_year}}</h4>
29
+      <div class="list-group" id='list'>
30
+        <h5 style="padding-left: 10px">First Semester {{$an_plan->academic_year}}</h6>
31
+        @foreach ($outcomes[$an_plan->id]["first"] as $outcome)
32
+
33
+            @if($outcome)
34
+              
35
+              <li style="padding-left: 25px" data-annual-plan = "{{$an_plan->id}}" data-semester-id = "{{$allSemesterOrder[$an_plan->id]["first"]->id}}" data-outcome-id="{{ $outcome->id }}" data-outcome-name ="{{$outcome->name}}"class="list-group-item">{{ $outcome->name }} </li>
36
+            @endif
37
+          
38
+        @endforeach
39
+        <h5  style="padding-left: 10px">Second Semester {{$an_plan->academic_year}}</h6>
40
+        @foreach ($outcomes[$an_plan->id]["second"] as $outcome)
41
+
42
+        @if($outcome)
43
+          
44
+          <li style="padding-left: 25px" data-semester-id = "{{$allSemesterOrder[$an_plan->id]["second"]->id}}" data-outcome-id="{{ $outcome->id }}" data-outcome-name ="{{$outcome->name}}"class="list-group-item">{{ $outcome->name }} </li>
45
+        @endif
46
+      
47
+    @endforeach
48
+      </div>
49
+        @endforeach
50
+      </div>
51
+    
52
+
53
+    <div class="col-md-9">
54
+      <div id="outcome-display" class="panel panel-default">
55
+        <div class="panel-heading">
56
+          <h4 class=" panel-title" style="cursor:auto!important;">
57
+            Primer Semestre 2019-2020
58
+          </h4>
59
+        </div>
60
+        <div class="panel-body">
61
+          <p class="outcome-definition "></p>
62
+            <div class="table-responsive">
63
+                <table class="table table-striped table-condensed datatable" style="table-layout: fixed ; width : 100%">
64
+                  <thead><tr><th>Objectives for courses</th><th>Criteria per Course</th><th>Transformative Actions</th></tr></thead>
65
+                  <tbody>
66
+                  </tbody>
67
+
68
+                </table>
69
+                
70
+            </div>
71
+
72
+        </div>
73
+      </div>
74
+    </div>
75
+
76
+
77
+    <div class="col-md-9">
78
+      <div class="no-outcome alert alert-info">
79
+        <p>Select a Learning Outcome to view its information</p>
80
+      </div>
81
+    </div>
82
+
83
+  </div>
84
+  <script>
85
+   function nextChar(c) {
86
+    return String.fromCharCode(c.charCodeAt(0) + 1);
87
+}
88
+changed = false;
89
+
90
+$(document).ready(function()
91
+{
92
+  // --------------------------------------------------------------------------
93
+  // Page load
94
+  // --------------------------------------------------------------------------
95
+
96
+  // Hide accordion panel contents by default
97
+  $('.panel-group .panel-body').hide();
98
+
99
+  $('#outcome-display').parent().hide();
100
+
101
+  // --------------------------------------------------------------------------
102
+  // Functions
103
+  // --------------------------------------------------------------------------
104
+
105
+  // --------------------------------------------------------------------------
106
+  // Events
107
+  // --------------------------------------------------------------------------
108
+
109
+  $('.datatable').append($('<tfoot/>',{
110
+          "style":'padding-top:10px;',
111
+          'align':'right'
112
+        }).html("<td></td><td></td><td><a href='{{ URL::action('CriteriaController@editSchool')}}'>Add A New Criteria</a></td>"));
113
+  // When list item is clicked, load corresponding info
114
+  $('.list-group-item').on('click', function()
115
+  {
116
+    var id = $(this).data('outcome-id');
117
+    var name = $(this).data('outcome-name');
118
+    var semester = $(this).data('semester-id');
119
+    var annual_plan = $(this).data('annual-plan');
120
+    $('#theChange').data('annual-plan', annual_plan);
121
+    $.post(
122
+    "../annual-plan-fetchTYP/{{$program->id}}",
123
+    { id: id,
124
+    semester: semester
125
+  },
126
+    function(json)
127
+    {
128
+        // Retrieve datatable instance
129
+        
130
+        
131
+
132
+        var table = $('.datatable').DataTable();
133
+        
134
+        table.clear();
135
+        
136
+
137
+
138
+       
139
+        var objectives = json.objectives;
140
+        var courses = json.courses;
141
+        var criteria = json.criteria;
142
+        var selected_criteria = json.selected_criteria;
143
+        var nextLetter ="A";
144
+        if(courses)
145
+        {
146
+          $('table').show();
147
+          $('#outcome-display').parent().show();
148
+        $('.no-outcome').parent().hide();
149
+
150
+        //Display title and definition
151
+        $('#outcome-display .panel-title').html(name);
152
+     
153
+
154
+        //Empty table
155
+        table.clear();
156
+        
157
+        for(objective in objectives){
158
+        
159
+        var objectivesHTML = '';
160
+        var courseshtml = '';
161
+        
162
+       
163
+
164
+        var criteriaHTML = '';
165
+          objectivesHTML += '<strong>' + nextLetter +'.    '+objectives[objective].text+'</strong>';
166
+         // courseshtml += "<strong>Objective "+nextLetter+"</strong>";
167
+         // courseshtml += '<ul>';
168
+          criteriaHTML +="<strong>Objective "+nextLetter+"</strong>";
169
+          //criteriaHTML+= '<ol>';
170
+          
171
+          var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
172
+          nextLetter= nextChar(nextLetter);
173
+          for(course in courses[objectives[objective].id]){
174
+            
175
+            courseshtml += ' &#8226; '+courses[objectives[objective].id][course].code+' '+courses[objectives[objective].id][course].number+'<br>'
176
+            $divForEach =$('<div/>',{
177
+            'id':'objective-'+objectives[objective].id
178
+          });
179
+          $divForSelects = $('<div/>', {
180
+            'id' : 'forObjective-'+objectives[objective].id+'-course-'+courses[objectives[objective].id][course].id,
181
+            'data-amount-select':'0',
182
+            'class':'form-group',
183
+            'data-annual-plan': json.annual_plan.id
184
+          });
185
+          options = "<option value = '0' >Nothing Selected</option>"
186
+          for (criterion in criteria[objectives[objective].id]){
187
+            options += "<option value='"+criteria[objectives[objective].id][criterion].id+"'>"+criteria[objectives[objective].id][criterion].name+"</option>";
188
+          } 
189
+           var $button = $('<button/>', {
190
+           'type': 'button',
191
+      'class': 'btn btn-secondary',
192
+      'onclick': 'addObjectiveTest("forObjective-'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", "'+objectives[objective].id+"-course-"+courses[objectives[objective].id][course].id+'", '+courses[objectives[objective].id][course].typ_course_id+', null, "'+options+'")'
193
+  });
194
+           
195
+          $button.append("+ Add criteria");
196
+ 
197
+          $divForEach.append($divForSelects);
198
+          $divForEach.append("<br>")
199
+          $divForEach.append($button);
200
+          courseshtml += $divForEach[0].innerHTML +"<br><br>";
201
+          }
202
+
203
+
204
+          //for(criterion in selected_criteria[objectives[objective].id]){
205
+          //  criteriaHTML += '<li>'+selected_criteria[objectives[objective].id][criterion].name+'</li>';
206
+          //}
207
+          //criteriaHTML +='</ol>';
208
+          //courseshtml +="</ul>";
209
+         
210
+
211
+
212
+
213
+          
214
+          /*$divForSelects = $('<div/>', {
215
+            'id' : 'forObjective-'+objectives[objective].id,
216
+            'data-amount-select':'0',
217
+            'class':'form-group',
218
+            'data-annual-plan': json.annual_plan.id
219
+          });*/
220
+
221
+
222
+
223
+
224
+          
225
+          var annual_plan = json.annual_plan.id;
226
+          $divForTA = $('<div/>',{
227
+            'id':'objectiveTA-'+objectives[objective].id
228
+          });
229
+          $divForTASelects = $('<div/>', {
230
+            'id': 'forTA-objective-'+objectives[objective].id,
231
+            'class':'form-group',
232
+            'data-amount-ta':'0'
233
+          });
234
+
235
+          var optionsForTa = "<option value = '0'>Nothing Selected</option>";
236
+          transformativeDefault = json.transformative_actions;
237
+          optionsForTa+= "<optgroup label='Default'>";
238
+          for(trans in transformativeDefault){
239
+            optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
240
+            
241
+          }
242
+          optionsForTa+='</optgroup>';
243
+          
244
+          transformativeDefault = json.custom_transformative[objectives[objective].id];
245
+          if(transformativeDefault!= undefined){
246
+          optionsForTa+="<optgroup label = 'Custom'>";
247
+            for(trans in transformativeDefault){
248
+            optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
249
+            
250
+          }
251
+          }
252
+          var $buttonTA = $('<button/>', {
253
+           'type': 'button',
254
+      'class': 'btn btn-secondary',
255
+      'onclick': 'addTAselect("'+optionsForTa+'", "forTA-objective-'+objectives[objective].id+'", '+annual_plan+', '+objectives[objective].id+', '+typ_objective_id+', 0)'
256
+  });
257
+           
258
+          $buttonTA.append("+ Add TA");
259
+
260
+
261
+          
262
+          
263
+
264
+          
265
+
266
+
267
+          $divForTA.append($divForTASelects);
268
+          
269
+          $divForTA.append($buttonTA)
270
+          $divForTA.append('<br>');
271
+
272
+
273
+           table.row.add([
274
+                objectivesHTML,
275
+                courseshtml,
276
+                
277
+                $divForTA[0].innerHTML
278
+                
279
+              ]);
280
+              table.draw();
281
+          if(json.annual_plans_transformative[objectives[objective].id].length){
282
+            for(i=0; i<json.annual_plans_transformative[objectives[objective].id].length; i++){
283
+              selected_ta = json.annual_plans_transformative[objectives[objective].id][i].trans_id;
284
+              addTAselect(optionsForTa, "forTA-objective-"+objectives[objective].id, annual_plan, objectives[objective].id, typ_objective_id, selected_ta);
285
+              
286
+            }
287
+          }
288
+            else{
289
+              addTAselect(optionsForTa, "forTA-objective-"+objectives[objective].id, annual_plan, objectives[objective].id, typ_objective_id, 0);
290
+            }
291
+        for(course in courses[objectives[objective].id]){ 
292
+        course_id = courses[objectives[objective].id][course].id
293
+        if(json.selected_criteria[objectives[objective].id][course_id].length){
294
+         
295
+         
296
+            
297
+            for(i =0; i<json.selected_criteria[objectives[objective].id][course_id].length; i++){
298
+              addObjectiveTest("forObjective-"+objectives[objective].id+"-course-"+course_id, ""+objectives[objective].id+"-course-"+course_id, ""+json.selected_criteria[objectives[objective].id][course_id][i].typ_course_id+"", i, options);
299
+              $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).val(json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
300
+              $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).data('old-criteria', json.selected_criteria[objectives[objective].id][course_id][i].criteria_id);
301
+              $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_'+i).selectpicker('refresh');
302
+
303
+            } // Update display
304
+      
305
+          }
306
+       
307
+          else{
308
+           
309
+            addObjectiveTest("forObjective-"+objectives[objective].id+"-course-"+course_id, ""+objectives[objective].id+"-course-"+course_id+"", ""+courses[objectives[objective].id][course].typ_course_id+"", 0, options);
310
+            $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').val(0);
311
+              $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').data('old-criteria', 0);
312
+              $('#criteriaFor'+objectives[objective].id+"-course-"+course_id+'_0').selectpicker('refresh');
313
+              
314
+          } 
315
+           }
316
+            
317
+        }
318
+                table.draw();
319
+
320
+
321
+        }
322
+
323
+        else
324
+        {
325
+          $('table').hide();
326
+        }
327
+
328
+       
329
+
330
+    
331
+
332
+    
333
+        
334
+        
335
+ 
336
+    },
337
+    'json'
338
+    );
339
+
340
+  })
341
+});
342
+function posttoTransAnnual(annual_id, selectTransId, typ_id){
343
+  ta = $("#"+selectTransId).val();
344
+  old_ta = $("#"+selectTransId).data('old-TA');
345
+  if(ta == "0")return;
346
+  $.post("../annual-plan-postTA",
347
+  {annual_id : annual_id,
348
+  TA_id:ta,
349
+  typ_id : typ_id,
350
+  old_ta:old_ta
351
+  },
352
+  function(message){
353
+    
354
+      $("#"+selectTransId).data('old-TA', ta);
355
+    
356
+  }
357
+  )
358
+}
359
+function addTAselect(options, master_div, annual_plan_id, objective_id, typ_objective_id, selected_ta){
360
+  var $div = $('<div/>', {
361
+      
362
+      'class': 'form-group '
363
+  });
364
+  counter = parseInt($('#'+master_div).data('amount-ta'));
365
+  
366
+  var selectTA = $('<select/>',{
367
+            'class': "selectpicker form-control",
368
+            'data-live-search':'true',
369
+            'data-old-TA' :'0',
370
+            'data-width': '180px',
371
+            
372
+            'id': 'transformativeForObjective'+objective_id+'_'+counter,
373
+            'onchange':'posttoTransAnnual('+annual_plan_id+', "transformativeForObjective'+objective_id+'_'+counter+'", '+typ_objective_id+')'
374
+
375
+          });
376
+          selectTA.append(options);
377
+          
378
+          selectTA.appendTo($div);
379
+          selectTA.val(selected_ta);
380
+          selectTA.data('old-TA', selected_ta);
381
+          selectTA.selectpicker('refresh');
382
+          $span = $('<span/>', {
383
+    'id':'close',
384
+    'onclick':'  postDeleteTA('+annual_plan_id+', "transformativeForObjective'+objective_id+'_'+counter+'", '+typ_objective_id+'); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
385
+  }).html('x');
386
+  $span.appendTo($div);
387
+  $div.append("<br><br>");
388
+  $div.appendTo('#'+master_div);
389
+  $('#'+master_div).data('amount-ta', counter+1);
390
+
391
+
392
+}
393
+function postDeleteTA(annual_id, selectTransId, typ_id){
394
+  ta = $("#"+selectTransId).val();
395
+
396
+  
397
+  if(ta == "0")return;
398
+  $.post("../annual-plan-deleteTA",
399
+  {annual_id : annual_id,
400
+  TA_id:ta,
401
+  typ_id : typ_id,
402
+
403
+  }
404
+  );
405
+  parent = $("#"+selectTransId).parent().parent().parent();
406
+  counter = parseInt(parent.data('amount-ta'));
407
+  parent.data('amount-ta', counter-1);
408
+}
409
+function postToAnnualPlans(typ_course_id, criteria_select){
410
+  var criteria = $('#'+criteria_select).val();
411
+  var oldCriteria = $('#'+criteria_select).data('old-criteria');
412
+  var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
413
+  
414
+  var annual = criteriaNode.dataset.annualPlan;
415
+  $.post("../annual-plan-postOnChange",
416
+  {criteria : criteria, 
417
+  typ_course_id : typ_course_id,
418
+  annual_plan : annual,
419
+  old_criteria :oldCriteria
420
+  },
421
+  function(message){
422
+    if(message =="Duplicate entry, please choose another criteria."){
423
+      alert(message)
424
+    }
425
+    else{
426
+        $('#'+criteria_select).data('old-criteria', criteria);  
427
+    changed = true;
428
+    }
429
+
430
+  })
431
+}
432
+
433
+
434
+function addObjectiveTest(div, new_id_for_select, typ_course_id, i=null, options) {
435
+  
436
+  if(!i) amount_select = $('#'+div).data("amount-select");
437
+  else amount_select = i;
438
+  $select = $('<select/>',{
439
+            'class': "selectpicker form-control",
440
+            'data-live-search':'true',
441
+            'data-old-criteria' :'0',
442
+            'data-width': '180px',
443
+            
444
+            'id': 'criteriaFor'+new_id_for_select+'_'+amount_select,
445
+            'onchange':'postToAnnualPlans('+typ_course_id+', "criteriaFor'+new_id_for_select+'_'+amount_select+'")'
446
+
447
+          })
448
+
449
+  var $div = $('<div/>', {
450
+      'id': 'courseSelect_' + new_id_for_select +'_'+amount_select,
451
+      'class': 'form-group '
452
+  });
453
+
454
+  $select.append(options);
455
+  $select.appendTo($div);
456
+  $span = $('<span/>', {
457
+    'id':'close',
458
+    'onclick':'  postDelete('+typ_course_id+', "criteriaFor'+new_id_for_select+'_'+amount_select+'"); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
459
+  }).html('x');
460
+  $div.append($span);
461
+ $div.append("<br><br>")
462
+  $div.appendTo($("#forObjective-"+new_id_for_select));
463
+  
464
+
465
+  
466
+          $select.selectpicker('refresh');
467
+  
468
+  
469
+
470
+ 
471
+  $("#forObjective-"+new_id_for_select).data("amount-select", amount_select+1);
472
+
473
+}
474
+
475
+function postDelete(typ_course_id, criteria_select){
476
+  var criteria = $('#'+criteria_select).val();
477
+  var oldCriteria = $('#'+criteria_select).data('old-criteria');
478
+  var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
479
+  
480
+  var annual = criteriaNode.dataset.annualPlan;
481
+  $.post("../annual-plan-deleteCriteria",
482
+  {criteria : criteria, 
483
+  typ_course_id : typ_course_id,
484
+  annual_plan : annual,
485
+  old_criteria :oldCriteria
486
+  });
487
+
488
+}
489
+
490
+
491
+
492
+function deleteObjective(objectiveSelectDiv, closeObj){
493
+
494
+  $('#'+objectiveSelectDiv).remove();
495
+  $('#'+closeObj).remove();
496
+  $('#'+div).data("amount-select", $('#'+div).data("amount-select")-1);
497
+
498
+}
499
+</script>
500
+
501
+
502
+  
503
+
504
+@stop
505
+
506
+@section('included-js')
507
+    @include('global._datatables_js')
508
+@stop
509
+
510
+

+ 163
- 0
app/views/local/managers/sCoords/annual_plan_js.blade.php Ver arquivo

@@ -0,0 +1,163 @@
1
+<script>
2
+
3
+$(document).ready(function()
4
+{
5
+  // --------------------------------------------------------------------------
6
+  // Page load
7
+  // --------------------------------------------------------------------------
8
+
9
+  // Hide accordion panel contents by default
10
+  $('.panel-group .panel-body').hide();
11
+
12
+  $('#outcome-display').parent().hide();
13
+
14
+  // --------------------------------------------------------------------------
15
+  // Functions
16
+  // --------------------------------------------------------------------------
17
+
18
+  // --------------------------------------------------------------------------
19
+  // Events
20
+  // --------------------------------------------------------------------------
21
+
22
+  // When list item is clicked, load corresponding info
23
+  $('.list-group-item').on('click', function()
24
+  {
25
+    var id = $(this).data('outcome-id');
26
+    var name = $(this).data('outcome-name');
27
+    var semester = $(this).data('semester-id');
28
+    $.post(
29
+    "../annual-plan-fetchTYP/{{$program->id}}",
30
+    { id: id,
31
+    semester: semester
32
+  },
33
+    function(json)
34
+    {
35
+        // Retrieve datatable instance
36
+        var table = $('.datatable').DataTable();
37
+        alert(json);
38
+        
39
+        var objectives = json.unique_objective;
40
+        var courses = json.courses;
41
+        var courseHTML = '<ol>';
42
+        var objectiveHTML = '';
43
+        var criteria = json.criteria
44
+        nextLetter ="@";
45
+        counter = 1;
46
+        for(course in courses){
47
+          courseHTML+='<li>'+courses[course].code+' '+courses[course].number+'</li>';
48
+        }
49
+        courseHTML += "</ol>"
50
+        courses = json.courses_objective;
51
+        for(objective in objectives){
52
+          for(course in courses[objectives[objective].id]){
53
+            objectiveHTML += "<strong>"+courses[objectives[objective].id][course].code+" "+courses[objectives[objective].id][course].number +", </strong>";
54
+          }
55
+          
56
+          objectiveHTML += "<ol type ='A' start='"+counter.toString()+"'>";
57
+          objectiveHTML += "<li>"+objectives[objective].text+"</li>";
58
+          objectiveHTML += "</ol>";
59
+          counter++;
60
+        }
61
+    
62
+        for(objective in objectives){
63
+          $divForEach =$('<div/>',{
64
+            'id':'objective #'+objectives[objective]
65
+          });
66
+
67
+          $objective = "<h4>"+objectives[objective].text+"</h4>";
68
+          
69
+
70
+          $divForEach.append($objective)
71
+          $select = $('<select/>',{
72
+            'class': "selectpicker form-control",
73
+            'name' : "criteriaFor["+objectives[objective].id+"]",
74
+            'data-live-search':'true',
75
+            'id': 'criteriaFor'+objectives[objective].id+'_0'
76
+
77
+          })
78
+          options = ''
79
+          for (criterion in criteria[objectives[objective].id]){
80
+            options += "<option value='"+criteria[objectives[objective].id][criterion].id+"'>"+criteria[objectives[objective].id][criterion].name+"</option>";
81
+          }
82
+          $select.append(options);
83
+          $divForEach.append($select);
84
+          $divForEach.appendTo('#theChange');
85
+          $select.selectpicker('refresh');
86
+          
87
+        }
88
+        
89
+        $('#outcome-display').parent().show();
90
+        $('.no-outcome').parent().hide();
91
+
92
+        //Display title and definition
93
+        $('#outcome-display .panel-title').html(name);
94
+     
95
+
96
+        //Empty table
97
+        table.clear();
98
+
99
+        // Add new criteria
100
+        if(courses)
101
+        {
102
+          $('table').show();
103
+          
104
+          
105
+              table.row.add([
106
+                courseHTML,
107
+                objectiveHTML
108
+              ]);
109
+        
110
+        }
111
+        else
112
+        {
113
+          $('table').hide();
114
+        }
115
+
116
+        // Update display
117
+        table.draw();
118
+    },
119
+    'json'
120
+    );
121
+
122
+  })
123
+});
124
+
125
+function addObjectiveTest() {
126
+  selectObj = document.getElementById('objective_0').innerHTML;
127
+  var $select = $('<select/>', {
128
+      'class': "selectpicker form-control",
129
+      'name': "objective[]",
130
+      'data-live-search': 'true',
131
+      'id': 'objective_' + counterObj.toString()
132
+
133
+  });
134
+  var $div = $('<div/>', {
135
+      'id': 'objectiveForm' + counterObj.toString(),
136
+      'class': 'form-group col-md-11'
137
+  });
138
+  var $divForButton = $('<div/>', {
139
+      'class': 'col-md-1',
140
+      'id': 'closeObj' + counterObj.toString()
141
+
142
+  });
143
+  var $button = $('<button/>', {
144
+      'type': 'button',
145
+      'class': 'btn btn-primary',
146
+      'onclick': 'deleteObjective("objectiveForm' + counterObj.toString() + '", "closeObj' + counterObj.toString() + '")'
147
+  });
148
+
149
+  $button.append('X');
150
+  $divForButton.append($button);
151
+
152
+  $div.appendTo('#objectiveGroup')
153
+  $select.append(selectObj);
154
+
155
+  $select.appendTo('#objectiveForm' + counterObj.toString()).selectpicker('refresh');
156
+  counterObj += 1;
157
+
158
+  $divForButton.appendTo('#objectiveGroup');
159
+  $('#counterObjective').val(counterObj)
160
+}
161
+
162
+</script>
163
+

+ 175
- 113
app/views/local/managers/sCoords/criteria.blade.php Ver arquivo

@@ -386,12 +386,13 @@
386 386
 
387 387
     //Add outcome Button
388 388
     function addOutcomeTest() {
389
+        counter = parseInt($('#outcomeGroup').data("value"));
389 390
         var $select = $('<select/>', {
390 391
             'class': "selectpicker form-control",
391 392
             'name': "outcome[]",
392 393
             'data-live-search': 'true',
393 394
             'id': 'outcome' + counter.toString(),
394
-            'onchange': 'fetchObjectiveForSelect("outcome' + counter.toString() + '")'
395
+            'onchange': 'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")'
395 396
 
396 397
         });
397 398
         var $div = $('<div/>', {
@@ -407,7 +408,7 @@
407 408
         var $button = $('<button/>', {
408 409
             'type': 'button',
409 410
             'class': 'btn btn-primary',
410
-            'onclick': 'deleteLast("outcomeForm' + counter.toString() + '", "' + outcomeString + (counter).toString() + '", "close' + counter.toString() + '","objective_")'
411
+            'onclick': 'deleteLast("outcomeForm'+counter.toString()+'", "outcomeGroup", "close' + counter.toString() + '", "objectiveGroup")'
411 412
         });
412 413
 
413 414
         $button.append('X');
@@ -417,11 +418,13 @@
417 418
         $select.append(selectOptions);
418 419
 
419 420
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
420
-        fetchObjectiveForSelect('outcome' + counter.toString());
421
-        counter += 1;
421
+        
422
+        $('#outcomeGroup').data("value", counter +1);
423
+        fetchObjectiveForSelect('outcomeGroup', "objectiveGroup");
424
+        
422 425
         $divForButton.appendTo('#outcomeGroup');
423 426
 
424
-        $('#counterOutcome').val(counter)
427
+       
425 428
 
426 429
 
427 430
     }
@@ -430,27 +433,29 @@
430 433
 
431 434
     //Delete Outcome and OptGroup associated
432 435
 
433
-    function deleteLast(outcomeForm, outcomeOptGroup, closeButton, objective) {
434
-        $div = document.getElementById(outcomeForm);
436
+    function deleteLast(outcomeForm, outcomeDiv, closeButton, objectiveGroup) {
437
+        $div = document.getElementById(outcomeForm );
435 438
         $div.remove();
436
-        $div = document.getElementById(outcomeOptGroup);
437
-        $div.remove();
438
-        $div = document.getElementById(closeButton)
439
+        $div = document.getElementById(closeButton);
439 440
         $div.remove();
441
+        if(outcomeDiv =='outcomeGroup'){
442
+        $('#' + outcomeDiv).data('value',parseInt($('#' + outcomeDiv).data('value')) - 1);
443
+        fetchObjectiveForSelect(outcomeDiv, objectiveGroup);}
444
+        
445
+
440 446
 
441
-        for (var i = 0; i < counterObj; i++) {
442 447
 
443 448
 
444
-            $('#' + objective + i.toString()).selectpicker('refresh');
445
-        }
446 449
 
447 450
     }
448 451
     //Delete Objective
449
-    function deleteObjective(objectiveForm, closeObj) {
452
+    function deleteObjective(objectiveForm, closeObj, objectiveGroup) {
450 453
         $div = document.getElementById(objectiveForm);
451 454
         $div.remove();
452 455
         $div = document.getElementById(closeObj);
453 456
         $div.remove();
457
+        counter = parseInt($('#'+objectiveGroup).data("value"));
458
+        $('#'+objectiveGroup).data("value", counter-1);
454 459
 
455 460
 
456 461
     }
@@ -459,6 +464,7 @@
459 464
 
460 465
     function addAssocObjective() {
461 466
         selectObj = document.getElementById('assoc_objective_0').innerHTML;
467
+        assocObjectiveCounter = parseInt($('#assoc_objectiveGroup').data('value'));
462 468
         var $select = $('<select/>', {
463 469
             'class': "selectpicker form-control",
464 470
             'name': "assoc_objective[]",
@@ -479,7 +485,7 @@
479 485
         var $button = $('<button/>', {
480 486
             'type': 'button',
481 487
             'class': 'btn btn-primary',
482
-            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + '")'
488
+            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + ', assoc_objectiveGroup")'
483 489
         });
484 490
 
485 491
         $button.append('X');
@@ -489,7 +495,7 @@
489 495
         $select.append(selectObj);
490 496
 
491 497
         $select.appendTo('#assoc_objectiveForm' + assocObjectiveCounter.toString()).selectpicker('refresh');
492
-        counterObj += 1;
498
+        $('#assoc_objectiveGroup').data("value", assocObjectiveCounter +1);
493 499
 
494 500
         $divForButton.appendTo('#assoc_objectiveGroup');
495 501
 
@@ -499,26 +505,28 @@
499 505
     //Add objective when creating a criteria
500 506
     function addObjectiveTest() {
501 507
         selectObj = document.getElementById('objective_0').innerHTML;
508
+        counter = $("#objectiveGroup").data('value');
509
+        $('#objectiveGroup')
502 510
         var $select = $('<select/>', {
503 511
             'class': "selectpicker form-control",
504 512
             'name': "objective[]",
505 513
             'data-live-search': 'true',
506
-            'id': 'objective_' + counterObj.toString()
514
+            'id': 'objective_' + counter.toString()
507 515
 
508 516
         });
509 517
         var $div = $('<div/>', {
510
-            'id': 'objectiveForm' + counterObj.toString(),
518
+            'id': 'objectiveForm' + counter.toString(),
511 519
             'class': 'form-group col-md-11'
512 520
         });
513 521
         var $divForButton = $('<div/>', {
514 522
             'class': 'col-md-1',
515
-            'id': 'closeObj' + counterObj.toString()
523
+            'id': 'closeObj' + counter.toString()
516 524
 
517 525
         });
518 526
         var $button = $('<button/>', {
519 527
             'type': 'button',
520 528
             'class': 'btn btn-primary',
521
-            'onclick': 'deleteObjective("objectiveForm' + counterObj.toString() + '", "closeObj' + counterObj.toString() + '")'
529
+            'onclick': 'deleteObjective("objectiveForm' + counter.toString() + '", "closeObj' + counter.toString() + '","objectiveGroup")'
522 530
         });
523 531
 
524 532
         $button.append('X');
@@ -527,11 +535,10 @@
527 535
         $div.appendTo('#objectiveGroup')
528 536
         $select.append(selectObj);
529 537
 
530
-        $select.appendTo('#objectiveForm' + counterObj.toString()).selectpicker('refresh');
531
-        counterObj += 1;
532
-
538
+        $select.appendTo('#objectiveForm' + counter.toString()).selectpicker('refresh');
539
+        
533 540
         $divForButton.appendTo('#objectiveGroup');
534
-        $('#counterObjective').val(counterObj)
541
+        $('#objectiveGroup').data('value', counter +1);
535 542
     }
536 543
 
537 544
     //Create outcome for editing
@@ -540,6 +547,7 @@
540 547
 
541 548
 
542 549
     function addAssocOutcome() {
550
+        assocOutcomeCounter = parseInt($('#assocOutcomeGroup').data('value'));
543 551
         var $select = $('<select/>', {
544 552
             'class': "selectpicker form-control",
545 553
             'name': "assoc_outcome[]",
@@ -561,7 +569,7 @@
561 569
         var $button = $('<button/>', {
562 570
             'type': 'button',
563 571
             'class': 'btn btn-primary',
564
-            'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "' + 'Associated_Outcome' + (assocOutcomeCounter).toString() + '", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objective_")'
572
+            'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "assocOutcomeGroup", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objectiveGroup")'
565 573
         });
566 574
 
567 575
         $button.append('X');
@@ -571,8 +579,10 @@
571 579
         $select.append(selectOptions);
572 580
 
573 581
         $select.appendTo('#assoc_outcomeForm' + assocOutcomeCounter.toString()).selectpicker('refresh');
574
-        //fetchAssocObjective('assoc_outcome_' + assocOutcomeCounter.toString());
582
+        
575 583
         assocOutcomeCounter += 1;
584
+        $('#assocOutcomeGroup').data('value', assocOutcomeCounter);
585
+
576 586
         $divForButton.appendTo('#assocOutcomeGroup');
577 587
 
578 588
 
@@ -584,37 +594,64 @@
584 594
 
585 595
     var assocObjectiveCounter = 1;
586 596
 
587
-    function fetchAssocObjective(outcomeId) {
588
-        var id = $('#' + outcomeId).find(':selected').val();
597
+    function fetchAssocObjective(outcomeDiv, objectiveGroup) {
598
+        var count = $('#'+outcomeDiv).data('value');
599
+        var allOutcomes =[];
600
+
601
+         $("#" + outcomeDiv + ' select').each(function() {
602
+            allOutcomes.push( this.value);
603
+
604
+        })
605
+        var allObjectives = [];
606
+        $("#" + objectiveGroup + ' select').each(function() {
607
+            var temp = {
608
+                id: this.id,
609
+                value: this.value
610
+            }
611
+            allObjectives.push(temp);
612
+        })
589 613
 
590 614
 
591 615
         $.post(
592 616
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
593
-                id: id
617
+                allOutcomes: allOutcomes
594 618
             },
595 619
 
596 620
             function(json) {
597 621
 
598
-                var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + 'Associated Outcome' + (assocOutcomeCounter).toString() + '"';
599
-                for (var i = 0; i < json.length; i++) {
600
-                    var option = '<option value ="' + json[i].id.toString() + '">' + json[i].text + '</option>'
601
-                    optionName += (option)
602
-
603
-                }
604
-                optGroup = document.getElementById('Associated_Outcome' + (assocOutcomeCounter - 1).toString());
605
-                if (optGroup != null) {
606
-                    optGroup.remove()
607
-
622
+                optionName = '';
623
+                for(outcome in varArray.outcomes){
624
+                    optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '"';
625
+                    var objectiveForOutcome = varArray.objectives;
626
+                    var objectives = objectiveForOutcome[outcome];
627
+                    for (objective in objectives) {
628
+                
629
+
630
+                        var obj= objectives[objective];
631
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
632
+                        optionName += (option);
633
+                    }
608 634
                 }
609 635
 
610 636
 
611
-                $('#assoc_objective_0').append(optionName);
637
+                $('#assoc_objective_0').html(optionName);
612 638
                 $('#assoc_objective_0').selectpicker('refresh');
639
+                if($("#assoc_objective_0 option[value='"+allObjectives[0].value+"']").length>0){
640
+                    $("#assoc_objective_0").val(allObjectives[0].value);
641
+                    $('#assoc_objective_0').selectpicker('refresh');
642
+                }
613 643
 
614
-                for (var i = assocObjectiveCounter - 1; i > 0; i--) {
615
-                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString())
644
+                for (var i = allObjectives.length - 1; i > 0; i--) {
645
+                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup');
646
+                }
647
+                for(var i=1; i<allObjectives.length; i++){
648
+                    addAssocObjective();
649
+                    $('#assoc_objective_'+i.toString()).selectpicker('refresh');
650
+                    if($("#assoc_objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
651
+                    $("#assoc_objective_"+i.toString()).val(allObjectives[i].value);
652
+                    $("#assoc_objective_"+i.toString()).selectpicker("refresh");
653
+                    }
616 654
                 }
617
-                assocObjectiveCounter = 1;
618 655
 
619 656
 
620 657
 
@@ -626,37 +663,66 @@
626 663
     //Fetch objective at creating criteria
627 664
     counterForPost = 0;
628 665
 
629
-    function fetchObjectiveForSelect(outcomeInput) {
630
-
631
-
632
-        var id = $('#' + outcomeInput).find(':selected').val();
666
+    function fetchObjectiveForSelect(outcomeDiv, objectiveGroup) {
667
+        var count = $("#" + outcomeDiv).data('value');
668
+        var allOutcomes = [];
669
+        $("#" + outcomeDiv + ' select').each(function() {
670
+            allOutcomes.push( this.value);
671
+
672
+        })
673
+        var allObjectives = [];
674
+        $("#" + objectiveGroup + ' select').each(function() {
675
+            var temp = {
676
+                id: this.id,
677
+                value: this.value
678
+            }
679
+            allObjectives.push(temp);
680
+        })
633 681
 
634 682
         $.post(
635 683
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
636
-                id: id
684
+                allOutcomes: allOutcomes
637 685
             },
638 686
             function(varArray) {
639
-
640
-                var optionName = '<optgroup id="' + outcomeString + (counter - 1).toString() + '"label="' + varArray[0].name + '"';
641
-                for (var i = 0; i < varArray.length; i++) {
642
-                    var option = '<option value ="' + varArray[i].id.toString() + '">' + varArray[i].text + '</option>'
643
-                    optionName += (option)
644
-
645
-                }
646
-                optGroup = document.getElementById(outcomeString + (counter - 1).toString());
647
-                if (optGroup != null) {
648
-                    optGroup.remove()
649
-
687
+                counterOutcome =0;
688
+                optionName = '';
689
+                for(outcome in varArray.outcomes){
690
+                    optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '"';
691
+                    var objectiveForOutcome = varArray.objectives;
692
+                    var objectives = objectiveForOutcome[outcome];
693
+                    for (objective in varArray.objectives[outcome]) {
694
+                
695
+
696
+                        var obj= objectives[objective];
697
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
698
+                        optionName += (option);
699
+                    }
650 700
                 }
701
+                
651 702
 
703
+                
652 704
 
653
-                $('#objective_0').append(optionName);
705
+                $('#objective_0').html(optionName);
654 706
                 $('#objective_0').selectpicker('refresh');
707
+                if($("#objective_0 option[value='"+allObjectives[0].value+"']").length>0){
708
+                    $("#objective_0").val(allObjectives[0].value);
709
+                    $('#objective_0').selectpicker('refresh');
710
+                }
711
+                
655 712
 
656
-                for (var i = counterObj - 1; i > 0; i--) {
657
-                    deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString())
713
+                for (var i = allObjectives.length - 1; i > 0; i--) {
714
+                    deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString(), 'objectiveGroup');
715
+                }
716
+                for(var i =1; i<allObjectives.length; i++){
717
+                    addObjectiveTest();
718
+                    $('#objective_'+i.toString()).selectpicker('refresh');
719
+                    if($("#objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
720
+                    $("#objective_"+i.toString()).val(allObjectives[i].value);
721
+                    $("#objective_"+i.toString()).selectpicker("refresh");
722
+                }
658 723
                 }
659
-                counterObj = 1;
724
+
725
+                
660 726
 
661 727
 
662 728
 
@@ -718,9 +784,10 @@
718 784
 
719 785
                 if (!(json.activity_criterion.length)) {
720 786
 
721
-                    var button = "<button type='button' class ='btn btn-primary btn-block' onclick ='deleteCriterion()'>Delete Criterion</button><br><br>"
722
-                    $('#delete').html(button)
787
+                    $('#DeleteButton').prop('disabled', true);
723 788
 
789
+                } else {
790
+                    $('#DeleteButton').prop('enabled', true);
724 791
                 }
725 792
 
726 793
                 if (!(json.criteria.length)) {
@@ -737,9 +804,16 @@
737 804
                     var name = json.criteria[0].name;
738 805
                     if (json.criteria[0].subcriteria) {
739 806
                         subcriteria = JSON.parse(json.criteria[0].subcriteria).join('\n');
807
+                    } else {
808
+                        subcriteria = "";
740 809
                     }
741
-                    var copyright = json.criteria[0].copyright;
742
-                    var notes = json.criteria[0].notes;
810
+                    if (json.criteria[0].copyright) {
811
+                        var copyright = json.criteria[0].copyright;
812
+                    } else {
813
+                        var copyright = ''
814
+                    }
815
+                    if (json.criteria[0].notes) notes = json.criteria[0].notes;
816
+                    else notes = '';
743 817
 
744 818
                     // Display info
745 819
                     $('#criterion_name').val(name);
@@ -756,16 +830,12 @@
756 830
                 }
757 831
 
758 832
 
759
-                if (copyright) {
760
-                    $('#criterion_copyright').text(copyright);
761
-                } else {
762
-                    $('#criterion_copyright').text('');
763
-                }
764
-                if (notes) {
765
-                    $('#criterion_notes').text(notes);
766
-                } else {
767
-                    $('#criterion_notes').text('');
768
-                }
833
+
834
+                $('#criterion_copyright').text(copyright);
835
+
836
+
837
+                $('#criterion_notes').text(notes);
838
+
769 839
 
770 840
 
771 841
 
@@ -774,8 +844,9 @@
774 844
 
775 845
                 // Select associated outcome
776 846
                 try {
847
+                    assocOutcomeCounter= parseInt($("#assocOutcomeGroup").data('value'));
777 848
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
778
-                        deleteLast("assoc_outcomeForm" + (i).toString(), 'Associated_Outcome' + (i).toString(), "assoc_close" + (i).toString(), "assoc_objective_");
849
+                        deleteLast("assoc_outcomeForm" + i.toString() , "assocOutcomeGroup", "assoc_close" + i.toString() ,"assoc_objectiveGroup");
779 850
                     }
780 851
                 } catch (err) {
781 852
                     var Notran = true;
@@ -800,15 +871,17 @@
800 871
 
801 872
 
802 873
 
874
+                counterObj =$('#assoc_objectiveGroup').data('value');
875
+                
803 876
 
804 877
                 try {
805 878
                     for (var i = counterObj - 1; i > 0; i--) {
806
-                        deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString())
879
+                        deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup')
807 880
                     }
808 881
                 } catch (err) {
809 882
                     var noEntro = true;
810 883
                 }
811
-                counterObj = 1;
884
+                $('#assoc_objectiveGroup').data('value', 1);
812 885
 
813 886
 
814 887
 
@@ -816,34 +889,24 @@
816 889
 
817 890
                 assocOutcomeCounter = 0;
818 891
                 var i = 0;
819
-                for (var j = 0; j < json.outcomes.length; j++) {
820
-                    assocOutcomeCounter += 1;
821
-                    var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + json.outcomes[j].name + '"';
822
-                    for (; i < json.objectives_outcome.length; i++) {
823
-                        if (json.objectives_outcome[i].outcome_id != json.outcomes[j].id) break;
824
-
825
-                        var option = '<option value ="' + json.objectives_outcome[i].id.toString() + '">' + json.objectives_outcome[i].text + '</option>'
826
-                        optionName += (option)
827
-
828
-                    }
829
-                    optGroup = document.getElementById('Associated_Outcome' + (assocOutcomeCounter - 1).toString());
830
-                    if (optGroup != null) {
831
-                        optGroup.remove()
832
-
892
+                optionName = '';
893
+                for(outcome in json.outcomes_assoc){
894
+                    optionName += '<optgroup label="' + json.outcomes_assoc[outcome][0].name + '"';
895
+                    var objectiveForOutcome = json.objectives_assoc;
896
+                    var objectives = objectiveForOutcome[outcome];
897
+                    for (objective in objectives) {
898
+                
899
+
900
+                        var obj= objectives[objective];
901
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
902
+                        optionName += (option);
833 903
                     }
834
-                    $('#assoc_objective_0').append(optionName);
835
-                    $('#assoc_objective_0').selectpicker('refresh');
836 904
                 }
837 905
 
838 906
 
839
-
840
-
841
-                for (var i = assocObjectiveCounter - 1; i > 0; i--) {
842
-                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString())
843
-                }
844
-                assocObjectiveCounter = 1;
845
-
846
-
907
+                $('#assoc_objective_0').html(optionName);
908
+                $('#assoc_objective_0').selectpicker('refresh');
909
+                
847 910
 
848 911
 
849 912
 
@@ -855,7 +918,7 @@
855 918
                         $('#assoc_objective_0').val(0);
856 919
                         $('#assoc_objective_0').selectpicker('refresh');
857 920
                     }
858
-                    var thereIsNoObjective = true;
921
+                 
859 922
                 }
860 923
 
861 924
                 for (var i = 1; i < json.objectives.length; i++) {
@@ -863,7 +926,7 @@
863 926
                     $('#assoc_objective_' + i.toString()).val(json.objectives[i].id);
864 927
                     $('#assoc_objective_' + i.toString()).selectpicker('refresh');
865 928
                 }
866
-                assocObjectiveCounter = json.objectives.length;
929
+                $('assoc_objectiveGroup').data('value',json.objectives.length);
867 930
 
868 931
 
869 932
 
@@ -947,8 +1010,7 @@
947 1010
             'json'
948 1011
         );
949 1012
     }
950
-</script>
951
-@stop
1013
+</script>@stop
952 1014
 
953 1015
 @section('javascript')
954 1016
 
@@ -962,7 +1024,7 @@ $('.panel-group .panel-body').hide();
962 1024
 $('#outcome-display').parent().hide();
963 1025
 
964 1026
 fetchCriterionForEditing();
965
-fetchObjectiveForSelect('outcome0');
1027
+fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
966 1028
 // setCriterionStatus();
967 1029
 
968 1030
 
@@ -1012,10 +1074,10 @@ $('.panel-group .panel-heading').on('click', function()
1012 1074
 $(this).next().stop().slideToggle();
1013 1075
 })
1014 1076
 
1015
-$('#outcome[0]').on('change', function(){
1016
-fetchObjectiveForSelect(0);
1017
-$('.selectpicker').selectpicker('refresh');
1018
-})
1077
+//$('#outcome[0]').on('change', function(){
1078
+//fetchObjectiveForSelect(0);
1079
+//$('.selectpicker').selectpicker('refresh');
1080
+//})
1019 1081
 // When list item is clicked, load corresponding info
1020 1082
 
1021 1083
 

+ 1
- 4
app/views/local/managers/sCoords/objectives.blade.php Ver arquivo

@@ -362,10 +362,7 @@
362 362
             'json'
363 363
         );
364 364
     }
365
-    },
366
-    'json'
367
-    );
368
-    }
365
+    
369 366
 
370 367
     function deleteLastAssoc() {
371 368
 

+ 1341
- 0
app/views/local/managers/sCoords/view-annual-plans.blade.php
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 4
- 1
composer.json Ver arquivo

@@ -26,7 +26,10 @@
26 26
 			"app/database/migrations",
27 27
 			"app/database/seeds",
28 28
 			"app/tests/TestCase.php"
29
-		]
29
+		],
30
+		"psr-4": {
31
+			"Acme\\controllers\\": "app/controllers"
32
+		}
30 33
 	},
31 34
 	"scripts": {
32 35
 		"post-install-cmd": [