diff --git a/ajax/invoices/temporary/getTimeForPayment.php b/ajax/invoices/temporary/getTimeForPayment.php index fe372b87265dc06368e2865d30bf1a444bd91fa0..4e193cc2aab3848de154b697a2bc7bcea2fe1b03 100644 --- a/ajax/invoices/temporary/getTimeForPayment.php +++ b/ajax/invoices/temporary/getTimeForPayment.php @@ -10,7 +10,7 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_invoice_ajax_invoices_temporary_getTimeForPayment', function ($uid) { - return QUI\ERP\Customer\Utils::getInstance()->getPaymentTimeForUser($uid); + return QUI\ERP\Customer\Utils::getInstance()->getPaymentTimeForUser((int)$uid); }, ['uid'], 'Permission::checkAdminUser' diff --git a/bin/backend/controls/panels/TemporaryInvoice.js b/bin/backend/controls/panels/TemporaryInvoice.js index a71d69fbf005df893468440f96f43600668d276e..188062b3049d8eea830ee83379ccd7230a6b8af2 100644 --- a/bin/backend/controls/panels/TemporaryInvoice.js +++ b/bin/backend/controls/panels/TemporaryInvoice.js @@ -371,11 +371,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [ events : { onSubmit: function (Win, addressId, address) { Win.close(); - - Container.getElement('[name="contact_person"]').set( - 'value', - (address.salutation + ' ' + address.firstname + ' ' + address.lastname).trim() - ); + self.$setContactPersonByAddress(address); } } }).open(); @@ -415,10 +411,33 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [ var userId = Data.getValue().userId; - self.setAttribute('customer_id', userId); + self.setAttribute('customer_id', parseInt(userId)); self.setAttribute('invoice_address_id', Data.getValue().addressId); - Content.getElements('[name="select-contact-id-address"]').set('disabled', false); + if (!userId) { + Content.getElements('[name="select-contact-id-address"]').set('disabled', true); + Content.getElements('[name="contact_person"]').set('value', ''); + } else { + Content.getElements('[name="select-contact-id-address"]').set('disabled', false); + + Users.get(userId).loadIfNotLoaded().then(function (User) { + var addressId = User.getAttribute('quiqqer.erp.customer.contact.person'); + + if (!addressId) { + return; + } + + addressId = parseInt(addressId); + + User.getAddressList().then(function (addressList) { + for (var i = 0, len = addressList.length; i < len; i++) { + if (addressList[i].id === addressId) { + self.$setContactPersonByAddress(addressList[i]); + } + } + }); + }); + } // reset deliver address if (self.$AddressDelivery) { @@ -442,8 +461,6 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [ }); }); - //Data.setAddress(); - // editor EditorId.addEvent('onChange', function () { self.setAttribute('editor_id', EditorId.getValue()); @@ -1640,8 +1657,25 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [ */ addComment: function (message) { return Invoices.addComment(this.getAttribute('invoiceId'), message); - } + }, //endregion + + /** + * set the contact person by an address data object to the contact person input field + * + * @param address + */ + $setContactPersonByAddress: function (address) { + var Content = this.getContent(), + PersonInput = Content.getElement('[name="contact_person"]'); + + if (!PersonInput) { + return; + } + + var value = (address.salutation + ' ' + address.firstname + ' ' + address.lastname).trim(); + PersonInput.set('value', value); + } }); }); diff --git a/locale.xml b/locale.xml index 16163c41217fb53294ffd7ae3bf083cdb3434905..6b15a7b888249b20eacb1b00ba4fbd42e32a7aab 100644 --- a/locale.xml +++ b/locale.xml @@ -421,7 +421,7 @@ </locale> <locale name="message.different,delivery.address"> - <de><![CDATA[Der Lieferadresse weicht von der Rechnungsadresse ab]]></de> + <de><![CDATA[Die Lieferadresse weicht von der Rechnungsadresse ab]]></de> <en><![CDATA[The delivery address differs from the billing address.]]></en> </locale>