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

style: code style

Übergeordneter ba530815
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!5Next,!4style: code style
Pipeline-Nr. 4550 mit Warnungen bestanden
werden angezeigt mit 61 Ergänzungen und 59 Löschungen
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
* @param integer $shippingId * @param integer $shippingId
* @return array * @return array
*/ */
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_activate', 'package_quiqqer_shipping_ajax_backend_activate',
function ($shippingId) { function ($shippingId) {
$Shipping = new Factory(); $Shipping = new Factory();
$ShippingEntry = $Shipping->getChild($shippingId); $ShippingEntry = $Shipping->getChild($shippingId);
$ShippingEntry->activate(); $ShippingEntry->activate();
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
'package_quiqqer_shipping_ajax_backend_articleList_getShippingPriceFactor', 'package_quiqqer_shipping_ajax_backend_articleList_getShippingPriceFactor',
function ($shippingId) { function ($shippingId) {
$Shipping = Shipping::getInstance()->getShippingEntry($shippingId); $Shipping = Shipping::getInstance()->getShippingEntry($shippingId);
return [ return [
'title' => $Shipping->getTitle(), 'title' => $Shipping->getTitle(),
'price' => $Shipping->getPrice() 'price' => $Shipping->getPrice()
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* This file contains package_quiqqer_shipping_ajax_backend_create * This file contains package_quiqqer_shipping_ajax_backend_create
*/ */
use \QUI\ERP\Shipping\Types\Factory; use QUI\ERP\Shipping\Shipping;
use \QUI\ERP\Shipping\Shipping; use QUI\ERP\Shipping\Types\Factory;
/** /**
* Create a new shipping method * Create a new shipping method
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
function ($shippingType) { function ($shippingType) {
$Type = Shipping::getInstance()->getShippingType($shippingType); $Type = Shipping::getInstance()->getShippingType($shippingType);
$Factory = new Factory(); $Factory = new Factory();
$Shipping = $Factory->createChild([ $Shipping = $Factory->createChild([
'shipping_type' => $Type->getType() 'shipping_type' => $Type->getType()
]); ]);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This file contains package_quiqqer_shipping_ajax_backend_deactivate * This file contains package_quiqqer_shipping_ajax_backend_deactivate
*/ */
use \QUI\ERP\Shipping\Types\Factory; use QUI\ERP\Shipping\Types\Factory;
/** /**
* Deactivate a shipping * Deactivate a shipping
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_deactivate', 'package_quiqqer_shipping_ajax_backend_deactivate',
function ($shippingId) { function ($shippingId) {
$factory = new Factory(); $factory = new Factory();
$Shipping = $factory->getChild($shippingId); $Shipping = $factory->getChild($shippingId);
$Shipping->deactivate(); $Shipping->deactivate();
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
'package_quiqqer_shipping_ajax_backend_getShippingList', 'package_quiqqer_shipping_ajax_backend_getShippingList',
function () { function () {
$shippingEntries = Shipping::getInstance()->getShippingList(); $shippingEntries = Shipping::getInstance()->getShippingList();
$result = []; $result = [];
foreach ($shippingEntries as $ShippingEntry) { foreach ($shippingEntries as $ShippingEntry) {
/* @var $ShippingEntry ShippingEntry */ /* @var $ShippingEntry ShippingEntry */
...@@ -25,7 +25,7 @@ function () { ...@@ -25,7 +25,7 @@ function () {
$current = QUI::getLocale()->getCurrent(); $current = QUI::getLocale()->getCurrent();
\usort($result, function ($a, $b) use ($current) { usort($result, function ($a, $b) use ($current) {
$aTitle = $a['title'][$current]; $aTitle = $a['title'][$current];
$bTitle = $b['title'][$current]; $bTitle = $b['title'][$current];
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This file contains package_quiqqer_shipping_ajax_backend_create * This file contains package_quiqqer_shipping_ajax_backend_create
*/ */
use \QUI\ERP\Shipping\Rules\Factory; use QUI\ERP\Shipping\Rules\Factory;
/** /**
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_rules_create', 'package_quiqqer_shipping_ajax_backend_rules_create',
function ($rules) { function ($rules) {
$rules = \json_decode($rules, true); $rules = json_decode($rules, true);
$Factory = new Factory(); $Factory = new Factory();
$Rule = $Factory->createChild($rules); $Rule = $Factory->createChild($rules);
return $Rule->getId(); return $Rule->getId();
}, },
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
use QUI\ERP\Shipping\Rules\Factory; use QUI\ERP\Shipping\Rules\Factory;
use QUI\ExceptionStack;
/** /**
* Delete the shipping rule(s) * Delete the shipping rule(s)
...@@ -15,10 +14,10 @@ ...@@ -15,10 +14,10 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_rules_delete', 'package_quiqqer_shipping_ajax_backend_rules_delete',
function ($ruleIds) { function ($ruleIds) {
$ruleIds = \json_decode($ruleIds, true); $ruleIds = json_decode($ruleIds, true);
$Factory = new Factory(); $Factory = new Factory();
if (!\is_array($ruleIds)) { if (!is_array($ruleIds)) {
$ruleIds = [$ruleIds]; $ruleIds = [$ruleIds];
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_rules_getList', 'package_quiqqer_shipping_ajax_backend_rules_getList',
function ($options) { function ($options) {
$options = \json_decode($options, true); $options = json_decode($options, true);
if (!is_array($options)) { if (!is_array($options)) {
$options = []; $options = [];
...@@ -44,8 +44,8 @@ function ($options) { ...@@ -44,8 +44,8 @@ function ($options) {
} }
$Factory = QUI\ERP\Shipping\Rules\Factory::getInstance(); $Factory = QUI\ERP\Shipping\Rules\Factory::getInstance();
$Grid = new Grid(); $Grid = new Grid();
$query = $Grid->parseDBParams($options); $query = $Grid->parseDBParams($options);
if (!isset($query['order'])) { if (!isset($query['order'])) {
$query['order'] = 'priority DESC'; $query['order'] = 'priority DESC';
...@@ -68,8 +68,8 @@ function ($options) { ...@@ -68,8 +68,8 @@ function ($options) {
$count = $Factory->countChildren($query); $count = $Factory->countChildren($query);
return [ return [
'data' => $result, 'data' => $result,
'page' => (int)$options['page'], 'page' => (int)$options['page'],
'total' => $count 'total' => $count
]; ];
}, },
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_rules_getRules', 'package_quiqqer_shipping_ajax_backend_rules_getRules',
function ($ruleIds) { function ($ruleIds) {
$ruleIds = \json_decode($ruleIds, true); $ruleIds = json_decode($ruleIds, true);
$Rules = QUI\ERP\Shipping\Rules\Factory::getInstance(); $Rules = QUI\ERP\Shipping\Rules\Factory::getInstance();
$result = []; $result = [];
if (!\is_array($ruleIds)) { if (!is_array($ruleIds)) {
$ruleIds = []; $ruleIds = [];
} }
...@@ -30,7 +30,7 @@ function ($ruleIds) { ...@@ -30,7 +30,7 @@ function ($ruleIds) {
} }
// sort by priority // sort by priority
\usort($result, function ($a, $b) { usort($result, function ($a, $b) {
if (!isset($a['priority'])) { if (!isset($a['priority'])) {
$a['priority'] = 0; $a['priority'] = 0;
} }
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_rules_settings_getUnitFieldSetting', 'package_quiqqer_shipping_ajax_backend_rules_settings_getUnitFieldSetting',
function () { function () {
$result = []; $result = [];
$Shipping = \QUI\ERP\Shipping\Shipping::getInstance(); $Shipping = \QUI\ERP\Shipping\Shipping::getInstance();
$ids = $Shipping->getShippingRuleUnitFieldIds(); $ids = $Shipping->getShippingRuleUnitFieldIds();
foreach ($ids as $id) { foreach ($ids as $id) {
try { try {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This file contains package_quiqqer_shipping_ajax_backend_rules_update * This file contains package_quiqqer_shipping_ajax_backend_rules_update
*/ */
use \QUI\ERP\Shipping\Rules\Factory; use QUI\ERP\Shipping\Rules\Factory;
/** /**
* Update a shipping method * Update a shipping method
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_rules_update', 'package_quiqqer_shipping_ajax_backend_rules_update',
function ($ruleId, $data) { function ($ruleId, $data) {
$data = \json_decode($data, true); $data = json_decode($data, true);
$Factory = new Factory(); $Factory = new Factory();
/* @var $Rule QUI\ERP\Shipping\Rules\ShippingRule */ /* @var $Rule QUI\ERP\Shipping\Rules\ShippingRule */
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* This file contains package_quiqqer_shipping_ajax_backend_shippingStatus_getNotificationText * This file contains package_quiqqer_shipping_ajax_backend_shippingStatus_getNotificationText
*/ */
use QUI\ERP\Shipping\ShippingStatus\Handler;
use QUI\ERP\Order\Handler as OrderHandler; use QUI\ERP\Order\Handler as OrderHandler;
use QUI\ERP\Shipping\ShippingStatus\Handler;
/** /**
* Get status change notification text for a specific order * Get status change notification text for a specific order
......
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_shippingStatus_list', 'package_quiqqer_shipping_ajax_backend_shippingStatus_list',
function () { function () {
$Grid = new QUI\Utils\Grid(); $Grid = new QUI\Utils\Grid();
$Handler = Handler::getInstance(); $Handler = Handler::getInstance();
$list = $Handler->getShippingStatusList(); $list = $Handler->getShippingStatusList();
$result = \array_map(function ($Status) { $result = \array_map(function ($Status) {
/* @var $Status \QUI\ERP\Shipping\ShippingStatus\Status */ /* @var $Status \QUI\ERP\Shipping\ShippingStatus\Status */
return $Status->toArray(QUI::getLocale()); return $Status->toArray(QUI::getLocale());
}, $list); }, $list);
\usort($result, function ($a, $b) { usort($result, function ($a, $b) {
if ($a['id'] == $b['id']) { if ($a['id'] == $b['id']) {
return 0; return 0;
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_shippingStatus_update', 'package_quiqqer_shipping_ajax_backend_shippingStatus_update',
function ($id, $color, $title, $notification) { function ($id, $color, $title, $notification) {
$id = (int)$id; $id = (int)$id;
$Handler = Handler::getInstance(); $Handler = Handler::getInstance();
$Handler->updateShippingStatus( $Handler->updateShippingStatus(
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_shipping_ajax_backend_update', 'package_quiqqer_shipping_ajax_backend_update',
function ($shippingId, $data) { function ($shippingId, $data) {
$Factory = new Factory(); $Factory = new Factory();
$ShippingEntry = $Factory->getChild($shippingId); $ShippingEntry = $Factory->getChild($shippingId);
$data = \json_decode($data, true); $data = \json_decode($data, true);
......
...@@ -102,9 +102,9 @@ abstract public function getWorkingTitle(); ...@@ -102,9 +102,9 @@ abstract public function getWorkingTitle();
*/ */
public function getIcon() public function getIcon()
{ {
return QUI\ERP\Shipping\Shipping::getInstance()->getHost(). return QUI\ERP\Shipping\Shipping::getInstance()->getHost() .
URL_OPT_DIR URL_OPT_DIR
.'quiqqer/shipping/bin/images/shipping/default.png'; . 'quiqqer/shipping/bin/images/shipping/default.png';
} }
/** /**
...@@ -115,8 +115,8 @@ public function getIcon() ...@@ -115,8 +115,8 @@ public function getIcon()
public function toArray() public function toArray()
{ {
return [ return [
'name' => $this->getName(), 'name' => $this->getName(),
'title' => $this->getTitle(), 'title' => $this->getTitle(),
'description' => $this->getDescription() 'description' => $this->getDescription()
]; ];
} }
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
namespace QUI\ERP\Shipping\Api; namespace QUI\ERP\Shipping\Api;
use QUI;
/** /**
* Shipping provider * Shipping provider
* *
......
...@@ -36,7 +36,7 @@ public function toArray($Locale = null) ...@@ -36,7 +36,7 @@ public function toArray($Locale = null)
return [ return [
'title' => $this->getTitle($Locale), 'title' => $this->getTitle($Locale),
'type' => $this->getType() 'type' => $this->getType()
]; ];
} }
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
use QUI; use QUI;
use QUI\ERP\Areas\Utils as AreaUtils; use QUI\ERP\Areas\Utils as AreaUtils;
use QUI\ERP\Products\Handler\Products; use QUI\ERP\Products\Handler\Products;
use QUI\ERP\Shipping\Debug;
use QUI\ERP\Products\Product\Types\DigitalProduct; use QUI\ERP\Products\Product\Types\DigitalProduct;
use QUI\ERP\Shipping\Debug;
/** /**
* Class DigitalType * Class DigitalType
...@@ -33,9 +33,9 @@ public function getTitle($Locale = null) ...@@ -33,9 +33,9 @@ public function getTitle($Locale = null)
*/ */
public function getIcon() public function getIcon()
{ {
return QUI\ERP\Shipping\Shipping::getInstance()->getHost(). return QUI\ERP\Shipping\Shipping::getInstance()->getHost() .
URL_OPT_DIR URL_OPT_DIR
.'quiqqer/shipping/bin/images/shipping/download.png'; . 'quiqqer/shipping/bin/images/shipping/download.png';
} }
/** /**
...@@ -72,7 +72,7 @@ public function canUsedInOrder( ...@@ -72,7 +72,7 @@ public function canUsedInOrder(
if (!($Product instanceof DigitalProduct)) { if (!($Product instanceof DigitalProduct)) {
Debug::addLog( Debug::addLog(
"{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: contains at least one NON-DIGITAL" "{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: contains at least one NON-DIGITAL"
." product that must be shipped physically." . " product that must be shipped physically."
); );
return false; return false;
...@@ -83,7 +83,7 @@ public function canUsedInOrder( ...@@ -83,7 +83,7 @@ public function canUsedInOrder(
} }
// Check restriction to certain products / product categories // Check restriction to certain products / product categories
$articles = $ShippingEntry->getAttribute('articles'); $articles = $ShippingEntry->getAttribute('articles');
$categories = $ShippingEntry->getAttribute('categories'); $categories = $ShippingEntry->getAttribute('categories');
$toInt = function ($article) { $toInt = function ($article) {
...@@ -109,7 +109,7 @@ public function canUsedInOrder( ...@@ -109,7 +109,7 @@ public function canUsedInOrder(
return true; return true;
} }
$ArticleList = $Order->getArticles(); $ArticleList = $Order->getArticles();
$orderArticles = $ArticleList->getArticles(); $orderArticles = $ArticleList->getArticles();
foreach ($orderArticles as $Article) { foreach ($orderArticles as $Article) {
...@@ -117,13 +117,15 @@ public function canUsedInOrder( ...@@ -117,13 +117,15 @@ public function canUsedInOrder(
$productId = $Article->getId(); $productId = $Article->getId();
if (!empty($articles) && \in_array($productId, $articles)) { if (!empty($articles) && \in_array($productId, $articles)) {
Debug::addLog("{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: product {$productId} is in allowed list [ok]"); Debug::addLog(
"{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: product {$productId} is in allowed list [ok]"
);
return true; return true;
} }
if (\is_array($categories)) { if (\is_array($categories)) {
$Product = QUI\ERP\Products\Handler\Products::getProduct($productId); $Product = QUI\ERP\Products\Handler\Products::getProduct($productId);
$articleCategories = $Product->getCategories(); $articleCategories = $Product->getCategories();
/* @var $Category QUI\ERP\Products\Category\Category */ /* @var $Category QUI\ERP\Products\Category\Category */
...@@ -131,7 +133,9 @@ public function canUsedInOrder( ...@@ -131,7 +133,9 @@ public function canUsedInOrder(
$categoryId = $Category->getId(); $categoryId = $Category->getId();
if (\in_array($categoryId, $categories)) { if (\in_array($categoryId, $categories)) {
Debug::addLog("{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: category {$categoryId} is in allowed list [ok]"); Debug::addLog(
"{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: category {$categoryId} is in allowed list [ok]"
);
return true; return true;
} }
...@@ -173,7 +177,7 @@ public function canUsedBy( ...@@ -173,7 +177,7 @@ public function canUsedBy(
// assignment // assignment
$userGroupValue = $ShippingEntry->getAttribute('user_groups'); $userGroupValue = $ShippingEntry->getAttribute('user_groups');
$areasValue = $ShippingEntry->getAttribute('areas'); $areasValue = $ShippingEntry->getAttribute('areas');
// if groups and areas are empty, everybody is allowed // if groups and areas are empty, everybody is allowed
if (empty($userGroupValue) && empty($areasValue)) { if (empty($userGroupValue) && empty($areasValue)) {
...@@ -202,7 +206,7 @@ public function canUsedBy( ...@@ -202,7 +206,7 @@ public function canUsedBy(
$ShippingEntry->getAttribute('user_groups') $ShippingEntry->getAttribute('user_groups')
); );
$discountUsers = $userGroups['users']; $discountUsers = $userGroups['users'];
$discountGroups = $userGroups['groups']; $discountGroups = $userGroups['groups'];
if (empty($discountUsers) && empty($discountGroups)) { if (empty($discountUsers) && empty($discountGroups)) {
......
...@@ -101,7 +101,7 @@ public function canUsedInOrder( ...@@ -101,7 +101,7 @@ public function canUsedInOrder(
} }
// assignment // assignment
$articles = $ShippingEntry->getAttribute('articles'); $articles = $ShippingEntry->getAttribute('articles');
$categories = $ShippingEntry->getAttribute('categories'); $categories = $ShippingEntry->getAttribute('categories');
$toInt = function ($article) { $toInt = function ($article) {
...@@ -127,7 +127,7 @@ public function canUsedInOrder( ...@@ -127,7 +127,7 @@ public function canUsedInOrder(
return true; return true;
} }
$ArticleList = $Order->getArticles(); $ArticleList = $Order->getArticles();
$orderArticles = $ArticleList->getArticles(); $orderArticles = $ArticleList->getArticles();
foreach ($orderArticles as $Article) { foreach ($orderArticles as $Article) {
...@@ -143,7 +143,7 @@ public function canUsedInOrder( ...@@ -143,7 +143,7 @@ public function canUsedInOrder(
} }
if (is_array($categories)) { if (is_array($categories)) {
$Product = QUI\ERP\Products\Handler\Products::getProduct($productId); $Product = QUI\ERP\Products\Handler\Products::getProduct($productId);
$articleCategories = $Product->getCategories(); $articleCategories = $Product->getCategories();
/* @var $Category QUI\ERP\Products\Category\Category */ /* @var $Category QUI\ERP\Products\Category\Category */
...@@ -195,7 +195,7 @@ public function canUsedBy( ...@@ -195,7 +195,7 @@ public function canUsedBy(
// assignment // assignment
$userGroupValue = $ShippingEntry->getAttribute('user_groups'); $userGroupValue = $ShippingEntry->getAttribute('user_groups');
$areasValue = $ShippingEntry->getAttribute('areas'); $areasValue = $ShippingEntry->getAttribute('areas');
// if groups and areas are empty, everybody is allowed // if groups and areas are empty, everybody is allowed
if (empty($userGroupValue) && empty($areasValue)) { if (empty($userGroupValue) && empty($areasValue)) {
...@@ -224,7 +224,7 @@ public function canUsedBy( ...@@ -224,7 +224,7 @@ public function canUsedBy(
$ShippingEntry->getAttribute('user_groups') $ShippingEntry->getAttribute('user_groups')
); );
$discountUsers = $userGroups['users']; $discountUsers = $userGroups['users'];
$discountGroups = $userGroups['groups']; $discountGroups = $userGroups['groups'];
if (empty($discountUsers) && empty($discountGroups)) { if (empty($discountUsers) && empty($discountGroups)) {
......
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