50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class RemettreLesPtnDeCodesDansLordre extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'app:remettre-les-ptn-de-codes-dans-lordre';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$this->info("Début de traitement");
|
|
|
|
$tempFilePath = \storage_path('export_codes_uniques/tmp/Demande1.csv');
|
|
$NewTempFilePath = \storage_path('export_codes_uniques/tmp/Demande1OK.csv');
|
|
$i = 1;
|
|
if (($handle = fopen($tempFilePath, "r")) !== false) {
|
|
while (($data = fgetcsv($handle, null, ";")) !== false) {
|
|
if ($i === 8) {
|
|
File::append($NewTempFilePath, $data[0] . "\n");
|
|
$i = 1;
|
|
} else {
|
|
File::append($NewTempFilePath, $data[0] . ';');
|
|
$i++;
|
|
}
|
|
}
|
|
fclose($handle);
|
|
}
|
|
$this->info("Fin de traitement");
|
|
}
|
|
}
|