@@ -64,7 +64,7 @@ |
||
64 | 64 | |
65 | 65 | |
66 | 66 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
67 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
67 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
68 | 68 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
69 | 69 | } |
70 | 70 | } |
@@ -53,32 +53,32 @@ |
||
53 | 53 | $this->start_time = microtime(TRUE); |
54 | 54 | $year = $this->argument('year'); |
55 | 55 | $academicPeriod = $this->academic_period->getAcademicPeriod($year); |
56 | - if($year <= 2019) { |
|
56 | + if ($year <= 2019) { |
|
57 | 57 | $this->output->writeln('2019 or previous data not allowed to delete from this script'); |
58 | 58 | exit(); |
59 | 59 | } |
60 | - $shift = $this->shifts->getShiftsToDelete($year,$academicPeriod->id); |
|
61 | - array_walk($shift,array($this,'process')); |
|
60 | + $shift = $this->shifts->getShiftsToDelete($year, $academicPeriod->id); |
|
61 | + array_walk($shift, array($this, 'process')); |
|
62 | 62 | |
63 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
63 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
64 | 64 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
65 | 65 | |
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | - public function process($shift){ |
|
69 | + public function process($shift) { |
|
70 | 70 | |
71 | 71 | try { |
72 | - $institutionClasses = $this->institution_classes->select('id')->where('id',$shift['id']); |
|
73 | - $this->institution_classes->where('id',$shift['id'])->delete(); |
|
72 | + $institutionClasses = $this->institution_classes->select('id')->where('id', $shift['id']); |
|
73 | + $this->institution_classes->where('id', $shift['id'])->delete(); |
|
74 | 74 | |
75 | - $this->institution_class_subjects->whereIn('id',$institutionClasses)->delete(); |
|
75 | + $this->institution_class_subjects->whereIn('id', $institutionClasses)->delete(); |
|
76 | 76 | |
77 | - $this->shifts->where('id',$shift['id'])->delete(); |
|
77 | + $this->shifts->where('id', $shift['id'])->delete(); |
|
78 | 78 | |
79 | - $this->output->writeln('Deleted '. $shift['id'] . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
79 | + $this->output->writeln('Deleted '.$shift['id'].($this->end_time - $this->start_time).' seconds to complete'); |
|
80 | 80 | |
81 | - } catch (\Throwable $th) { |
|
81 | + }catch (\Throwable $th) { |
|
82 | 82 | dd($th); |
83 | 83 | } |
84 | 84 |
@@ -27,11 +27,11 @@ |
||
27 | 27 | */ |
28 | 28 | protected $description = 'Update the students count male/female'; |
29 | 29 | |
30 | - /** |
|
31 | - * Create a new command instance. |
|
32 | - * |
|
33 | - * @return void |
|
34 | - */ |
|
30 | + /** |
|
31 | + * Create a new command instance. |
|
32 | + * |
|
33 | + * @return void |
|
34 | + */ |
|
35 | 35 | public function __construct() |
36 | 36 | { |
37 | 37 | parent::__construct(); |
@@ -46,16 +46,16 @@ |
||
46 | 46 | public function handle() |
47 | 47 | { |
48 | 48 | $classes = Institution_class::get()->toArray(); |
49 | - $this->output->writeln('start updating:'. count($classes)); |
|
49 | + $this->output->writeln('start updating:'.count($classes)); |
|
50 | 50 | $this->output->writeln('#########################################'); |
51 | - array_walk($classes , array($this,'updateCount')); |
|
52 | - $this->output->writeln('start finish:'. count($classes)); |
|
51 | + array_walk($classes, array($this, 'updateCount')); |
|
52 | + $this->output->writeln('start finish:'.count($classes)); |
|
53 | 53 | $this->output->writeln('#########################################'); |
54 | 54 | } |
55 | 55 | |
56 | - public function updateCount($class){ |
|
57 | - $this->output->writeln('updating:'. $class['id']); |
|
58 | - $totalStudents = Institution_class_student::getStudentsCount($class['id']); |
|
56 | + public function updateCount($class) { |
|
57 | + $this->output->writeln('updating:'.$class['id']); |
|
58 | + $totalStudents = Institution_class_student::getStudentsCount($class['id']); |
|
59 | 59 | Institution_class::where('id', '=', $class['id']) |
60 | 60 | ->update([ |
61 | 61 | 'total_male_students' => $totalStudents['total_male_students'], |
@@ -137,9 +137,9 @@ |
||
137 | 137 | ->join('user_contacts', 'uploads.security_user_id', '=', 'user_contacts.security_user_id') |
138 | 138 | ->join('contact_types', 'user_contacts.contact_type_id', '=', 'contact_types.id') |
139 | 139 | //only for UAT |
140 | - ->where('contact_types.contact_option_id', '=', 5) |
|
140 | + ->where('contact_types.contact_option_id', '=', 5) |
|
141 | 141 | // ->where('contact_types.contact_option_id', '!=', 5) |
142 | - ->where('contact_types.name', '=', 'TestEmail') |
|
142 | + ->where('contact_types.name', '=', 'TestEmail') |
|
143 | 143 | ->limit(1) |
144 | 144 | ->get()->toArray(); |
145 | 145 | $node = $this->argument('node'); |
@@ -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 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $files[0]['node'] = $node; |
96 | 96 | $this->processSheet($files[0]); |
97 | 97 | $now = Carbon::now()->tz('Asia/Colombo'); |
98 | - $this->output->writeln('=============== Time taken to batch ' . $now->diffInMinutes($time)); |
|
98 | + $this->output->writeln('=============== Time taken to batch '.$now->diffInMinutes($time)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function getTerminatedFiles() |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | public function processSuccessEmail($file, $user, $subject) |
168 | 168 | { |
169 | 169 | $file['subject'] = $subject; |
170 | - $this->output->writeln('Processing the file: ' . $file['filename']); |
|
170 | + $this->output->writeln('Processing the file: '.$file['filename']); |
|
171 | 171 | try { |
172 | 172 | Mail::to($user->email)->send(new StudentImportSuccess($file)); |
173 | 173 | DB::table('uploads') |
174 | 174 | ->where('id', $file['id']) |
175 | 175 | ->update(['is_processed' => 1, 'is_email_sent' => 1, 'updated_at' => now()]); |
176 | - } catch (\Exception $ex) { |
|
176 | + }catch (\Exception $ex) { |
|
177 | 177 | $this->output->writeln($ex->getMessage()); |
178 | 178 | DB::table('uploads') |
179 | 179 | ->where('id', $file['id']) |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | DB::table('uploads') |
190 | 190 | ->where('id', $file['id']) |
191 | 191 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
192 | - } catch (\Exception $ex) { |
|
192 | + }catch (\Exception $ex) { |
|
193 | 193 | $this->output->writeln($ex->getMessage()); |
194 | 194 | DB::table('uploads') |
195 | 195 | ->where('id', $file['id']) |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | DB::table('uploads') |
206 | 206 | ->where('id', $file['id']) |
207 | 207 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
208 | - } catch (\Exception $ex) { |
|
208 | + }catch (\Exception $ex) { |
|
209 | 209 | $this->output->writeln($ex->getMessage()); |
210 | 210 | DB::table('uploads') |
211 | 211 | ->where('id', $file['id']) |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | $node = $this->argument('node'); |
219 | 219 | if ($node == $file['node']) { |
220 | 220 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
221 | - $this->output->writeln('Processing from:' . $node); |
|
221 | + $this->output->writeln('Processing from:'.$node); |
|
222 | 222 | return true; |
223 | - } else { |
|
223 | + }else { |
|
224 | 224 | exit; |
225 | 225 | return false; |
226 | 226 | } |
@@ -232,20 +232,20 @@ discard block |
||
232 | 232 | $user = User::find($file['security_user_id']); |
233 | 233 | $this->checkNode($file); |
234 | 234 | $this->output->writeln('##########################################################################################################################'); |
235 | - $this->output->writeln('Processing the file: ' . $file['filename']); |
|
235 | + $this->output->writeln('Processing the file: '.$file['filename']); |
|
236 | 236 | if ($this->checkTime()) { |
237 | 237 | try { |
238 | 238 | $this->import($file, 1, 'C'); |
239 | 239 | sleep(10); |
240 | 240 | $this->import($file, 2, 'B'); |
241 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
241 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
242 | 242 | $this->output->writeln($e->getMessage()); |
243 | 243 | try { |
244 | 244 | Mail::to($user->email)->send(new IncorrectTemplate($file)); |
245 | 245 | DB::table('uploads') |
246 | 246 | ->where('id', $file['id']) |
247 | 247 | ->update(['is_processed' => 2, 'is_email_sent' => 1, 'updated_at' => now()]); |
248 | - } catch (\Exception $ex) { |
|
248 | + }catch (\Exception $ex) { |
|
249 | 249 | $this->output->writeln($e->getMessage()); |
250 | 250 | $this->handle(); |
251 | 251 | DB::table('uploads') |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | ->update(['is_processed' => 2, 'is_email_sent' => 2, 'updated_at' => now()]); |
254 | 254 | } |
255 | 255 | } |
256 | - } else { |
|
256 | + }else { |
|
257 | 257 | exit(); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | 261 | protected function getType($file) |
262 | 262 | { |
263 | - $file = storage_path() . '/app/sis-bulk-data-files/' . $file; |
|
264 | - $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file); |
|
263 | + $file = storage_path().'/app/sis-bulk-data-files/'.$file; |
|
264 | + $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file); |
|
265 | 265 | return $inputFileType; |
266 | 266 | } |
267 | 267 | |
@@ -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->higestRow = $this->getHigestRow($file, $sheet, $column); |
327 | 327 | switch ($sheet) { |
328 | 328 | case 1; |
@@ -341,11 +341,11 @@ 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->higestRow); |
344 | - } else { |
|
344 | + }else { |
|
345 | 345 | $this->processSuccessEmail($file, $user, 'Fresh Student Data Upload:Success '); |
346 | 346 | $this->stdOut('Insert Students', $this->higestRow); |
347 | 347 | } |
348 | - } else if (($this->getSheetName($file, 'Insert Students')) && $this->higestRow > 0) { |
|
348 | + }else if (($this->getSheetName($file, 'Insert Students')) && $this->higestRow > 0) { |
|
349 | 349 | DB::table('uploads') |
350 | 350 | ->where('id', $file['id']) |
351 | 351 | ->update(['is_processed' => 2]); |
@@ -367,11 +367,11 @@ 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->higestRow); |
370 | - } else { |
|
370 | + }else { |
|
371 | 371 | $this->processSuccessEmail($file, $user, 'Existing Student Data Update:Success '); |
372 | 372 | $this->stdOut('Update Students', $this->higestRow); |
373 | 373 | } |
374 | - } else if (($this->getSheetName($file, 'Update Students')) && $this->higestRow == 0) { |
|
374 | + }else if (($this->getSheetName($file, 'Update Students')) && $this->higestRow == 0) { |
|
375 | 375 | DB::table('uploads') |
376 | 376 | ->where('id', $file['id']) |
377 | 377 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | } |
380 | 380 | break; |
381 | 381 | } |
382 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
382 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
383 | 383 | $this->output->writeln($e->getMessage()); |
384 | 384 | if ($sheet == 1) { |
385 | 385 | self::writeErrors($e, $file, 'Insert Students'); |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | ->where('id', $file['id']) |
388 | 388 | ->update(['insert' => 2, 'updated_at' => now()]); |
389 | 389 | $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Failed'); |
390 | - } else if ($sheet == 2) { |
|
390 | + }else if ($sheet == 2) { |
|
391 | 391 | self::writeErrors($e, $file, 'Update Students'); |
392 | 392 | DB::table('uploads') |
393 | 393 | ->where('id', $file['id']) |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $this->processFailedEmail($file, $user, 'Existing Student Data Update:Failed'); |
396 | 396 | } |
397 | 397 | DB::table('uploads') |
398 | - ->where('id', $file['id']) |
|
398 | + ->where('id', $file['id']) |
|
399 | 399 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
400 | 400 | } |
401 | 401 | } |
@@ -413,14 +413,14 @@ discard block |
||
413 | 413 | |
414 | 414 | protected function getFileSize($file) |
415 | 415 | { |
416 | - $excelFile = '/sis-bulk-data-files/' . $file['filename']; |
|
416 | + $excelFile = '/sis-bulk-data-files/'.$file['filename']; |
|
417 | 417 | $size = Storage::disk('local')->size($excelFile); |
418 | 418 | $user = User::find($file['security_user_id']); |
419 | 419 | if ($size > 0) { |
420 | 420 | return true; |
421 | - } else { |
|
421 | + }else { |
|
422 | 422 | DB::table('uploads') |
423 | - ->where('id', $file['id']) |
|
423 | + ->where('id', $file['id']) |
|
424 | 424 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
425 | 425 | $this->stdOut('No valid data found :Please re-upload the file', 0); |
426 | 426 | $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
@@ -430,21 +430,21 @@ discard block |
||
430 | 430 | protected function setReader($file) |
431 | 431 | { |
432 | 432 | try { |
433 | - $excelFile = '/sis-bulk-data-files/processed/' . $file['filename']; |
|
433 | + $excelFile = '/sis-bulk-data-files/processed/'.$file['filename']; |
|
434 | 434 | $exists = Storage::disk('local')->exists($excelFile); |
435 | 435 | if (!$exists) { |
436 | 436 | |
437 | - $excelFile = "/sis-bulk-data-files/" . $file['filename']; |
|
437 | + $excelFile = "/sis-bulk-data-files/".$file['filename']; |
|
438 | 438 | } |
439 | - $excelFile = storage_path() . "/app" . $excelFile; |
|
439 | + $excelFile = storage_path()."/app".$excelFile; |
|
440 | 440 | $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($this->getType($file['filename'])); |
441 | - $objPHPExcel = $reader->load($excelFile); |
|
441 | + $objPHPExcel = $reader->load($excelFile); |
|
442 | 442 | return $objPHPExcel; |
443 | - } catch (Exception $e) { |
|
443 | + }catch (Exception $e) { |
|
444 | 444 | $this->output->writeln($e->getMessage()); |
445 | 445 | $user = User::find($file['security_user_id']); |
446 | 446 | DB::table('uploads') |
447 | - ->where('id', $file['id']) |
|
447 | + ->where('id', $file['id']) |
|
448 | 448 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
449 | 449 | $this->stdOut('No valid data found :Please re-upload the file', 0); |
450 | 450 | $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | { |
456 | 456 | try {; |
457 | 457 | $objPHPExcel = $this->setReader($file); |
458 | - return $objPHPExcel->getSheetByName($sheet) !== null; |
|
459 | - } catch (Exception $e) { |
|
458 | + return $objPHPExcel->getSheetByName($sheet) !== null; |
|
459 | + }catch (Exception $e) { |
|
460 | 460 | $this->output->writeln($e->getMessage()); |
461 | 461 | $user = User::find($file['security_user_id']); |
462 | 462 | DB::table('uploads') |
463 | - ->where('id', $file['id']) |
|
463 | + ->where('id', $file['id']) |
|
464 | 464 | ->update(['is_processed' => 2, 'updated_at' => now()]); |
465 | 465 | $this->stdOut('No valid data found :Please re-upload the file', 0); |
466 | 466 | $this->processEmptyEmail($file, $user, 'No valid data found :Please re-upload the file'); |
@@ -473,17 +473,17 @@ discard block |
||
473 | 473 | $reader = $this->setReader($file); |
474 | 474 | $reader->setActiveSheetIndex($sheet); |
475 | 475 | $higestRow = 0; |
476 | - $highestRow = $reader->getActiveSheet()->getHighestRow($column); |
|
476 | + $highestRow = $reader->getActiveSheet()->getHighestRow($column); |
|
477 | 477 | for ($row = 3; $row <= $highestRow; $row++) { |
478 | - $rowData = $reader->getActiveSheet()->getCell($column . $row)->getValue(); |
|
478 | + $rowData = $reader->getActiveSheet()->getCell($column.$row)->getValue(); |
|
479 | 479 | if (empty($rowData) || $rowData == null) { |
480 | 480 | continue; |
481 | - } else { |
|
481 | + }else { |
|
482 | 482 | $higestRow += 1; |
483 | 483 | } |
484 | 484 | } |
485 | 485 | return $higestRow; |
486 | - } catch (\Exception $e) { |
|
486 | + }catch (\Exception $e) { |
|
487 | 487 | $this->output->writeln($e->getMessage()); |
488 | 488 | $user = User::find($file['security_user_id']); |
489 | 489 | DB::beginTransaction(); |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | |
499 | 499 | protected function stdOut($title, $rows) |
500 | 500 | { |
501 | - $this->output->writeln($title . ' Process completed at . ' . ' ' . now()); |
|
501 | + $this->output->writeln($title.' Process completed at . '.' '.now()); |
|
502 | 502 | $now = Carbon::now()->tz('Asia/Colombo'); |
503 | - $this->output->writeln('Total Processed lines: ' . $rows); |
|
504 | - $this->output->writeln('Time taken to process : ' . $now->diffInSeconds($this->startTime) . ' Seconds'); |
|
503 | + $this->output->writeln('Total Processed lines: '.$rows); |
|
504 | + $this->output->writeln('Time taken to process : '.$now->diffInSeconds($this->startTime).' Seconds'); |
|
505 | 505 | $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------'); |
506 | 506 | } |
507 | 507 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | $sheet = $reader->getActiveSheet(); |
514 | 514 | if (!in_array($row, $params['rows'])) { |
515 | 515 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
516 | - $this->output->writeln(' removing row . ' . ' ' . $row); |
|
516 | + $this->output->writeln(' removing row . '.' '.$row); |
|
517 | 517 | $reader->getActiveSheet()->getCellCollection()->removeRow($row); |
518 | 518 | } |
519 | 519 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | if (count($failures) > 0) { |
540 | 540 | $rows = array_map('rows', $failures); |
541 | 541 | $rows = array_unique($rows); |
542 | - $rowIndex = range(3, $this->higestRow + 2); |
|
542 | + $rowIndex = range(3, $this->higestRow + 2); |
|
543 | 543 | $params = [ |
544 | 544 | 'rows' => $rows, |
545 | 545 | 'reader' => $reader |
@@ -548,17 +548,17 @@ discard block |
||
548 | 548 | array_walk($rowIndex, array($this, 'removeRows'), $params); |
549 | 549 | $objWriter = $this->getSheetWriter($file, $reader); |
550 | 550 | Storage::disk('local')->makeDirectory('sis-bulk-data-files/processed'); |
551 | - $objWriter->save(storage_path() . '/app/sis-bulk-data-files/processed/' . $file['filename']); |
|
551 | + $objWriter->save(storage_path().'/app/sis-bulk-data-files/processed/'.$file['filename']); |
|
552 | 552 | $now = Carbon::now()->tz('Asia/Colombo'); |
553 | - $this->output->writeln($reader->getActiveSheet()->getTitle() . ' Process completed at . ' . ' ' . now()); |
|
554 | - $this->output->writeln('memory usage for the processes : ' . (memory_get_usage() - $baseMemory)); |
|
555 | - $this->output->writeln('Time taken to process : ' . $now->diffInSeconds($this->startTime) . ' Seconds'); |
|
556 | - $this->output->writeln(' errors reported : ' . count($failures)); |
|
553 | + $this->output->writeln($reader->getActiveSheet()->getTitle().' Process completed at . '.' '.now()); |
|
554 | + $this->output->writeln('memory usage for the processes : '.(memory_get_usage() - $baseMemory)); |
|
555 | + $this->output->writeln('Time taken to process : '.$now->diffInSeconds($this->startTime).' Seconds'); |
|
556 | + $this->output->writeln(' errors reported : '.count($failures)); |
|
557 | 557 | $this->output->writeln('--------------------------------------------------------------------------------------------------------------------------'); |
558 | 558 | unset($objWriter); |
559 | 559 | unset($failures); |
560 | 560 | } |
561 | - } catch (Eception $e) { |
|
561 | + }catch (Eception $e) { |
|
562 | 562 | $this->output->writeln($e->getMessage()); |
563 | 563 | $user = User::find($file['security_user_id']); |
564 | 564 | DB::beginTransaction(); |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function handle() |
41 | 41 | { |
42 | - $views = new DashboardViewsController(); |
|
43 | - $views->callback(); |
|
42 | + $views = new DashboardViewsController(); |
|
43 | + $views->callback(); |
|
44 | 44 | } |
45 | 45 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | { |
42 | 42 | $output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
43 | 43 | $output->writeln('###########################################------Inserting file records------###########################################'); |
44 | - $this->examinationController = new ExaminationStudentsController($this->argument('year'),$this->argument('grade')); |
|
44 | + $this->examinationController = new ExaminationStudentsController($this->argument('year'), $this->argument('grade')); |
|
45 | 45 | $this->examinationController->doMatch(); |
46 | 46 | $this->examinationController->export(); |
47 | 47 | $output->writeln('###########################################------Finished inserting file records------###########################################'); |
@@ -52,9 +52,9 @@ |
||
52 | 52 | 'academic_period' => $academicPeriod |
53 | 53 | ]; |
54 | 54 | |
55 | - if($year <= 2019){ |
|
55 | + if ($year <= 2019) { |
|
56 | 56 | die('Academic Year 2019 or earlier can`t be deleted'); |
57 | - }else{ |
|
57 | + }else { |
|
58 | 58 | $this->clone->cleanConfig($params); |
59 | 59 | } |
60 | 60 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | |
55 | 55 | if($year <= 2019){ |
56 | 56 | die('Academic Year 2019 or earlier can`t be deleted'); |
57 | - }else{ |
|
57 | + } else{ |
|
58 | 58 | $this->clone->cleanConfig($params); |
59 | 59 | } |
60 | 60 | } |
@@ -247,7 +247,7 @@ |
||
247 | 247 | // if the same gender same DOE has more than one |
248 | 248 | if (!is_null($sis_users) && (count($sis_users) > 1)) { |
249 | 249 | $studentData = $this->searchSimilarName($student, $sis_users); |
250 | - }else if (!is_null($sis_users) && (count($sis_users) == 1)){ |
|
250 | + } else if (!is_null($sis_users) && (count($sis_users) == 1)){ |
|
251 | 251 | $studentData = $sis_users[0]; |
252 | 252 | } |
253 | 253 | return $studentData; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->grade = $grade; |
29 | 29 | $this->student = new Security_user(); |
30 | 30 | $this->examination_student = new Examination_student(); |
31 | - $this->academic_period = Academic_period::where('code', '=', $this->year)->first(); |
|
31 | + $this->academic_period = Academic_period::where('code', '=', $this->year)->first(); |
|
32 | 32 | $this->education_grade = Education_grade::where('code', '=', $this->grade)->first(); |
33 | 33 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
34 | 34 | } |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | ); |
71 | 71 | Session::flash('message', 'File upload successfully!'); |
72 | 72 | // Redirect to index |
73 | - } else { |
|
73 | + }else { |
|
74 | 74 | Session::flash('message', 'File too large. File must be less than 20MB.'); |
75 | 75 | } |
76 | - } else { |
|
76 | + }else { |
|
77 | 77 | Session::flash('message', 'Invalid File Extension.'); |
78 | 78 | } |
79 | 79 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $import->import($excelFile, 'local', \Maatwebsite\Excel\Excel::CSV); |
96 | 96 | if ($import->failures()->count() > 0) { |
97 | 97 | $errors = $import->failures(); |
98 | - $columns = [ |
|
98 | + $columns = [ |
|
99 | 99 | 'remarks', |
100 | 100 | 'st_no', |
101 | 101 | 'stu_no', |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | Storage::put($file, implode(',', $columns)); |
117 | 117 | |
118 | 118 | foreach ($errors as $error) { |
119 | - Storage::append($file, implode(':', $error->errors()) . ',' . implode(',', $error->values())); |
|
119 | + Storage::append($file, implode(':', $error->errors()).','.implode(',', $error->values())); |
|
120 | 120 | } |
121 | 121 | } |
122 | - } catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
122 | + }catch (\Maatwebsite\Excel\Validators\ValidationException $e) { |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | //TODO implement insert student to admission table |
209 | 209 | $student['id'] = $sis_student['id']; |
210 | - $sis_student['student_id'] = $student['id']; |
|
210 | + $sis_student['student_id'] = $student['id']; |
|
211 | 211 | |
212 | 212 | $student = $this->setIsTakingExam($student); |
213 | 213 | if (count($institutionClass) == 1) { |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | Institution_student::createExaminationData($student, $admissionInfo); |
216 | 216 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
217 | 217 | Institution_class_student::createExaminationData($student, $admissionInfo); |
218 | - } else { |
|
218 | + }else { |
|
219 | 219 | Institution_student_admission::createExaminationData($student, $admissionInfo); |
220 | 220 | Institution_student::createExaminationData($student, $admissionInfo); |
221 | 221 | } |
222 | 222 | $this->updateStudentId($student, $sis_student); |
223 | 223 | // update the matched student's data |
224 | - } else { |
|
224 | + }else { |
|
225 | 225 | $student = $this->setIsTakingExam($student); |
226 | 226 | $studentData = $this->student->updateExaminationStudent($student, $matchedStudent); |
227 | 227 | $matchedStudent = array_merge((array) $student, $matchedStudent); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | // if the same gender same DOE has more than one |
249 | 249 | if (!is_null($sis_users) && (count($sis_users) > 1)) { |
250 | 250 | $studentData = $this->searchSimilarName($student, $sis_users); |
251 | - }else if (!is_null($sis_users) && (count($sis_users) == 1)){ |
|
251 | + }else if (!is_null($sis_users) && (count($sis_users) == 1)) { |
|
252 | 252 | $studentData = $sis_users[0]; |
253 | 253 | } |
254 | 254 | return $studentData; |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | public function updateStudentId($student, $sis_student) |
310 | 310 | { |
311 | 311 | try { |
312 | - $student['nsid'] = $sis_student['openemis_no']; |
|
312 | + $student['nsid'] = $sis_student['openemis_no']; |
|
313 | 313 | // add new NSID to the examinations data set |
314 | 314 | unset($student['id']); |
315 | 315 | unset($studentData['taking_g5_exam']); |
316 | 316 | unset($studentData['taking_al_exam']); |
317 | 317 | unset($studentData['taking_ol_exam']); |
318 | - $this->examination_student->where('st_no' , $student['st_no'])->update($student); |
|
319 | - $this->output->writeln('Updated ' . $sis_student['student_id'] . ' to NSID' . $sis_student['openemis_no']); |
|
320 | - } catch (\Exception $th) { |
|
318 | + $this->examination_student->where('st_no', $student['st_no'])->update($student); |
|
319 | + $this->output->writeln('Updated '.$sis_student['student_id'].' to NSID'.$sis_student['openemis_no']); |
|
320 | + }catch (\Exception $th) { |
|
321 | 321 | Log::error($th); |
322 | 322 | } |
323 | 323 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | try { |
334 | 334 | (new ExaminationStudentsExport)->store('examination/student_data_with_nsid.csv'); |
335 | 335 | (new ExportReady($adminUser)); |
336 | - } catch (\Throwable $th) { |
|
336 | + }catch (\Throwable $th) { |
|
337 | 337 | //throw $th; |
338 | 338 | dd($th); |
339 | 339 | } |
@@ -343,13 +343,13 @@ discard block |
||
343 | 343 | public function downloadErrors() |
344 | 344 | { |
345 | 345 | |
346 | - $file_path = storage_path() . '/app/examination/errors.csv'; |
|
346 | + $file_path = storage_path().'/app/examination/errors.csv'; |
|
347 | 347 | return Response::download($file_path); |
348 | 348 | } |
349 | 349 | |
350 | 350 | public function downloadProcessedFile() |
351 | 351 | { |
352 | - $file_path = storage_path() . '/app/examination/student_data_with_nsid.csv'; |
|
352 | + $file_path = storage_path().'/app/examination/student_data_with_nsid.csv'; |
|
353 | 353 | return Response::download($file_path); |
354 | 354 | } |
355 | 355 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $studentData['id'] = $id; |
182 | 182 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
183 | 183 | return $studentData; |
184 | - } catch (\Exception $th) { |
|
184 | + }catch (\Exception $th) { |
|
185 | 185 | Log::error($th->getMessage()); |
186 | 186 | // in case of duplication of the Unique ID this will recursive. |
187 | 187 | $this->insertExaminationStudent($student); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $this->uniqueUserId = new Unique_user_id(); |
202 | 202 | $this->uniqueUId = new UniqueUid(); |
203 | 203 | // regenerate unique id if it's not available |
204 | - $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'],9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
204 | + $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
205 | 205 | |
206 | 206 | $studentData = [ |
207 | 207 | 'username' => str_replace('-', '', $uniqueId), |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | ]; |
216 | 216 | |
217 | 217 | try { |
218 | - self::where( 'id' , $sis_student['student_id'])->update($studentData); |
|
218 | + self::where('id', $sis_student['student_id'])->update($studentData); |
|
219 | 219 | $studentData['id'] = $sis_student['student_id']; |
220 | 220 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
221 | 221 | return $studentData; |
222 | - } catch (\Exception $th) { |
|
222 | + }catch (\Exception $th) { |
|
223 | 223 | Log::error($th); |
224 | 224 | // in case of duplication of the Unique ID this will recursive. |
225 | 225 | $this->updateExaminationStudent($student, $sis_student); |