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