diff --git a/bin/frontend/controls/frontendUsers/VatType.js b/bin/frontend/controls/frontendUsers/VatType.js new file mode 100644 index 0000000000000000000000000000000000000000..0204fc1d5790de031888e5b66314de6933fc7d18 --- /dev/null +++ b/bin/frontend/controls/frontendUsers/VatType.js @@ -0,0 +1,99 @@ +/** + * @module package/quiqqer/erp/bin/frontend/controls/frontendUsers/VatType + * @author www.pcsg.de (Henning Leutz) + */ +define('package/quiqqer/erp/bin/frontend/controls/frontendUsers/VatType', [ + + 'qui/QUI', + 'qui/controls/Control' + +], function (QUI, QUIControl) { + "use strict"; + + return new Class({ + + Extends: QUIControl, + Type : 'package/quiqqer/erp/bin/frontend/controls/frontendUsers/VatType', + + Binds: [ + '$onImport', + '$onCountryChange' + ], + + initialize: function (options) { + this.parent(options); + + this.$Country = null; + this.$Vat = null; + this.$ChUID = null; + + this.addEvents({ + onImport: this.$onImport + }); + }, + + /** + * event: on import + */ + $onImport: function () { + var Parent = this.getElm().getParent( + '[data-qui="package/quiqqer/frontend-users/bin/frontend/controls/profile/UserData"]' + ); + + if (!Parent) { + return; + } + + this.$Country = Parent.getElement('[name="country"]'); + this.$Vat = Parent.getElement('[name="vatId"]'); + this.$ChUID = Parent.getElement('[name="chUID"]'); + + if (!this.$Country) { + return; + } + + if (!this.$Vat) { + this.$Vat = new Element('div'); + } + + if (!this.$ChUID) { + this.$ChUID = new Element('div'); + } + + // country edit + var self = this; + var Country = this.$Country; + + if (Country.get('data-qui') && !Country.get('data-quiid')) { + QUI.parse(this.getElm()).then(function () { + QUI.Controls + .getById(Country.get('data-quiid')) + .addEvent('onCountryChange', self.$onCountryChange); + }); + } else if (Country.get('data-quiid')) { + QUI.Controls + .getById(Country.get('data-quiid')) + .addEvent('onCountryChange', self.$onCountryChange); + } else { + Country.addEvent('change', self.$onCountryChange); + } + + this.$onCountryChange(); + }, + + /** + * event: on country change + */ + $onCountryChange: function () { + var country = this.$Country.value; + + if (country === 'CH') { + this.$Vat.getParent('label').setStyle('display', 'none'); + this.$ChUID.getParent('label').setStyle('display', null); + } else { + this.$Vat.getParent('label').setStyle('display', null); + this.$ChUID.getParent('label').setStyle('display', 'none'); + } + } + }); +}); diff --git a/locale.xml b/locale.xml index cc46b2d87570ff63de93080ae331dc97a5b6440f..6a8b50eb283464fc645291199a827474b780971d 100644 --- a/locale.xml +++ b/locale.xml @@ -91,6 +91,10 @@ <de><![CDATA[Umsatzsteuer-ID]]></de> <en><![CDATA[VAT ID]]></en> </locale> + <locale name="quiqqer.erp.chUID"> + <de><![CDATA[Unternehmens-ID (UID)]]></de> + <en><![CDATA[Company ID (UID)]]></en> + </locale> <locale name="global_process_id"> <de><![CDATA[Vorgangsnummer]]></de> diff --git a/src/QUI/ERP/FrontendUsers/profileData.html b/src/QUI/ERP/FrontendUsers/profileData.html index 53bcf0dbd089222a8bbdf7fef4f9e1c1ecd56e0d..d9facdc4280675a064d0ecec27a4391522435b2a 100644 --- a/src/QUI/ERP/FrontendUsers/profileData.html +++ b/src/QUI/ERP/FrontendUsers/profileData.html @@ -1,5 +1,7 @@ {if $isB2B} -<section class="quiqqer-frontendUsers-userdata-section quiqqer-erp-userProfile-vat"> +<section class="quiqqer-frontendUsers-userdata-section quiqqer-erp-userProfile-vat" + data-qui="package/quiqqer/erp/bin/frontend/controls/frontendUsers/VatType" +> <header> <h2>{locale group="quiqqer/erp" var="user.profile.userdata.title"}</h2> </header> @@ -14,5 +16,16 @@ value="{$User->getAttribute('quiqqer.erp.euVatId')|escape:'html'}" /> </label> + + <label class="quiqqer-order-customerData-edit-chUID"> + <span class="quiqqer-frontendUsers-userdata-label"> + {locale group="quiqqer/erp" var="quiqqer.erp.chUID"} + </span> + <input type="text" + name="chUID" + class="quiqqer-frontendUsers-userdata-field" + value="{$User->getAttribute('quiqqer.erp.chUID')|escape:'html'}" + /> + </label> </section> {/if}