@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function __construct() |
49 | 49 | { |
50 | - $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
|
50 | + $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
|
51 | 51 | parent::__construct(); |
52 | 52 | } |
53 | 53 | |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | $this->process($files); |
70 | 70 | unset($files); |
71 | 71 | exit(); |
72 | - } else { |
|
72 | + }else { |
|
73 | 73 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
74 | 74 | $this->output->writeln('No files found,Waiting for files'); |
75 | 75 | exit(); |
76 | 76 | } |
77 | - } catch (Exception $e) { |
|
77 | + }catch (Exception $e) { |
|
78 | 78 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
79 | 79 | $this->output->writeln($e); |
80 | 80 | sleep(300); |
81 | 81 | $this->handle(); |
82 | 82 | } |
83 | - } else { |
|
83 | + }else { |
|
84 | 84 | exit(); |
85 | 85 | } |
86 | 86 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $files[0]['node'] = $node; |
95 | 95 | $this->processSheet($files[0]); |
96 | 96 | $now = Carbon::now()->tz('Asia/Colombo'); |
97 | - $this->output->writeln('=============== Time taken to batch ' . $now->diffInMinutes($time)); |
|
97 | + $this->output->writeln('=============== Time taken to batch '.$now->diffInMinutes($time)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | protected function getTerminatedFiles() |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | ->join('contact_types', 'user_contacts.contact_type_id', '=', 'contact_types.id') |
138 | 138 | |
139 | 139 | ; |
140 | - if(env('APP_ENV') == 'stage'){ |
|
140 | + if (env('APP_ENV') == 'stage') { |
|
141 | 141 | $query->where('contact_types.contact_option_id', '=', 5) |
142 | 142 | ->where('contact_types.name', '=', 'TestEmail'); |
143 | - }else{ |
|
143 | + }else { |
|
144 | 144 | $query->where('contact_types.contact_option_id', '!=', 5); |
145 | 145 | } |
146 | 146 | |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | public function processSuccessEmail($file, $user, $subject) |
171 | 171 | { |
172 | 172 | $file['subject'] = $subject; |
173 | - $this->output->writeln('Processing the file: ' . $file['filename']); |
|
173 | + $this->output->writeln('Processing the file: '.$file['filename']); |
|
174 | 174 | try { |
175 | 175 | Mail::to($user->email)->send(new StudentImportSuccess($file)); |
176 | 176 | DB::table('uploads') |
177 | 177 | ->where('id', $file['id']) |
178 | 178 | ->update(['is_processed' => 1, 'is_email_sent' => 1, 'updated_at' => now()]); |
179 | - } catch (\Exception $ex) { |
|
179 | + }catch (\Exception $ex) { |
|
180 | 180 | $this->output->writeln($ex->getMessage()); |
181 | 181 | DB::table('uploads') |
182 | 182 | ->where('id', $file['id']) |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | DB::table('uploads') |
193 | 193 | ->where('id', $file['id']) |
194 | 194 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
195 | - } catch (\Exception $ex) { |
|
195 | + }catch (\Exception $ex) { |
|
196 | 196 | $this->output->writeln($ex->getMessage()); |
197 | 197 | DB::table('uploads') |
198 | 198 | ->where('id', $file['id']) |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | DB::table('uploads') |
209 | 209 | ->where('id', $file['id']) |
210 | 210 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
211 | - } catch (\Exception $ex) { |
|
211 | + }catch (\Exception $ex) { |
|
212 | 212 | $this->output->writeln($ex->getMessage()); |
213 | 213 | DB::table('uploads') |
214 | 214 | ->where('id', $file['id']) |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | $node = $this->argument('node'); |
222 | 222 | if ($node == $file['node']) { |
223 | 223 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
224 | - $this->output->writeln('Processing from:' . $node); |
|
224 | + $this->output->writeln('Processing from:'.$node); |
|
225 | 225 | return true; |
226 | - } else { |
|
226 | + }else { |
|
227 | 227 | exit; |
228 | 228 | return false; |
229 | 229 | } |
@@ -235,20 +235,20 @@ discard block |
||
235 | 235 | $user = User::find($file['security_user_id']); |
236 | 236 | $this->checkNode($file); |
237 | 237 | $this->output->writeln('##########################################################################################################################'); |
238 | - $this->output->writeln('Processing the file: ' . $file['filename']); |
|
238 | + $this->output->writeln('Processing the file: '.$file['filename']); |
|
239 | 239 | if ($this->checkTime()) { |
240 | 240 | try { |
241 | 241 | $this->import($file, 1, 'C'); |
242 | 242 | sleep(10); |
243 | 243 | $this->import($file, 2, 'B'); |
244 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
244 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
245 | 245 | $this->output->writeln($e->getMessage()); |
246 | 246 | try { |
247 | 247 | Mail::to($user->email)->send(new IncorrectTemplate($file)); |
248 | 248 | DB::table('uploads') |
249 | 249 | ->where('id', $file['id']) |
250 | 250 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
251 | - } catch (\Exception $ex) { |
|
251 | + }catch (\Exception $ex) { |
|
252 | 252 | $this->output->writeln($e->getMessage()); |
253 | 253 | $this->handle(); |
254 | 254 | DB::table('uploads') |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | ->update(['is_processed' => 2, 'is_email_sent' => 2, 'updated_at' => now()]); |
257 | 257 | } |
258 | 258 | } |
259 | - } else { |
|
259 | + }else { |
|
260 | 260 | exit(); |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | 264 | protected function getType($file) |
265 | 265 | { |
266 | - $file = storage_path() . '/app/sis-bulk-data-files/' . $file; |
|
267 | - $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file); |
|
266 | + $file = storage_path().'/app/sis-bulk-data-files/'.$file; |
|
267 | + $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file); |
|
268 | 268 | return $inputFileType; |
269 | 269 | } |
270 | 270 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | ini_set('memory_limit', '2048M'); |
323 | 323 | $this->getFileSize($file); |
324 | 324 | $user = User::find($file['security_user_id']); |
325 | - $excelFile = '/sis-bulk-data-files/' . $file['filename']; |
|
325 | + $excelFile = '/sis-bulk-data-files/'.$file['filename']; |
|
326 | 326 | $this->highestRow = $this->getHighestRow($file, $sheet, $column); |
327 | 327 | switch ($sheet) { |
328 | 328 | case 1; |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | ->update(['insert' => 3, 'updated_at' => now()]); |
342 | 342 | $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Partial Success '); |
343 | 343 | $this->stdOut('Insert Students', $this->highestRow); |
344 | - } else { |
|
344 | + }else { |
|
345 | 345 | DB::table('uploads') |
346 | 346 | ->where('id', $file['id']) |
347 | 347 | ->update(['insert' => 1, 'updated_at' => now()]); |
348 | 348 | $this->processSuccessEmail($file, $user, 'Fresh Student Data Upload:Success '); |
349 | 349 | $this->stdOut('Insert Students', $this->highestRow); |
350 | 350 | } |
351 | - } else if (($this->getSheetName($file, 'Insert Students')) && $this->highestRow > 0) { |
|
351 | + }else if (($this->getSheetName($file, 'Insert Students')) && $this->highestRow > 0) { |
|
352 | 352 | DB::table('uploads') |
353 | 353 | ->where('id', $file['id']) |
354 | 354 | ->update(['is_processed' => 2]); |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | ->update(['update' => 3, 'is_processed' => 1, 'updated_at' => now()]); |
368 | 368 | $this->processFailedEmail($file, $user, 'Existing Student Data Update:Partial Success '); |
369 | 369 | $this->stdOut('Update Students', $this->highestRow); |
370 | - } else { |
|
370 | + }else { |
|
371 | 371 | DB::table('uploads') |
372 | 372 | ->where('id', $file['id']) |
373 | 373 | ->update(['update' => 1, 'is_processed' => 1, 'updated_at' => now()]); |
374 | 374 | $this->processSuccessEmail($file, $user, 'Existing Student Data Update:Success '); |
375 | 375 | $this->stdOut('Update Students', $this->highestRow); |
376 | 376 | } |
377 | - } else if (($this->getSheetName($file, 'Update Students')) && $this->highestRow == 0) { |
|
377 | + }else if (($this->getSheetName($file, 'Update Students')) && $this->highestRow == 0) { |
|
378 | 378 | DB::table('uploads') |
379 | 379 | ->where('id', $file['id']) |
380 | 380 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | } |
383 | 383 | break; |
384 | 384 | } |
385 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
385 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
386 | 386 | $this->output->writeln($e->getMessage()); |
387 | 387 | if ($sheet == 1) { |
388 | 388 | self::writeErrors($e, $file, 'Insert Students'); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | ->where('id', $file['id']) |
391 | 391 | ->update(['insert' => 2, 'updated_at' => now()]); |
392 | 392 | $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Failed'); |
393 | - } else if ($sheet == 2) { |
|
393 | + }else if ($sheet == 2) { |
|
394 | 394 | self::writeErrors($e, $file, 'Update Students'); |
395 | 395 | DB::table('uploads') |
396 | 396 | ->where('id', $file['id']) |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $this->processFailedEmail($file, $user, 'Existing Student Data Update:Failed'); |
399 | 399 | } |
400 | 400 | DB::table('uploads') |
401 | - ->where('id', $file['id']) |
|
401 | + ->where('id', $file['id']) |
|
402 | 402 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
403 | 403 | } |
404 | 404 | } |
@@ -416,14 +416,14 @@ discard block |
||
416 | 416 | |
417 | 417 | protected function getFileSize($file) |
418 | 418 | { |
419 | - $excelFile = '/sis-bulk-data-files/' . $file['filename']; |
|
419 | + $excelFile = '/sis-bulk-data-files/'.$file['filename']; |
|
420 | 420 | $size = Storage::disk('local')->size($excelFile); |
421 | 421 | $user = User::find($file['security_user_id']); |
422 | 422 | if ($size > 0) { |
423 | 423 | return true; |
424 | - } else { |
|
424 | + }else { |
|
425 | 425 | DB::table('uploads') |
426 | - ->where('id', $file['id']) |
|
426 | + ->where('id', $file['id']) |
|
427 | 427 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
428 | 428 | $this->stdOut('No valid data found :Please re-upload the file', 0); |
429 | 429 | $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
@@ -433,21 +433,21 @@ discard block |
||
433 | 433 | protected function setReader($file) |
434 | 434 | { |
435 | 435 | try { |
436 | - $excelFile = '/sis-bulk-data-files/processed/' . $file['filename']; |
|
436 | + $excelFile = '/sis-bulk-data-files/processed/'.$file['filename']; |
|
437 | 437 | $exists = Storage::disk('local')->exists($excelFile); |
438 | 438 | if (!$exists) { |
439 | 439 | |
440 | - $excelFile = "/sis-bulk-data-files/" . $file['filename']; |
|
440 | + $excelFile = "/sis-bulk-data-files/".$file['filename']; |
|
441 | 441 | } |
442 | - $excelFile = storage_path() . "/app" . $excelFile; |
|
442 | + $excelFile = storage_path()."/app".$excelFile; |
|
443 | 443 | $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($this->getType($file['filename'])); |
444 | - $objPHPExcel = $reader->load($excelFile); |
|
444 | + $objPHPExcel = $reader->load($excelFile); |
|
445 | 445 | return $objPHPExcel; |
446 | - } catch (Exception $e) { |
|
446 | + }catch (Exception $e) { |
|
447 | 447 | $this->output->writeln($e->getMessage()); |
448 | 448 | $user = User::find($file['security_user_id']); |
449 | 449 | DB::table('uploads') |
450 | - ->where('id', $file['id']) |
|
450 | + ->where('id', $file['id']) |
|
451 | 451 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
452 | 452 | $this->stdOut('No valid data found :Please re-upload the file', 0); |
453 | 453 | $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | { |
459 | 459 | try {; |
460 | 460 | $objPHPExcel = $this->setReader($file); |
461 | - return $objPHPExcel->getSheetByName($sheet) !== null; |
|
462 | - } catch (Exception $e) { |
|
461 | + return $objPHPExcel->getSheetByName($sheet) !== null; |
|
462 | + }catch (Exception $e) { |
|
463 | 463 | $this->output->writeln($e->getMessage()); |
464 | 464 | $user = User::find($file['security_user_id']); |
465 | 465 | DB::table('uploads') |
466 | - ->where('id', $file['id']) |
|
466 | + ->where('id', $file['id']) |
|
467 | 467 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
468 | 468 | $this->stdOut('No valid data found :Please re-upload the file', 0); |
469 | 469 | $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
@@ -476,9 +476,9 @@ discard block |
||
476 | 476 | $reader = $this->setReader($file); |
477 | 477 | $reader->setActiveSheetIndex($sheet); |
478 | 478 | $highestRow = 0; |
479 | - $highestRow = $reader->getActiveSheet()->getHighestRow($column); |
|
480 | - return $highestRow-1; |
|
481 | - } catch (\Exception $e) { |
|
479 | + $highestRow = $reader->getActiveSheet()->getHighestRow($column); |
|
480 | + return $highestRow - 1; |
|
481 | + }catch (\Exception $e) { |
|
482 | 482 | $this->output->writeln($e->getMessage()); |
483 | 483 | $user = User::find($file['security_user_id']); |
484 | 484 | DB::beginTransaction(); |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | |
494 | 494 | protected function stdOut($title, $rows) |
495 | 495 | { |
496 | - $this->output->writeln($title . ' Process completed at . ' . ' ' . now()); |
|
496 | + $this->output->writeln($title.' Process completed at . '.' '.now()); |
|
497 | 497 | $now = Carbon::now()->tz('Asia/Colombo'); |
498 | - $this->output->writeln('Total Processed lines: ' . $rows); |
|
499 | - $this->output->writeln('Time taken to process : ' . $now->diffInSeconds($this->startTime) . ' Seconds'); |
|
498 | + $this->output->writeln('Total Processed lines: '.$rows); |
|
499 | + $this->output->writeln('Time taken to process : '.$now->diffInSeconds($this->startTime).' Seconds'); |
|
500 | 500 | $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------'); |
501 | 501 | } |
502 | 502 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | $sheet = $reader->getActiveSheet(); |
509 | 509 | if (!in_array($row, $params['rows'])) { |
510 | 510 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
511 | - $this->output->writeln(' removing row . ' . ' ' . $row); |
|
511 | + $this->output->writeln(' removing row . '.' '.$row); |
|
512 | 512 | $reader->getActiveSheet()->getCellCollection()->removeRow($row); |
513 | 513 | } |
514 | 514 | } |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | if (count($failures) > 0) { |
532 | 532 | $rows = array_map('rows', $failures); |
533 | 533 | $rows = array_unique($rows); |
534 | - $rowIndex = range(3, $this->highestRow + 2); |
|
534 | + $rowIndex = range(3, $this->highestRow + 2); |
|
535 | 535 | $params = [ |
536 | 536 | 'rows' => $rows, |
537 | 537 | 'reader' => $reader |
@@ -540,17 +540,17 @@ discard block |
||
540 | 540 | array_walk($rowIndex, array($this, 'removeRows'), $params); |
541 | 541 | $objWriter = $this->getSheetWriter($file, $reader); |
542 | 542 | Storage::disk('local')->makeDirectory('sis-bulk-data-files/processed'); |
543 | - $objWriter->save(storage_path() . '/app/sis-bulk-data-files/processed/' . $file['filename']); |
|
543 | + $objWriter->save(storage_path().'/app/sis-bulk-data-files/processed/'.$file['filename']); |
|
544 | 544 | $now = Carbon::now()->tz('Asia/Colombo'); |
545 | - $this->output->writeln($reader->getActiveSheet()->getTitle() . ' Process completed at . ' . ' ' . now()); |
|
546 | - $this->output->writeln('memory usage for the processes : ' . (memory_get_usage() - $baseMemory)); |
|
547 | - $this->output->writeln('Time taken to process : ' . $now->diffInSeconds($this->startTime) . ' Seconds'); |
|
548 | - $this->output->writeln(' errors reported : ' . count($failures)); |
|
545 | + $this->output->writeln($reader->getActiveSheet()->getTitle().' Process completed at . '.' '.now()); |
|
546 | + $this->output->writeln('memory usage for the processes : '.(memory_get_usage() - $baseMemory)); |
|
547 | + $this->output->writeln('Time taken to process : '.$now->diffInSeconds($this->startTime).' Seconds'); |
|
548 | + $this->output->writeln(' errors reported : '.count($failures)); |
|
549 | 549 | $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------'); |
550 | 550 | unset($objWriter); |
551 | 551 | unset($failures); |
552 | 552 | } |
553 | - } catch (Eception $e) { |
|
553 | + }catch (Eception $e) { |
|
554 | 554 | $this->output->writeln($e->getMessage()); |
555 | 555 | $user = User::find($file['security_user_id']); |
556 | 556 | DB::beginTransaction(); |
@@ -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([]); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $row = $this->setGender($row); |
116 | 116 | $mandatorySubject = Institution_class_subject::getMandatorySubjects($this->file['institution_class_id']); |
117 | 117 | $subjects = getMatchingKeys($row); |
118 | - $student = Security_user::createOrUpdateStudentProfile($row,'create',$this->file); |
|
118 | + $student = Security_user::createOrUpdateStudentProfile($row, 'create', $this->file); |
|
119 | 119 | $academicPeriod = Academic_period::where('id', '=', $institutionClass->academic_period_id)->first(); |
120 | 120 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $institutionClass->id)->first(); |
121 | 121 | $assignee_id = $institutionClass->staff_id ? $institutionClass->staff_id : $this->file['security_user_id']; |
@@ -128,24 +128,24 @@ discard block |
||
128 | 128 | 'institution_class' => $institutionClass |
129 | 129 | ]; |
130 | 130 | |
131 | - Institution_student_admission::createAdmission($student->id,$row,$params,$this->file); |
|
132 | - Institution_student::createOrUpdate($student->id,$row,$params,$this->file); |
|
133 | - $student = Institution_class_student::createOrUpdate($student->id,$params,$this->file); |
|
134 | - User_special_need::createOrUpdate($student->student_id,$row,$this->file); |
|
135 | - User_body_mass::createOrUpdate($student->student_id,$row,$this->file); |
|
131 | + Institution_student_admission::createAdmission($student->id, $row, $params, $this->file); |
|
132 | + Institution_student::createOrUpdate($student->id, $row, $params, $this->file); |
|
133 | + $student = Institution_class_student::createOrUpdate($student->id, $params, $this->file); |
|
134 | + User_special_need::createOrUpdate($student->student_id, $row, $this->file); |
|
135 | + User_body_mass::createOrUpdate($student->student_id, $row, $this->file); |
|
136 | 136 | |
137 | - $this->createOrUpdateGuardian($row,$student,'father'); |
|
138 | - $this->createOrUpdateGuardian($row,$student,'mother'); |
|
139 | - $this->createOrUpdateGuardian($row,$student,'guardian'); |
|
137 | + $this->createOrUpdateGuardian($row, $student, 'father'); |
|
138 | + $this->createOrUpdateGuardian($row, $student, 'mother'); |
|
139 | + $this->createOrUpdateGuardian($row, $student, 'guardian'); |
|
140 | 140 | |
141 | 141 | Institution_student::updateStudentArea($student->toArray()); |
142 | 142 | |
143 | - $this->insertOrUpdateSubjects($row,$student,$institution); |
|
143 | + $this->insertOrUpdateSubjects($row, $student, $institution); |
|
144 | 144 | |
145 | 145 | $totalStudents = Institution_class_student::getStudentsCount($this->file['institution_class_id']); |
146 | 146 | if ($totalStudents['total'] > $institutionClass->no_of_students) { |
147 | 147 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
148 | - $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is ' . $institutionClass->no_of_students], [null]); |
|
148 | + $failure = new Failure(3, 'rows', [3 => 'Class student count exceeded! Max number of students is '.$institutionClass->no_of_students], [null]); |
|
149 | 149 | $failures = [0 => $failure]; |
150 | 150 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
151 | 151 | Log::info('email-sent', [$this->file]); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $institutionClass = new Institution_class(); |
155 | 155 | $institutionClass->updateClassCount($this->file); |
156 | 156 | } |
157 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
157 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
158 | 158 | $error = \Illuminate\Validation\ValidationException::withMessages([]); |
159 | 159 | $failures = $e->failures(); |
160 | 160 | throw new \Maatwebsite\Excel\Validators\ValidationException($error, $failures); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | '*.full_name' => 'required|regex:/^[a-zA-Z .]*$/u|max:256', |
170 | 170 | '*.preferred_name' => 'nullable|regex:/^[a-zA-Z .]*$/u|max:90', |
171 | 171 | '*.gender_mf' => 'required|in:M,F', |
172 | - '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:' . $this->file['institution_class_id'], |
|
172 | + '*.date_of_birth_yyyy_mm_dd' => 'date|required|admission_age:'.$this->file['institution_class_id'], |
|
173 | 173 | '*.address' => 'nullable', |
174 | 174 | '*.birth_registrar_office_as_in_birth_certificate' => 'nullable|exists:area_administratives,name|required_if:identity_type,BC|birth_place', |
175 | 175 | '*.birth_divisional_secretariat' => 'nullable|exists:area_administratives,name|required_with:birth_registrar_office_as_in_birth_certificate', |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | '*.identity_number' => 'nullable|identity:identity_type|required_with:*.identity_type', |
179 | 179 | '*.education_grade' => 'required', |
180 | 180 | '*.option_*' => 'nullable|exists:education_subjects,name', |
181 | - '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:' . $this->file['institution_class_id'], |
|
182 | - '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:' . $this->file['institution_class_id'], |
|
181 | + '*.bmi_height' => 'bail|required_with:*.bmi_weight|bmi:'.$this->file['institution_class_id'], |
|
182 | + '*.bmi_weight' => 'bail|required_with:*.bmi_height|bmi:'.$this->file['institution_class_id'], |
|
183 | 183 | '*.bmi_date_yyyy_mm_dd' => 'bail|required_with:*.bmi_height|date', //bmi:'. $this->file['institution_class_id'].' |
184 | 184 | '*.bmi_academic_period' => 'bail|required_with:*.bmi_height|exists:academic_periods,name', |
185 | 185 | '*.admission_no' => 'required|max:12|min:4|regex:/^[A-Za-z0-9\/]+$/', |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | if (empty($value)) { |
72 | 72 | return false; |
73 | 73 | } elseif ($gradeEntity !== null) { |
74 | - $admissionAge = (($gradeEntity->admission_age) * 12) - 1; |
|
74 | + $admissionAge = (($gradeEntity->admission_age)*12) - 1; |
|
75 | 75 | $to = $academicPeriod->start_date; |
76 | 76 | $diff_in_months = $to->diffInMonths($value); |
77 | 77 | $ageOfStudent = $diff_in_months; |
78 | 78 | $enrolmentMaximumAge = $admissionAge + 120; |
79 | 79 | return ($ageOfStudent <= $enrolmentMaximumAge) && ($ageOfStudent >= $admissionAge); |
80 | - } else { |
|
80 | + }else { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | - } else { |
|
84 | - $this->_custom_messages['admission_age'] = 'given' . $attribute . 'Not found'; |
|
83 | + }else { |
|
84 | + $this->_custom_messages['admission_age'] = 'given'.$attribute.'Not found'; |
|
85 | 85 | $this->_set_custom_stuff(); |
86 | 86 | return false; |
87 | 87 | } |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | |
93 | 93 | if (is_numeric($value)) { |
94 | 94 | if ($value < 10) { |
95 | - $this->_custom_messages['bmi'] = $attribute . ' is must greater than 10'; |
|
95 | + $this->_custom_messages['bmi'] = $attribute.' is must greater than 10'; |
|
96 | 96 | $this->_set_custom_stuff(); |
97 | 97 | return false; |
98 | 98 | } elseif ($value > 250) { |
99 | - $this->_custom_messages['bmi'] = $attribute . ' is must smaller than 250'; |
|
99 | + $this->_custom_messages['bmi'] = $attribute.' is must smaller than 250'; |
|
100 | 100 | $this->_set_custom_stuff(); |
101 | 101 | return false; |
102 | 102 | } |
103 | - } else { |
|
104 | - $this->_custom_messages['bmi'] = $attribute . ' is must a valid numeric'; |
|
103 | + }else { |
|
104 | + $this->_custom_messages['bmi'] = $attribute.' is must a valid numeric'; |
|
105 | 105 | $this->_set_custom_stuff(); |
106 | 106 | return false; |
107 | 107 | } |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | |
111 | 111 | protected function validateBmi($attribute, $value, $parameters) |
112 | 112 | { |
113 | - $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
113 | + $bmiGrades = ['G1', 'G4', 'G7', 'G10']; |
|
114 | 114 | $institutionGrade = Institution_class_grade::where('institution_class_id', '=', $parameters[0]) |
115 | 115 | ->join('education_grades', 'institution_class_grades.education_grade_id', 'education_grades.id') |
116 | 116 | ->first(); |
117 | - $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
117 | + $educationGrade = Education_grade::where('id', '=', $institutionGrade->education_grade_id)->first(); |
|
118 | 118 | if (in_array($institutionGrade->code, $bmiGrades)) { |
119 | 119 | if (!empty($value)) { |
120 | 120 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
121 | 121 | return $this->validateHW($attribute, $value); |
122 | 122 | } |
123 | - } else { |
|
124 | - $this->_custom_messages['bmi'] = $attribute . ' is required for ' . $educationGrade->name; |
|
123 | + }else { |
|
124 | + $this->_custom_messages['bmi'] = $attribute.' is required for '.$educationGrade->name; |
|
125 | 125 | $this->_set_custom_stuff(); |
126 | 126 | return false; |
127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | if (($attribute == 'bmi_height') || ('bmi_weight')) { |
130 | 130 | return $this->validateHW($attribute, $value); |
131 | 131 | } |
132 | - } else { |
|
132 | + }else { |
|
133 | 133 | return true; |
134 | 134 | } |
135 | 135 | } |
@@ -138,19 +138,19 @@ discard block |
||
138 | 138 | { |
139 | 139 | foreach ($validator->getData() as $data) { |
140 | 140 | if ($data['identity_type'] == 'BC' && key_exists('birth_divisional_secretariat', $data)) { |
141 | - $BirthDivision = Area_administrative::where('name', '=', '%' . $data['birth_divisional_secretariat'] . '%')->where('area_administrative_level_id', '=', 5); // |
|
141 | + $BirthDivision = Area_administrative::where('name', '=', '%'.$data['birth_divisional_secretariat'].'%')->where('area_administrative_level_id', '=', 5); // |
|
142 | 142 | if ($BirthDivision->count() > 0) { |
143 | - $BirthArea = Area_administrative::where('name', '=', '%' . $value . '%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
143 | + $BirthArea = Area_administrative::where('name', '=', '%'.$value.'%') //$data['birth_registrar_office_as_in_birth_certificate'] |
|
144 | 144 | ->where('parent_id', '=', $BirthDivision->first()->id)->count(); |
145 | - return $BirthArea > 0; |
|
145 | + return $BirthArea > 0; |
|
146 | 146 | } elseif (key_exists('birth_divisional_secretariat', $data) && (!key_exists('birth_registrar_office_as_in_birth_certificate', $data))) { |
147 | 147 | $this->_custom_messages['birth_place'] = 'birth_registrar_office_as_in_birth_certificate required with BC'; |
148 | 148 | $this->_set_custom_stuff(); |
149 | 149 | return false; |
150 | - } else { |
|
150 | + }else { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | - } else { |
|
153 | + }else { |
|
154 | 154 | return true; |
155 | 155 | } |
156 | 156 | } |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | |
159 | 159 | protected function validateIsStudentInClass($attribute, $value, $perameters, $validator) |
160 | 160 | { |
161 | - $student = Security_user::where('openemis_no', '=', $value); |
|
161 | + $student = Security_user::where('openemis_no', '=', $value); |
|
162 | 162 | if ($student->count() > 0) { |
163 | 163 | $student = $student->first()->toArray(); |
164 | - $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
164 | + $check = Institution_class_student::where('student_id', '=', $student['id'])->where('institution_class_id', '=', $perameters[0])->count(); |
|
165 | 165 | if ($check == 1) { |
166 | 166 | return true; |
167 | - } else { |
|
167 | + }else { |
|
168 | 168 | return false; |
169 | 169 | } |
170 | - } else { |
|
170 | + }else { |
|
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | { |
179 | 179 | $valid = true; |
180 | 180 | foreach ($validator->getData() as $data) { |
181 | - switch($data[$perameters[0]]){ |
|
181 | + switch ($data[$perameters[0]]) { |
|
182 | 182 | case 'BC': |
183 | 183 | $valid = preg_match('/^([0-9]{3,5})$/i', $value); |
184 | 184 | break; |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | if (!$valid) { |
194 | - $this->_custom_messages['nic'] = $attribute . ' is not valid, Please check the NIC number'; |
|
194 | + $this->_custom_messages['nic'] = $attribute.' is not valid, Please check the NIC number'; |
|
195 | 195 | $this->_set_custom_stuff(); |
196 | 196 | return false; |
197 | - } else { |
|
197 | + }else { |
|
198 | 198 | return true; |
199 | 199 | } |
200 | 200 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | protected function validateUserUnique($attribute, $value, $perameters, $validator) |
203 | 203 | { |
204 | 204 | foreach ($validator->getData() as $data) { |
205 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
205 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
206 | 206 | if ($identityType !== null && ($value !== null)) { |
207 | 207 | if ($identityType->national_code === 'BC') { |
208 | 208 | return $this->checkUnique($value, $data, $identityType); |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | protected function validateIsBc($attribute, $value, $perameters, $validator) |
219 | 219 | { |
220 | 220 | foreach ($validator->getData() as $data) { |
221 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
221 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
222 | 222 | if (($identityType !== null) && ($identityType !== "")) { |
223 | 223 | if (($identityType->national_code) === 'BC') { |
224 | 224 | return (strlen((string) $data['identity_number']) < 7); |
225 | - } else { |
|
225 | + }else { |
|
226 | 226 | return true; |
227 | 227 | } |
228 | - } else { |
|
228 | + }else { |
|
229 | 229 | return true; |
230 | 230 | } |
231 | 231 | } |
@@ -235,24 +235,24 @@ discard block |
||
235 | 235 | { |
236 | 236 | $isUnique = Security_user::where('identity_number', '=', $value)->where('identity_type_id', '=', $identityType->id); |
237 | 237 | if ($isUnique->count() > 0) { |
238 | - $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : ' . $isUnique->first()->openemis_no; |
|
238 | + $this->_custom_messages['user_unique'] = 'The identity number already in use. User ID is : '.$isUnique->first()->openemis_no; |
|
239 | 239 | $this->_set_custom_stuff(); |
240 | 240 | return false; |
241 | - } else { |
|
241 | + }else { |
|
242 | 242 | return true; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | 246 | protected function IsBc($data, $value) |
247 | 247 | { |
248 | - $identityType = Identity_type::where('national_code', 'like', '%' . $data['identity_type'] . '%')->first(); |
|
248 | + $identityType = Identity_type::where('national_code', 'like', '%'.$data['identity_type'].'%')->first(); |
|
249 | 249 | if ($identityType !== null) { |
250 | 250 | if (($identityType->national_code) === 'BC' && strlen((string) $value) < 8) { |
251 | 251 | return false; |
252 | - } else { |
|
252 | + }else { |
|
253 | 253 | return true; |
254 | 254 | } |
255 | - } else { |
|
255 | + }else { |
|
256 | 256 | return true; |
257 | 257 | } |
258 | 258 | } |