@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | public function registerEvents(): array |
76 | 76 | { |
77 | 77 | return [ |
78 | - BeforeSheet::class => function (BeforeSheet $event) { |
|
78 | + BeforeSheet::class => function(BeforeSheet $event) { |
|
79 | 79 | $this->sheetNames[] = $event->getSheet()->getTitle(); |
80 | 80 | $this->worksheet = $event->getSheet(); |
81 | 81 | $this->validateClass(); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
88 | 88 | } |
89 | 89 | }, |
90 | - BeforeImport::class => function (BeforeImport $event) { |
|
90 | + BeforeImport::class => function(BeforeImport $event) { |
|
91 | 91 | $this->highestRow = ($event->getReader()->getDelegate()->getActiveSheet()->getHighestDataRow('C')); |
92 | 92 | if ($this->highestRow < 3) { |
93 | 93 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | if (!empty($institutionClass)) { |
115 | 115 | $row = $this->setGender($row); |
116 | - $studentInfo = Security_user::createOrUpdateStudentProfile($row,'create',$this->file); |
|
116 | + $studentInfo = Security_user::createOrUpdateStudentProfile($row, 'create', $this->file); |
|
117 | 117 | $academicPeriod = Academic_period::where('id', '=', $institutionClass->academic_period_id)->first(); |
118 | 118 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass->id)->first(); |
119 | 119 | $assignee_id = $institutionClass->staff_id ? $institutionClass->staff_id : $this->file['security_user_id']; |
@@ -126,25 +126,25 @@ discard block |
||
126 | 126 | 'institution_class' => $institutionClass |
127 | 127 | ]; |
128 | 128 | |
129 | - Institution_student_admission::createAdmission($studentInfo->id,$row,$params,$this->file); |
|
130 | - Institution_student::createOrUpdate($studentInfo->id,$row,$params,$this->file); |
|
131 | - $student = Institution_class_student::createOrUpdate($studentInfo->id,$params,$this->file); |
|
132 | - User_special_need::createOrUpdate($student->student_id,$row,$this->file); |
|
133 | - User_body_mass::createOrUpdate($student->student_id,$row,$this->file); |
|
129 | + Institution_student_admission::createAdmission($studentInfo->id, $row, $params, $this->file); |
|
130 | + Institution_student::createOrUpdate($studentInfo->id, $row, $params, $this->file); |
|
131 | + $student = Institution_class_student::createOrUpdate($studentInfo->id, $params, $this->file); |
|
132 | + User_special_need::createOrUpdate($student->student_id, $row, $this->file); |
|
133 | + User_body_mass::createOrUpdate($student->student_id, $row, $this->file); |
|
134 | 134 | |
135 | - $this->createOrUpdateGuardian($row,$student,'father'); |
|
136 | - $this->createOrUpdateGuardian($row,$student,'mother'); |
|
137 | - $this->createOrUpdateGuardian($row,$student,'guardian'); |
|
135 | + $this->createOrUpdateGuardian($row, $student, 'father'); |
|
136 | + $this->createOrUpdateGuardian($row, $student, 'mother'); |
|
137 | + $this->createOrUpdateGuardian($row, $student, 'guardian'); |
|
138 | 138 | |
139 | 139 | $studentInfo['student_id'] = $studentInfo->id; |
140 | 140 | Institution_student::updateStudentArea($studentInfo->toArray()); |
141 | 141 | |
142 | - $this->insertOrUpdateSubjects($row,$student,$institution); |
|
142 | + $this->insertOrUpdateSubjects($row, $student, $institution); |
|
143 | 143 | |
144 | 144 | $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']); |
145 | 145 | if ($totalStudents['total'] > $institutionClass->no_of_students) { |
146 | 146 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
147 | - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); |
|
147 | + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); |
|
148 | 148 | $failures = [0 => $failure]; |
149 | 149 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
150 | 150 | Log::info('email-sent', [$this->file]); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $institutionClass = new Institution_class(); |
154 | 154 | $institutionClass->updateClassCount($this->file); |
155 | 155 | } |
156 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
156 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
157 | 157 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
158 | 158 | $failures = $e->failures(); |
159 | 159 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | '*.full_name' => 'required|regex:/^[a-zA-Z .]*$/u|max:256', |
169 | 169 | '*.preferred_name' => 'nullable|regex:/^[a-zA-Z .]*$/u|max:90', |
170 | 170 | '*.gender_mf' => 'required|in:M,F', |
171 | - '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'], |
|
171 | + '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'], |
|
172 | 172 | '*.address' => 'nullable', |
173 | 173 | '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place', |
174 | 174 | '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate', |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | '*.identity_number' => 'nullable|identity:identity_type|required_with:*.identity_type', |
178 | 178 | '*.education_grade' => 'required', |
179 | 179 | '*.option_*' => 'nullable|exists:education_subjects,name', |
180 | - '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'], |
|
181 | - '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'], |
|
180 | + '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'], |
|
181 | + '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'], |
|
182 | 182 | '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].' |
183 | 183 | '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name', |
184 | 184 | '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public static function boot() |
72 | 72 | { |
73 | 73 | parent::boot(); |
74 | - self::creating(function ($model) { |
|
74 | + self::creating(function($model) { |
|
75 | 75 | $model->id = (string) Uuid::generate(4); |
76 | 76 | $model->created = now(); |
77 | 77 | }); |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | 'institution_students.admission_id' |
130 | 130 | ) |
131 | 131 | ->where('institution_students.institution_id', $institutionGrade['institution_id']) |
132 | - ->where('institution_students.student_status_id',1) |
|
132 | + ->where('institution_students.student_status_id', 1) |
|
133 | 133 | ->where('institution_students.education_grade_id', $institutionGrade['education_grade_id']) |
134 | - ->where('institution_students.deleted_at',null) |
|
134 | + ->where('institution_students.deleted_at', null) |
|
135 | 135 | ->where('institution_students.academic_period_id', $academicPeriod->id)->get()->toArray(); |
136 | 136 | } |
137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public static function createExaminationData($student, $admissionInfo) |
146 | 146 | { |
147 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
147 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
148 | 148 | try { |
149 | 149 | self::create([ |
150 | 150 | 'id' => (string) Uuid::generate(4), |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | 'created' => now(), |
170 | 170 | 'created_user_id' => 1 |
171 | 171 | ]); |
172 | - } catch (\Throwable $th) { |
|
172 | + }catch (\Throwable $th) { |
|
173 | 173 | Log::error($th); |
174 | 174 | } |
175 | 175 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public static function updateExaminationData($student, $admissionInfo) |
185 | 185 | { |
186 | - $student['sp_center'] = gettype((int)$student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
186 | + $student['sp_center'] = gettype((int) $student['sp_center']) == 'integer' ? $student['sp_center'] : 0; |
|
187 | 187 | try { |
188 | 188 | self::where([ |
189 | 189 | 'student_id' => $student['student_id'], |
@@ -204,55 +204,55 @@ discard block |
||
204 | 204 | 'modified_user_id' => 1 |
205 | 205 | ] |
206 | 206 | ); |
207 | - } catch (\Throwable $th) { |
|
207 | + }catch (\Throwable $th) { |
|
208 | 208 | Log::error($th); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - public static function updateStudentArea(array $student){ |
|
213 | - $father = Student_guardian::where('student_id',$student['student_id']) |
|
214 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
215 | - ->where('guardian_relation_id',1) |
|
212 | + public static function updateStudentArea(array $student) { |
|
213 | + $father = Student_guardian::where('student_id', $student['student_id']) |
|
214 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
215 | + ->where('guardian_relation_id', 1) |
|
216 | 216 | ->get()->first(); |
217 | 217 | |
218 | - $mother = Student_guardian::where('student_id',$student['student_id']) |
|
219 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
220 | - ->where('guardian_relation_id',2) |
|
218 | + $mother = Student_guardian::where('student_id', $student['student_id']) |
|
219 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
220 | + ->where('guardian_relation_id', 2) |
|
221 | 221 | ->get()->first(); |
222 | 222 | |
223 | - $guardian = Student_guardian::where('student_id',$student['student_id']) |
|
224 | - ->join('security_users as sg','guardian_id', 'sg.id') |
|
225 | - ->where('guardian_relation_id',3) |
|
223 | + $guardian = Student_guardian::where('student_id', $student['student_id']) |
|
224 | + ->join('security_users as sg', 'guardian_id', 'sg.id') |
|
225 | + ->where('guardian_relation_id', 3) |
|
226 | 226 | ->get()->first(); |
227 | 227 | |
228 | - if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
|
229 | - Security_user::where('id',$student['student_id']) |
|
228 | + if (!is_null($father) && is_null($mother) && is_null($guardian)) { |
|
229 | + Security_user::where('id', $student['student_id']) |
|
230 | 230 | ->update(['address_area_id' => $father->address_area_id]); |
231 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
232 | - Security_user::where('id',$student['student_id']) |
|
231 | + }elseif (!is_null($mother) && (is_null($father) && is_null($guardian))) { |
|
232 | + Security_user::where('id', $student['student_id']) |
|
233 | 233 | ->update(['address_area_id' => $mother->address_area_id]); |
234 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
235 | - Security_user::where('id',$student['student_id']) |
|
234 | + }elseif (!is_null($guardian) && is_null($father) && is_null($mother)) { |
|
235 | + Security_user::where('id', $student['student_id']) |
|
236 | 236 | ->update(['address_area_id' => $guardian->address_area_id]); |
237 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
238 | - Security_user::where('id',$student['student_id']) |
|
237 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)) { |
|
238 | + Security_user::where('id', $student['student_id']) |
|
239 | 239 | ->update(['address_area_id' => $mother->address_area_id]); |
240 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
241 | - Security_user::where('id',$student['student_id']) |
|
240 | + }elseif (!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)) { |
|
241 | + Security_user::where('id', $student['student_id']) |
|
242 | 242 | ->update(['address_area_id' => $guardian->address_area_id]); |
243 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
244 | - Security_user::where('id',$student['student_id']) |
|
243 | + }elseif (!is_null($father) && $father->address == $student['address']) { |
|
244 | + Security_user::where('id', $student['student_id']) |
|
245 | 245 | ->update(['address_area_id' => $father->address_area_id]); |
246 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
247 | - Security_user::where('id',$student['student_id']) |
|
246 | + }elseif (!is_null($mother) && $mother->address == $student['address']) { |
|
247 | + Security_user::where('id', $student['student_id']) |
|
248 | 248 | ->update(['address_area_id' => $mother->address_area_id]); |
249 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
250 | - Security_user::where('id',$student['student_id']) |
|
249 | + }elseif (!is_null($guardian) && $guardian->address == $student['address']) { |
|
250 | + Security_user::where('id', $student['student_id']) |
|
251 | 251 | ->update(['address_area_id' => $guardian->address_area_id]); |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | - public static function createOrUpdate($studentId,$row,$params,$file){ |
|
255 | + public static function createOrUpdate($studentId, $row, $params, $file) { |
|
256 | 256 | self::create([ |
257 | 257 | 'student_status_id' => 1, |
258 | 258 | 'student_id' => $studentId, |
@@ -228,25 +228,25 @@ |
||
228 | 228 | if(!is_null($father) && is_null($mother) && is_null($guardian)){ |
229 | 229 | Security_user::where('id',$student['student_id']) |
230 | 230 | ->update(['address_area_id' => $father->address_area_id]); |
231 | - }elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
231 | + } elseif(!is_null($mother) && (is_null($father) && is_null($guardian))){ |
|
232 | 232 | Security_user::where('id',$student['student_id']) |
233 | 233 | ->update(['address_area_id' => $mother->address_area_id]); |
234 | - }elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
234 | + } elseif(!is_null($guardian) && is_null($father) && is_null($mother)){ |
|
235 | 235 | Security_user::where('id',$student['student_id']) |
236 | 236 | ->update(['address_area_id' => $guardian->address_area_id]); |
237 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
237 | + } elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id == $mother->address_area_id)){ |
|
238 | 238 | Security_user::where('id',$student['student_id']) |
239 | 239 | ->update(['address_area_id' => $mother->address_area_id]); |
240 | - }elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
240 | + } elseif(!is_null($mother) && !is_null($father) && ($father->address_area_id !== $mother->address_area_id) && !is_null($guardian)){ |
|
241 | 241 | Security_user::where('id',$student['student_id']) |
242 | 242 | ->update(['address_area_id' => $guardian->address_area_id]); |
243 | - }elseif(!is_null($father) && $father->address == $student['address']){ |
|
243 | + } elseif(!is_null($father) && $father->address == $student['address']){ |
|
244 | 244 | Security_user::where('id',$student['student_id']) |
245 | 245 | ->update(['address_area_id' => $father->address_area_id]); |
246 | - }elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
246 | + } elseif(!is_null($mother) && $mother->address == $student['address']){ |
|
247 | 247 | Security_user::where('id',$student['student_id']) |
248 | 248 | ->update(['address_area_id' => $mother->address_area_id]); |
249 | - }elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
249 | + } elseif(!is_null($guardian) && $guardian->address == $student['address']){ |
|
250 | 250 | Security_user::where('id',$student['student_id']) |
251 | 251 | ->update(['address_area_id' => $guardian->address_area_id]); |
252 | 252 | } |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | if (empty($value)) { |
71 | 71 | return false; |
72 | 72 | } elseif ($gradeEntity !== null) { |
73 | - $admissionAge = (($gradeEntity->admission_age) * 12) - 1; |
|
73 | + $admissionAge = (($gradeEntity->admission_age)*12) - 1; |
|
74 | 74 | $to = $academicPeriod->start_date; |
75 | 75 | $diff_in_months = $to->diffInMonths($value); |
76 | 76 | $ageOfStudent = $diff_in_months; |
77 | 77 | $enrolmentMaximumAge = $admissionAge + 120; |
78 | 78 | return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); |
79 | - } else { |
|
79 | + }else { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | - } else { |
|
83 | - $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found'; |
|
82 | + }else { |
|
83 | + $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found'; |
|
84 | 84 | $this->_set_custom_stuff(); |
85 | 85 | return false; |
86 | 86 | } |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | |
92 | 92 | if (is_numeric($value)) { |
93 | 93 | if ($value < 10) { |
94 | - $this->_custom_messages['bmi'] = $attribute . ' is must greater than 10'; |
|
94 | + $this->_custom_messages['bmi'] = $attribute.' is must greater than 10'; |
|
95 | 95 | $this->_set_custom_stuff(); |
96 | 96 | return false; |
97 | 97 | } elseif ($value > 250) { |
98 | - $this->_custom_messages['bmi'] = $attribute . ' is must smaller than 250'; |
|
98 | + $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250'; |
|
99 | 99 | $this->_set_custom_stuff(); |
100 | 100 | return false; |
101 | 101 | } |
102 | - } else { |
|
103 | - $this->_custom_messages['bmi'] = $attribute . ' is must a valid numeric'; |
|
102 | + }else { |
|
103 | + $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric'; |
|
104 | 104 | $this->_set_custom_stuff(); |
105 | 105 | return false; |
106 | 106 | } |
@@ -109,18 +109,18 @@ discard block |
||
109 | 109 | |
110 | 110 | protected function validateBmi($attribute, $value, $parameters) |
111 | 111 | { |
112 | - $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
112 | + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
113 | 113 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) |
114 | 114 | ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
115 | 115 | ->first(); |
116 | - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
116 | + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
117 | 117 | if (in_array($institutionGrade->code, $bmiGrades)) { |
118 | 118 | if (!empty($value)) { |
119 | 119 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
120 | 120 | return $this->validateHW($attribute, $value); |
121 | 121 | } |
122 | - } else { |
|
123 | - $this->_custom_messages['bmi'] = $attribute . ' is required for ' . $educationGrade->name; |
|
122 | + }else { |
|
123 | + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; |
|
124 | 124 | $this->_set_custom_stuff(); |
125 | 125 | return false; |
126 | 126 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
129 | 129 | return $this->validateHW($attribute, $value); |
130 | 130 | } |
131 | - } else { |
|
131 | + }else { |
|
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | } |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | { |
138 | 138 | foreach ($validator->getData() as $data) { |
139 | 139 | if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) { |
140 | - $BirthDivision = Area_administrative::where('name', '=', '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); // |
|
140 | + $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
141 | 141 | if ($BirthDivision->count() > 0) { |
142 | - $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
142 | + $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
143 | 143 | ->where('parent_id', '=', $BirthDivision->first()->id)->count(); |
144 | - return $BirthArea > 0; |
|
144 | + return $BirthArea > 0; |
|
145 | 145 | } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) { |
146 | 146 | $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC'; |
147 | 147 | $this->_set_custom_stuff(); |
148 | 148 | return false; |
149 | - } else { |
|
149 | + }else { |
|
150 | 150 | return true; |
151 | 151 | } |
152 | - } else { |
|
152 | + }else { |
|
153 | 153 | return true; |
154 | 154 | } |
155 | 155 | } |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | |
158 | 158 | protected function validateIsStudentInClass($attribute, $value, $perameters, $validator) |
159 | 159 | { |
160 | - $student = Security_user::where('openemis_no', '=', $value); |
|
160 | + $student = Security_user::where('openemis_no', '=', $value); |
|
161 | 161 | if ($student->count() > 0) { |
162 | 162 | $student = $student->first()->toArray(); |
163 | - $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
163 | + $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
164 | 164 | if ($check == 1) { |
165 | 165 | return true; |
166 | - } else { |
|
166 | + }else { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | - } else { |
|
169 | + }else { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | { |
178 | 178 | $valid = true; |
179 | 179 | foreach ($validator->getData() as $data) { |
180 | - switch($data[$perameters[0]]){ |
|
180 | + switch ($data[$perameters[0]]) { |
|
181 | 181 | case 'BC': |
182 | 182 | $valid = preg_match('/^([0-9]{3,5})/i', $value); |
183 | 183 | break; |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | if ($valid == 0) { |
193 | - $this->_custom_messages['identity'] = $attribute . ' is not valid Please check the NIC number'; |
|
193 | + $this->_custom_messages['identity'] = $attribute.' is not valid Please check the NIC number'; |
|
194 | 194 | $this->_set_custom_stuff(); |
195 | 195 | return false; |
196 | - } else { |
|
196 | + }else { |
|
197 | 197 | return true; |
198 | 198 | } |
199 | 199 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | protected function validateUserUnique($attribute, $value, $perameters, $validator) |
202 | 202 | { |
203 | 203 | foreach ($validator->getData() as $data) { |
204 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
204 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
205 | 205 | if ($identityType !== null && ($value !== null)) { |
206 | 206 | if ($identityType->national_code === 'BC') { |
207 | 207 | return $this->checkUnique($value, $data, $identityType); |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | protected function validateIsBc($attribute, $value, $perameters, $validator) |
218 | 218 | { |
219 | 219 | foreach ($validator->getData() as $data) { |
220 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
220 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
221 | 221 | if (($identityType !== null) && ($identityType !== "")) { |
222 | 222 | if (($identityType->national_code) === 'BC') { |
223 | 223 | return (strlen((string) $data['identity_number']) < 7); |
224 | - } else { |
|
224 | + }else { |
|
225 | 225 | return true; |
226 | 226 | } |
227 | - } else { |
|
227 | + }else { |
|
228 | 228 | return true; |
229 | 229 | } |
230 | 230 | } |
@@ -234,24 +234,24 @@ discard block |
||
234 | 234 | { |
235 | 235 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
236 | 236 | if ($isUnique->count() > 0) { |
237 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
237 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
238 | 238 | $this->_set_custom_stuff(); |
239 | 239 | return false; |
240 | - } else { |
|
240 | + }else { |
|
241 | 241 | return true; |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | 245 | protected function IsBc($data, $value) |
246 | 246 | { |
247 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
247 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
248 | 248 | if ($identityType !== null) { |
249 | 249 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
250 | 250 | return false; |
251 | - } else { |
|
251 | + }else { |
|
252 | 252 | return true; |
253 | 253 | } |
254 | - } else { |
|
254 | + }else { |
|
255 | 255 | return true; |
256 | 256 | } |
257 | 257 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
42 | 42 | $output->writeln('###########################################------Inserting file records------###########################################'); |
43 | 43 | |
44 | - ExaminationStudentsController::callOnClick($this->argument('year'),$this->argument('grade')); |
|
44 | + ExaminationStudentsController::callOnClick($this->argument('year'), $this->argument('grade')); |
|
45 | 45 | $output->writeln('###########################################------Finished inserting file records------###########################################'); |
46 | 46 | } |
47 | 47 | } |
@@ -42,9 +42,9 @@ |
||
42 | 42 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
43 | 43 | $output->writeln('###########################################------Inserting file records------###########################################'); |
44 | 44 | $this->examinationController = new ExaminationStudentsController(2019, 'G4'); |
45 | - $students = Examination_student::all()->toArray(); |
|
45 | + $students = Examination_student::all()->toArray(); |
|
46 | 46 | $func = $this->examinationController; |
47 | - array_walk($students,array($func,'updateCensusNo')); |
|
47 | + array_walk($students, array($func, 'updateCensusNo')); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | break; |
193 | 193 | case 'empty'; |
194 | 194 | $students = Examination_student:: |
195 | - whereNull('nsid') |
|
195 | + whereNull('nsid') |
|
196 | 196 | ->where('grade', $this->grade) |
197 | 197 | ->where('year', $this->year) |
198 | 198 | ->offset($offset) |
@@ -323,13 +323,13 @@ discard block |
||
323 | 323 | $sis_student['student_id'] = $student['id' ]; |
324 | 324 | |
325 | 325 | $student = $this->setIsTakingExam($student); |
326 | - if (count($institutionClass) == 1) { |
|
326 | + if (count($institutionClass) == 1) { |
|
327 | 327 | $admissionInfo['instituion_class'] = $institutionClass[0]; |
328 | - Institution_student::createExaminationData($student, $admissionInfo); |
|
328 | + Institution_student::createExaminationData($student, $admissionInfo); |
|
329 | 329 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
330 | 330 | Institution_class_student::createExaminationData($student, $admissionInfo); |
331 | 331 | } else { |
332 | - Institution_student_admission::createExaminationData($student, $admissionInfo); |
|
332 | + Institution_student_admission::createExaminationData($student, $admissionInfo); |
|
333 | 333 | Institution_student::createExaminationData($student, $admissionInfo); |
334 | 334 | } |
335 | 335 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $this->grade = $grade; |
31 | 31 | $this->student = new Security_user(); |
32 | 32 | $this->examination_student = new Examination_student(); |
33 | - $this->academic_period = Academic_period::where('code', '=', $this->year)->first(); |
|
33 | + $this->academic_period = Academic_period::where('code', '=', $this->year)->first(); |
|
34 | 34 | $this->education_grade = Education_grade::where('code', '=', $this->grade)->first(); |
35 | 35 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
36 | 36 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | ); |
72 | 72 | Session::flash('message', 'File upload successfully!'); |
73 | 73 | // Redirect to index |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | Session::flash('message', 'File too large. File must be less than 20MB.'); |
76 | 76 | } |
77 | - } else { |
|
77 | + }else { |
|
78 | 78 | Session::flash('message', 'Invalid File Extension.'); |
79 | 79 | } |
80 | 80 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $import->import($excelFile, 'local', \Maatwebsite\Excel\Excel::CSV); |
97 | 97 | if ($import->failures()->count() > 0) { |
98 | 98 | $errors = $import->failures(); |
99 | - $columns = [ |
|
99 | + $columns = [ |
|
100 | 100 | 'remarks', |
101 | 101 | 'st_no', |
102 | 102 | 'stu_no', |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | Storage::put($file, implode(',', $columns)); |
118 | 118 | |
119 | 119 | foreach ($errors as $error) { |
120 | - Storage::append($file, implode(':', $error->errors()) . ',' . implode(',', $error->values())); |
|
120 | + Storage::append($file, implode(':', $error->errors()).','.implode(',', $error->values())); |
|
121 | 121 | } |
122 | 122 | } |
123 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
123 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $Institution = $Institution[0]; |
144 | 144 | if (count($student) == 1) { |
145 | 145 | $student = $student[0]; |
146 | - if (((int)$Institution['id']) != ((int)$student['institution_id'])) { |
|
146 | + if (((int) $Institution['id']) != ((int) $student['institution_id'])) { |
|
147 | 147 | $studentClass = Institution_class_student::where('student_id', $student['student_id']) |
148 | 148 | ->first(); |
149 | 149 | Institution_class_student::where('student_id', $student['student_id'])->delete(); |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | if (!is_null($studentClass)) { |
154 | 154 | $class->updateClassCount($studentClass->toArray()); |
155 | 155 | } |
156 | - $output->writeln('updated student info:' . $data['nsid']); |
|
156 | + $output->writeln('updated student info:'.$data['nsid']); |
|
157 | 157 | } |
158 | - } else { |
|
158 | + }else { |
|
159 | 159 | Institution_student::where('institution_id', '<>', $Institution['id'])->where('student_id', $student[0]['student_id']) |
160 | 160 | ->delete(); |
161 | - $output->writeln('updated student info:' . $Institution['id'] . '==' . $Institution['id']); |
|
161 | + $output->writeln('updated student info:'.$Institution['id'].'=='.$Institution['id']); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $students = []; |
175 | 175 | switch ($mode) { |
176 | 176 | case 'duplicate': |
177 | - $students = DB::table('examination_students as es') |
|
177 | + $students = DB::table('examination_students as es') |
|
178 | 178 | ->select(DB::raw('count(*) as total'), 'e2.*') |
179 | 179 | ->where('grade', $this->grade) |
180 | 180 | ->where('year', $this->year) |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | ->limit($limit) |
187 | 187 | ->get()->toArray(); |
188 | 188 | $students = (array) json_decode(json_encode($students)); |
189 | - $this->output->writeln(count($students) . 'students remaining duplicate'); |
|
189 | + $this->output->writeln(count($students).'students remaining duplicate'); |
|
190 | 190 | array_walk($students, array($this, 'clone')); |
191 | 191 | $this->output->writeln('All are generated'); |
192 | 192 | break; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ->limit($limit) |
200 | 200 | ->get()->toArray(); |
201 | 201 | $students = (array) json_decode(json_encode($students)); |
202 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
202 | + $this->output->writeln(count($students).'students remaining empty'); |
|
203 | 203 | array_walk($students, array($this, 'clone')); |
204 | 204 | $this->output->writeln('All are generated'); |
205 | 205 | break; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | ->where('year', $this->year) |
210 | 210 | ->get()->toArray(); |
211 | 211 | $students = (array) json_decode(json_encode($students)); |
212 | - $this->output->writeln(count($students) . 'students remaining with wrong NSID'); |
|
212 | + $this->output->writeln(count($students).'students remaining with wrong NSID'); |
|
213 | 213 | array_walk($students, array($this, 'clone')); |
214 | 214 | $this->output->writeln('All are generated'); |
215 | 215 | break; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ->count(); |
221 | 221 | $all = Examination_student::select('nsid') |
222 | 222 | ->count(); |
223 | - $this->output->writeln($all . 'Total Unique nsid are: ' . $count); |
|
223 | + $this->output->writeln($all.'Total Unique nsid are: '.$count); |
|
224 | 224 | break; |
225 | 225 | default: |
226 | 226 | $students = Examination_student::offset($offset) |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | ->limit($limit) |
230 | 230 | ->get()->toArray(); |
231 | 231 | $students = (array) json_decode(json_encode($students)); |
232 | - $this->output->writeln(count($students) . 'students remaining empty'); |
|
232 | + $this->output->writeln(count($students).'students remaining empty'); |
|
233 | 233 | array_walk($students, array($this, 'clone')); |
234 | 234 | $this->output->writeln('All are generated'); |
235 | 235 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function clone($student) |
279 | 279 | { |
280 | - $student = (array)json_decode(json_encode($student)); |
|
280 | + $student = (array) json_decode(json_encode($student)); |
|
281 | 281 | //get student matching with same dob and gender |
282 | 282 | |
283 | 283 | $matchedStudent = $this->getMatchingStudents($student); |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | 'academic_period_id' => $this->academic_period->id |
297 | 297 | ] |
298 | 298 | ) |
299 | - ->where( 'education_grade_id','in', [$this->student->education_garde_id]) |
|
299 | + ->where('education_grade_id', 'in', [$this->student->education_garde_id]) |
|
300 | 300 | ->join('institution_class_grades', 'institution_classes.id', 'institution_class_grades.institution_class_id')->get()->toArray(); |
301 | 301 | |
302 | 302 | |
303 | - if(!is_null($this->student->education_garde_id)){ |
|
303 | + if (!is_null($this->student->education_garde_id)) { |
|
304 | 304 | $this->education_grade = Education_grade::where('id', '=', $this->student->education_garde_id)->first(); |
305 | - }else{ |
|
305 | + }else { |
|
306 | 306 | $this->student->education_garde_id = $this->education_grade->id; |
307 | 307 | } |
308 | 308 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | |
321 | 321 | //TODO implement insert student to admission table |
322 | 322 | $student['id'] = $sis_student['id']; |
323 | - $sis_student['student_id'] = $student['id' ]; |
|
323 | + $sis_student['student_id'] = $student['id']; |
|
324 | 324 | |
325 | 325 | $student = $this->setIsTakingExam($student); |
326 | 326 | if (count($institutionClass) == 1) { |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | Institution_student::createExaminationData($student, $admissionInfo); |
329 | 329 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
330 | 330 | Institution_class_student::createExaminationData($student, $admissionInfo); |
331 | - } else { |
|
331 | + }else { |
|
332 | 332 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
333 | 333 | Institution_student::createExaminationData($student, $admissionInfo); |
334 | 334 | } |
335 | 335 | |
336 | 336 | $this->updateStudentId($student, $sis_student); |
337 | 337 | // update the matched student's data |
338 | - } else { |
|
338 | + }else { |
|
339 | 339 | $student = $this->setIsTakingExam($student); |
340 | 340 | $studentData = $this->student->updateExaminationStudent($student, $matchedStudent); |
341 | 341 | $matchedStudent = array_merge((array) $student, $matchedStudent); |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | Institution_student::updateExaminationData($studentData, $admissionInfo); |
344 | 344 | $this->updateStudentId($student, $studentData); |
345 | 345 | } |
346 | - } else { |
|
346 | + }else { |
|
347 | 347 | |
348 | - $this->output->writeln('Student ' . $student['st_no'] . ' not imorted' . $student['f_name']); |
|
348 | + $this->output->writeln('Student '.$student['st_no'].' not imorted'.$student['f_name']); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
@@ -362,20 +362,20 @@ discard block |
||
362 | 362 | /** |
363 | 363 | */ |
364 | 364 | $sis_student = $this->student->getMatches($student); |
365 | - $doe_students = Examination_student::where('gender', $student['gender']) |
|
365 | + $doe_students = Examination_student::where('gender', $student['gender']) |
|
366 | 366 | ->where('b_date', $student['b_date']) |
367 | 367 | ->where('schoolid', $student['schoolid']) |
368 | - ->where('year',$this->year) |
|
369 | - ->where('grade',$this->grade) |
|
368 | + ->where('year', $this->year) |
|
369 | + ->where('grade', $this->grade) |
|
370 | 370 | ->count(); |
371 | 371 | $count = $this->student->getStudentCount($student); |
372 | 372 | |
373 | 373 | $studentData = []; |
374 | - $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
374 | + $sis_users = (array) json_decode(json_encode($sis_student), true); |
|
375 | 375 | // if the same gender same DOE has more than one |
376 | 376 | if (($doe_students > 1) || ($count > 1)) { |
377 | 377 | $studentData = $this->searchSimilarName($student, $sis_users, false); |
378 | - } else { |
|
378 | + }else { |
|
379 | 379 | $studentData = $this->searchSimilarName($student, $sis_users); |
380 | 380 | } |
381 | 381 | return $studentData; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | if (count($matches) > 1) { |
428 | - $highest = $this->searchSimilarName($student, $sis_students, false); |
|
428 | + $highest = $this->searchSimilarName($student, $sis_students, false); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | return $highest; |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | public function updateStudentId($student, $sis_student) |
442 | 442 | { |
443 | 443 | try { |
444 | - $student['nsid'] = $sis_student['openemis_no']; |
|
444 | + $student['nsid'] = $sis_student['openemis_no']; |
|
445 | 445 | // add new NSID to the examinations data set |
446 | 446 | unset($student['id']); |
447 | 447 | unset($student['taking_g5_exam']); |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | unset($student['taking_ol_exam']); |
450 | 450 | unset($student['taking_git_exam']); |
451 | 451 | unset($student['total']); |
452 | - $students['updated_at'] = now(); |
|
452 | + $students['updated_at'] = now(); |
|
453 | 453 | $this->examination_student->where('st_no', $student['st_no'])->update($student); |
454 | 454 | unset($student['st_no']); |
455 | - $this->output->writeln('Updated to NSID' . $sis_student['openemis_no']); |
|
456 | - } catch (\Exception $th) { |
|
455 | + $this->output->writeln('Updated to NSID'.$sis_student['openemis_no']); |
|
456 | + }catch (\Exception $th) { |
|
457 | 457 | $this->output->writeln('error'); |
458 | 458 | Log::error($th); |
459 | 459 | } |
@@ -468,9 +468,9 @@ discard block |
||
468 | 468 | { |
469 | 469 | $adminUser = Security_user::where('username', 'admin')->first(); |
470 | 470 | try { |
471 | - (new ExaminationStudentsExport($this->year,$this->grade))->store('examination/student_data_with_nsid.' . time() . '.csv'); |
|
471 | + (new ExaminationStudentsExport($this->year, $this->grade))->store('examination/student_data_with_nsid.'.time().'.csv'); |
|
472 | 472 | (new ExportReady($adminUser)); |
473 | - } catch (\Throwable $th) { |
|
473 | + }catch (\Throwable $th) { |
|
474 | 474 | //throw $th; |
475 | 475 | } |
476 | 476 | return back()->withSuccess('Export started!'); |
@@ -479,14 +479,14 @@ discard block |
||
479 | 479 | public function downloadErrors() |
480 | 480 | { |
481 | 481 | |
482 | - $file_path = storage_path() . '/app/examination/errors.csv'; |
|
482 | + $file_path = storage_path().'/app/examination/errors.csv'; |
|
483 | 483 | return Response::download($file_path); |
484 | 484 | } |
485 | 485 | |
486 | 486 | public function downloadProcessedFile() |
487 | 487 | { |
488 | 488 | |
489 | - $file_path = storage_path() . '/app/examination/student_data_with_nsid.1628499466.csv'; //hard coded file name |
|
489 | + $file_path = storage_path().'/app/examination/student_data_with_nsid.1628499466.csv'; //hard coded file name |
|
490 | 490 | return Response::download($file_path); |
491 | 491 | } |
492 | 492 | } |
@@ -302,7 +302,7 @@ |
||
302 | 302 | |
303 | 303 | if(!is_null($this->student->education_garde_id)){ |
304 | 304 | $this->education_grade = Education_grade::where('id', '=', $this->student->education_garde_id)->first(); |
305 | - }else{ |
|
305 | + } else{ |
|
306 | 306 | $this->student->education_garde_id = $this->education_grade->id; |
307 | 307 | } |
308 | 308 |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $studentData['id'] = $id; |
205 | 205 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
206 | 206 | return $studentData; |
207 | - } catch (\Exception $th) { |
|
207 | + }catch (\Exception $th) { |
|
208 | 208 | Log::error($th->getMessage()); |
209 | 209 | // in case of duplication of the Unique ID this will recursive till success. |
210 | 210 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $this->uniqueUserId = new Unique_user_id(); |
226 | 226 | $this->uniqueUId = new UniqueUid(); |
227 | 227 | // regenerate unique id if it's not available |
228 | - $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
228 | + $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
229 | 229 | |
230 | 230 | $studentData = [ |
231 | 231 | 'username' => str_replace('-', '', $uniqueId), |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | $studentData['id'] = $sis_student['student_id']; |
244 | 244 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
245 | 245 | return $studentData; |
246 | - } catch (\Exception $th) { |
|
246 | + }catch (\Exception $th) { |
|
247 | 247 | Log::error($th); |
248 | 248 | // in case of duplication of the Unique ID this will recursive. |
249 | 249 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |
250 | - $this->updateExaminationStudent($student,$sis_student); |
|
250 | + $this->updateExaminationStudent($student, $sis_student); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | { |
256 | 256 | try { |
257 | 257 | $uniqueUid = new UniqueUid(); |
258 | - $BirthArea = Area_administrative::where('name', 'like', '%' . $row['birth_registrar_office_as_in_birth_certificate'] . '%')->first(); |
|
259 | - $nationalityId = Nationality::where('name', 'like', '%' . $row['nationality'] . '%')->first(); |
|
260 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row['identity_type'] . '%')->first(); |
|
258 | + $BirthArea = Area_administrative::where('name', 'like', '%'.$row['birth_registrar_office_as_in_birth_certificate'].'%')->first(); |
|
259 | + $nationalityId = Nationality::where('name', 'like', '%'.$row['nationality'].'%')->first(); |
|
260 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row['identity_type'].'%')->first(); |
|
261 | 261 | |
262 | 262 | $date = $row['date_of_birth_yyyy_mm_dd']; |
263 | 263 | $identityType = $identityType !== null ? $identityType->id : null; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | ]); |
290 | 290 | case 'update': |
291 | 291 | if (!is_null($row['student_id'])) { |
292 | - $studentInfo = Security_user::where('openemis_no',trim($row['student_id']))->first(); |
|
292 | + $studentInfo = Security_user::where('openemis_no', trim($row['student_id']))->first(); |
|
293 | 293 | self::query()->where('openemis_no', $row['student_id']) |
294 | 294 | ->update([ |
295 | 295 | 'first_name' => $row['full_name'] ? $row['full_name'] : $studentInfo['first_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | break; |
312 | 312 | } |
313 | - } catch (\Exception $e) { |
|
313 | + }catch (\Exception $e) { |
|
314 | 314 | dd($e); |
315 | 315 | } |
316 | 316 | } |
@@ -319,48 +319,48 @@ discard block |
||
319 | 319 | { |
320 | 320 | try { |
321 | 321 | $uniqueUid = new UniqueUid(); |
322 | - $AddressArea = Area_administrative::where('name', 'like', '%' . $row[$prefix . 's_address_area'] . '%')->first(); |
|
323 | - $nationalityId = Nationality::where('name', 'like', '%' . $row[$prefix . 's_nationality'] . '%')->first(); |
|
324 | - $identityType = Identity_type::where('national_code', 'like', '%' . $row[$prefix . 's_identity_type'] . '%')->first(); |
|
322 | + $AddressArea = Area_administrative::where('name', 'like', '%'.$row[$prefix.'s_address_area'].'%')->first(); |
|
323 | + $nationalityId = Nationality::where('name', 'like', '%'.$row[$prefix.'s_nationality'].'%')->first(); |
|
324 | + $identityType = Identity_type::where('national_code', 'like', '%'.$row[$prefix.'s_identity_type'].'%')->first(); |
|
325 | 325 | $openemisNo = $uniqueUid::getUniqueAlphanumeric(); |
326 | 326 | |
327 | 327 | $identityType = ($identityType !== null) ? $identityType->id : null; |
328 | 328 | $nationalityId = $nationalityId !== null ? $nationalityId->id : null; |
329 | 329 | |
330 | 330 | $guardian = null; |
331 | - if (!empty($row[$prefix . 's_identity_number'])) { |
|
331 | + if (!empty($row[$prefix.'s_identity_number'])) { |
|
332 | 332 | $guardian = Security_user::where('identity_type_id', '=', $nationalityId) |
333 | - ->where('identity_number', '=', $row[$prefix . 's_identity_number'])->first(); |
|
333 | + ->where('identity_number', '=', $row[$prefix.'s_identity_number'])->first(); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | if (is_null($guardian)) { |
337 | 337 | $guardian = self::create([ |
338 | 338 | 'username' => str_replace('-', '', $openemisNo), |
339 | 339 | 'openemis_no' => $openemisNo, |
340 | - 'first_name' => $row[$prefix . 's_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
|
341 | - 'last_name' => genNameWithInitials($row[$prefix . 's_full_name']), |
|
340 | + 'first_name' => $row[$prefix.'s_full_name'], // here we save full name in the column of first name. re reduce breaks of the system. |
|
341 | + 'last_name' => genNameWithInitials($row[$prefix.'s_full_name']), |
|
342 | 342 | 'gender_id' => 1, |
343 | - 'date_of_birth' => $row[$prefix . 's_date_of_birth_yyyy_mm_dd'], |
|
344 | - 'address' => $row[$prefix . 's_address'], |
|
343 | + 'date_of_birth' => $row[$prefix.'s_date_of_birth_yyyy_mm_dd'], |
|
344 | + 'address' => $row[$prefix.'s_address'], |
|
345 | 345 | 'address_area_id' => $AddressArea ? $AddressArea->id : null, |
346 | 346 | 'nationality_id' => $nationalityId, |
347 | 347 | 'identity_type_id' => $identityType, |
348 | - 'identity_number' => $row[$prefix . 's_identity_number'], |
|
348 | + 'identity_number' => $row[$prefix.'s_identity_number'], |
|
349 | 349 | 'is_guardian' => 1, |
350 | 350 | 'created_user_id' => $file['security_user_id'] |
351 | 351 | ]); |
352 | 352 | |
353 | 353 | |
354 | 354 | $guardian['guardian_relation_id'] = 1; |
355 | - if (array_key_exists($prefix . 's_phone', $row)) { |
|
356 | - $father['contact'] = $row[$prefix . 's_phone']; |
|
355 | + if (array_key_exists($prefix.'s_phone', $row)) { |
|
356 | + $father['contact'] = $row[$prefix.'s_phone']; |
|
357 | 357 | User_contact::createOrUpdate($father, $file['security_user_id']); |
358 | 358 | } |
359 | - } else { |
|
360 | - Security_user::where('id', $guardian->id)->update(['address_area_id' => $AddressArea ? $AddressArea->id : null,]); |
|
359 | + }else { |
|
360 | + Security_user::where('id', $guardian->id)->update(['address_area_id' => $AddressArea ? $AddressArea->id : null, ]); |
|
361 | 361 | } |
362 | 362 | return $guardian; |
363 | - } catch (\Exception $e) { |
|
363 | + }catch (\Exception $e) { |
|
364 | 364 | Log::error($e->getMessage(), [$e]); |
365 | 365 | } |
366 | 366 | } |
@@ -65,21 +65,21 @@ |
||
65 | 65 | */ |
66 | 66 | if (!empty($institution_grades)) { |
67 | 67 | |
68 | - $this->info('Fetched ' . count($institution_grades) . ' records'); |
|
68 | + $this->info('Fetched '.count($institution_grades).' records'); |
|
69 | 69 | |
70 | 70 | foreach ($institution_grades as $institute_grade) { |
71 | 71 | if ($institute_grade->promoted == "2019") { |
72 | 72 | $this->info('Promoted year have already set to 2019'); |
73 | - } else { |
|
73 | + }else { |
|
74 | 74 | $this->info('Updating record ======================================='); |
75 | 75 | DB::update("update institution_grades set promoted ='2019' where institution_id = ?", [$this->argument('institution')]); |
76 | 76 | $this->info('Record updated ========================================'); |
77 | 77 | } |
78 | 78 | } |
79 | - } else { |
|
79 | + }else { |
|
80 | 80 | $this->info('No results!'); |
81 | 81 | } |
82 | - } catch (\Exception $e) { |
|
82 | + }catch (\Exception $e) { |
|
83 | 83 | return $e->getMessage(); |
84 | 84 | } |
85 | 85 | } |
@@ -84,32 +84,32 @@ |
||
84 | 84 | try{ |
85 | 85 | $output->writeln($approvedstudent['student_id']."Updated"); |
86 | 86 | Institution_student::create([ |
87 | - 'student_status_id' => 1, |
|
88 | - 'student_id' => $approvedstudent['student_id'], |
|
89 | - 'education_grade_id' => $approvedstudent['education_grade_id'], |
|
90 | - 'academic_period_id' => $approvedstudent['academic_period_id'], |
|
91 | - 'start_date' => $approvedstudent['start_date'], |
|
92 | - 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['start_date'])->year , // $approvedstudent['start_date']->format('Y'), |
|
93 | - 'end_date' => $approvedstudent['end_date'], |
|
94 | - 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['end_date'])->year , //$approvedstudent['end_date']->format('Y'), |
|
95 | - 'institution_id' => $approvedstudent['institution_id'], |
|
96 | - 'admission_id' => $approvedstudent['admission_id'], |
|
97 | - 'created_user_id' => $approvedstudent['created_user_id'], |
|
98 | - ]); |
|
99 | - if(!is_null($approvedstudent['institution_class_id'])){ |
|
100 | - Institution_class_student::create([ |
|
101 | - 'student_id' => $approvedstudent['student_id'], |
|
102 | - 'institution_class_id' => $approvedstudent['institution_class_id'], |
|
103 | - 'education_grade_id' => $approvedstudent['education_grade_id'], |
|
104 | - 'academic_period_id' => $approvedstudent['academic_period_id'], |
|
105 | - 'institution_id' =>$approvedstudent['institution_id'], |
|
106 | - 'student_status_id' => 1, |
|
107 | - 'created_user_id' => $approvedstudent['created_user_id'], |
|
108 | - ]); |
|
109 | - } |
|
110 | - }catch (\Exception $e){ |
|
111 | - echo $e->getMessage(); |
|
112 | - } |
|
87 | + 'student_status_id' => 1, |
|
88 | + 'student_id' => $approvedstudent['student_id'], |
|
89 | + 'education_grade_id' => $approvedstudent['education_grade_id'], |
|
90 | + 'academic_period_id' => $approvedstudent['academic_period_id'], |
|
91 | + 'start_date' => $approvedstudent['start_date'], |
|
92 | + 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['start_date'])->year , // $approvedstudent['start_date']->format('Y'), |
|
93 | + 'end_date' => $approvedstudent['end_date'], |
|
94 | + 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['end_date'])->year , //$approvedstudent['end_date']->format('Y'), |
|
95 | + 'institution_id' => $approvedstudent['institution_id'], |
|
96 | + 'admission_id' => $approvedstudent['admission_id'], |
|
97 | + 'created_user_id' => $approvedstudent['created_user_id'], |
|
98 | + ]); |
|
99 | + if(!is_null($approvedstudent['institution_class_id'])){ |
|
100 | + Institution_class_student::create([ |
|
101 | + 'student_id' => $approvedstudent['student_id'], |
|
102 | + 'institution_class_id' => $approvedstudent['institution_class_id'], |
|
103 | + 'education_grade_id' => $approvedstudent['education_grade_id'], |
|
104 | + 'academic_period_id' => $approvedstudent['academic_period_id'], |
|
105 | + 'institution_id' =>$approvedstudent['institution_id'], |
|
106 | + 'student_status_id' => 1, |
|
107 | + 'created_user_id' => $approvedstudent['created_user_id'], |
|
108 | + ]); |
|
109 | + } |
|
110 | + }catch (\Exception $e){ |
|
111 | + echo $e->getMessage(); |
|
112 | + } |
|
113 | 113 | } |
114 | 114 | $output->writeln(' |
115 | 115 | #################################################### |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | 'id' => $this->argument('institution') |
51 | 51 | ])->first(); |
52 | 52 | |
53 | - if(!is_null($institution)){ |
|
53 | + if (!is_null($institution)) { |
|
54 | 54 | DB::enableQueryLog(); |
55 | 55 | try { |
56 | - $this->info('adding missing students to the institution ' . $institution->name); |
|
56 | + $this->info('adding missing students to the institution '.$institution->name); |
|
57 | 57 | $approvedstudent = Institution_student_admission::select('institution_student_admission.*') |
58 | 58 | ->leftJoin('institution_students', 'institution_student_admission.student_id', '=', 'institution_students.student_id') |
59 | - ->whereIn('status_id',[121,122,123,124]) |
|
60 | - ->where('institution_student_admission.institution_id',$institution->id)->get()->toArray(); |
|
59 | + ->whereIn('status_id', [121, 122, 123, 124]) |
|
60 | + ->where('institution_student_admission.institution_id', $institution->id)->get()->toArray(); |
|
61 | 61 | |
62 | 62 | $approvedstudent = array_chunk($approvedstudent, 50); |
63 | 63 | |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - protected function addStudents($approvedstudent){ |
|
73 | - array_walk($approvedstudent,array($this,'addStudent')); |
|
72 | + protected function addStudents($approvedstudent) { |
|
73 | + array_walk($approvedstudent, array($this, 'addStudent')); |
|
74 | 74 | } |
75 | 75 | |
76 | - protected function addStudent($approvedstudent){ |
|
76 | + protected function addStudent($approvedstudent) { |
|
77 | 77 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
78 | 78 | Log::info($approvedstudent); |
79 | 79 | // sleep(1); |
80 | - if((Institution_student::isDuplicated($approvedstudent) == 0)){ |
|
80 | + if ((Institution_student::isDuplicated($approvedstudent) == 0)) { |
|
81 | 81 | dd($approvedstudent); |
82 | 82 | $this->count += 1; |
83 | - $this->student = $approvedstudent ; |
|
84 | - try{ |
|
83 | + $this->student = $approvedstudent; |
|
84 | + try { |
|
85 | 85 | $output->writeln($approvedstudent['student_id']."Updated"); |
86 | 86 | Institution_student::create([ |
87 | 87 | 'student_status_id' => 1, |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | 'education_grade_id' => $approvedstudent['education_grade_id'], |
90 | 90 | 'academic_period_id' => $approvedstudent['academic_period_id'], |
91 | 91 | 'start_date' => $approvedstudent['start_date'], |
92 | - 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['start_date'])->year , // $approvedstudent['start_date']->format('Y'), |
|
92 | + 'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['start_date'])->year, // $approvedstudent['start_date']->format('Y'), |
|
93 | 93 | 'end_date' => $approvedstudent['end_date'], |
94 | - 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['end_date'])->year , //$approvedstudent['end_date']->format('Y'), |
|
94 | + 'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['end_date'])->year, //$approvedstudent['end_date']->format('Y'), |
|
95 | 95 | 'institution_id' => $approvedstudent['institution_id'], |
96 | 96 | 'admission_id' => $approvedstudent['admission_id'], |
97 | 97 | 'created_user_id' => $approvedstudent['created_user_id'], |
98 | 98 | ]); |
99 | - if(!is_null($approvedstudent['institution_class_id'])){ |
|
99 | + if (!is_null($approvedstudent['institution_class_id'])) { |
|
100 | 100 | Institution_class_student::create([ |
101 | 101 | 'student_id' => $approvedstudent['student_id'], |
102 | 102 | 'institution_class_id' => $approvedstudent['institution_class_id'], |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'created_user_id' => $approvedstudent['created_user_id'], |
108 | 108 | ]); |
109 | 109 | } |
110 | - }catch (\Exception $e){ |
|
110 | + }catch (\Exception $e) { |
|
111 | 111 | echo $e->getMessage(); |
112 | 112 | } |
113 | 113 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | array_walk($approvedstudent, array($this, 'addStudents')); |
65 | 65 | |
66 | - }catch (\Exception $e) { |
|
66 | + } catch (\Exception $e) { |
|
67 | 67 | Log::error($e); |
68 | 68 | } |
69 | 69 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'created_user_id' => $approvedstudent['created_user_id'], |
108 | 108 | ]); |
109 | 109 | } |
110 | - }catch (\Exception $e){ |
|
110 | + } catch (\Exception $e){ |
|
111 | 111 | echo $e->getMessage(); |
112 | 112 | } |
113 | 113 | } |