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

Merge branch 'next-2.x' into 'main'

feat: add attributes to createCustomer function

See merge request !56
Übergeordnete f65d99e1 905c5471
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!56feat: add attributes to createCustomer function,!54Update 'next-3.x' with latest changes from 'main'
Pipeline-Nr. 14422 mit Warnungen bestanden
...@@ -12,9 +12,10 @@ ...@@ -12,9 +12,10 @@
QUI::$Ajax->registerFunction( QUI::$Ajax->registerFunction(
'package_quiqqer_customer_ajax_backend_create_createCustomer', 'package_quiqqer_customer_ajax_backend_create_createCustomer',
function ($customerId, $address, $groups) { function ($customerId, $address, $groups, $attributes) {
$address = json_decode($address, true); $address = json_decode($address, true);
$groups = json_decode($groups, true); $groups = json_decode($groups, true);
$attributes = json_decode($attributes, true);
$User = QUI\ERP\Customer\Customers::getInstance()->createCustomer( $User = QUI\ERP\Customer\Customers::getInstance()->createCustomer(
$customerId, $customerId,
...@@ -22,8 +23,13 @@ function ($customerId, $address, $groups) { ...@@ -22,8 +23,13 @@ function ($customerId, $address, $groups) {
$groups $groups
); );
if (is_array($attributes)) {
$User->setAttributes($attributes);
$User->save();
}
return $User->getUUID(); return $User->getUUID();
}, },
['customerId', 'address', 'groups'], ['customerId', 'address', 'groups', 'attributes'],
'Permission::checkAdminUser' 'Permission::checkAdminUser'
); );
<?php
/**
* This file contains package_quiqqer_customer_ajax_backend_getBusinessType
*/
/**
* Return the shop business type
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_customer_ajax_backend_getBusinessType',
function () {
return QUI\ERP\Utils\Shop::getBusinessType();
},
false,
'Permission::checkAdminUser'
);
...@@ -34,6 +34,20 @@ ...@@ -34,6 +34,20 @@
</label> </label>
</td> </td>
</tr> </tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item">
{{textIsNettoBruttoUser}}
</span>
<select name="quiqqer.erp.isNettoUser" class="field-container-field">
<option value=""></option>
<option value="2">{{textBrutto}}</option>
<option value="1">{{textNetto}}</option>
</select>
</label>
</td>
</tr>
<tr> <tr>
<td> <td>
<label class="field-container"> <label class="field-container">
......
...@@ -21,7 +21,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -21,7 +21,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
], function(QUI, QUIControl, Countries, Handler, QUILocale, QUIAjax, Mustache, template) { ], function(QUI, QUIControl, Countries, Handler, QUILocale, QUIAjax, Mustache, template) {
'use strict'; 'use strict';
var lg = 'quiqqer/customer'; const lg = 'quiqqer/customer';
return new Class({ return new Class({
...@@ -66,6 +66,9 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -66,6 +66,9 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
customerGroupsHeader: QUILocale.get(lg, 'window.customer.creation.groups.title'), customerGroupsHeader: QUILocale.get(lg, 'window.customer.creation.groups.title'),
customerGroupsText: QUILocale.get(lg, 'window.customer.creation.groups.text'), customerGroupsText: QUILocale.get(lg, 'window.customer.creation.groups.text'),
labelPrefix: QUILocale.get(lg, 'window.customer.creation.customerNo.labelPrefix'), labelPrefix: QUILocale.get(lg, 'window.customer.creation.customerNo.labelPrefix'),
textIsNettoBruttoUser: QUILocale.get(lg, 'customer.user.information.textBruttoNetto'),
textNetto: QUILocale.get('quiqqer/erp', 'user.settings.userNettoStatus.netto'),
textBrutto: QUILocale.get('quiqqer/erp', 'user.settings.userNettoStatus.brutto'),
textAddressCompany: QUILocale.get('quiqqer/core', 'company'), textAddressCompany: QUILocale.get('quiqqer/core', 'company'),
textAddressSalutation: QUILocale.get('quiqqer/core', 'salutation'), textAddressSalutation: QUILocale.get('quiqqer/core', 'salutation'),
...@@ -86,10 +89,10 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -86,10 +89,10 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
this.$Form = this.$Elm.getElement('form'); this.$Form = this.$Elm.getElement('form');
// key events // key events
var self = this; const self = this;
var CustomerId = this.$Elm.getElement('[name="customerId"]'); const CustomerId = this.$Elm.getElement('[name="customerId"]');
var Company = this.$Elm.getElement('[name="address-company"]'); const Company = this.$Elm.getElement('[name="address-company"]');
var Country = this.$Elm.getElement('[name="address-country"]'); const Country = this.$Elm.getElement('[name="address-country"]');
CustomerId.addEvent('keydown', function(event) { CustomerId.addEvent('keydown', function(event) {
if (event.key === 'tab') { if (event.key === 'tab') {
...@@ -140,13 +143,13 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -140,13 +143,13 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
* event: on inject * event: on inject
*/ */
$onInject: function() { $onInject: function() {
var self = this; const self = this;
var Group = this.$Elm.getElement('[name="group"]'); const Group = this.$Elm.getElement('[name="group"]');
Countries.getCountries().then(function(countries) { Countries.getCountries().then(function(countries) {
var CountrySelect = self.$Elm.getElement('[name="address-country"]'); const CountrySelect = self.$Elm.getElement('[name="address-country"]');
for (var code in countries) { for (let code in countries) {
if (!countries.hasOwnProperty(code)) { if (!countries.hasOwnProperty(code)) {
continue; continue;
} }
...@@ -160,10 +163,32 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -160,10 +163,32 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
if (QUIQQER_CONFIG.globals.country) { if (QUIQQER_CONFIG.globals.country) {
CountrySelect.value = QUIQQER_CONFIG.globals.country; CountrySelect.value = QUIQQER_CONFIG.globals.country;
} }
}).then(() => {
const Select = this.$Elm.getElement('[name="quiqqer.erp.isNettoUser"]')
return new Promise((resolve) => {
QUIAjax.get('package_quiqqer_customer_ajax_backend_getBusinessType', (businessType) => {
switch (businessType.toLowerCase()) {
case 'b2b':
case 'b2b-b2c':
Select.value = '1';
break;
case 'b2c':
case 'b2c-b2b':
Select.value = '2';
break;
}
resolve();
}, {
'package': 'quiqqer/customer',
});
});
}).then(function() { }).then(function() {
return QUI.parse(self.$Elm); return QUI.parse(self.$Elm);
}).then(function() { }).then(function() {
var GroupControl = QUI.Controls.getById(Group.get('data-quiid')); const GroupControl = QUI.Controls.getById(Group.get('data-quiid'));
GroupControl.disable(); GroupControl.disable();
self.showCustomerNumber(); self.showCustomerNumber();
...@@ -174,12 +199,12 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -174,12 +199,12 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
* Create the customer * Create the customer
*/ */
createCustomer: function() { createCustomer: function() {
var self = this; const self = this;
var elements = this.$Form.elements; const elements = this.$Form.elements;
var customerId = elements.customerId.value; const customerId = elements.customerId.value;
var groups = elements.groups.value.split(','); const groups = elements.groups.value.split(',');
var address = { const address = {
'salutation': elements['address-salutation'].value, 'salutation': elements['address-salutation'].value,
'firstname': elements['address-firstname'].value, 'firstname': elements['address-firstname'].value,
'lastname': elements['address-lastname'].value, 'lastname': elements['address-lastname'].value,
...@@ -200,7 +225,10 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -200,7 +225,10 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
'package': 'quiqqer/customer', 'package': 'quiqqer/customer',
customerId: customerId, customerId: customerId,
address: JSON.encode(address), address: JSON.encode(address),
groups: JSON.encode(groups) groups: JSON.encode(groups),
attributes: JSON.encode({
'quiqqer.erp.isNettoUser': this.$Elm.getElement('[name="quiqqer.erp.isNettoUser"]').value
})
}); });
}, },
...@@ -212,16 +240,16 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -212,16 +240,16 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
return this.createCustomer(); return this.createCustomer();
} }
var self = this; const self = this;
var steps = this.$List.getElements('li'); const steps = this.$List.getElements('li');
var pos = this.$List.getPosition(this.$Container); const pos = this.$List.getPosition(this.$Container);
var top = pos.y; const top = pos.y;
var height = this.$Container.getSize().y; const height = this.$Container.getSize().y;
var scrollHeight = this.$Container.getScrollSize().y; const scrollHeight = this.$Container.getScrollSize().y;
var newTop = this.$roundToStepPos(top - height); const newTop = this.$roundToStepPos(top - height);
var step = 1; let step = 1;
if ((top * -1) / height) { if ((top * -1) / height) {
step = Math.round(((top * -1) / height) + 1); step = Math.round(((top * -1) / height) + 1);
...@@ -239,11 +267,11 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -239,11 +267,11 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
} }
return new Promise(function(resolve) { return new Promise(function(resolve) {
var checkPromises = []; const checkPromises = [];
if (step === 1) { if (step === 1) {
var elements = self.$Form.elements; const elements = self.$Form.elements;
var customerId = elements.customerId.value; const customerId = elements.customerId.value;
checkPromises.push(Handler.validateCustomerNo(customerId)); checkPromises.push(Handler.validateCustomerNo(customerId));
} }
...@@ -267,12 +295,12 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -267,12 +295,12 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
* Previous next step * Previous next step
*/ */
previous: function() { previous: function() {
var self = this; const self = this;
var pos = this.$List.getPosition(this.$Container); const pos = this.$List.getPosition(this.$Container);
var top = pos.y; const top = pos.y;
var height = this.$Container.getSize().y; const height = this.$Container.getSize().y;
var newTop = this.$roundToStepPos(top + height); let newTop = this.$roundToStepPos(top + height);
this.$Next.set('html', QUILocale.get(lg, 'window.customer.creation.next')); this.$Next.set('html', QUILocale.get(lg, 'window.customer.creation.next'));
this.$Next.set('data-last', null); this.$Next.set('data-last', null);
...@@ -297,11 +325,11 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -297,11 +325,11 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
* refresh the step display * refresh the step display
*/ */
refreshStepDisplay: function() { refreshStepDisplay: function() {
var step = 1; let step = 1;
var steps = this.$List.getElements('li'); const steps = this.$List.getElements('li');
var pos = this.$List.getPosition(this.$Container); const pos = this.$List.getPosition(this.$Container);
var top = pos.y; const top = pos.y;
var height = this.$Container.getSize().y; const height = this.$Container.getSize().y;
if ((top * -1) / height) { if ((top * -1) / height) {
step = Math.round(((top * -1) / height) + 1); step = Math.round(((top * -1) / height) + 1);
...@@ -329,8 +357,8 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -329,8 +357,8 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
* @return {number} * @return {number}
*/ */
$roundToStepPos: function(currentPos) { $roundToStepPos: function(currentPos) {
var height = this.$Container.getSize().y; const height = this.$Container.getSize().y;
var pos = Math.round(currentPos / height) * -1; const pos = Math.round(currentPos / height) * -1;
return pos * height * -1; return pos * height * -1;
}, },
...@@ -339,7 +367,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -339,7 +367,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
* Show the customer number step * Show the customer number step
*/ */
showCustomerNumber: function() { showCustomerNumber: function() {
var self = this; const self = this;
this.$Next.disabled = true; this.$Next.disabled = true;
...@@ -347,8 +375,8 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [ ...@@ -347,8 +375,8 @@ define('package/quiqqer/customer/bin/backend/controls/create/Customer', [
Handler.getNewCustomerNo(), Handler.getNewCustomerNo(),
Handler.getCustomerIdPrefix() Handler.getCustomerIdPrefix()
]).then(function(result) { ]).then(function(result) {
var Input = self.$Elm.getElement('input[name="customerId"]'); const Input = self.$Elm.getElement('input[name="customerId"]');
var InputPrefix = self.$Elm.getElement('input[name="prefix"]'); const InputPrefix = self.$Elm.getElement('input[name="prefix"]');
if (result[1]) { if (result[1]) {
InputPrefix.value = result[1]; InputPrefix.value = result[1];
......
...@@ -24,7 +24,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/CustomerWindow', [ ...@@ -24,7 +24,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/CustomerWindow', [
], ],
options: { options: {
maxHeight: 700, maxHeight: 750,
maxWidth: 600, maxWidth: 600,
buttons: false buttons: false
}, },
...@@ -50,6 +50,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/CustomerWindow', [ ...@@ -50,6 +50,7 @@ define('package/quiqqer/customer/bin/backend/controls/create/CustomerWindow', [
this.getContent().set('html', ''); this.getContent().set('html', '');
this.getContent().setStyle('padding', 0); this.getContent().setStyle('padding', 0);
this.Loader.show();
new CreateCustomer({ new CreateCustomer({
events: { events: {
......
...@@ -67,11 +67,7 @@ public function createCustomer($customerId, array $address = [], array $groupIds ...@@ -67,11 +67,7 @@ public function createCustomer($customerId, array $address = [], array $groupIds
$User->save(); $User->save();
if (!empty($address)) { if (!empty($address)) {
try { $Address = $User->getStandardAddress();
$Address = $User->getStandardAddress();
} catch (QUI\Exception) {
$Address = $User->addAddress();
}
$needles = [ $needles = [
'salutation', 'salutation',
......
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