This commit is contained in:
parent
b0f7f04ba6
commit
b992fd42ba
@ -17,7 +17,7 @@ steps:
|
|||||||
- chmod +x /usr/local/bin/phpcs
|
- chmod +x /usr/local/bin/phpcs
|
||||||
- chmod +x /usr/local/bin/phpcbf
|
- chmod +x /usr/local/bin/phpcbf
|
||||||
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
- phpcs -n --standard=PSR2 .
|
- phpcs -d memory_limit=512M --extensions=php --standard=PSR2 ./src/
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: php:8.1
|
image: php:8.1
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"symfony/console": "6.1.*",
|
"symfony/console": "6.1.*",
|
||||||
"symfony/dotenv": "6.1.*",
|
"symfony/dotenv": "6.1.*",
|
||||||
"symfony/expression-language": "6.1.*",
|
"symfony/expression-language": "6.1.*",
|
||||||
|
"symfony/filesystem": "6.1.*",
|
||||||
"symfony/flex": "^2",
|
"symfony/flex": "^2",
|
||||||
"symfony/form": "6.1.*",
|
"symfony/form": "6.1.*",
|
||||||
"symfony/framework-bundle": "6.1.*",
|
"symfony/framework-bundle": "6.1.*",
|
||||||
|
461
composer.lock
generated
461
composer.lock
generated
File diff suppressed because it is too large
Load Diff
1
hiltes/c2h/WU040801.0001
Normal file
1
hiltes/c2h/WU040801.0001
Normal file
@ -0,0 +1 @@
|
|||||||
|
Test
|
20661
hiltes/h2c/WS000001.0000
Normal file
20661
hiltes/h2c/WS000001.0000
Normal file
File diff suppressed because it is too large
Load Diff
52
src/Command/HiltesExportCommand.php
Normal file
52
src/Command/HiltesExportCommand.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use App\Repository\OrdersRepository;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
use App\Helper\Hiltes;
|
||||||
|
|
||||||
|
#[AsCommand(
|
||||||
|
name: 'hiltes:export',
|
||||||
|
description: 'Erstellt die Hiltes-Exportdatei aus den aktuellen Bestelldaten',
|
||||||
|
)]
|
||||||
|
class HiltesExportCommand extends Command
|
||||||
|
{
|
||||||
|
public function __construct(OrdersRepository $ordersRepository, LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
$this->ordersRepository = $ordersRepository;
|
||||||
|
$this->logger = $logger;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function configure(): void
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
|
||||||
|
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
$hiltes = new Hiltes();
|
||||||
|
|
||||||
|
$hiltes->export('Test');
|
||||||
|
|
||||||
|
|
||||||
|
$io->success('Done!');
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
44
src/Command/HiltesImportCommand.php
Normal file
44
src/Command/HiltesImportCommand.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
|
#[AsCommand(
|
||||||
|
name: 'hiltes:import',
|
||||||
|
description: 'Add a short description for your command',
|
||||||
|
)]
|
||||||
|
class HiltesImportCommand extends Command
|
||||||
|
{
|
||||||
|
protected function configure(): void
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
|
||||||
|
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
$arg1 = $input->getArgument('arg1');
|
||||||
|
|
||||||
|
if ($arg1) {
|
||||||
|
$io->note(sprintf('You passed an argument: %s', $arg1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input->getOption('option1')) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
@ -27,7 +27,7 @@ use Vin\ShopwareSdk\Factory\RepositoryFactory;
|
|||||||
|
|
||||||
#[AsCommand(
|
#[AsCommand(
|
||||||
name: 'sw:get-orders',
|
name: 'sw:get-orders',
|
||||||
description: 'Holt alle offenen Bestellungen von SW ab',
|
description: 'Holt alle offenen Bestellungen von Shopware ab',
|
||||||
)]
|
)]
|
||||||
class SwGetOrdersCommand extends Command
|
class SwGetOrdersCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -8,9 +8,10 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use ApiPlatform\Core\Annotation\ApiResource;
|
use ApiPlatform\Core\Annotation\ApiResource;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: OrdersRepository::class)]
|
#[ORM\Entity(repositoryClass: OrdersRepository::class)]
|
||||||
|
#[ORM\HasLifecycleCallbacks]
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
itemOperations: ["GET"],
|
|
||||||
description: "Manage orders",
|
description: "Manage orders",
|
||||||
|
itemOperations: ["GET"],
|
||||||
normalizationContext: ["groups" => "read"]
|
normalizationContext: ["groups" => "read"]
|
||||||
)]
|
)]
|
||||||
class Orders
|
class Orders
|
||||||
@ -48,7 +49,6 @@ class Orders
|
|||||||
public function setOrderId(string $order_id): self
|
public function setOrderId(string $order_id): self
|
||||||
{
|
{
|
||||||
$this->order_id = $order_id;
|
$this->order_id = $order_id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,6 @@ class Orders
|
|||||||
public function setStatus(int $status): self
|
public function setStatus(int $status): self
|
||||||
{
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,10 +68,11 @@ class Orders
|
|||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[ORM\PrePersist]
|
||||||
public function setData(array $data): self
|
public function setData(array $data): self
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,6 @@ class Warehouse
|
|||||||
public function setPriority(int $priority): self
|
public function setPriority(int $priority): self
|
||||||
{
|
{
|
||||||
$this->priority = $priority;
|
$this->priority = $priority;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,12 @@ class OrdersRepository extends ServiceEntityRepository
|
|||||||
parent::__construct($registry, Orders::class);
|
parent::__construct($registry, Orders::class);
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Orders $entity
|
||||||
|
* @param bool $flush
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function add(Orders $entity, bool $flush = false): void
|
public function add(Orders $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -39,6 +45,11 @@ class OrdersRepository extends ServiceEntityRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Orders $entity
|
||||||
|
* @param bool $flush
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function update(Orders $entity, bool $flush = false): void
|
public function update(Orders $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
$order = $this->getEntityManager()->find(Orders::class, $entity->getId());
|
$order = $this->getEntityManager()->find(Orders::class, $entity->getId());
|
||||||
@ -48,6 +59,11 @@ class OrdersRepository extends ServiceEntityRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Orders $entity
|
||||||
|
* @param bool $flush
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function remove(Orders $entity, bool $flush = false): void
|
public function remove(Orders $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
$this->getEntityManager()->remove($entity);
|
$this->getEntityManager()->remove($entity);
|
||||||
|
Loading…
Reference in New Issue
Block a user