Skip to content
Code-Schnipsel Gruppen Projekte
Commit 1f4789a8 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: AddProductWindow has now the possibility to set extra fields for the onSubmit event

Übergeordneter b40064b2
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -12,8 +12,9 @@
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_erp_ajax_products_parseProductToArticle',
function ($productId, $attributes, $user) {
function ($productId, $attributes, $user, $fields) {
$user = \json_decode($user, true);
$fields = \json_decode($fields, true);
$attributes = \json_decode($attributes, true);
$User = null;
$Locale = QUI::getLocale();
......@@ -69,14 +70,32 @@ function ($productId, $attributes, $user) {
}
$Unique->calc();
$result = $Unique->toArticle($Locale)->toArray();
return $Unique->toArticle($Locale)->toArray();
if (empty($fields)) {
return $result;
}
$fieldResult = [];
foreach ($fields as $fieldId) {
try {
$Field = $Product->getField($fieldId);
$fieldResult[$Field->getId()] = $Field->getValue();
} catch (QUI\Exception $Exception) {
}
}
$result['fields'] = $fieldResult;
return $result;
} catch (QUI\Exception $Exception) {
QUI\System\Log::write($Exception->getMessage());
}
return [];
},
['productId', 'attributes', 'user'],
['productId', 'attributes', 'user', 'fields'],
'Permission::checkAdminUser'
);
......@@ -26,7 +26,8 @@ define('package/quiqqer/erp/bin/backend/controls/articles/product/AddProductWind
Type : 'package/quiqqer/erp/bin/backend/controls/articles/product/AddProductWindow',
options: {
user: false
user : false,
fields: false // field ids that should be delivered additionally (onSubmit)
},
initialize: function (options) {
......@@ -96,7 +97,7 @@ define('package/quiqqer/erp/bin/backend/controls/articles/product/AddProductWind
Content.addClass('quiqqer-erp-addProductWin');
var Form = Content.getElement('form');
Form.setStyles({
'float': 'left',
width : '100%'
......@@ -196,6 +197,7 @@ define('package/quiqqer/erp/bin/backend/controls/articles/product/AddProductWind
productId : productId,
attributes: JSON.encode(attributes),
user : JSON.encode(self.getUserData()),
fields : JSON.encode(self.getAttribute('fields')),
onError : reject
});
});
......
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