Skip to content
Code-Schnipsel Gruppen Projekte
Commit b0fd730e erstellt von Henning's avatar Henning
Dateien durchsuchen

feat: category filter at shipping rules

Übergeordneter 638386b9
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -214,6 +214,20 @@
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
{{usageAssignmentCategory}}
</span>
<span class="field-container-field field-container-field-no-padding">
<input type="text" name="categories"
data-qui="package/quiqqer/products/bin/controls/categories/Select"
/>
</span>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
......
......@@ -55,31 +55,32 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/CreateRule',
this.$Elm.addClass('quiqqer-shipping-rule-create');
this.$Elm.set('html', Mustache.render(template, {
generalHeader : QUILocale.get(lg, 'shipping.edit.template.general'),
title : QUILocale.get(lg, 'shipping.edit.template.title'),
workingTitle : QUILocale.get('quiqqer/system', 'workingtitle'),
calculationPriority : QUILocale.get(lg, 'shipping.edit.template.calculationPriority'),
discountTitle : QUILocale.get(lg, 'shipping.edit.template.discount'),
discountDescription : QUILocale.get(lg, 'shipping.edit.template.discount.description'),
discountAbsolute : QUILocale.get(lg, 'shipping.edit.template.discount.absolute'),
discountPercentage : QUILocale.get(lg, 'shipping.edit.template.discount.percentage'),
discountPercentageOrder: QUILocale.get(lg, 'shipping.edit.template.discount.percentageOrder'),
statusTitle : QUILocale.get(lg, 'shipping.edit.template.status'),
statusDescription : QUILocale.get(lg, 'shipping.edit.template.status.description'),
noRulesTitle : QUILocale.get(lg, 'shipping.edit.template.noRules'),
noRulesText : QUILocale.get(lg, 'shipping.edit.template.noRules.text'),
unitTitle : QUILocale.get(lg, 'shipping.edit.template.unit'),
unitHeader : QUILocale.get(lg, 'shipping.edit.template.unitTitle'),
usageHeader : QUILocale.get(lg, 'shipping.edit.template.usage'),
usageFrom : QUILocale.get(lg, 'shipping.edit.template.usage.from'),
usageTo : QUILocale.get(lg, 'shipping.edit.template.usage.to'),
usageAmountOf : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.of'),
usageAmountTo : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.to'),
usageValueOf : QUILocale.get(lg, 'shipping.edit.template.purchase.value.of'),
usageValueTo : QUILocale.get(lg, 'shipping.edit.template.purchase.value.to'),
usageAssignmentUser : QUILocale.get(lg, 'shipping.edit.template.assignment.user'),
usageAssignmentProduct : QUILocale.get(lg, 'shipping.edit.template.assignment.product'),
usageAssignmentArea : QUILocale.get(lg, 'shipping.edit.template.assignment.areas'),
generalHeader : QUILocale.get(lg, 'shipping.edit.template.general'),
title : QUILocale.get(lg, 'shipping.edit.template.title'),
workingTitle : QUILocale.get('quiqqer/system', 'workingtitle'),
calculationPriority : QUILocale.get(lg, 'shipping.edit.template.calculationPriority'),
discountTitle : QUILocale.get(lg, 'shipping.edit.template.discount'),
discountDescription : QUILocale.get(lg, 'shipping.edit.template.discount.description'),
discountAbsolute : QUILocale.get(lg, 'shipping.edit.template.discount.absolute'),
discountPercentage : QUILocale.get(lg, 'shipping.edit.template.discount.percentage'),
discountPercentageOrder : QUILocale.get(lg, 'shipping.edit.template.discount.percentageOrder'),
statusTitle : QUILocale.get(lg, 'shipping.edit.template.status'),
statusDescription : QUILocale.get(lg, 'shipping.edit.template.status.description'),
noRulesTitle : QUILocale.get(lg, 'shipping.edit.template.noRules'),
noRulesText : QUILocale.get(lg, 'shipping.edit.template.noRules.text'),
unitTitle : QUILocale.get(lg, 'shipping.edit.template.unit'),
unitHeader : QUILocale.get(lg, 'shipping.edit.template.unitTitle'),
usageHeader : QUILocale.get(lg, 'shipping.edit.template.usage'),
usageFrom : QUILocale.get(lg, 'shipping.edit.template.usage.from'),
usageTo : QUILocale.get(lg, 'shipping.edit.template.usage.to'),
usageAmountOf : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.of'),
usageAmountTo : QUILocale.get(lg, 'shipping.edit.template.shopping.amount.to'),
usageValueOf : QUILocale.get(lg, 'shipping.edit.template.purchase.value.of'),
usageValueTo : QUILocale.get(lg, 'shipping.edit.template.purchase.value.to'),
usageAssignmentUser : QUILocale.get(lg, 'shipping.edit.template.assignment.user'),
usageAssignmentProduct : QUILocale.get(lg, 'shipping.edit.template.assignment.product'),
usageAssignmentCategory : QUILocale.get(lg, 'shipping.edit.template.assignment.category'),
usageAssignmentArea : QUILocale.get(lg, 'shipping.edit.template.assignment.areas'),
productHeader : QUILocale.get(lg, 'shipping.edit.template.assignment.product.header'),
usageAssignmentProductOnly : QUILocale.get(lg, 'shipping.edit.template.assignment.product.only'),
......
......@@ -260,6 +260,20 @@
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
{{usageAssignmentCategory}}
</span>
<span class="field-container-field field-container-field-no-padding">
<input type="text" name="categories"
data-qui="package/quiqqer/products/bin/controls/categories/Select"
/>
</span>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
......
......@@ -232,6 +232,12 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [
.get('data-quiid')
);
self.$Categories = QUI.Controls.getById(
self.$Elm
.getElement('[name="categories"]')
.get('data-quiid')
);
return new Promise(function (resolve) {
require([
'package/quiqqer/shipping/bin/backend/ShippingRules',
......@@ -245,6 +251,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/Rule', [
self.$Areas.importValue(rule.areas);
self.$UserGroups.importValue(rule.user_groups);
self.$Articles.importValue(rule.articles);
self.$Categories.importValue(rule.categories);
new QUISwitch({
status: parseInt(rule.active),
......
......@@ -27,7 +27,8 @@
"quiqqer\/quiqqer": ">=1.5|dev-master|dev-dev",
"quiqqer\/erp": ">=1.0|dev-master|dev-dev",
"quiqqer\/areas": ">=1.1|dev-master|dev-dev",
"quiqqer\/order": ">=1.0|dev-master|dev-dev"
"quiqqer\/order": ">=1.0|dev-master|dev-dev",
"quiqqer\/products": ">=1.5|dev-master|dev-dev"
},
"autoload": {
"psr-4": {
......
......@@ -374,6 +374,7 @@ public function canUsedInOrder($Order)
}
$articles = $this->getAttribute('articles');
$categories = $this->getAttribute('categories');
$articleOnly = (int)$this->getAttribute('articles_only');
$unitTerms = $this->getUnitTerms();
......@@ -406,13 +407,22 @@ public function canUsedInOrder($Order)
$articleOnly = 0;
}
$categoryIdsInOrder = [];
foreach ($articleList as $Article) {
$aid = $Article->getId();
$articleQuantity = $Article->getQuantity();
// get product because of units
try {
$Product = Products::getProduct($aid);
$Product = Products::getProduct($aid);
$productCategories = $Product->getCategories();
$categoryIds = \array_map(function($Category) {
return $Category->getId();
}, $productCategories);
$categoryIdsInOrder = \array_merge($categoryIdsInOrder, $categoryIds);
foreach ($unitIds as $unitId) {
$Weight = $Product->getField($unitId);
......@@ -475,6 +485,29 @@ public function canUsedInOrder($Order)
return false;
}
// category check
$categoryIdsInOrder = \array_unique($categoryIdsInOrder);
$categories = trim(',');
$categories = explode(',', $categories);
if (!empty($categoryIdsInOrder)
&& !empty($categories)
&& (count($categoryIdsInOrder) === 1 && $categoryIdsInOrder[0] !== 0)
) {
$found = false;
foreach ($categories as $cid) {
if (!in_array($cid, $categoryIdsInOrder)) {
$found = true;
break;
}
}
if ($found === false) {
return false;
}
}
// unit terms check
if (!empty($unitTerms)) {
foreach ($unitTerms as $unitTerm) {
......@@ -646,6 +679,8 @@ public function canUsedInOrder($Order)
}
}
// categories check
try {
QUI::getEvents()->fireEvent('shippingCanUsedInOrder', [$this, $Order]);
......
......@@ -82,7 +82,7 @@ public function createShippingStatus($id, $color, array $title)
*
* @return int
*/
public function getNextId()
public function getNextId(): int
{
$list = Handler::getInstance()->getList();
......
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