@@ -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 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | ini_set('memory_limit', '2048M'); |
320 | 320 | $this->getFileSize($file); |
321 | 321 | $user = User::find($file['security_user_id']); |
322 | - $excelFile = '/sis-bulk-data-files/' . $file['filename']; |
|
322 | + $excelFile = '/sis-bulk-data-files/'.$file['filename']; |
|
323 | 323 | $this->higestRow = $this->getHigestRow($file, $sheet, $column); |
324 | 324 | switch ($sheet) { |
325 | 325 | case 1; |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | ->update(['insert' => 3, 'updated_at' => now()]); |
339 | 339 | $this->processFailedEmail($file, $user, 'Fresh Student Data Upload:Partial Success '); |
340 | 340 | $this->stdOut('Insert Students', $this->higestRow); |
341 | - } else { |
|
341 | + }else { |
|
342 | 342 | DB::table('uploads') |
343 | 343 | ->where('id', $file['id']) |
344 | 344 | ->update(['insert' => 1, 'updated_at' => now()]); |
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]); |
@@ -364,14 +364,14 @@ discard block |
||
364 | 364 | ->update(['update' => 3, 'is_processed' => 1, 'updated_at' => now()]); |
365 | 365 | $this->processFailedEmail($file, $user, 'Existing Student Data Update:Partial Success '); |
366 | 366 | $this->stdOut('Update Students', $this->higestRow); |
367 | - } else { |
|
367 | + }else { |
|
368 | 368 | DB::table('uploads') |
369 | 369 | ->where('id', $file['id']) |
370 | 370 | ->update(['update' => 1, 'is_processed' => 1, 'updated_at' => now()]); |
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(); |
@@ -13,101 +13,101 @@ |
||
13 | 13 | |
14 | 14 | public function index() |
15 | 15 | { |
16 | - return Datatables::of(Upload::with(['classRoom'])->where('security_user_id','=',Auth::user()->id)) |
|
17 | - ->editColumn('is_processed', function ($data) { |
|
16 | + return Datatables::of(Upload::with(['classRoom'])->where('security_user_id', '=', Auth::user()->id)) |
|
17 | + ->editColumn('is_processed', function($data) { |
|
18 | 18 | |
19 | 19 | $nowTime = \Carbon\Carbon::now(); |
20 | 20 | $to = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $nowTime); |
21 | 21 | $from = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $data->updated_at); |
22 | 22 | $diff_in_hours = $to->diffInHours($from); |
23 | 23 | |
24 | - if($diff_in_hours >= 2 && $data->is_processed == 3){ |
|
24 | + if ($diff_in_hours >= 2 && $data->is_processed == 3) { |
|
25 | 25 | return "Terminated"; |
26 | 26 | } |
27 | 27 | elseif ($data->is_processed === 1) { |
28 | 28 | return "Success"; |
29 | - }elseif ($data->is_processed === 2){ |
|
29 | + }elseif ($data->is_processed === 2) { |
|
30 | 30 | return "Failed"; |
31 | - }elseif($diff_in_hours < 2 && $data->is_processed == 3){ |
|
31 | + }elseif ($diff_in_hours < 2 && $data->is_processed == 3) { |
|
32 | 32 | return "Processing"; |
33 | - }elseif ($data->is_processed == 4){ |
|
33 | + }elseif ($data->is_processed == 4) { |
|
34 | 34 | return "Process Paused"; |
35 | - }else{ |
|
35 | + }else { |
|
36 | 36 | return 'Pending'; |
37 | 37 | }; |
38 | 38 | |
39 | 39 | }) |
40 | - ->editColumn('is_email_sent', function ($data) { |
|
40 | + ->editColumn('is_email_sent', function($data) { |
|
41 | 41 | if ($data->is_email_sent == 1) { |
42 | 42 | return "Success"; |
43 | - }elseif($data->is_email_sent == 2 ){ |
|
43 | + }elseif ($data->is_email_sent == 2) { |
|
44 | 44 | return 'Failed'; |
45 | - }else{ |
|
45 | + }else { |
|
46 | 46 | return 'Pending'; |
47 | 47 | }; |
48 | 48 | |
49 | 49 | }) |
50 | - ->editColumn('update', function ($data) { |
|
51 | - if ((int)$data->update == 0) { |
|
50 | + ->editColumn('update', function($data) { |
|
51 | + if ((int) $data->update == 0) { |
|
52 | 52 | return "No Processes"; |
53 | - }elseif((int)$data->update == 1 ){ |
|
53 | + }elseif ((int) $data->update == 1) { |
|
54 | 54 | return 'Success'; |
55 | - }elseif((int)$data->update == 2 ){ |
|
55 | + }elseif ((int) $data->update == 2) { |
|
56 | 56 | return 'Failed'; |
57 | - }elseif((int)$data->update == 3 ){ |
|
57 | + }elseif ((int) $data->update == 3) { |
|
58 | 58 | return 'Partial Success'; |
59 | 59 | }; |
60 | 60 | |
61 | 61 | }) |
62 | - ->editColumn('insert', function ($data) { |
|
62 | + ->editColumn('insert', function($data) { |
|
63 | 63 | if ($data->insert == 0) { |
64 | 64 | return "No Processes"; |
65 | - }elseif($data->insert == 1 ){ |
|
65 | + }elseif ($data->insert == 1) { |
|
66 | 66 | return 'Success'; |
67 | - }elseif($data->insert == 2 ){ |
|
67 | + }elseif ($data->insert == 2) { |
|
68 | 68 | return 'Failed'; |
69 | - }elseif($data->insert == 3 ){ |
|
69 | + }elseif ($data->insert == 3) { |
|
70 | 70 | return 'Partial Success'; |
71 | 71 | }; |
72 | 72 | |
73 | 73 | }) |
74 | - ->editColumn('filename', function ($data) { |
|
75 | - if(\App::environment('local') || \App::environment('stage')){ |
|
74 | + ->editColumn('filename', function($data) { |
|
75 | + if (\App::environment('local') || \App::environment('stage')) { |
|
76 | 76 | return '<a href="/download_file/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
77 | 77 | |
78 | - }else{ |
|
78 | + }else { |
|
79 | 79 | return '<a href="/bulk-upload/download_file/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
80 | 80 | } |
81 | 81 | |
82 | 82 | }) |
83 | - ->editColumn('error', function ($data) { |
|
84 | - if(\App::environment('local') || \App::environment('stage')){ |
|
83 | + ->editColumn('error', function($data) { |
|
84 | + if (\App::environment('local') || \App::environment('stage')) { |
|
85 | 85 | return '<a href="/download/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
86 | 86 | |
87 | - }else{ |
|
87 | + }else { |
|
88 | 88 | return '<a href="/bulk-upload/download/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
89 | 89 | } |
90 | 90 | |
91 | - })->editColumn('actions', function ($data) { |
|
91 | + })->editColumn('actions', function($data) { |
|
92 | 92 | |
93 | 93 | $nowTime = \Carbon\Carbon::now(); |
94 | 94 | $to = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $nowTime); |
95 | 95 | $from = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', $data->updated_at); |
96 | 96 | $diff_in_hours = $to->diffInHours($from); |
97 | 97 | |
98 | - if($diff_in_hours >= 2 && $data->is_processed == 3){ |
|
98 | + if ($diff_in_hours >= 2 && $data->is_processed == 3) { |
|
99 | 99 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-primary text-uppercase">reprocess</button>'; |
100 | - }elseif ($data->is_processed == 1){ |
|
100 | + }elseif ($data->is_processed == 1) { |
|
101 | 101 | return '<div><h6>Processing <span class="badge badge-success text-uppercase">Successful</span></h6></div>'; |
102 | - }elseif ($data->is_processed == 2){ |
|
102 | + }elseif ($data->is_processed == 2) { |
|
103 | 103 | return '<div><h6>Processing <span class="badge badge-danger text-uppercase">Failed</span></h6></div>'; |
104 | - }elseif ($data->is_processed == 0){ |
|
104 | + }elseif ($data->is_processed == 0) { |
|
105 | 105 | return '<button onclick="updateProcess('.($data->id).',200)" class="btn btn-block btn-warning text-uppercase">pause</button>'; |
106 | - }elseif ($data->is_processed == 4){ |
|
106 | + }elseif ($data->is_processed == 4) { |
|
107 | 107 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-block btn-success text-uppercase">resume</button>'; |
108 | 108 | } |
109 | 109 | }) |
110 | - ->rawColumns(['filename','error','actions']) |
|
110 | + ->rawColumns(['filename', 'error', 'actions']) |
|
111 | 111 | ->make(true); |
112 | 112 | } |
113 | 113 |
@@ -23,16 +23,15 @@ discard block |
||
23 | 23 | |
24 | 24 | if($diff_in_hours >= 2 && $data->is_processed == 3){ |
25 | 25 | return "Terminated"; |
26 | - } |
|
27 | - elseif ($data->is_processed === 1) { |
|
26 | + } elseif ($data->is_processed === 1) { |
|
28 | 27 | return "Success"; |
29 | - }elseif ($data->is_processed === 2){ |
|
28 | + } elseif ($data->is_processed === 2){ |
|
30 | 29 | return "Failed"; |
31 | - }elseif($diff_in_hours < 2 && $data->is_processed == 3){ |
|
30 | + } elseif($diff_in_hours < 2 && $data->is_processed == 3){ |
|
32 | 31 | return "Processing"; |
33 | - }elseif ($data->is_processed == 4){ |
|
32 | + } elseif ($data->is_processed == 4){ |
|
34 | 33 | return "Process Paused"; |
35 | - }else{ |
|
34 | + } else{ |
|
36 | 35 | return 'Pending'; |
37 | 36 | }; |
38 | 37 | |
@@ -40,9 +39,9 @@ discard block |
||
40 | 39 | ->editColumn('is_email_sent', function ($data) { |
41 | 40 | if ($data->is_email_sent == 1) { |
42 | 41 | return "Success"; |
43 | - }elseif($data->is_email_sent == 2 ){ |
|
42 | + } elseif($data->is_email_sent == 2 ){ |
|
44 | 43 | return 'Failed'; |
45 | - }else{ |
|
44 | + } else{ |
|
46 | 45 | return 'Pending'; |
47 | 46 | }; |
48 | 47 | |
@@ -50,11 +49,11 @@ discard block |
||
50 | 49 | ->editColumn('update', function ($data) { |
51 | 50 | if ((int)$data->update == 0) { |
52 | 51 | return "No Processes"; |
53 | - }elseif((int)$data->update == 1 ){ |
|
52 | + } elseif((int)$data->update == 1 ){ |
|
54 | 53 | return 'Success'; |
55 | - }elseif((int)$data->update == 2 ){ |
|
54 | + } elseif((int)$data->update == 2 ){ |
|
56 | 55 | return 'Failed'; |
57 | - }elseif((int)$data->update == 3 ){ |
|
56 | + } elseif((int)$data->update == 3 ){ |
|
58 | 57 | return 'Partial Success'; |
59 | 58 | }; |
60 | 59 | |
@@ -62,11 +61,11 @@ discard block |
||
62 | 61 | ->editColumn('insert', function ($data) { |
63 | 62 | if ($data->insert == 0) { |
64 | 63 | return "No Processes"; |
65 | - }elseif($data->insert == 1 ){ |
|
64 | + } elseif($data->insert == 1 ){ |
|
66 | 65 | return 'Success'; |
67 | - }elseif($data->insert == 2 ){ |
|
66 | + } elseif($data->insert == 2 ){ |
|
68 | 67 | return 'Failed'; |
69 | - }elseif($data->insert == 3 ){ |
|
68 | + } elseif($data->insert == 3 ){ |
|
70 | 69 | return 'Partial Success'; |
71 | 70 | }; |
72 | 71 | |
@@ -75,7 +74,7 @@ discard block |
||
75 | 74 | if(\App::environment('local') || \App::environment('stage')){ |
76 | 75 | return '<a href="/download_file/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
77 | 76 | |
78 | - }else{ |
|
77 | + } else{ |
|
79 | 78 | return '<a href="/bulk-upload/download_file/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
80 | 79 | } |
81 | 80 | |
@@ -84,7 +83,7 @@ discard block |
||
84 | 83 | if(\App::environment('local') || \App::environment('stage')){ |
85 | 84 | return '<a href="/download/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
86 | 85 | |
87 | - }else{ |
|
86 | + } else{ |
|
88 | 87 | return '<a href="/bulk-upload/download/'.$data->filename.'">'.$data->classRoom->name.'</a>'; |
89 | 88 | } |
90 | 89 | |
@@ -97,13 +96,13 @@ discard block |
||
97 | 96 | |
98 | 97 | if($diff_in_hours >= 2 && $data->is_processed == 3){ |
99 | 98 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-primary text-uppercase">reprocess</button>'; |
100 | - }elseif ($data->is_processed == 1){ |
|
99 | + } elseif ($data->is_processed == 1){ |
|
101 | 100 | return '<div><h6>Processing <span class="badge badge-success text-uppercase">Successful</span></h6></div>'; |
102 | - }elseif ($data->is_processed == 2){ |
|
101 | + } elseif ($data->is_processed == 2){ |
|
103 | 102 | return '<div><h6>Processing <span class="badge badge-danger text-uppercase">Failed</span></h6></div>'; |
104 | - }elseif ($data->is_processed == 0){ |
|
103 | + } elseif ($data->is_processed == 0){ |
|
105 | 104 | return '<button onclick="updateProcess('.($data->id).',200)" class="btn btn-block btn-warning text-uppercase">pause</button>'; |
106 | - }elseif ($data->is_processed == 4){ |
|
105 | + } elseif ($data->is_processed == 4){ |
|
107 | 106 | return '<button onclick="updateProcess('.($data->id).',100)" class="btn btn-block btn-success text-uppercase">resume</button>'; |
108 | 107 | } |
109 | 108 | }) |