add authentication
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Marko 2023-11-10 16:54:07 +01:00
parent 9c2e2b6ade
commit 8554cf714d
No known key found for this signature in database
28 changed files with 699 additions and 774 deletions

View File

@ -1,6 +1,7 @@
kind: pipeline
name: default
load: [docker, composer]
steps:
- name: install
image: composer
@ -17,7 +18,9 @@ steps:
- chmod +x /usr/local/bin/phpcs
- chmod +x /usr/local/bin/phpcbf
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- phpcs -d memory_limit=512M --extensions=php --standard=PSR2 ./src/
- phpcbf -w ./src/
- name: test
image: php:8.1

View File

@ -8,13 +8,13 @@
<jdbc-url>jdbc:mysql://127.0.0.1:3306</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="DDEV" uuid="460f8880-31b0-4942-b249-e8c664c61f08">
<data-source source="LOCAL" name="DDEV" uuid="5149739e-7c31-440b-a2ab-9c77c78be0cd">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<configured-by-url>true</configured-by-url>
<remarks>DDEV generated data source</remarks>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://127.0.0.1:51773/db?user=db&amp;password=db</jdbc-url>
<jdbc-url>jdbc:mariadb://127.0.0.1:55034/db?user=db&amp;password=db</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>

458
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -22,9 +22,6 @@ services:
App\EventSubscriber\SlackNotifySubscriber:
arguments:
$slackWebhookUrl: '%env(SLACK_DSN)%'
# App\Helper\Hiltes:
# arguments:
# $orderRepository: '@App\Repository\OrderRepository'
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231110153931 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `order` CHANGE data data JSON NOT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('CREATE UNIQUE INDEX UNIQ_F52993988D9F6D38 ON `order` (order_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_F52993988D9F6D38 ON `order`');
$this->addSql('ALTER TABLE `order` CHANGE data data JSON NOT NULL COMMENT \'(DC2Type:json)\'');
}
}

View File

@ -2,9 +2,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-cyrillic-ext-400-normal.woff2) format('woff2'), url(./files/open-sans-cyrillic-ext-400-normal.woff) format('woff');
src: url(./files/open-sans-cyrillic-ext-400-normal.woff2) format('woff2');
unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
@ -12,9 +12,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-cyrillic-400-normal.woff2) format('woff2'), url(./files/open-sans-cyrillic-400-normal.woff) format('woff');
src: url(./files/open-sans-cyrillic-400-normal.woff2) format('woff2');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@ -22,9 +22,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-greek-ext-400-normal.woff2) format('woff2'), url(./files/open-sans-greek-ext-400-normal.woff) format('woff');
src: url(./files/open-sans-greek-ext-400-normal.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
@ -32,9 +32,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-greek-400-normal.woff2) format('woff2'), url(./files/open-sans-greek-400-normal.woff) format('woff');
src: url(./files/open-sans-greek-400-normal.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
@ -42,9 +42,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-hebrew-400-normal.woff2) format('woff2'), url(./files/open-sans-hebrew-400-normal.woff) format('woff');
src: url(./files/open-sans-hebrew-400-normal.woff2) format('woff2');
unicode-range: U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@ -52,9 +52,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-vietnamese-400-normal.woff2) format('woff2'), url(./files/open-sans-vietnamese-400-normal.woff) format('woff');
src: url(./files/open-sans-vietnamese-400-normal.woff2) format('woff2');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@ -62,18 +62,18 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-latin-ext-400-normal.woff2) format('woff2'), url(./files/open-sans-latin-ext-400-normal.woff) format('woff');
unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
src: url(./files/open-sans-latin-ext-400-normal.woff2) format('woff2');
unicode-range: U+0100-02AF,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
/* open-sans-latin-400-normal */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 400;
src: url(./files/open-sans-latin-400-normal.woff2) format('woff2'), url(./files/open-sans-latin-400-normal.woff) format('woff');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
src: url(./files/open-sans-latin-400-normal.woff2) format('woff2');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

View File

@ -2,9 +2,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-cyrillic-ext-700-normal.woff2) format('woff2'), url(./files/open-sans-cyrillic-ext-700-normal.woff) format('woff');
src: url(./files/open-sans-cyrillic-ext-700-normal.woff2) format('woff2');
unicode-range: U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}
@ -12,9 +12,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-cyrillic-700-normal.woff2) format('woff2'), url(./files/open-sans-cyrillic-700-normal.woff) format('woff');
src: url(./files/open-sans-cyrillic-700-normal.woff2) format('woff2');
unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@ -22,9 +22,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-greek-ext-700-normal.woff2) format('woff2'), url(./files/open-sans-greek-ext-700-normal.woff) format('woff');
src: url(./files/open-sans-greek-ext-700-normal.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
@ -32,9 +32,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-greek-700-normal.woff2) format('woff2'), url(./files/open-sans-greek-700-normal.woff) format('woff');
src: url(./files/open-sans-greek-700-normal.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
@ -42,9 +42,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-hebrew-700-normal.woff2) format('woff2'), url(./files/open-sans-hebrew-700-normal.woff) format('woff');
src: url(./files/open-sans-hebrew-700-normal.woff2) format('woff2');
unicode-range: U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F;
}
@ -52,9 +52,9 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-vietnamese-700-normal.woff2) format('woff2'), url(./files/open-sans-vietnamese-700-normal.woff) format('woff');
src: url(./files/open-sans-vietnamese-700-normal.woff2) format('woff2');
unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@ -62,18 +62,18 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-latin-ext-700-normal.woff2) format('woff2'), url(./files/open-sans-latin-ext-700-normal.woff) format('woff');
unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
src: url(./files/open-sans-latin-ext-700-normal.woff2) format('woff2');
unicode-range: U+0100-02AF,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
/* open-sans-latin-700-normal */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: swap;
font-display: var(--fontsource-display, swap);
font-weight: 700;
src: url(./files/open-sans-latin-700-normal.woff2) format('woff2'), url(./files/open-sans-latin-700-normal.woff) format('woff');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
src: url(./files/open-sans-latin-700-normal.woff2) format('woff2');
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

