diff --git a/forms/ecomerce/basket/index.js b/forms/ecomerce/basket/index.js index 16762bc3..961b84a5 100644 --- a/forms/ecomerce/basket/index.js +++ b/forms/ecomerce/basket/index.js @@ -6,19 +6,35 @@ export default new Class({ async open() { await Hedera.Form.prototype.open.call(this); - this.basket = new Hedera.Basket(this.app); + const basket = new Hedera.Basket(this.app); - this.orderId = this.$.params.$.id || this.basket.orderId; - if (!this.orderId) - return this.hash.setAll({form: 'ecomerce/checkout'}); + if (this.$.params.$.id) { + this.orderId = this.$.params.$.id; + } else if (await basket.check()) { + this.orderId = basket.orderId; + } - this.$.lot.assign({id: this.orderId}); + if (this.orderId) + this.$.lot.assign({id: this.orderId}); }, activate() { this.$.items.setInfo('bi', 'myOrderRow', 'hedera'); }, + onOrderReady(form) { + if (form.row < 0) + return; + + if (form.$.method != 'PICKUP') { + Vn.Node.show(this.$.address); + Vn.Node.setText(this.$.method, _('Agency')); + } else { + Vn.Node.hide(this.$.address); + Vn.Node.setText(this.$.method, _('Warehouse')); + } + }, + onConfigureClick() { Htk.Toast.showWarning(_('RememberReconfiguringImpact')); this.hash.setAll({ diff --git a/forms/ecomerce/basket/locale/ca.yml b/forms/ecomerce/basket/locale/ca.yml index 702db20f..40308fb8 100644 --- a/forms/ecomerce/basket/locale/ca.yml +++ b/forms/ecomerce/basket/locale/ca.yml @@ -1,13 +1,16 @@ ShoppingBasket: Cistella de la compra Order: Encàrrec ShippingInformation: Dades d'enviament +DeliveryAddress: Adreça de lliurament +Delivery at: Lliurament el +Agency: Agència +Warehouse: Magatzem Delete: Borrar encàrrec GoToCatalog: Anar al catàleg ConfigureOrder: Configurar encàrrec Checkout: Tramitar encàrrec OrderNumber: N encàrec DateExit: Data d'eixida -Warehouse: Magatzem OrderTotal: Total encàrrec Amount: Quant Pack: Pack diff --git a/forms/ecomerce/basket/locale/en.yml b/forms/ecomerce/basket/locale/en.yml index e82ebf7e..4bb1a83d 100644 --- a/forms/ecomerce/basket/locale/en.yml +++ b/forms/ecomerce/basket/locale/en.yml @@ -1,13 +1,16 @@ ShoppingBasket: Shopping basket Order: Order ShippingInformation: Shipping information +DeliveryAddress: Delivery address +Delivery at: Delivery at +Agency: Agency +Warehouse: Store Delete: Delete order GoToCatalog: Go to catalog ConfigureOrder: Configure order Checkout: Checkout OrderNumber: Order number DateExit: Shipping date -Warehouse: Store OrderTotal: Total Amount: Amount Pack: Pack diff --git a/forms/ecomerce/basket/locale/es.yml b/forms/ecomerce/basket/locale/es.yml index d216da1d..43aa80b8 100644 --- a/forms/ecomerce/basket/locale/es.yml +++ b/forms/ecomerce/basket/locale/es.yml @@ -1,13 +1,16 @@ ShoppingBasket: Cesta de la compra Order: Pedido ShippingInformation: Datos de envío +DeliveryAddress: Dirección de entrega +Delivery at: Entrega el +Agency: Agencia +Warehouse: Almacén Delete: Borrar pedido GoToCatalog: Ir al catálogo ConfigureOrder: Configurar pedido Checkout: Finalizar pedido OrderNumber: Nº pedido DateExit: Fecha de salida -Warehouse: Almacén OrderTotal: Total Amount: Cantidad Pack: Pack diff --git a/forms/ecomerce/basket/locale/fr.yml b/forms/ecomerce/basket/locale/fr.yml index 74f4ad67..f4c28c9f 100644 --- a/forms/ecomerce/basket/locale/fr.yml +++ b/forms/ecomerce/basket/locale/fr.yml @@ -1,13 +1,16 @@ ShoppingBasket: Panier Order: Commande ShippingInformation: Informations sur la livraison +DeliveryAddress: Addresse de livraison +Delivery at: Livraison à +Agency: Agence +Warehouse: Entrepôt Delete: Effacer GoToCatalog: Aller au catalogue ConfigureOrder: Définissez l'ordre Checkout: Caisse OrderNumber: Numéro de commande DateExit: Date de sortie -Warehouse: Magasin OrderTotal: Total commande Amount: Quant Pack: Pack diff --git a/forms/ecomerce/basket/locale/pt.yml b/forms/ecomerce/basket/locale/pt.yml index eab4e1e5..ba71b27c 100644 --- a/forms/ecomerce/basket/locale/pt.yml +++ b/forms/ecomerce/basket/locale/pt.yml @@ -1,13 +1,16 @@ ShoppingBasket: Cesta da compra Order: Encomenda ShippingInformation: Dados de envio +DeliveryAddress: Endereço de entrega +Delivery at: Entrega na +Agency: Agência +Warehouse: Armazém Delete: Eliminar encomenda GoToCatalog: Ir ao catálogo ConfigureOrder: Configurar encomenda Checkout: Finalizar encomenda OrderNumber: Nº encomenda DateExit: Data de saída -Warehouse: Armazém OrderTotal: Total Amount: Quantidade Pack: Pack diff --git a/forms/ecomerce/basket/ui.xml b/forms/ecomerce/basket/ui.xml index 90a5ccaf..0ff8ea48 100644 --- a/forms/ecomerce/basket/ui.xml +++ b/forms/ecomerce/basket/ui.xml @@ -21,13 +21,14 @@ - + SELECT o.id, o.sent, - ag.description agency, v.code method, ad.nickname + ag.description agency, v.code method, + ad.nickname, ad.postalCode, ad.city, ad.street FROM myOrder o - JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk - LEFT JOIN myAddress ad ON ad.id = o.addressFk + JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk + LEFT JOIN myAddress ad ON ad.id = o.addressFk JOIN vn.deliveryMethod v ON v.id = o.deliveryMethodFk WHERE o.id = #id; @@ -37,12 +38,21 @@
#{{order.id}}
-
+
ShippingInformation
-

-

Delivery at {{Vn.Value.format(order.sent, _('%D'))}}

-

Agency {{order.agency}}

+

{{order.nickname}}

+

+ Delivery at {{Vn.Value.format(order.sent, _('%D'))}} +

+

+ Agency {{order.agency}} +

+
+
+
DeliveryAddress

{{order.nickname}}

+

{{order.street}}

+

{{order.postalCode}}, {{order.city}}

Total diff --git a/forms/ecomerce/catalog/index.js b/forms/ecomerce/catalog/index.js index 211c40d2..062424a4 100644 --- a/forms/ecomerce/catalog/index.js +++ b/forms/ecomerce/catalog/index.js @@ -7,15 +7,11 @@ const Catalog = new Class({ ,_menuShown: false ,async open() { - let isOk = true; const basket = new Hedera.Basket(this.app); - this.orderId = basket.orderId; if (!localStorage.getItem('hederaGuest')) { - if (!this.orderId) - return this.hash.setAll({form: 'ecomerce/checkout'}); - else - isOk = await basket.checkRedirect(this.orderId); + if (await basket.check()) + this.orderId = basket.orderId; } else { const resultSet = await this.conn.execQuery( 'CALL myOrder_configureForGuest(@orderId); SELECT @orderId;'); @@ -24,7 +20,8 @@ const Catalog = new Class({ this.orderId = resultSet.fetchValue(); } - if (isOk) await Hedera.Form.prototype.open.call(this); + if (this.orderId) + await Hedera.Form.prototype.open.call(this); } ,activate() { diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 59bf2126..b8871eb7 100644 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -94,10 +94,9 @@ - SELECT o.id, o.sent, a.description agency, m.code method + SELECT o.id, o.sent, ad.nickname FROM myOrder o - JOIN vn.agencyMode a ON a.id = o.agencyModeFk - JOIN vn.deliveryMethod m ON m.id = o.deliveryMethodFk + LEFT JOIN myAddress ad ON ad.id = o.addressFk WHERE o.id = #orderId @@ -207,11 +206,8 @@

+

{{basket.nickname}}

{{Vn.Value.format(basket.sent, '%D')}}

-

- {{_(basket.method != 'PICKUP' ? 'Agency' : 'Warehouse')}} - {{basket.agency}} -

diff --git a/forms/ecomerce/confirm/index.js b/forms/ecomerce/confirm/index.js index fc51c82c..6f09172d 100644 --- a/forms/ecomerce/confirm/index.js +++ b/forms/ecomerce/confirm/index.js @@ -7,7 +7,7 @@ export default new Class({ async open() { const basket = new Hedera.Basket(this.app); try { - await basket.check(this.hash.$.id); + await basket.checkOrder(this.hash.$.id); } catch (err) { Htk.Toast.showError(err.message); } diff --git a/forms/ecomerce/confirm/ui.xml b/forms/ecomerce/confirm/ui.xml index 1cfa35ba..e8b83b63 100644 --- a/forms/ecomerce/confirm/ui.xml +++ b/forms/ecomerce/confirm/ui.xml @@ -6,9 +6,9 @@ CALL myOrder_getTax(#id); - SELECT o.id, o.sent, o.notes, o.companyFk, - ag.description agency, v.code method, - ad.nickname, ad.postalCode, ad.city, ad.street, + SELECT o.id, o.sent, o.notes, o.companyFk, + ag.description agency, v.code method, + ad.nickname, ad.postalCode, ad.city, ad.street, t.*, c.credit, myClient_getDebt(NULL) debt FROM myOrder o JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk @@ -35,8 +35,10 @@
+
#{{order.id}}
ShippingInformation
+

{{order.nickname}}

Delivery at {{Vn.Value.format(order.sent, _('%D'))}}

@@ -46,7 +48,6 @@
DeliveryAddress
-

{{order.nickname}}

{{order.street}}

{{order.postalCode}}, {{order.city}}

diff --git a/js/hedera/basket.js b/js/hedera/basket.js index 517ed125..8df2c05e 100644 --- a/js/hedera/basket.js +++ b/js/hedera/basket.js @@ -6,33 +6,51 @@ module.exports = class { if (orderId) orderId = parseInt(orderId); this.orderId = orderId; } - async check(orderId) { + async checkOrder(orderId) { const resultSet = await this.app.conn.execQuery( 'CALL myOrder_checkConfig(#id)', {id: orderId} ); resultSet.fetchValue(); } - async checkRedirect(orderId) { + async check() { + if (this.orderId) { + return await this.checkRedirect(); + } else { + this.app.hash.setAll({form: 'ecomerce/checkout'}); + return false; + } + } + async checkRedirect() { try { - await this.check(orderId); + await this.checkOrder(this.orderId); return true; } catch(err) { - Htk.Toast.showError(err.message); - this.app.hash.setAll({ - form: 'ecomerce/checkout', - id: orderId, - continue: 'catalog' - }); - return false; + if (err.exception == 'Vn.Lib.UserError') { + const dst = { + form: 'ecomerce/checkout', + continue: 'catalog' + }; + + if (err.code == 'orderNotOwnedByUser') { + this.constructor.unload(); + } else { + dst.id = this.orderId; + Htk.Toast.showError(err.message); + } + + this.app.hash.setAll(dst); + return false; + } else + throw err; } } async load(orderId) { this.loadIntoBasket(orderId); - if (!await this.checkRedirect(orderId)) return; - this.app.hash.setAll({ - form: 'ecomerce/catalog' - }); + if (await this.checkRedirect()) + this.app.hash.setAll({ + form: 'ecomerce/catalog' + }); } loadIntoBasket(orderId) { if (this.orderId != orderId) {