This commit is contained in:
62
src/Helper/Hiltes.php
Normal file
62
src/Helper/Hiltes.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helper;
|
||||
|
||||
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
class Hiltes
|
||||
{
|
||||
// init file system
|
||||
protected $fsObject;
|
||||
protected $current_dir_path;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fsObject = new Filesystem();
|
||||
$this->current_dir_path = getcwd();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Aufbau des Dateinamens:
|
||||
* WU + Datum(TTMM) + Fortlaufendenummer (x2) + “.“ +Filialnummer(x4)
|
||||
* Beispieldateiname : WU220401.0001
|
||||
*/
|
||||
public function createFileName() :String
|
||||
{
|
||||
$date = date('dm');
|
||||
$number = '01';
|
||||
$filial = '0001';
|
||||
return 'WU'.$date.$number.'.'.$filial;
|
||||
}
|
||||
|
||||
|
||||
public function import()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function export(string $data)
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$new_file_path = $this->current_dir_path . "/hiltes/c2h/".$this->createFileName();
|
||||
|
||||
if (!$this->fsObject->exists($new_file_path))
|
||||
{
|
||||
$this->fsObject->touch($new_file_path);
|
||||
$this->fsObject->chmod($new_file_path, 0777);
|
||||
$this->fsObject->dumpFile($new_file_path, $data);
|
||||
}
|
||||
} catch (IOExceptionInterface $exception) {
|
||||
echo "Error creating file at". $exception->getPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user