View File

@ -3,6 +3,7 @@
namespace App\Command;
use App\Entity\Order;
use App\Helper\Hiltes;
use App\Repository\OrderRepository;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
@ -12,7 +13,6 @@ 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',
@ -22,10 +22,10 @@ class HiltesExportCommand extends Command
{
public function __construct(OrderRepository $orderRepository, LoggerInterface $logger, private Hiltes $hiltes)
{
$this->orderRepository = $orderRepository;
$this->logger = $logger;
$this->orderRepository = $orderRepository;
$this->logger = $logger;
parent::__construct();
parent::__construct();
}
@ -33,8 +33,7 @@ class HiltesExportCommand extends Command
{
$this
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
;
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description');
}
/**
@ -46,131 +45,131 @@ class HiltesExportCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$io = new SymfonyStyle($input, $output);
$io->info('Start Hiltes Export');
$l = $this->hiltes->loginToHiltes('','');
if(!$l){
dd('Login faild'.'STOP '.__METHOD__.' / '.__LINE__);
}
$l = $this->hiltes->loginToHiltes('', '');
if (!$l) {
dd('Login faild' . 'STOP ' . __METHOD__ . ' / ' . __LINE__);
}
$orders = $this->orderRepository->findAll();
#dump($orders);
/**
* @var Order
*/
$order = false;
foreach ($orders as $order) {
if($order->getStatus()>0) continue;
$tA = $order->getData();#json_decode($order->getData());
/**
* @var Order
*/
$order = false;
foreach ($orders as $order) {
if ($order->getStatus() > 0) continue;
$tA = $order->getData();#json_decode($order->getData());
$tA['orderdate'] = "2023-08-30T12:05:24.000Z";
#dd($order->getData());
#dd(array(
# 'orderdate'=> $tA['orderdate'],
# 'time'=> strtotime($tA['orderdate']),
# 'gmdate '=> gmdate ('d-m-Y\TH:i:s.v\Z',strtotime($tA['orderdate'])),
#));
#*** Umkonvertieren des Datumstings *****************
$tA['orderdate'] = gmdate ('Y-m-d\TH:i:s.v\Z',strtotime($tA['orderdate']));
#****
$arr = array(
'SalesDate' => $tA['orderdate'],
"BranchNumber" => 8, #Die Filialnummer
"ShopNumber" => 1, #Die Shopnummer
"DistributionChannel" => 5, #Der Vertriebskanal
'SaleList' => array(),
'CustomerList' => array(),
);
#*** Items ***************
if(!empty($tA['data']) && is_array($tA['data'])){
# Noch nötig
# "CalculatedSellingPrice" => 0, #X Kalkulierter Verkaufspreis
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
$tSalNr = array();
foreach ($tA['data'] as $v){
$SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']);
if(preg_match('/^([0-9]+)_/',$SalesNumber,$tP)){
$SalesNumber = $tP[1];
}
if(isset($tSalNr[$SalesNumber])){
$tSalNr[$SalesNumber]++;
$SalesNumber.= $tSalNr[$SalesNumber];
}else{
$tSalNr[$SalesNumber] = 0;
}
#dump($SalesNumber);
#********
$v['CalculatedSellingPrice'] = 100.00;
$v['AchievedSalesPrice'] = 90.00;
$arr['SaleList'][] = array(
"SalesLabel" => 'Ean',#$v['sku'],#X
"SalesLabelNumber" => $SalesNumber,#X
"SalesGoodsGroupNumber" => 0,
"SizeDescription" => '',#"string",
"CustomerNumber" => 0,
"TypeOfEstate" => 0,
"Amount" => $v['menge'],#X
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'], #X Kalkulierter Verkaufspreis
"AchievedSalesPrice" => $v['AchievedSalesPrice'], #X Erzielter Verkaufspreis
"TransactionType" => "Sale", #X Die Vorgangsart Sale=Verkauf Exchange=Umtausch / Storno
"ReceiptNumber" => 0, #Die Belegnummer
"DateOfSale" => $tA['orderdate'],#X das Verkaufsdatum mit Verkaufszeit
"PaymentMethod" => 'Invoice',#X "CreditCard",
"Currency" => 'EUR',#X "string",
"Unit" => "Piece",#X
"DistributionChannel" => 'JTL',#"string"
);
#dd($order->getData());
#dd(array(
# 'orderdate'=> $tA['orderdate'],
# 'time'=> strtotime($tA['orderdate']),
# 'gmdate '=> gmdate ('d-m-Y\TH:i:s.v\Z',strtotime($tA['orderdate'])),
#));
#*** Umkonvertieren des Datumstings *****************
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', strtotime($tA['orderdate']));
#****
$arr = array(
'SalesDate' => $tA['orderdate'],
"BranchNumber" => 8, #Die Filialnummer
"ShopNumber" => 1, #Die Shopnummer
"DistributionChannel" => 5, #Der Vertriebskanal
'SaleList' => array(),
'CustomerList' => array(),
);
#*** Items ***************
if (!empty($tA['data']) && is_array($tA['data'])) {
# Noch nötig
# "CalculatedSellingPrice" => 0, #X Kalkulierter Verkaufspreis
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
$tSalNr = array();
foreach ($tA['data'] as $v) {
$SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']);
if (preg_match('/^([0-9]+)_/', $SalesNumber, $tP)) {
$SalesNumber = $tP[1];
}
if (isset($tSalNr[$SalesNumber])) {
$tSalNr[$SalesNumber]++;
$SalesNumber .= $tSalNr[$SalesNumber];
} else {
$tSalNr[$SalesNumber] = 0;
}
#dump($SalesNumber);
#********
$v['CalculatedSellingPrice'] = 100.00;
$v['AchievedSalesPrice'] = 90.00;
$arr['SaleList'][] = array(
"SalesLabel" => 'Ean',#$v['sku'],#X
"SalesLabelNumber" => $SalesNumber,#X
"SalesGoodsGroupNumber" => 0,
"SizeDescription" => '',#"string",
"CustomerNumber" => 0,
"TypeOfEstate" => 0,
"Amount" => $v['menge'],#X
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'], #X Kalkulierter Verkaufspreis
"AchievedSalesPrice" => $v['AchievedSalesPrice'], #X Erzielter Verkaufspreis
"TransactionType" => "Sale", #X Die Vorgangsart Sale=Verkauf Exchange=Umtausch / Storno
"ReceiptNumber" => 0, #Die Belegnummer
"DateOfSale" => $tA['orderdate'],#X das Verkaufsdatum mit Verkaufszeit
"PaymentMethod" => 'Invoice',#X "CreditCard",
"Currency" => 'EUR',#X "string",
"Unit" => "Piece",#X
"DistributionChannel" => 'JTL',#"string"
);
}
}
#*** Kundne *******************************
$arr['CustomerList'][] = array(
"CustomerNumber" => 99999, # Fake Daten
"Surname" => 'MAX',#"string",
"Forename" => 'MUSTERMANN',#"string",
"AddressCity" => 'ERFURT',#"string",
"AddressZipCode" => '99084',"string",
"AddressStreet" => 'MusterStrasse 22',#"string",
"AddressCountry" => 'DE',#"string",
#*** Nicht nötig
#"CardNumber" => 0,
#"SalutionNumber" => 0,
#"PostOfficeBox" => '',#"string",
#"PostOfficeBoxZipCode" => '',#"string",
#"Title" => '',#"string",
#"PhoneNumber1" => '',#"string",
#"PhoneNumber2" => '',#"string",
#"FaxNumber" => '',#"string",
#"BirthDay" => '',#"2023-09-14T11:54:26.708Z",
#"Gender" => 'Male',
#"EmailAddress" => '',#"string",
#"Discount" => 0,
#"Limit" => 0,
#"LockMark" => 'Unblocked',
#"DubiousMark" => 'Undubious',
#"DubiousText" => '',#"string",
#"DirectDebit" => '',#true,
#"BankName1" => '',#"string",
#"BankAccountNumber1" => '',#"string",
#"BankCodeNumber1" => '',#"string",
#"BankName2" => '',#"string",
#"BankAccountNumber2" => '',#"string",
#"BankCodeNumber2" => '',#"string",
#"BankName3" => '',#"string",
#"BankAccountNumber3" => '',#"string",
#"BankCodeNumber3" => '',#"string",
#"CreditcardNumber1" => '',#"string",
#"CreditcardNumber2" => '',#"string",
#"CreditcardNumber3" => '',#"string",
#"CreditcardNumber4" => '',#"string",
#"ChangeIndicator" => '',#true,
#"Newsletter" => '',#true,
#"Password" => '',#"string",
#"AdBan" => '',#true
);
$data = $this->hiltes->createJson($arr);
}
}
}
#*** Kundne *******************************
$arr['CustomerList'][] = array(
"CustomerNumber" => 99999, # Fake Daten
"Surname" => 'MAX',#"string",
"Forename" => 'MUSTERMANN',#"string",
"AddressCity" => 'ERFURT',#"string",
"AddressZipCode" => '99084', "string",
"AddressStreet" => 'MusterStrasse 22',#"string",
"AddressCountry" => 'DE',#"string",
#*** Nicht nötig
#"CardNumber" => 0,
#"SalutionNumber" => 0,
#"PostOfficeBox" => '',#"string",
#"PostOfficeBoxZipCode" => '',#"string",
#"Title" => '',#"string",
#"PhoneNumber1" => '',#"string",
#"PhoneNumber2" => '',#"string",
#"FaxNumber" => '',#"string",
#"BirthDay" => '',#"2023-09-14T11:54:26.708Z",
#"Gender" => 'Male',
#"EmailAddress" => '',#"string",
#"Discount" => 0,
#"Limit" => 0,
#"LockMark" => 'Unblocked',
#"DubiousMark" => 'Undubious',
#"DubiousText" => '',#"string",
#"DirectDebit" => '',#true,
#"BankName1" => '',#"string",
#"BankAccountNumber1" => '',#"string",
#"BankCodeNumber1" => '',#"string",
#"BankName2" => '',#"string",
#"BankAccountNumber2" => '',#"string",
#"BankCodeNumber2" => '',#"string",
#"BankName3" => '',#"string",
#"BankAccountNumber3" => '',#"string",
#"BankCodeNumber3" => '',#"string",
#"CreditcardNumber1" => '',#"string",
#"CreditcardNumber2" => '',#"string",
#"CreditcardNumber3" => '',#"string",
#"CreditcardNumber4" => '',#"string",
#"ChangeIndicator" => '',#true,
#"Newsletter" => '',#true,
#"Password" => '',#"string",
#"AdBan" => '',#true
);
$data = $this->hiltes->createJson($arr);
}
$this->hiltes->sendOrderToHiltes($data);

View File

@ -10,14 +10,11 @@ use App\Repository\WarehouseRepository;
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 Symfony\Component\Finder\Finder;
#[AsCommand(
name: 'hiltes:import',
description: 'Importiert die Bestandsdaten von Hiltes',
@ -28,11 +25,12 @@ class HiltesImportCommand extends Command
private $warehouseRepository;
private $productRepository;
private $logger;
public function __construct(
ProductRepository $productRepository,
StockRepository $stockRepository,
ProductRepository $productRepository,
StockRepository $stockRepository,
WarehouseRepository $warehouseRepository,
LoggerInterface $logger
LoggerInterface $logger
)
{
$this->productRepository = $productRepository;
@ -41,6 +39,7 @@ class HiltesImportCommand extends Command
$this->logger = $logger;
parent::__construct();
}
protected function configure(): void
{
$this->addOption('delta', 'd', InputOption::VALUE_NONE, 'Delta Import');
@ -52,22 +51,22 @@ class HiltesImportCommand extends Command
$io->success('Start Hiltes Import');
/**
* @var HiltesImport
*/
$hiltesImport = new HiltesImport($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
/**
* @var HiltesImport
*/
$hiltesImport = new HiltesImport($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger);
$r = $hiltesImport->startImport($input->getOption('delta'));
if(isset($r['error'])){
if (isset($r['error'])) {
$io->error($r['text']);
$this->logger->error($r['text']);
return Command::FAILURE;
}else{
} else {
$io->info('Start Hiltes Push JTL');
$jtl = new Jtl($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
$jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger);
$jtl->createExportFile($jtl->getProducts());
$io->success('Done.');

View File

@ -26,11 +26,12 @@ class JtlExportCommand extends Command
private $warehouseRepository;
private $productRepository;
private $logger;
public function __construct(
ProductRepository $productRepository,
StockRepository $stockRepository,
ProductRepository $productRepository,
StockRepository $stockRepository,
WarehouseRepository $warehouseRepository,
LoggerInterface $logger
LoggerInterface $logger
)
{
$this->productRepository = $productRepository;
@ -44,8 +45,7 @@ class JtlExportCommand extends Command
{
$this
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
;
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description');
}
protected function execute(InputInterface $input, OutputInterface $output): int
@ -68,13 +68,12 @@ class JtlExportCommand extends Command
/**
* @var HiltesImport
*/
$jtl = new Jtl($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
$jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger);
$data = $jtl->getProducts();
$jtl->createExportFile($data);
$io->success('Ende JTL Export');
return Command::SUCCESS;

View File

@ -11,7 +11,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Notifier\Chatter;
use Symfony\Component\Notifier\Message\ChatMessage;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Transport;
#[AsCommand(
@ -24,8 +23,7 @@ class JtlImportCommand extends Command
{
$this
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
;
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description');
}
protected function execute(InputInterface $input, OutputInterface $output): int
@ -50,7 +48,6 @@ class JtlImportCommand extends Command
->transport('slack');
$sentMessage = $chatter->send($message);
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');

View File

@ -1,40 +0,0 @@
<?php
namespace App\Controller;
use App\Entity\Orders;
use App\Form\OrdersType;
use App\Repository\OrdersRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Psr\Log\LoggerInterface;
#[Route('/orders')]
class OrdersController extends AbstractController
{
private $logger;
private $ordersRepository;
public function index(
OrdersRepository $ordersRepository,
LoggerInterface $logger
)
{
$this->logger = $logger;
$this->ordersRepository = $ordersRepository;
}
public function getOrders(): Orders
{
$this->logger->info('I just got the logger');
$orders = $this->ordersRepository->findAll();
return $orders->getData();
}
}

View File

@ -2,8 +2,10 @@
namespace App\Entity;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\OrderRepository;
use DateTimeInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
@ -14,6 +16,7 @@ use Doctrine\ORM\Mapping as ORM;
* 2 = Bestellung in Bearbeitung
* 3 = Bestellung versendet
*/
#[ORM\Entity(repositoryClass: OrderRepository::class)]
#[ORM\Table(name: '`order`')]
#[ApiResource]
@ -22,9 +25,12 @@ class Order
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[ApiProperty(identifier: false)]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[ORM\Column(length: 255,unique: true)]
#[ApiProperty(identifier: true)]
private ?string $orderId = null;
#[ORM\Column]
@ -33,8 +39,8 @@ class Order
#[ORM\Column]
private array $data = [];
#[ORM\Column(name: 'change_date',type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
private ?\DateTimeInterface $changeDate = null;
#[ORM\Column(name: 'change_date', type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
private ?DateTimeInterface $changeDate = null;
public function getId(): ?int
{
@ -77,12 +83,12 @@ class Order
return $this;
}
public function getChangeDate(): ?\DateTimeInterface
public function getChangeDate(): ?DateTimeInterface
{
return $this->changeDate;
}
public function setChangeDate(\DateTimeInterface $changeDate): static
public function setChangeDate(DateTimeInterface $changeDate): static
{
$this->changeDate = $changeDate;

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\ProductRepository;
use App\Repository\StockRepository;
use DateTimeInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
@ -21,7 +21,7 @@ class Product
private ?string $gtin = null;
#[ORM\Column(name: 'update_time', type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
private ?\DateTimeInterface $updateTime = null;
private ?DateTimeInterface $updateTime = null;
public function getId(): ?int
@ -41,12 +41,12 @@ class Product
return $this;
}
public function getUpdateTime(): ?\DateTimeInterface
public function getUpdateTime(): ?DateTimeInterface
{
return $this->updateTime;
}
public function setUpdateTime(\DateTimeInterface $updateTime): self
public function setUpdateTime(DateTimeInterface $updateTime): self
{
$this->updateTime = $updateTime;

View File

@ -3,16 +3,17 @@
namespace App\Entity;
use App\Repository\StockRepository;
#use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use DateTimeInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[ORM\Entity(repositoryClass: StockRepository::class)]
#[ORM\UniqueEntity(['warehouse_id', 'product_id'])]
#[ORM\UniqueConstraint(
name: 'UNIQ_D34A04ADDCD6110',
columns: ['warehouse_id', 'product_id']
name: 'UNIQ_D34A04ADDCD6110',
columns: ['warehouse_id', 'product_id']
)]
class Stock
{
@ -29,19 +30,19 @@ class Stock
#[ORM\ManyToOne(inversedBy: 'stocks')]
private ?Warehouse $warehouse = null;
#[ORM\Column(name: 'update_time',type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
private ?\DateTimeInterface $update_time = null;
#[ORM\Column(name: 'update_time', type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
private ?DateTimeInterface $update_time = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): ?self
{
$this->id = $id;
return $this;
return $this;
}
public function getInstock(): ?int
@ -55,6 +56,7 @@ class Stock
return $this;
}
public function getProductId(): ?int
{
return $this->product_id;
@ -66,6 +68,7 @@ class Stock
return $this;
}
public function getWarehouseId(): ?int
{
return $this->warehouse_id;
@ -112,12 +115,12 @@ class Stock
return $this;
}
public function getUpdateTime(): ?\DateTimeInterface
public function getUpdateTime(): ?DateTimeInterface
{
return $this->update_time;
}
public function setUpdateTime(?\DateTimeInterface $update_time): self
public function setUpdateTime(?DateTimeInterface $update_time): self
{
$this->update_time = $update_time;

View File

@ -33,6 +33,7 @@ class Warehouse
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
@ -92,4 +93,4 @@ class Warehouse
return $this;
}
}
}

View File

@ -3,16 +3,15 @@
namespace App\EventSubscriber;
use ApiPlatform\Symfony\EventListener\EventPriorities;
use App\Entity\Order;
use App\Helper\Hiltes;
use App\Helper\Slack;
use App\Entity\Order;
use Maknz\Slack\Client;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Notifier\ChatterInterface;
class SlackNotifySubscriber implements EventSubscriberInterface
@ -26,7 +25,7 @@ class SlackNotifySubscriber implements EventSubscriberInterface
private $hiltes;
public function __construct(string $slackWebhookUrl, LoggerInterface $logger, Hiltes $hiltes)
public function __construct(string $slackWebhookUrl, LoggerInterface $logger, Hiltes $hiltes)
{
$this->slackWebhookUrl = $slackWebhookUrl;
$this->logger = $logger;
@ -58,29 +57,29 @@ class SlackNotifySubscriber implements EventSubscriberInterface
$order = $event->getControllerResult();
$method = $event->getRequest()->getMethod();
//wenn es keine Bestellung ist oder es kein POST Request ist, dann return
if (!$order instanceof Order || Request::METHOD_POST !== $method) {
//wenn es keine Bestellung ist oder es kein POST Request ist, dann return
if (!$order instanceof Order || Request::METHOD_POST !== $method) {
return;
}
}
$msg = "Bestellung {$order->getOrderId()}: \n";
$msg = "Bestellung {$order->getOrderId()}: \n";
foreach($order->getData() as $item) {
if($item['menge'] > 0 && strlen($item['sku']) > 0) {
$msg .= $item['name'];
$msg .= ' '.$item['sku'];
$msg .= ' Menge: '.$item['menge']."\n";
}
}
foreach ($order->getData() as $item) {
if ($item['menge'] > 0 && strlen($item['sku']) > 0) {
$msg .= $item['name'];
$msg .= ' ' . $item['sku'];
$msg .= ' Menge: ' . $item['menge'] . "\n";
}
}
if($order->getStatus() == 1) {
$slack->from('CDS-Notify')
->send($msg);
}elseif($order->getStatus() == 2){
if ($order->getStatus() == 1) {
$slack->from('CDS-Notify')
->send($msg);
} elseif ($order->getStatus() == 2) {
//Send to Hiltes
$this->hiltes->createRequest($order);
}else{
$this->logger->error('Status ist nicht 1 oder 2');
}
$this->hiltes->createRequest($order);
} else {
$this->logger->error('Status ist nicht 1 oder 2');
}
}
}

View File

@ -3,6 +3,8 @@
namespace App\Helper;
use Exception;
class Ftp
{
private string $host;
@ -23,6 +25,55 @@ class Ftp
}
/**
* Uploads a local file to a remote FTP server.
*
* @param string $localFile The local file path to upload.
*
* @return void
* @throws Exception If the upload fails or encounters an error.
*
*/
public function uploadFile(string $localFile): void
{
$ftp = ftp_ssl_connect($this->getHost(), $this->getPort());
if (!$ftp) {
throw new Exception("Failed to connect to FTP server");
}
$ftp_login = ftp_login($ftp, $this->getUser(), $this->getPassword());
if (!$ftp_login) {
throw new Exception("FTP login failed");
}
ftp_pasv($ftp, true);
$remoteFile = 'stock_hiltes.csv';
if (!file_exists($localFile)) {
throw new Exception("Local file does not exist: $localFile");
}
$r = ftp_nb_put($ftp, $this->getRemoteDir() . $remoteFile, $localFile, FTP_BINARY);
while ($r == FTP_MOREDATA) {
// Continue uploading...
$r = ftp_nb_continue($ftp);
}
if ($r != FTP_FINISHED) {
throw new Exception("File upload failed");
}
ftp_close($ftp);
if (!unlink($localFile)) {
throw new Exception("Failed to delete local file: $localFile");
}
}
public function getHost(): string
{
return $this->host;
@ -32,6 +83,7 @@ class Ftp
{
$this->host = $host;
}
public function getPort(): int
{
return $this->port;
@ -71,53 +123,4 @@ class Ftp
{
$this->remoteDir = $remoteDir;
}
/**
* Uploads a local file to a remote FTP server.
*
* @param string $localFile The local file path to upload.
*
* @throws \Exception If the upload fails or encounters an error.
*
* @return void
*/
public function uploadFile(string $localFile): void
{
$ftp = ftp_ssl_connect($this->getHost(), $this->getPort());
if (!$ftp) {
throw new \Exception("Failed to connect to FTP server");
}
$ftp_login = ftp_login($ftp, $this->getUser(), $this->getPassword());
if (!$ftp_login) {
throw new \Exception("FTP login failed");
}
ftp_pasv($ftp, true);
$remoteFile = 'stock_hiltes.csv';
if (!file_exists($localFile)) {
throw new \Exception("Local file does not exist: $localFile");
}
$r = ftp_nb_put($ftp, $this->getRemoteDir() . $remoteFile, $localFile, FTP_BINARY);
while ($r == FTP_MOREDATA) {
// Continue uploading...
$r = ftp_nb_continue($ftp);
}
if ($r != FTP_FINISHED) {
throw new \Exception("File upload failed");
}
ftp_close($ftp);
if (!unlink($localFile)) {
throw new \Exception("Failed to delete local file: $localFile");
}
}
}

View File

@ -4,7 +4,6 @@ namespace App\Helper;
use App\Entity\Order;
use App\Repository\OrderRepository;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
@ -97,8 +96,8 @@ class Hiltes
if ($order) {
//foreach ($orders as $order) {
// if ($order->getStatus() > 0) continue;
//foreach ($orders as $order) {
// if ($order->getStatus() > 0) continue;
$tA = $order->getData();#json_decode($order->getData());
#$tA['orderdate'] = "2023-08-30T12:05:24.000Z";
@ -211,7 +210,7 @@ class Hiltes
dd($arr);
$data = $this->createJson($arr);
// }
// }
return $this->sendOrderToHiltes($data);

View File

@ -9,118 +9,122 @@ use App\Entity\Warehouse;
use App\Repository\ProductRepository;
use App\Repository\StockRepository;
use App\Repository\WarehouseRepository;
use Exception;
use Psr\Log\LoggerInterface;
use RuntimeException;
use SplFileObject;
use Symfony\Component\Finder\Finder;
class HiltesImport
{
protected $currentDirPath;
protected $cachedWarehouseIds;
protected $arrData = array();
private $productRepository;
private $stockRepository;
private $stockRepository;
private $warehouseRepository;
private $logger;
protected $currentDirPath;
protected $cachedWarehouseIds;
private $cachedProdIds;
private $cachedStockIds;
protected $arrData = array();
private $cachedProdIds;
private $cachedStockIds;
public function __construct(ProductRepository $productRepository,WarehouseRepository $warehouseRepository,StockRepository $stockRepository, LoggerInterface $logger)
{
public function __construct(ProductRepository $productRepository, WarehouseRepository $warehouseRepository, StockRepository $stockRepository, LoggerInterface $logger)
{
$this->productRepository = $productRepository;
$this->warehouseRepository = $warehouseRepository;
$this->stockRepository = $stockRepository;
$this->stockRepository = $stockRepository;
$this->logger = $logger;
$this->currentDirPath = getcwd();
}
$this->currentDirPath = getcwd();
}
/**
* @return array|void
*/
public function startImport($delta = false)
{
#*** Holt alle Dateien
if($this->getFiles($delta)){
#*** Holt alle Stocks und setzt ein Array **************
$this->getStocks();
public function startImport($delta = false)
{
#*** Holt alle Dateien
if ($this->getFiles($delta)) {
#*** Holt alle Stocks und setzt ein Array **************
$this->getStocks();
$count = 0;
if(!empty($this->arrData['orgFiles']['data']) && count($this->arrData['orgFiles']['data'])){
foreach ($this->arrData['orgFiles']['data'] as $file) {
if (!empty($this->arrData['orgFiles']['data']) && count($this->arrData['orgFiles']['data'])) {
foreach ($this->arrData['orgFiles']['data'] as $file) {
if(is_file($file['realPath'])){
$count += $this->loadFiles($file['realPath']);
}else{
throw new \RuntimeException("Error: File not found - " . $file['realPath']);
if (is_file($file['realPath'])) {
$count += $this->loadFiles($file['realPath']);
} else {
throw new RuntimeException("Error: File not found - " . $file['realPath']);
}
}
$this->logger->info("Imported $count stocks");
} else {
$this->logger->info('No Files');
}
}
} else {
throw new \RuntimeException('Error in getFiles or no file WS.FERTIG');
throw new RuntimeException('Error in getFiles or no file WS.FERTIG');
}
}
}
/**
* @return bool
*/
protected function getFiles($delta = false)
{
$finder = Finder::create();
$finder
->in($this->currentDirPath.'/hiltes/h2c/')
->depth(0);
protected function getFiles($delta = false)
{
$finder = Finder::create();
$finder
->in($this->currentDirPath . '/hiltes/h2c/')
->depth(0);
if($delta) {
if ($delta) {
$finder->name('/_D/');
}else{
} else {
$finder->notName('/_D/');
}
if ($finder->hasResults()) {
foreach ($finder as $file) {
if($file->getExtension() != 'Ende') {
if ($finder->hasResults()) {
foreach ($finder as $file) {
if ($file->getExtension() != 'Ende') {
//prüfen ob Ende Datei vorhanden ist
if(file_exists($this->currentDirPath.'/hiltes/h2c/'.$file->getRelativePathname().'.Ende')) {
if (file_exists($this->currentDirPath . '/hiltes/h2c/' . $file->getRelativePathname() . '.Ende')) {
$this->arrData['orgFiles']['data'][] = array(
'realPath' => $file->getRealPath(),
'fileSize' => $file->getFileInfo()->getSize(),
'onlyFileName' => $file->getRelativePathname(),
'realPath' => $file->getRealPath(),
'fileSize' => $file->getFileInfo()->getSize(),
'onlyFileName' => $file->getRelativePathname(),
);
}
}
}
}else{
return false;
}
}
} else {
return false;
}
return true;
}
protected function getStocks()
{
}
protected function getStocks()
{
$stocks = $this->stockRepository->findAll();
foreach ($stocks as $stock) {
$this->cachedStockIds[$stock->getProductId()][$stock->getWarehouse()->getId()] = $stock;
}
}
}
}
protected function loadFiles($srcFile)
{
protected function loadFiles($srcFile)
{
try {
$file = new \SplFileObject($srcFile);
$file = new SplFileObject($srcFile);
$this->logger->info('Starte Import von ' . $file->getRealPath());
$count = 0;
while (!$file->eof()) {
$this->processLine($file->fgets());
$count++;
}
}catch (\Exception $e) {
}
} catch (Exception $e) {
$this->logger->error($e->getMessage());
}
@ -130,7 +134,7 @@ class HiltesImport
$this->logger->info($count . ' Datensätze importiert');
return $count;
}
}
protected function processLine($line)
{
@ -139,15 +143,15 @@ class HiltesImport
if (!empty($data[0])) {
$this->trimArray($data);
$this->saveData($data);
}
}
}
}
protected function trimArray(array &$arr)
{
foreach ($arr as $k=>$v) {
$arr[$k] = trim($v);
}
}
foreach ($arr as $k => $v) {
$arr[$k] = trim($v);
}
}
protected function saveData(array $data)
{
@ -156,63 +160,64 @@ class HiltesImport
if (!empty($warehouse) && !empty($this->cachedStockIds[$gtin][$warehouse->getId()])) {
$stock = $this->cachedStockIds[$gtin][$warehouse->getId()];
}else{
$stock = new Stock();
$stock->setProductId($gtin);
} else {
$stock = new Stock();
$stock->setProductId($gtin);
$stock->setWarehouse($warehouse);
}
}
$stock->setInstock((int) $data[1] / 100);
$this->stockRepository->save($stock,true);
}
$stock->setInstock((int)$data[1] / 100);
$this->stockRepository->save($stock, true);
}
private function checkWarehouseName(string $warehouseName)
{
$warehouseName = ltrim($warehouseName, 0);
if (empty($this->cachedWarehouseIds[$warehouseName])) {
$warehouse = $this->warehouseRepository->findOneBy(['id' => (int) $warehouseName]);
$warehouse = $this->warehouseRepository->findOneBy(['id' => (int)$warehouseName]);
if (empty($warehouse)) {
$warehouse = new Warehouse();
$warehouse->setId((int) $warehouseName);
$warehouse = new Warehouse();
$warehouse->setId((int)$warehouseName);
$warehouse->setName($warehouseName);
$this->warehouseRepository->save($warehouse,true);
$this->warehouseRepository->save($warehouse, true);
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
}else{
} else {
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
}
}
}
if (!empty($this->cachedWarehouseIds[$warehouseName])) {
return $this->cachedWarehouseIds[$warehouseName];
}
}
return false;
}
return false;
}
/**
* @param string $gtin
* @return false|int|mixed|null
*/
private function checkProduct(string $gtin){
#*** WEnn keine geCached Id Vorhanden
if(empty($this->cachedProdIds[$gtin])){
private function checkProduct(string $gtin)
{
#*** WEnn keine geCached Id Vorhanden
if (empty($this->cachedProdIds[$gtin])) {
$product = $this->productRepository->findOneBy(['gtin' => $gtin]);
if (empty($product)) {
$product = new Product();
$product->setGtin($gtin);
$this->cachedProdIds[$gtin] = $this->productRepository->save($product, true);
}else{
} else {
$this->cachedProdIds[$gtin] = $product->getId();
}
}
if (!empty($this->cachedProdIds[$gtin])) {
return $this->cachedProdIds[$gtin];
}
return false;
}
if (!empty($this->cachedProdIds[$gtin])) {
return $this->cachedProdIds[$gtin];
}
return false;
}
}

