diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index a831897..ffa1385 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -8,13 +8,13 @@
jdbc:mysql://127.0.0.1:3306
$ProjectFileDir$
-
+
mariadb
true
true
DDEV generated data source
org.mariadb.jdbc.Driver
- jdbc:mariadb://127.0.0.1:55619/db?user=db&password=db
+ jdbc:mariadb://127.0.0.1:51773/db?user=db&password=db
$ProjectFileDir$
diff --git a/config/services.yaml b/config/services.yaml
index e20161b..0a38397 100644
--- a/config/services.yaml
+++ b/config/services.yaml
@@ -22,6 +22,9 @@ 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
\ No newline at end of file
diff --git a/public/.htaccess b/public/.htaccess
index 3853fa9..aeca260 100644
--- a/public/.htaccess
+++ b/public/.htaccess
@@ -20,7 +20,7 @@ DirectoryIndex index.php
# This Option needs to be enabled for RewriteRule, otherwise it will show an error like
# 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden'
- Options +FollowSymlinks
+ #Options +FollowSymlinks
RewriteEngine On
@@ -67,4 +67,4 @@ DirectoryIndex index.php
RedirectMatch 307 ^/$ /index.php/
# RedirectTemp cannot be used instead
-
+
\ No newline at end of file
diff --git a/src/EventSubscriber/SlackNotifySubscriber.php b/src/EventSubscriber/SlackNotifySubscriber.php
index 9589565..289336e 100644
--- a/src/EventSubscriber/SlackNotifySubscriber.php
+++ b/src/EventSubscriber/SlackNotifySubscriber.php
@@ -3,6 +3,7 @@
namespace App\EventSubscriber;
use ApiPlatform\Symfony\EventListener\EventPriorities;
+use App\Helper\Hiltes;
use App\Helper\Slack;
use App\Entity\Order;
use Maknz\Slack\Client;
@@ -23,10 +24,13 @@ class SlackNotifySubscriber implements EventSubscriberInterface
private $slackWebhookUrl;
- public function __construct(string $slackWebhookUrl, LoggerInterface $logger)
+ private $hiltes;
+
+ public function __construct(string $slackWebhookUrl, LoggerInterface $logger, Hiltes $hiltes)
{
$this->slackWebhookUrl = $slackWebhookUrl;
$this->logger = $logger;
+ $this->hiltes = $hiltes;
}
public static function getSubscribedEvents(): array
@@ -46,7 +50,9 @@ class SlackNotifySubscriber implements EventSubscriberInterface
$slack = new Client($this->slackWebhookUrl, [
'username' => 'CDS-Notify',
'channel' => '#general',
- 'link_names' => true
+ 'link_names' => true,
+ 'icon' => ':robot_face:',
+ 'allow_markdown' => true,
]);
$order = $event->getControllerResult();
@@ -57,19 +63,24 @@ class SlackNotifySubscriber implements EventSubscriberInterface
return;
}
- $msg = "Bestellung {$order->getId()}: ";
+ $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'];
+ $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){
+ //Send to Hiltes
+ $this->hiltes->createRequest($order);
+ }else{
+ $this->logger->error('Status ist nicht 1 oder 2');
}
}
}
\ No newline at end of file
diff --git a/src/Helper/Hiltes.php b/src/Helper/Hiltes.php
index 2a372c9..c326e08 100644
--- a/src/Helper/Hiltes.php
+++ b/src/Helper/Hiltes.php
@@ -2,6 +2,9 @@
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;
@@ -9,296 +12,437 @@ use Symfony\Component\Finder\Finder;
class Hiltes
{
- // init file system
- protected $fsObject;
- protected $current_dir_path;
- protected $apiKey;
- protected $hiltesApiHash = '';
- protected $hiltesUsr;
- protected $hiltesPass;
- protected $hiltesApiUrl;
-
- public function __construct()
- {
- $this->fsObject = new Filesystem();
- $this->current_dir_path = getcwd();
+ // init file system
+ protected $fsObject;
+ protected $current_dir_path;
+ protected $apiKey;
+ protected $hiltesApiHash = '';
+ protected $hiltesUsr;
+ protected $hiltesPass;
+ protected $hiltesApiUrl;
- $this->hiltesApiUrl = $_ENV['HILTES_API_URL'];
- $this->hiltesUsr = $_ENV['HILTES_API_USER'];
- $this->hiltesPass = $_ENV['HILTES_API_PASSWORD'];
- }
+ public function __construct(private OrderRepository $orderRepository)
+ {
+ $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()
- {
-
- $finder = new Finder();
- $finder->files()->in($this->current_dir_path . "/hiltes/h2c/");
-
- foreach ($finder as $file) {
- $contents = $file->getContents();
-
- var_dump($contents);
- }
-
- }
-
- /**
- * @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();
+ $this->hiltesApiUrl = $_ENV['HILTES_API_URL'];
+ $this->hiltesUsr = $_ENV['HILTES_API_USER'];
+ $this->hiltesPass = $_ENV['HILTES_API_PASS'];
}
- }
- public function checkData($data)
- {
- $umsatz = [
- 'EtikettKz' => 'E', // E = EAN, I = Ident, W = Warengruppe
- 'Etikettnummer'=> $data['sku'], // mit führenden Nullen bei Satzart „W“ die Warengruppennummer
- 'Warengruppennummer'=> '0000', // mit führenden Nullen
- 'Groessenbez'=> '',
- 'Kundennummer'=> '00000000000000000000',
- 'Nachlassart'=> '0',
- 'Menge'=> '00000000000000000000', //7 Vor – und 2 Nachkommastellen (Darstellung ohne Komma mit führenden Nullen).
- 'Kalk-VkPreis'=> '00000000000000000000', //7 Vor – und 2 Nachkommastellen (Darstellung ohne Komma mit führenden Nullen).
- 'Vorgangsart'=> 'v', // u = Umtausch, v = Verkauf
- 'Belegnummer'=> '00000000000000000000', // mit führenden Nullen
- 'Verkaufsdatum'=> '00000000', // YYYYMMTT
- 'Verkaufszeit'=> '000000', // HHMM
- 'Zahlungsart'=>2, // 1 = Kreditkarte, 2 = Rechnung, 3 = Lastschrift, 4 = Gutschein, 5 = Gutschrift, 6 = Mischzahlung
- 'Währung'=> 'EUR', // EUR
- 'Einheit'=> 'S', // S= Stück, M = Meter
- 'Vertriebskanal'=> '0000', // Vertriebskanäle werden über das Stammdatenprogramm angelegt und müssen mit der hinterlegten Nummer aus dem Webshop übergeben werden
- ];
+ public function import()
+ {
- $kunde = [
- 'Kunden-Nummer'=> '00000000000000000000', // mit führenden Nullen
- 'Kartennummer'=> '00000000000000000000', // mit führenden Nullen
- 'Nachname'=> '00000000000000000000', // mit führenden Nullen
- 'Vorname'=> '00000000000000000000', // mit führenden Nullen
- 'Ort'=> '00000000000000000000', // mit führenden Nullen
- 'PLZ'=> '00000000000000000000', // mit führenden Nullen
- 'Straße'=> '00000000000000000000', // mit führenden Nullen
- 'Land'=> '00000000000000000000', // mit führenden Nullen
- 'Postfach'=> '00000000000000000000', // mit führenden Nullen
- 'PostfachPLZ'=> '00000000000000000000', // mit führenden Nullen
- 'Titel'=> '00000000000000000000', // mit führenden Nullen
- 'Telefon1'=> '00000000000000000000', // mit führenden Nullen
- 'Telefon2'=> '00000000000000000000', // mit führenden Nullen
- 'Telefax'=> '00000000000000000000', // mit führenden Nullen
- 'Geburtsdatum'=> '00000000', // YYYYMMDD
- 'Geschlecht'=> '00000000000000000000', // s = sonstiges, m = männlich, w = weiblich
- 'Email'=> '00000000000000000000', // mit führenden Nullen
- 'Rabatt'=> '00000000000000000000', // mit führenden Nullen
- 'Limit'=> '00000000000000000000', // mit führenden Nullen
- 'Sperr Kennzeichen'=> '0', // 0 = nicht gesperrt, 1 = gesperrt
- 'Dubios Kennzeichen'=> '0', // 0 = nicht dubios, 1 = dubios
- 'Bankeinzug'=> '0', // 0 = kein Bankeinzug, 1 = Bankeinzug
- 'BankName1'=> '00000000000000000000', // mit führenden Nullen
- 'Konto1'=> '00000000000000000000', // mit führenden Nullen
- 'BLZ1'=> '00000000000000000000', // mit führenden Nullen
- 'BankName2'=> '00000000000000000000', // mit führenden Nullen
- 'Konto2'=> '00000000000000000000', // mit führenden Nullen
- 'BLZ2'=> '00000000000000000000', // mit führenden Nullen
- 'BankName3'=> '00000000000000000000', // mit führenden Nullen
- 'Konto3'=> '00000000000000000000', // mit führenden Nullen
- 'BLZ3'=> '00000000000000000000', // mit führenden Nullen
- 'Kreditkartennummer Kreditkarte1'=> '', // mit führenden Nullen
- 'Kreditkartennummer Kreditkarte2'=> '', // mit führenden Nullen
- 'Kreditkartennummer Kreditkarte3'=> '', // mit führenden Nullen
- 'Kreditkartennummer Kreditkarte4'=> '', // mit führenden Nullen
- 'Änderungskennzeichen'=> '0', // 0 = Kunde ist OK, 1 = Änderung
- 'Newsletter'=> '0', // 0 = kein Newsletter, 1 = Newsletter
- 'Passwort'=> '', //
- 'Werbesperre'=> '0', // 0 = keine Werbung, 1 = Werbung
- ];
- }
- public function createJson($data){
- $arr = array(
- 'File' => array(
- "BranchNumber" => $data['BranchNumber'], #Die Filialnummer
- "ShopNumber" => $data['ShopNumber'], #Die Shopnummer
- "SalesDate" => $data['SalesDate'], #Das Umsatzdatu
- "DistributionChannel" => $data['DistributionChannel'] #Der Vertriebskanal
- ),
- 'SaleList' => array(
- ),
- 'CustomerList' => array(
- ),
- );
- #*** Sale List
- if(!empty($data['SaleList'])){
- foreach ($data['SaleList'] as $v){
- $arr['SaleList'][] = array(
- "SalesLabel" => $v['SalesLabel'], #Das Etikettkennzeichen
- "SalesLabelNumber" => $v['SalesLabelNumber'], #Etikettennummer
- "SalesGoodsGroupNumber" => $v['SalesGoodsGroupNumber'],
- #"SizeDescription" => $v['SizeDescription'],
- #"CustomerNumber" => $v['CustomerNumber'],
- #"TypeOfEstate" => $v['TypeOfEstate'],
- "Amount" => $v['Amount'],
- "CalculatedSellingPrice" => $v['CalculatedSellingPrice'],
- "AchievedSalesPrice" => $v['AchievedSalesPrice'],
- "TransactionType" => $v['TransactionType'],
- #"ReceiptNumber" => $v['ReceiptNumber'],
- "DateOfSale" => $data['SalesDate'],#"2023-09-14T11:54:26.708Z",
- "PaymentMethod" => $v['PaymentMethod'],
- "Currency" => $v['Currency'],
- "Unit" => $v['Unit'],
- "DistributionChannel" => $v['DistributionChannel']
- );
- }
- }
- #*** Sale List
- if(true){
- foreach ($data['CustomerList'] as $v){
- $arr['CustomerList'][] = array(
- "CustomerNumber" => $v['CustomerNumber'],
- #"CardNumber" => $v['CardNumber'],
- #"SalutionNumber" => $v['SalutionNumber'],
- "Surname" => $v['Surname'],
- "Forename" => $v['Forename'],
- "AddressCity" => $v['AddressCity'],
- "AddressZipCode" => $v['AddressZipCode'],
- "AddressStreet" => $v['AddressStreet'],
- "AddressCountry" => $v['AddressCountry'],
- #"PostOfficeBox" => $v['PostOfficeBox'],
- #"PostOfficeBoxZipCode" => $v['PostOfficeBoxZipCode'],
- #"Title" => $v['Title'],
- #"PhoneNumber1" => $v['PhoneNumber1'],
- #"PhoneNumber2" => $v['PhoneNumber2'],
- #"FaxNumber" => $v['FaxNumber'],#"string",
- #"BirthDay" => $v['BirthDay'],
- #"Gender" => $v['Gender'],
- #"EmailAddress" => $v['EmailAddress'],
- #"Discount" => $v['Discount'],
- #"Limit" => $v['Limit'],
- #"LockMark" => $v['LockMark'],
- #"DubiousMark" => $v['DubiousMark'],
- #"DubiousText" => $v['DubiousText'],
- #"DirectDebit" => $v['DirectDebit'],
- #"BankName1" => $v['BankName1'],#"string",
- #"BankAccountNumber1" => $v['BankAccountNumber1'],#"string",
- #"BankCodeNumber1" => $v['BankCodeNumber1'],#"string",
- #"BankName2" => $v['BankName2'],#"string",
- #"BankAccountNumber2" => $v['BankAccountNumber2'],#"string",
- #"BankCodeNumber2" => $v['BankCodeNumber2'],#"string",
- #"BankName3" => $v['BankName3'],#"string",
- #"BankAccountNumber3" => $v['BankAccountNumber3'],#"string",
- #"BankCodeNumber3" => $v['BankCodeNumber3'],#"string",
- #"CreditcardNumber1" => $v['CreditcardNumber1'],#"string",
- #"CreditcardNumber2" => $v['CreditcardNumber2'],#"string",
- #"CreditcardNumber3" => $v['CreditcardNumber3'],#"string",
- #"CreditcardNumber4" => $v['CreditcardNumber4'],#"string",
- #"ChangeIndicator" => $v['ChangeIndicator'],
- #"Newsletter" => $v['Newsletter'],
- #"Password" => $v['Password'],
- #"AdBan" => $v['AdBan']
- );
- }
- }
- #dump($arr);
- return $arr;
- }
- public function sendToHiltes($url,$param,$auth=false){
- if($auth){
- #var_export($this->hiltesApiHash);
- #var_export($url);
- #var_export($param);
+ $finder = new Finder();
+ $finder->files()->in($this->current_dir_path . "/hiltes/h2c/");
- }
+ foreach ($finder as $file) {
+ $contents = $file->getContents();
- $ch = curl_init($url);
- if($auth){
- $authorization = "Authorization: Bearer ".$this->hiltesApiHash;
- }else{
- $authorization = false;
- }
-#dump($param);
-# Setup request to send json via POST.
- $payload = json_encode( $param );
-#dump($payload);
- curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json',$authorization));
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
-# Return response instead of printing.
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
-# Send request.
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- public function loginToHiltes($usr,$pass){
- $url = $this->hiltesApiUrl.'/api/Authentication/authenticate';
- /*
- {
- "Username": "string",
- "Password": "string"
- }
- */
- $param = array(
- 'Username' => (!empty($usr) ? $usr : $this->hiltesUsr),
- 'Password' => (!empty($pass) ? $pass : $this->hiltesPass),
+ var_dump($contents);
+ }
+
+ }
+
+ /**
+ * @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();
+ }
+ }
+
+ /**
+ * 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 createRequest($orderData)
+ {
+
+ dump($orderData);
+
+ $data = array();
+ $this->loginToHiltes('', '');
+
+
+ $order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
+
+
+ dump($order);
+ /**
+ * @var Order
+ */
+ if ($order) {
+
+
+ //foreach ($orders as $order) {
+ // if ($order->getStatus() > 0) continue;
+ $tA = $order->getData();#json_decode($order->getData());
+ #$tA['orderdate'] = "2023-08-30T12:05:24.000Z";
+
+ dump($tA);
+ #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', $tA['orderdate'] ? strtotime($tA['orderdate']) : time());
+ #****
+ $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" => 5,
+ );
+
+ }
+ }
+ #*** Kundne *******************************
+ $arr['CustomerList'][] = array(
+ "CustomerNumber" => $tA['kundennummer'], # 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
+ );
+
+ dd($arr);
+
+ $data = $this->createJson($arr);
+ // }
+
+ return $this->sendOrderToHiltes($data);
+
+
+ }
+
+ }
+
+ /**
+ * @param $usr
+ * @param $pass
+ * @return bool
+ */
+ public function loginToHiltes($usr, $pass): bool
+ {
+ $url = $this->hiltesApiUrl . '/api/Authentication/authenticate';
+
+ $param = array(
+ 'Username' => (!empty($usr) ? $usr : $this->hiltesUsr),
+ 'Password' => (!empty($pass) ? $pass : $this->hiltesPass),
# 'parse_mode' => 'html',
# 'disable_notification' => $disable_notification,
# 'text' => $message_text
- );
- $r = $this->sendToHiltes($url,$param);
- $t = json_decode($r,true);
- if($t['Success']){
- $this->hiltesApiHash = $t['Data'];
- return true;
- }else{
- dump($r);
- dump('Login Error '.__LINE__);
- return false;
- }
- }
- public function sendOrderToHiltes($data){
- $url = $this->hiltesApiUrl.'/api/WebSale/import';
- /*
- {
- "Username": "string",
- "Password": "string"
- }
- */
- $param = $data;
- dump($param);
- $r = $this->sendToHiltes($url,$param,true);
- $t = json_decode($r,true);
- if($t['Success']){
- $this->hiltesApiHash = $t['Data'];
- }else{
- dump($r);
- dd('Submit Error'.__LINE__);
- }
- }
+ );
+
+ $r = $this->sendToHiltes($url, $param);
+ $t = json_decode($r, true);
+ if ($t['Success']) {
+ $this->hiltesApiHash = $t['Data'];
+ return true;
+ } else {
+ dump($r);
+ dump('Login Error ' . __LINE__);
+ return false;
+ }
+ }
+
+ public function sendToHiltes($url, $param, $auth = false)
+ {
+ if ($auth) {
+ #var_export($this->hiltesApiHash);
+ #var_export($url);
+ #var_export($param);
+
+ }
+
+ $ch = curl_init($url);
+ if ($auth) {
+ $authorization = "Authorization: Bearer " . $this->hiltesApiHash;
+ } else {
+ $authorization = false;
+ }
+#dump($param);
+# Setup request to send json via POST.
+ $payload = json_encode($param);
+#dump($payload);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $authorization));
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
+# Return response instead of printing.
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+# Send request.
+ $result = curl_exec($ch);
+ curl_close($ch);
+ return $result;
+ }
+
+ public function createJson($data)
+ {
+ $arr = array(
+ 'File' => array(
+ "BranchNumber" => $data['BranchNumber'], #Die Filialnummer
+ "ShopNumber" => $data['ShopNumber'], #Die Shopnummer
+ "SalesDate" => $data['SalesDate'], #Das Umsatzdatu
+ "DistributionChannel" => $data['DistributionChannel'] #Der Vertriebskanal
+ ),
+ 'SaleList' => array(),
+ 'CustomerList' => array(),
+ );
+ #*** Sale List
+ if (!empty($data['SaleList'])) {
+ foreach ($data['SaleList'] as $v) {
+ $arr['SaleList'][] = array(
+ "SalesLabel" => $v['SalesLabel'], #Das Etikettkennzeichen
+ "SalesLabelNumber" => $v['SalesLabelNumber'], #Etikettennummer
+ "SalesGoodsGroupNumber" => $v['SalesGoodsGroupNumber'],
+ #"SizeDescription" => $v['SizeDescription'],
+ #"CustomerNumber" => $v['CustomerNumber'],
+ #"TypeOfEstate" => $v['TypeOfEstate'],
+ "Amount" => $v['Amount'],
+ "CalculatedSellingPrice" => $v['CalculatedSellingPrice'],
+ "AchievedSalesPrice" => $v['AchievedSalesPrice'],
+ "TransactionType" => $v['TransactionType'],
+ #"ReceiptNumber" => $v['ReceiptNumber'],
+ "DateOfSale" => $data['SalesDate'],#"2023-09-14T11:54:26.708Z",
+ "PaymentMethod" => $v['PaymentMethod'],
+ "Currency" => $v['Currency'],
+ "Unit" => $v['Unit'],
+ "DistributionChannel" => $v['DistributionChannel']
+ );
+ }
+ }
+ #*** Sale List
+ if (true) {
+ foreach ($data['CustomerList'] as $v) {
+ $arr['CustomerList'][] = array(
+ "CustomerNumber" => $v['CustomerNumber'],
+ #"CardNumber" => $v['CardNumber'],
+ #"SalutionNumber" => $v['SalutionNumber'],
+ "Surname" => $v['Surname'],
+ "Forename" => $v['Forename'],
+ "AddressCity" => $v['AddressCity'],
+ "AddressZipCode" => $v['AddressZipCode'],
+ "AddressStreet" => $v['AddressStreet'],
+ "AddressCountry" => $v['AddressCountry'],
+ #"PostOfficeBox" => $v['PostOfficeBox'],
+ #"PostOfficeBoxZipCode" => $v['PostOfficeBoxZipCode'],
+ #"Title" => $v['Title'],
+ #"PhoneNumber1" => $v['PhoneNumber1'],
+ #"PhoneNumber2" => $v['PhoneNumber2'],
+ #"FaxNumber" => $v['FaxNumber'],#"string",
+ #"BirthDay" => $v['BirthDay'],
+ #"Gender" => $v['Gender'],
+ #"EmailAddress" => $v['EmailAddress'],
+ #"Discount" => $v['Discount'],
+ #"Limit" => $v['Limit'],
+ #"LockMark" => $v['LockMark'],
+ #"DubiousMark" => $v['DubiousMark'],
+ #"DubiousText" => $v['DubiousText'],
+ #"DirectDebit" => $v['DirectDebit'],
+ #"BankName1" => $v['BankName1'],#"string",
+ #"BankAccountNumber1" => $v['BankAccountNumber1'],#"string",
+ #"BankCodeNumber1" => $v['BankCodeNumber1'],#"string",
+ #"BankName2" => $v['BankName2'],#"string",
+ #"BankAccountNumber2" => $v['BankAccountNumber2'],#"string",
+ #"BankCodeNumber2" => $v['BankCodeNumber2'],#"string",
+ #"BankName3" => $v['BankName3'],#"string",
+ #"BankAccountNumber3" => $v['BankAccountNumber3'],#"string",
+ #"BankCodeNumber3" => $v['BankCodeNumber3'],#"string",
+ #"CreditcardNumber1" => $v['CreditcardNumber1'],#"string",
+ #"CreditcardNumber2" => $v['CreditcardNumber2'],#"string",
+ #"CreditcardNumber3" => $v['CreditcardNumber3'],#"string",
+ #"CreditcardNumber4" => $v['CreditcardNumber4'],#"string",
+ #"ChangeIndicator" => $v['ChangeIndicator'],
+ #"Newsletter" => $v['Newsletter'],
+ #"Password" => $v['Password'],
+ #"AdBan" => $v['AdBan']
+ );
+ }
+ }
+ #dump($arr);
+ return $arr;
+ }
+
+ public function sendOrderToHiltes($data)
+ {
+ $url = $this->hiltesApiUrl . '/api/WebSale/import';
+
+ $param = $data;
+ dump($param);
+ $r = $this->sendToHiltes($url, $param, true);
+ $t = json_decode($r, true);
+ if ($t['Success']) {
+ return true;
+ } else {
+ dump($r);
+ return false;
+ }
+ }
+
+ public function checkData($data)
+ {
+ $umsatz = [
+ 'EtikettKz' => 'E', // E = EAN, I = Ident, W = Warengruppe
+ 'Etikettnummer' => $data['sku'], // mit führenden Nullen bei Satzart „W“ die Warengruppennummer
+ 'Warengruppennummer' => '0000', // mit führenden Nullen
+ 'Groessenbez' => '',
+ 'Kundennummer' => '00000000000000000000',
+ 'Nachlassart' => '0',
+ 'Menge' => '00000000000000000000', //7 Vor – und 2 Nachkommastellen (Darstellung ohne Komma mit führenden Nullen).
+ 'Kalk-VkPreis' => '00000000000000000000', //7 Vor – und 2 Nachkommastellen (Darstellung ohne Komma mit führenden Nullen).
+ 'Vorgangsart' => 'v', // u = Umtausch, v = Verkauf
+ 'Belegnummer' => '00000000000000000000', // mit führenden Nullen
+ 'Verkaufsdatum' => '00000000', // YYYYMMTT
+ 'Verkaufszeit' => '000000', // HHMM
+ 'Zahlungsart' => 2, // 1 = Kreditkarte, 2 = Rechnung, 3 = Lastschrift, 4 = Gutschein, 5 = Gutschrift, 6 = Mischzahlung
+ 'Währung' => 'EUR', // EUR
+ 'Einheit' => 'S', // S= Stück, M = Meter
+ 'Vertriebskanal' => '0000', // Vertriebskanäle werden über das Stammdatenprogramm angelegt und müssen mit der hinterlegten Nummer aus dem Webshop übergeben werden
+ ];
+
+ $kunde = [
+ 'Kunden-Nummer' => '00000000000000000000', // mit führenden Nullen
+ 'Kartennummer' => '00000000000000000000', // mit führenden Nullen
+ 'Nachname' => '00000000000000000000', // mit führenden Nullen
+ 'Vorname' => '00000000000000000000', // mit führenden Nullen
+ 'Ort' => '00000000000000000000', // mit führenden Nullen
+ 'PLZ' => '00000000000000000000', // mit führenden Nullen
+ 'Straße' => '00000000000000000000', // mit führenden Nullen
+ 'Land' => '00000000000000000000', // mit führenden Nullen
+ 'Postfach' => '00000000000000000000', // mit führenden Nullen
+ 'PostfachPLZ' => '00000000000000000000', // mit führenden Nullen
+ 'Titel' => '00000000000000000000', // mit führenden Nullen
+ 'Telefon1' => '00000000000000000000', // mit führenden Nullen
+ 'Telefon2' => '00000000000000000000', // mit führenden Nullen
+ 'Telefax' => '00000000000000000000', // mit führenden Nullen
+ 'Geburtsdatum' => '00000000', // YYYYMMDD
+ 'Geschlecht' => '00000000000000000000', // s = sonstiges, m = männlich, w = weiblich
+ 'Email' => '00000000000000000000', // mit führenden Nullen
+ 'Rabatt' => '00000000000000000000', // mit führenden Nullen
+ 'Limit' => '00000000000000000000', // mit führenden Nullen
+ 'Sperr Kennzeichen' => '0', // 0 = nicht gesperrt, 1 = gesperrt
+ 'Dubios Kennzeichen' => '0', // 0 = nicht dubios, 1 = dubios
+ 'Bankeinzug' => '0', // 0 = kein Bankeinzug, 1 = Bankeinzug
+ 'BankName1' => '00000000000000000000', // mit führenden Nullen
+ 'Konto1' => '00000000000000000000', // mit führenden Nullen
+ 'BLZ1' => '00000000000000000000', // mit führenden Nullen
+ 'BankName2' => '00000000000000000000', // mit führenden Nullen
+ 'Konto2' => '00000000000000000000', // mit führenden Nullen
+ 'BLZ2' => '00000000000000000000', // mit führenden Nullen
+ 'BankName3' => '00000000000000000000', // mit führenden Nullen
+ 'Konto3' => '00000000000000000000', // mit führenden Nullen
+ 'BLZ3' => '00000000000000000000', // mit führenden Nullen
+ 'Kreditkartennummer Kreditkarte1' => '', // mit führenden Nullen
+ 'Kreditkartennummer Kreditkarte2' => '', // mit führenden Nullen
+ 'Kreditkartennummer Kreditkarte3' => '', // mit führenden Nullen
+ 'Kreditkartennummer Kreditkarte4' => '', // mit führenden Nullen
+ 'Änderungskennzeichen' => '0', // 0 = Kunde ist OK, 1 = Änderung
+ 'Newsletter' => '0', // 0 = kein Newsletter, 1 = Newsletter
+ 'Passwort' => '', //
+ 'Werbesperre' => '0', // 0 = keine Werbung, 1 = Werbung
+ ];
+ }
}
\ No newline at end of file
diff --git a/src/Helper/Slack.php b/src/Helper/Slack.php
index 3e1bb09..6cab4e9 100644
--- a/src/Helper/Slack.php
+++ b/src/Helper/Slack.php
@@ -23,7 +23,6 @@ class Slack
try {
$sentMessage = $this->chatter->send($message);
- dump($sentMessage);
} catch (TransportExceptionInterface $e) {
}