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