@@ -20,7 +20,7 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | public function __construct($user) |
| 22 | 22 | { |
| 23 | - $this->user = $user; |
|
| 23 | + $this->user = $user; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -41,10 +41,10 @@ |
||
| 41 | 41 | { |
| 42 | 42 | $year = $this->argument('year'); |
| 43 | 43 | $institutions = $this->instituion_grade->getInstitutionGradeList($year); |
| 44 | - array_walk($institutions,array($this,'callPromotion'),$year); |
|
| 44 | + array_walk($institutions, array($this, 'callPromotion'), $year); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - protected function callPromotion($institution,$count,$year){ |
|
| 48 | - $this->call('promote:students',['year' => $year,'institution' => $institution['code']]); |
|
| 47 | + protected function callPromotion($institution, $count, $year) { |
|
| 48 | + $this->call('promote:students', ['year' => $year, 'institution' => $institution['code']]); |
|
| 49 | 49 | } |
| 50 | 50 | } |
@@ -43,29 +43,29 @@ |
||
| 43 | 43 | $this->start_time = microtime(TRUE); |
| 44 | 44 | $this->output = new \Symfony\Component\Console\Output\ConsoleOutput(); |
| 45 | 45 | $this->output->writeln('############### Starting delete Duplication ################'); |
| 46 | - $studentsIdsWithDuplication = DB::table('institution_students as ins') |
|
| 47 | - ->select(DB::raw('count(*) as total'),'student_id','id','academic_period_id','education_grade_id') |
|
| 48 | - ->having('total','>',1) |
|
| 46 | + $studentsIdsWithDuplication = DB::table('institution_students as ins') |
|
| 47 | + ->select(DB::raw('count(*) as total'), 'student_id', 'id', 'academic_period_id', 'education_grade_id') |
|
| 48 | + ->having('total', '>', 1) |
|
| 49 | 49 | ->groupBy('ins.student_id') |
| 50 | 50 | ->orderBy('ins.student_id') |
| 51 | - ->chunk(100,function($Students){ |
|
| 51 | + ->chunk(100, function($Students) { |
|
| 52 | 52 | foreach ($Students as $Student) { |
| 53 | - Institution_student::where('institution_students.id','>',$Student->id) |
|
| 54 | - ->where('institution_students.student_id',$Student->student_id) |
|
| 55 | - ->where('institution_students.academic_period_id',$Student->academic_period_id) |
|
| 56 | - ->where('institution_students.education_grade_id',$Student->education_grade_id) |
|
| 53 | + Institution_student::where('institution_students.id', '>', $Student->id) |
|
| 54 | + ->where('institution_students.student_id', $Student->student_id) |
|
| 55 | + ->where('institution_students.academic_period_id', $Student->academic_period_id) |
|
| 56 | + ->where('institution_students.education_grade_id', $Student->education_grade_id) |
|
| 57 | 57 | ->delete(); |
| 58 | 58 | } |
| 59 | 59 | $this->end_time = microtime(TRUE); |
| 60 | - $this->output->writeln('Deleted 100 starting with' .$Students[0]->id); |
|
| 61 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
| 60 | + $this->output->writeln('Deleted 100 starting with'.$Students[0]->id); |
|
| 61 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
| 62 | 62 | }); |
| 63 | 63 | $this->end_time = microtime(TRUE); |
| 64 | 64 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
| 65 | - $this->output->writeln('The cook took ' . ($this->end_time - $this->start_time) . ' seconds to complete'); |
|
| 65 | + $this->output->writeln('The cook took '.($this->end_time - $this->start_time).' seconds to complete'); |
|
| 66 | 66 | $this->output->writeln('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'); |
| 67 | 67 | |
| 68 | - } catch (\Throwable $th) { |
|
| 68 | + }catch (\Throwable $th) { |
|
| 69 | 69 | dd($th); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | { |
| 62 | 62 | $year = $this->argument('year'); |
| 63 | 63 | $institution = $this->argument('institution'); |
| 64 | - $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($year,$institution); |
|
| 65 | - (new BulkPromotion())->callback($institutionGrade,$year); |
|
| 64 | + $institutionGrade = $this->instituion_grade->getInstitutionGradeToPromoted($year, $institution); |
|
| 65 | + (new BulkPromotion())->callback($institutionGrade, $year); |
|
| 66 | 66 | } |
| 67 | 67 | } |
@@ -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(); |
@@ -48,36 +48,36 @@ discard block |
||
| 48 | 48 | public function handle() |
| 49 | 49 | { |
| 50 | 50 | $this->output->writeln('#########################################'); |
| 51 | - if($this->argument('entity') == 'class'){ |
|
| 51 | + if ($this->argument('entity') == 'class') { |
|
| 52 | 52 | $classes = Institution_class::get()->toArray(); |
| 53 | - $func = array($this,'updateCount'); |
|
| 54 | - array_walk($subjects,array($this,'process')); |
|
| 55 | - $this->output->writeln('start updating:'. count($classes)); |
|
| 56 | - }elseif($this->argument('entity') == 'subject'){ |
|
| 53 | + $func = array($this, 'updateCount'); |
|
| 54 | + array_walk($subjects, array($this, 'process')); |
|
| 55 | + $this->output->writeln('start updating:'.count($classes)); |
|
| 56 | + }elseif ($this->argument('entity') == 'subject') { |
|
| 57 | 57 | $subjects = Institution_subject::get()->toArray(); |
| 58 | - $subjects = array_chunk($subjects,10000); |
|
| 59 | - $this->output->writeln('start updating:'. count($subjects)); |
|
| 60 | - array_walk($subjects,array($this,'process')); |
|
| 58 | + $subjects = array_chunk($subjects, 10000); |
|
| 59 | + $this->output->writeln('start updating:'.count($subjects)); |
|
| 60 | + array_walk($subjects, array($this, 'process')); |
|
| 61 | 61 | $this->output->writeln('#########################################'); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function process($data){ |
|
| 67 | - if($this->argument('entity') == 'class'){ |
|
| 68 | - $func = array($this,'updateCount'); |
|
| 69 | - processParallel($func,$data,$this->argument('max')); |
|
| 70 | - $this->output->writeln('start updating calss count:'. count($data)); |
|
| 71 | - }elseif($this->argument('entity') == 'subject'){ |
|
| 72 | - $this->output->writeln('start updating subject count:'. count($data)); |
|
| 73 | - $func_subject = array($this,'updateSubjectCount'); |
|
| 74 | - processParallel($func_subject,$data,$this->argument('max')); |
|
| 66 | + public function process($data) { |
|
| 67 | + if ($this->argument('entity') == 'class') { |
|
| 68 | + $func = array($this, 'updateCount'); |
|
| 69 | + processParallel($func, $data, $this->argument('max')); |
|
| 70 | + $this->output->writeln('start updating calss count:'.count($data)); |
|
| 71 | + }elseif ($this->argument('entity') == 'subject') { |
|
| 72 | + $this->output->writeln('start updating subject count:'.count($data)); |
|
| 73 | + $func_subject = array($this, 'updateSubjectCount'); |
|
| 74 | + processParallel($func_subject, $data, $this->argument('max')); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function updateCount($class){ |
|
| 79 | - $this->output->writeln('updating class:'. $class['id']); |
|
| 80 | - $totalStudents = Institution_class_student::getStudentsCount($class['id']); |
|
| 78 | + public function updateCount($class) { |
|
| 79 | + $this->output->writeln('updating class:'.$class['id']); |
|
| 80 | + $totalStudents = Institution_class_student::getStudentsCount($class['id']); |
|
| 81 | 81 | Institution_class::where('id', '=', $class['id']) |
| 82 | 82 | ->update([ |
| 83 | 83 | 'total_male_students' => $totalStudents['total_male_students'], |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | ]); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function updateSubjectCount($subject){ |
|
| 89 | - $this->output->writeln('updating subject:'. $subject['id']); |
|
| 88 | + public function updateSubjectCount($subject) { |
|
| 89 | + $this->output->writeln('updating subject:'.$subject['id']); |
|
| 90 | 90 | $totalStudents = Institution_subject_student::getStudentsCount($subject['id']); |
| 91 | 91 | Institution_subject::where(['id' => $subject['id']]) |
| 92 | 92 | ->update([ |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $func = array($this,'updateCount'); |
| 54 | 54 | array_walk($subjects,array($this,'process')); |
| 55 | 55 | $this->output->writeln('start updating:'. count($classes)); |
| 56 | - }elseif($this->argument('entity') == 'subject'){ |
|
| 56 | + } elseif($this->argument('entity') == 'subject'){ |
|
| 57 | 57 | $subjects = Institution_subject::get()->toArray(); |
| 58 | 58 | $subjects = array_chunk($subjects,10000); |
| 59 | 59 | $this->output->writeln('start updating:'. count($subjects)); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $func = array($this,'updateCount'); |
| 69 | 69 | processParallel($func,$data,$this->argument('max')); |
| 70 | 70 | $this->output->writeln('start updating calss count:'. count($data)); |
| 71 | - }elseif($this->argument('entity') == 'subject'){ |
|
| 71 | + } elseif($this->argument('entity') == 'subject'){ |
|
| 72 | 72 | $this->output->writeln('start updating subject count:'. count($data)); |
| 73 | 73 | $func_subject = array($this,'updateSubjectCount'); |
| 74 | 74 | processParallel($func_subject,$data,$this->argument('max')); |
@@ -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(); |
@@ -138,7 +138,7 @@ |
||
| 138 | 138 | ->join('contact_types', 'user_contacts.contact_type_id', '=', 'contact_types.id') |
| 139 | 139 | //only for UAT |
| 140 | 140 | // ->where('contact_types.contact_option_id', '=', 5) |
| 141 | - ->where('contact_types.contact_option_id', '!=', 5) |
|
| 141 | + ->where('contact_types.contact_option_id', '!=', 5) |
|
| 142 | 142 | // ->where('contact_types.name', '=', 'TestEmail') |
| 143 | 143 | ->limit(1) |
| 144 | 144 | ->get()->toArray(); |
@@ -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 | } |
@@ -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 | } |
@@ -152,12 +152,12 @@ |
||
| 152 | 152 | ->get()->toArray(); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * First level search for students |
|
| 157 | - * |
|
| 158 | - * @param array $student |
|
| 159 | - * @return array |
|
| 160 | - */ |
|
| 155 | + /** |
|
| 156 | + * First level search for students |
|
| 157 | + * |
|
| 158 | + * @param array $student |
|
| 159 | + * @return array |
|
| 160 | + */ |
|
| 161 | 161 | public function getStudentCount($student) |
| 162 | 162 | { |
| 163 | 163 | return $this |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | public function getMatches($student) |
| 150 | 150 | { |
| 151 | 151 | return $this |
| 152 | - ->where('gender_id',$student['gender'] + 1) |
|
| 153 | - ->where('institutions.code',$student['schoolid']) |
|
| 154 | - ->where('date_of_birth',$student['b_date']) |
|
| 152 | + ->where('gender_id', $student['gender'] + 1) |
|
| 153 | + ->where('institutions.code', $student['schoolid']) |
|
| 154 | + ->where('date_of_birth', $student['b_date']) |
|
| 155 | 155 | ->join('institution_students', 'security_users.id', 'institution_students.student_id') |
| 156 | 156 | ->join('institutions', 'institution_students.institution_id', 'institutions.id') |
| 157 | 157 | ->get()->toArray(); |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | public function getStudentCount($student) |
| 167 | 167 | { |
| 168 | 168 | return $this |
| 169 | - ->where('gender_id',$student['gender'] + 1) |
|
| 170 | - ->where('institutions.code',$student['schoolid']) |
|
| 171 | - ->where('date_of_birth',$student['b_date']) |
|
| 169 | + ->where('gender_id', $student['gender'] + 1) |
|
| 170 | + ->where('institutions.code', $student['schoolid']) |
|
| 171 | + ->where('date_of_birth', $student['b_date']) |
|
| 172 | 172 | ->join('institution_students', 'security_users.id', 'institution_students.student_id') |
| 173 | 173 | ->join('institutions', 'institution_students.institution_id', 'institutions.id') |
| 174 | 174 | ->count(); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $studentData['id'] = $id; |
| 203 | 203 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
| 204 | 204 | return $studentData; |
| 205 | - } catch (\Exception $th) { |
|
| 205 | + }catch (\Exception $th) { |
|
| 206 | 206 | Log::error($th->getMessage()); |
| 207 | 207 | // in case of duplication of the Unique ID this will recursive. |
| 208 | 208 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $this->uniqueUserId = new Unique_user_id(); |
| 224 | 224 | $this->uniqueUId = new UniqueUid(); |
| 225 | 225 | // regenerate unique id if it's not available |
| 226 | - $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'],9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
| 226 | + $uniqueId = ($this->uniqueUId::isValidUniqueId($sis_student['openemis_no'], 9)) ? $sis_student['openemis_no'] : $this->uniqueUId::getUniqueAlphanumeric(); |
|
| 227 | 227 | |
| 228 | 228 | $studentData = [ |
| 229 | 229 | 'username' => str_replace('-', '', $uniqueId), |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | ]; |
| 238 | 238 | |
| 239 | 239 | try { |
| 240 | - self::where( 'id' , $sis_student['student_id'])->update($studentData); |
|
| 240 | + self::where('id', $sis_student['student_id'])->update($studentData); |
|
| 241 | 241 | $studentData['id'] = $sis_student['student_id']; |
| 242 | 242 | $this->uniqueUserId->updateOrInsertRecord($studentData); |
| 243 | 243 | return $studentData; |
| 244 | - } catch (\Exception $th) { |
|
| 244 | + }catch (\Exception $th) { |
|
| 245 | 245 | Log::error($th); |
| 246 | 246 | // in case of duplication of the Unique ID this will recursive. |
| 247 | 247 | $sis_student['openemis_no'] = $this->uniqueUId::getUniqueAlphanumeric(); |