wip
This commit is contained in:
1 parent
db051d6e32
commit
c8cf1edaf4
3 files changed
+83
-76
No files matched your search
@@ -20,31 +20,30 @@ class SetStorage
|
||||
// must be connectet to task for activated ligas
|
||||
$task = SofaScoreTask::where('id', $task_id)->first();
|
||||
|
||||
$sofascore_data = storage_path('sofascore_data').'/';
|
||||
$sofascore_data = storage_path('sofascore_data') . '/';
|
||||
if ($task) {
|
||||
$storage_name = Strings::clean($task->name);
|
||||
|
||||
switch ($task->id) {
|
||||
case 1:
|
||||
Grap::$storage = $sofascore_data.$storage_name;
|
||||
Grap::$storage = $sofascore_data . $storage_name;
|
||||
Grap::$folder = Carbon::now()->subDays($day)->format('Y-m-d');
|
||||
break;
|
||||
case 2:
|
||||
Grap::$storage = $sofascore_data.$storage_name.'/'.$task->day_from;
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'/'.$task->day_from.'.zip';
|
||||
Grap::$storage = $sofascore_data . $storage_name . '/' . $task->day_from;
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '/' . $task->day_from . '.zip';
|
||||
break;
|
||||
case 3:
|
||||
Grap::$storage = $sofascore_data.$storage_name.'-'.$task->day_from.'-'.$task->day_to;
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'-'.$task->day_from.'-'.$task->day_to.'.zip';
|
||||
Grap::$storage = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to;
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to . '.zip';
|
||||
break;
|
||||
case 4:
|
||||
Grap::$storage = $sofascore_data.$storage_name.'/rosa-'.Carbon::now()->format('Y-m-d');
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'/rosa-'.Carbon::now()->format('Y-m-d').'.zip';
|
||||
Grap::$storage = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d');
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
|
||||
break;
|
||||
|
||||
default:
|
||||
Grap::$storage = $sofascore_data.$storage_name;
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'/archive.zip';
|
||||
case 5:
|
||||
Grap::$storage = $sofascore_data;
|
||||
Grap::$folder = $folder;
|
||||
break;
|
||||
}
|
||||
} elseif ($folder) {
|
||||
@@ -53,7 +52,7 @@ class SetStorage
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Task: $task->name\n".'Storage: '.Grap::$storage."\nFolder: ".Grap::$folder);
|
||||
Notice::note("Task: $task->name\n" . 'Storage: ' . Grap::$storage . "\nFolder: " . Grap::$folder);
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ class MakeExcel
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Make Excel folder to import: '.Grap::$folder."\nmaximum files in excel: ".self::$max, 'b');
|
||||
Notice::note('Make Excel folder to import: ' . Grap::$folder . "\nmaximum files in excel: " . self::$max, 'b');
|
||||
}
|
||||
|
||||
$files = ReadDir::get_tree(Grap::$storage.'/'.Grap::$folder);
|
||||
$files = ReadDir::get_tree(Grap::$storage . '/' . Grap::$folder);
|
||||
|
||||
$files = array_chunk(FileType::filter($files), self::$max);
|
||||
|
||||
@@ -49,7 +49,7 @@ class MakeExcel
|
||||
$to = $key * self::$max + $has;
|
||||
}
|
||||
|
||||
$filename = Grap::$folder.'-'.$from.'-'.$to.'.xlsx';
|
||||
$filename = Grap::$folder . '-' . $from . '-' . $to . '.xlsx';
|
||||
$spreadsheet = new Spreadsheet;
|
||||
$spreadsheet->getProperties()->setTitle($filename);
|
||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||
@@ -62,18 +62,20 @@ class MakeExcel
|
||||
|
||||
$arr = explode(PHP_EOL, $json_string);
|
||||
$row = 0;
|
||||
foreach ($arr as $val) {
|
||||
foreach ($arr as $string) {
|
||||
$row++;
|
||||
$activeWorksheet->setCellValue([$column, $row], $val);
|
||||
$replacedString = preg_replace("/\\\\u([0-9abcdef]{4})/", "&#x$1;", $string);
|
||||
$utf8string = mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');
|
||||
$activeWorksheet->setCellValue([$column, $row], $utf8string);
|
||||
}
|
||||
$column++;
|
||||
}
|
||||
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save(Grap::$storage.'/'.$filename);
|
||||
$writer->save(Grap::$storage . '/' . $filename);
|
||||
|
||||
self::$filesToMail[] = Grap::$storage.'/'.$filename;
|
||||
self::$filesToMail[] = Grap::$storage . '/' . $filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user