View File

@ -5,8 +5,10 @@ namespace App\Helper;
use App\Repository\ProductRepository;
use App\Repository\StockRepository;
use App\Repository\WarehouseRepository;
use Psr\Log\LoggerInterface;
use ArrayIterator;
use Exception;
use League\Csv\Writer;
use Psr\Log\LoggerInterface;
class Jtl
@ -28,7 +30,7 @@ class Jtl
10 => 'Lager 10 - OJ EF',
);
public function __construct(ProductRepository $productRepository,WarehouseRepository $warehouseRepository,StockRepository $stockRepository, LoggerInterface $logger)
public function __construct(ProductRepository $productRepository, WarehouseRepository $warehouseRepository, StockRepository $stockRepository, LoggerInterface $logger)
{
$this->productRepository = $productRepository;
$this->warehouseRepository = $warehouseRepository;
@ -47,31 +49,31 @@ class Jtl
$data = array();
foreach($r as $product){
$stock = $this->stockRepository->findBy(['product_id'=>$product->getId()]);
foreach ($r as $product) {
$stock = $this->stockRepository->findBy(['product_id' => $product->getId()]);
if($stock){
foreach($stock as $s){
if ($stock) {
foreach ($stock as $s) {
$warehouse = $s->getWarehouse();
$warehouseName = $warehouse->getName();
$data[$product->getId().$warehouseName] = [
$data[$product->getId() . $warehouseName] = [
'gtin' => $product->getGtin(),
'stock' => $s->getInstock(),
'warehouse' => $this->arrLager[$warehouseName] ?? 'Lager ' . $warehouseName
];
}
}else{
} else {
$data[$product->getId()] = [
'gtin' => $product->getGtin(),
'stock' => 0,
'warehouse' => 0
];
$this->logger->info('No stock for product '.$product->getId());
$this->logger->info('No stock for product ' . $product->getId());
}
// dump($data);
// dump($data);
}
@ -86,22 +88,20 @@ class Jtl
public function createExportFile($data): void
{
try {
$writer = Writer::createFromPath(getcwd().'/jtl/cds-export.csv', 'w+');
$bytes = $writer->insertAll(new \ArrayIterator($data));
$writer = Writer::createFromPath(getcwd() . '/jtl/cds-export.csv', 'w+');
$bytes = $writer->insertAll(new ArrayIterator($data));
if($bytes){
$this->logger->info('Exported '.$bytes.' bytes');
if ($bytes) {
$this->logger->info('Exported ' . $bytes . ' bytes');
$FTP = new Ftp();
$FTP->uploadFile(getcwd().'/jtl/cds-export.csv');
$FTP->uploadFile(getcwd() . '/jtl/cds-export.csv');
}
}catch (\Exception $e){
} catch (Exception $e) {
$this->logger->error($e->getMessage());
}
}
}

View File

@ -2,7 +2,6 @@
namespace App\Helper;
use Symfony\Component\Notifier\Chatter;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Exception\TransportExceptionInterface;
use Symfony\Component\Notifier\Message\ChatMessage;
@ -16,7 +15,7 @@ class Slack
$this->chatter = $chatter;
}
public function sendMessage(String $message): void
public function sendMessage(string $message): void
{
$message = (new ChatMessage($message))
->transport('slack');

View File

@ -5,6 +5,7 @@ namespace App\Repository;
use App\Entity\Order;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Exception;
/**
* @extends ServiceEntityRepository<Order>
@ -39,6 +40,22 @@ class OrderRepository extends ServiceEntityRepository
}
}
/**
* @throws Exception
*/
public function update(Order $entity, bool $flush = false): void
{
$order = $this->getEntityManager()->find(Order::class, $entity->getId());
if (!$order) {
throw $this->createNotFoundException('Order not found: ' . $entity->getId());
}
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return Order[] Returns an array of Order objects
// */
@ -63,4 +80,11 @@ class OrderRepository extends ServiceEntityRepository
// ->getOneOrNullResult()
// ;
// }
}
/**
* @throws Exception
*/
private function createNotFoundException(string $string)
{
throw new Exception($string);
}
}

View File

@ -1,105 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\Orders;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* @extends ServiceEntityRepository<Orders>
*
* @method Orders|null find($id, $lockMode = null, $lockVersion = null)
* @method Orders|null findOneBy(array $criteria, array $orderBy = null)
* @method Orders[] findAll()
* @method Orders[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class OrdersRepository extends ServiceEntityRepository
{
private ValidatorInterface $validator;
public function __construct(ManagerRegistry $registry, ValidatorInterface $validator)
{
parent::__construct($registry, Orders::class);
$this->validator = $validator;
}
/**
* @param Orders $entity
* @param bool $flush
* @return void
*/
public function add(Orders $entity, bool $flush = false): void
{
$errors = $this->validator->validate($entity);
if (count($errors) > 0) {
var_dump($errors);
}
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
/**
* @param Orders $entity
* @param bool $flush
* @return void
*/
public function update(Orders $entity, bool $flush = false): void
{
$order = $this->getEntityManager()->find(Orders::class, $entity->getId());
if (!$order) {
throw $this->createNotFoundException('Order not found: '.$entity->getId());
}
}
/**
* @param Orders $entity
* @param bool $flush
* @return void
*/
public function remove(Orders $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
/**
* @return Orders[] Returns an array of Orders objects
*/
public function findByStatus($status): array
{
return $this->createQueryBuilder('o')
->andWhere('o.status = :val')
->setParameter('val', $status)
->orderBy('o.id', 'ASC')
->setMaxResults(100)
->getQuery()
->getResult()
;
}
/**
* @param $orderId
* @return Orders|null
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneByOrderId($orderId): ?Orders
{
return $this->createQueryBuilder('o')
->andWhere('o.order_id = :val')
->setParameter('val', $orderId)
->getQuery()
->getOneOrNullResult()
;
}
}

View File

@ -3,6 +3,7 @@
namespace App\Repository;
use App\Entity\Product;
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@ -24,7 +25,7 @@ class ProductRepository extends ServiceEntityRepository
public function save(Product $entity, bool $flush = false): ?int
{
$entity->setUpdateTime(new \DateTime());
$entity->setUpdateTime(new DateTime());
$this->getEntityManager()->persist($entity);
@ -68,4 +69,4 @@ class ProductRepository extends ServiceEntityRepository
// ->getOneOrNullResult()
// ;
// }
}
}

View File

@ -3,6 +3,7 @@
namespace App\Repository;
use App\Entity\Stock;
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@ -23,7 +24,7 @@ class StockRepository extends ServiceEntityRepository
public function save(Stock $entity, bool $flush = false): void
{
$entity->setUpdateTime(new \DateTime());
$entity->setUpdateTime(new DateTime());
$this->getEntityManager()->persist($entity);

View File

@ -23,7 +23,7 @@ class WarehouseRepository extends ServiceEntityRepository
public function save(Warehouse $entity, bool $flush = false): ?int
{
$entity->setPrio(0);
$entity->setPrio(0);
$this->getEntityManager()->persist($entity);
if ($flush) {
@ -66,4 +66,4 @@ class WarehouseRepository extends ServiceEntityRepository
// ->getOneOrNullResult()
// ;
// }
}
}

View File

@ -52,7 +52,7 @@ class ApiKeyAuthenticator extends AbstractAuthenticator
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
{
# dump($exception);
# dump($exception);
$data = [
'message' => $exception->getMessage()