Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit 0729b532 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: complete refactor - quiqqer v2 compatibility

Übergeordneter 9133c66b
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
3 Merge Requests!81fix(CouponCodeInput): mobile buttons adjusted,!80fix(CouponCodeInput): mobile buttons adjusted,!79feat!: quiqqer v2
werden angezeigt mit 52 Ergänzungen und 45 Löschungen
......@@ -17,7 +17,7 @@ function (int $orderId) {
$Order = $Handler->get($orderId);
$SalesOrder = $Order->createSalesOrder();
return $SalesOrder->getHash();
return $SalesOrder->getUUID();
},
['orderId'],
'Permission::checkAdminUser'
......
......@@ -16,7 +16,7 @@
function ($orderId) {
try {
return Handler::getInstance()->get($orderId)->toArray();
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
return Handler::getInstance()->getOrderByHash($orderId)->toArray();
......
......@@ -11,6 +11,10 @@
*
* @return array
*/
use QUI\ERP\Accounting\Payments\Transactions\Transaction;
use QUI\ERP\Order\Order;
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_backend_getHistory',
function ($orderId) {
......@@ -18,44 +22,44 @@ function ($orderId) {
try {
$Order = $Orders->get($orderId);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
$Order = $Orders->getOrderByHash($orderId);
}
/* @var $Order \QUI\ERP\Order\Order */
/* @var $Order Order */
QUI\ERP\Accounting\Calc::calculatePayments($Order);
$History = $Order->getHistory();
$history = \array_map(function ($history) {
$history = array_map(function ($history) {
$history['type'] = 'history';
return $history;
}, $History->toArray());
$Comments = $Order->getComments();
$comments = \array_map(function ($comment) {
$comments = array_map(function ($comment) {
$comment['type'] = 'comment';
return $comment;
}, $Comments->toArray());
$history = \array_merge($history, $comments);
$history = array_merge($history, $comments);
// transactions
$Transactions = QUI\ERP\Accounting\Payments\Transactions\Handler::getInstance();
$transactions = $Transactions->getTransactionsByHash($Order->getHash());
$transactions = $Transactions->getTransactionsByHash($Order->getUUID());
foreach ($transactions as $Tx) {
/* @var $Tx \QUI\ERP\Accounting\Payments\Transactions\Transaction */
/* @var $Tx Transaction */
$history[] = [
'message' => $Tx->parseToText(),
'time' => \strtotime($Tx->getDate()),
'time' => strtotime($Tx->getDate()),
'type' => 'transaction',
];
}
// sort
\usort($history, function ($a, $b) {
usort($history, function ($a, $b) {
if ($a['time'] == $b['time']) {
return 0;
}
......
......@@ -19,7 +19,7 @@ function ($orderHash, $txId) {
$Transaction = TransactionHandler::getInstance()->get(Orthos::clear($txId));
if ($Transaction->isHashLinked($Order->getHash())) {
if ($Transaction->isHashLinked($Order->getUUID())) {
throw new Exception([
'quiqqer/order',
'message.ajax.backend.linkTransaction.error.tx_already_linked',
......
......@@ -23,7 +23,7 @@ function ($params) {
$query = $Grid->parseDBParams(json_decode($params, true));
if (isset($query['limit'])) {
$limit = \explode(',', $query['limit']);
$limit = explode(',', $query['limit']);
$Search->limit($limit[0], $limit[1]);
}
......
......@@ -12,7 +12,7 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_backend_payments_format',
function ($payments) {
$payments = \json_decode($payments, true);
$payments = json_decode($payments, true);
$result = [];
$Locale = QUI::getLocale();
......@@ -21,23 +21,23 @@ function ($payments) {
foreach ($payments as $payment) {
$paymentTitle = '';
$txid = '';
$txId = '';
try {
$Payment = $Payments->getPaymentType($payment['payment']);
$paymentTitle = $Payment->getTitle();
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
if (isset($payment['txid'])) {
$txid = $payment['txid'];
$txId = $payment['txid'];
}
$result[] = [
'date' => $Locale->formatDate($payment['date']),
'amount' => $Currency->format($payment['amount']),
'payment' => $paymentTitle,
'txid' => $txid
'txid' => $txId
];
}
......
......@@ -12,7 +12,7 @@
function ($orderId, $onlyArticles) {
try {
$Order = QUI\ERP\Order\Handler::getInstance()->get($orderId);
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
$Order = QUI\ERP\Order\Handler::getInstance()->getOrderByHash($orderId);
}
......
......@@ -21,7 +21,7 @@ function ($id, $color, $title, $notification) {
Factory::getInstance()->createProcessingStatus(
$id,
Orthos::clear($color),
Orthos::clearArray(\json_decode($title, true))
Orthos::clearArray(json_decode($title, true))
);
Handler::getInstance()->setProcessingStatusNotification($id, boolval($notification));
......
......@@ -21,7 +21,7 @@ function ($id, $orderId) {
$Order = Orders::getInstance()->get($orderId);
return Handler::getInstance()->getProcessingStatus($id)->getStatusChangeNotificationText($Order);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
return '';
......
......@@ -4,6 +4,7 @@
* This file contains package_quiqqer_order_ajax_backend_processingStatus_list
*/
use QUI\ERP\Accounting\Invoice\ProcessingStatus\Status;
use QUI\ERP\Order\ProcessingStatus\Handler;
/**
......@@ -18,12 +19,12 @@ function () {
$Handler = Handler::getInstance();
$list = $Handler->getProcessingStatusList();
$result = \array_map(function ($Status) {
/* @var $Status \QUI\ERP\Accounting\Invoice\ProcessingStatus\Status */
$result = array_map(function ($Status) {
/* @var $Status Status */
return $Status->toArray(QUI::getLocale());
}, $list);
\usort($result, function ($a, $b) {
usort($result, function ($a, $b) {
if ($a['id'] == $b['id']) {
return 0;
}
......
......@@ -5,7 +5,7 @@
*
* @param int $id - ProcessingStatus ID
* @param string $color - hex color code
* @param array $title - (multilignual) titel
* @param array $title - (multilingual) title
* @param bool $notification - send auto-notification on status change
*/
......@@ -21,7 +21,7 @@ function ($id, $color, $title, $notification) {
$Handler->updateProcessingStatus(
$id,
Orthos::clear($color),
Orthos::clearArray(\json_decode($title, true))
Orthos::clearArray(json_decode($title, true))
);
$Handler->setProcessingStatusNotification($id, boolval($notification));
......
......@@ -16,7 +16,7 @@ function ($orderId) {
try {
$Order = $Orders->get($orderId);
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
$Order = $Orders->getOrderByHash($orderId);
}
......
......@@ -15,7 +15,7 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_backend_settings_paymentChangeable_save',
function ($data) {
$data = \json_decode($data, true);
$data = json_decode($data, true);
$Config = QUI::getPackage('quiqqer/order')->getConfig();
$payments = Payments::getInstance()->getPayments();
$section = $Config->getSection('paymentChangeable');
......
......@@ -4,6 +4,7 @@
* This file contains package_quiqqer_order_ajax_backend_update
*/
use QUI\ERP\Accounting\ArticleList;
use QUI\ERP\Accounting\PriceFactors\Factor;
use QUI\ERP\Accounting\PriceFactors\FactorList;
use QUI\ERP\Order\ProcessingStatus\Handler;
......@@ -106,16 +107,16 @@ function ($orderId, $data) {
$Order->setInvoiceAddress($data['addressInvoice']);
}
if (isset($data['addressDelivery']) && !empty($data['addressDelivery'])) {
if (!empty($data['addressDelivery'])) {
$Order->setDeliveryAddress($data['addressDelivery']);
} elseif (isset($data['addressDelivery']) && empty($data['addressDelivery'])) {
} elseif (isset($data['addressDelivery'])) {
$Order->removeDeliveryAddress();
}
if (isset($data['paymentId'])) {
try {
$Order->setPayment($data['paymentId']);
} catch (\Exception $Exception) {
} catch (Exception) {
}
}
......@@ -131,7 +132,7 @@ function ($orderId, $data) {
$data['notification']
);
}
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::addError($Exception->getMessage());
}
}
......@@ -148,7 +149,7 @@ function ($orderId, $data) {
$data['notificationShipping']
);
}
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
......@@ -184,14 +185,14 @@ function ($orderId, $data) {
$Order->addArticle(
new QUI\ERP\Accounting\Article($article)
);
} catch (\Exception) {
} catch (Exception) {
}
}
}
// import factor list
if (isset($data['priceFactors'])) {
/* @var $Articles \QUI\ERP\Accounting\ArticleList */
/* @var $Articles ArticleList */
/* @var $FactorList FactorList */
$Articles = $Order->getArticles();
$factors = [];
......
......@@ -23,9 +23,9 @@ function ($orderHash, $productId, $fields, $quantity) {
return;
}
$fields = \json_decode($fields, true);
$fields = json_decode($fields, true);
if (!\is_array($fields)) {
if (!is_array($fields)) {
$fields = [];
}
......
......@@ -42,7 +42,7 @@ function ($productId, $fields, $quantity) {
$Order->save();
return $Order->getHash();
return $Order->getUUID();
},
['productId', 'fields', 'quantity']
);
......@@ -15,7 +15,7 @@
'package_quiqqer_order_ajax_frontend_basket_calc',
function ($products) {
$Basket = new QUI\ERP\Order\Basket\BasketGuest();
$Basket->import(\json_decode($products, true));
$Basket->import(json_decode($products, true));
return $Basket->toArray();
},
......
......@@ -30,7 +30,7 @@ function ($basketId, $editable, $orderHash) {
}
$Control = new QUI\ERP\Order\Controls\Basket\Basket([
'editable' => \boolval($editable)
'editable' => boolval($editable)
]);
$Control->setBasket($Basket);
......
......@@ -14,8 +14,8 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_frontend_basket_controls_basketGuest',
function ($products, $options = '', $editable = true) {
if (isset($options) && !\is_array($options)) {
$options = \json_decode($options, true);
if (isset($options) && !is_array($options)) {
$options = json_decode($options, true);
if (empty($options)) {
$options = [];
......@@ -26,13 +26,14 @@ function ($products, $options = '', $editable = true) {
$editable = true;
}
$products = \json_decode($products, true);
$products = json_decode($products, true);
$Basket = new QUI\ERP\Order\Basket\BasketGuest();
$Basket->import($products);
$Control = new QUI\ERP\Order\Controls\Basket\Basket([
'editable' => \boolval($editable)
'editable' => boolval($editable)
]);
$Control->setAttributes($options);
$Control->setBasket($Basket);
......
......@@ -13,7 +13,7 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_order_ajax_frontend_basket_controls_smallGuest',
function ($products) {
$products = \json_decode($products, true);
$products = json_decode($products, true);
$Basket = new QUI\ERP\Order\Basket\BasketGuest();
$Basket->import($products);
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren