From 806c4cc3ad11260b7fb746edd12c9ce9dd88ca73 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 30 Jan 2023 11:08:26 +0100 Subject: [PATCH 1/5] refs #5122 Checkpoint --- forms/ecomerce/basket/index.js | 24 +++- forms/ecomerce/basket/style.scss | 164 +++++++++++++++------------ forms/ecomerce/basket/ui.xml | 37 +++++- forms/ecomerce/catalog/index.js | 2 +- forms/ecomerce/checkout/index.js | 20 +++- forms/ecomerce/checkout/ui.xml | 8 +- forms/ecomerce/confirm/index.js | 19 ++-- forms/ecomerce/confirm/ui.xml | 14 ++- forms/ecomerce/orders/style.scss | 1 - forms/ecomerce/pending/index.js | 21 ++++ forms/ecomerce/pending/locale/ca.yml | 1 + forms/ecomerce/pending/locale/en.yml | 1 + forms/ecomerce/pending/locale/es.yml | 8 ++ forms/ecomerce/pending/locale/fr.yml | 1 + forms/ecomerce/pending/locale/pt.yml | 1 + forms/ecomerce/pending/style.scss | 0 forms/ecomerce/pending/ui.xml | 54 +++++++++ import.js | 4 +- js/hedera/app.js | 20 ++++ js/hedera/basket-checker.js | 21 ---- js/hedera/basket.js | 42 +++++++ js/hedera/form.js | 1 + js/hedera/hedera.js | 2 +- 23 files changed, 338 insertions(+), 128 deletions(-) create mode 100644 forms/ecomerce/pending/index.js create mode 100644 forms/ecomerce/pending/locale/ca.yml create mode 100644 forms/ecomerce/pending/locale/en.yml create mode 100644 forms/ecomerce/pending/locale/es.yml create mode 100644 forms/ecomerce/pending/locale/fr.yml create mode 100644 forms/ecomerce/pending/locale/pt.yml create mode 100644 forms/ecomerce/pending/style.scss create mode 100644 forms/ecomerce/pending/ui.xml delete mode 100644 js/hedera/basket-checker.js create mode 100644 js/hedera/basket.js diff --git a/forms/ecomerce/basket/index.js b/forms/ecomerce/basket/index.js index 2e2ec1f2..d1880829 100644 --- a/forms/ecomerce/basket/index.js +++ b/forms/ecomerce/basket/index.js @@ -5,8 +5,16 @@ export default new Class({ Template: require('./ui.xml'), async open() { - const isOk = await Hedera.BasketChecker.check(this.conn, this.hash); - if (isOk) await Hedera.Form.prototype.open.call(this); + await Hedera.Form.prototype.open.call(this); + + let orderId = this.$.params.$.id; + if (!orderId) + orderId = localStorage.getItem('hederaBasket'); + if (!orderId) + this.hash.setAll({form: 'ecomerce/pending'}); + else + await Hedera.Basket.check(this.conn, this.hash); + this.$.params.set('id', orderId); }, activate() { @@ -15,7 +23,17 @@ export default new Class({ onConfigureClick() { Htk.Toast.showWarning(_('RememberReconfiguringImpact')); - this.hash.setAll({form: 'ecomerce/checkout'}); + this.hash.setAll({ + form: 'ecomerce/checkout', + id: this.$.params.$.id + }); + }, + + onConfirmClick() { + this.hash.setAll({ + form: 'ecomerce/confirm', + id: this.$.params.$.id + }); }, onDeleteClick(form) { diff --git a/forms/ecomerce/basket/style.scss b/forms/ecomerce/basket/style.scss index f46a077c..47f3f910 100644 --- a/forms/ecomerce/basket/style.scss +++ b/forms/ecomerce/basket/style.scss @@ -1,76 +1,94 @@ -.basket .head { - border-bottom: 1px solid #DDD; -} -.basket .head p { - font-weight: bold; - margin: 0; - padding: 0; - font-size: 1.4rem; - text-align: right; -} -.basket .form > p { - margin: 0; - font-size: 1.4rem; - color: white; - text-align: right; -} - -/* Lines */ - -.basket .line { - display: flex; - align-items: center; - gap: 12px; - margin: 10px 0; - height: 80px; -} -.basket .line:first-child { - margin-top: 0; -} -.basket .line:last-child { - margin-bottom: 0; -} -.basket .line > .delete { - margin: 0 -8px; -} -.basket .line > .photo { - flex: none; - border-radius: 50%; - width: 68px; - height: 68px; - gap: 0; -} -.basket .line > .info { - flex: 1; - overflow: hidden; -} -.basket .line > .info > * { - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; -} -.basket .line > .info > h2 { - font-size: 1rem; - font-weight: normal; - margin: 0; -} -.basket .line > .info > p { - margin: 0; -} -.basket .line > .info > .tags { - color: #777; -} -.basket .line .subtotal { - float: right; -} - -/* Fields */ - -.basket td.available-exceeded input { - background-color: #FCC; -} -.basket .icon > img { - border-radius: 50%; +.hedera-basket { + .head { + border-bottom: 1px solid #DDD; + + & > div > div { + margin: 15px 0; + } + & > div > div:first-child { + margin: 0; + } + p { + margin: 3px 0; + + &.important { + font-size: 1.2rem; + font-weight: bold; + } + } + .total { + + font-weight: bold; + margin: 0; + padding: 0; + font-size: 1.4rem; + text-align: right; + } + } + .form > p { + margin: 0; + font-size: 1.4rem; + color: white; + text-align: right; + } + + /* Lines */ + + .line { + display: flex; + align-items: center; + gap: 12px; + margin: 10px 0; + height: 80px; + } + .line:first-child { + margin-top: 0; + } + .line:last-child { + margin-bottom: 0; + } + .line > .delete { + margin: 0 -8px; + } + .line > .photo { + flex: none; + border-radius: 50%; + width: 68px; + height: 68px; + gap: 0; + } + .line > .info { + flex: 1; + overflow: hidden; + } + .line > .info > * { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + } + .line > .info > h2 { + font-size: 1rem; + font-weight: normal; + margin: 0; + } + .line > .info > p { + margin: 0; + } + .line > .info > .tags { + color: #777; + } + .line .subtotal { + float: right; + } + + /* Fields */ + + td.available-exceeded input { + background-color: #FCC; + } + .icon > img { + border-radius: 50%; + } } diff --git a/forms/ecomerce/basket/ui.xml b/forms/ecomerce/basket/ui.xml index fd23a819..29e08853 100644 --- a/forms/ecomerce/basket/ui.xml +++ b/forms/ecomerce/basket/ui.xml @@ -1,6 +1,9 @@ + + +
-

ShoppingBasket

+

{{_(params.$.id ? 'Order' : 'ShoppingBasket')}}

+ on-click="this.onConfirmClick()"/>
-
+ + + + SELECT o.id, o.sent, + ag.description agency, v.code method, ad.nickname + FROM myOrder o + 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; + + + +
-

+

#{{order.id}}
+
+
ShippingInformation
+

+

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

+

Agency {{order.agency}}

+

{{order.nickname}}

+
+

Total @@ -28,15 +52,16 @@

- + SELECT bi.id, bi.amount, bi.price, i.longName item, i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7, i.image, im.updated - FROM myBasketItem bi + FROM myOrderRow bi JOIN vn.item i ON i.id = bi.itemFk LEFT JOIN image im ON im.collectionFk = 'catalog' AND im.name = i.image + WHERE orderFk = #id
diff --git a/forms/ecomerce/catalog/index.js b/forms/ecomerce/catalog/index.js index 8b6eddd9..d9ce71f5 100644 --- a/forms/ecomerce/catalog/index.js +++ b/forms/ecomerce/catalog/index.js @@ -10,7 +10,7 @@ const Catalog = new Class({ let isOk = true; if (!localStorage.getItem('hederaGuest')) - isOk = await Hedera.BasketChecker.check(this.conn, this.hash); + isOk = await Hedera.Basket.check(this.conn, this.hash); else await this.conn.execQuery('CALL mybasket_configureForGuest'); diff --git a/forms/ecomerce/checkout/index.js b/forms/ecomerce/checkout/index.js index df10cd88..03113c1b 100644 --- a/forms/ecomerce/checkout/index.js +++ b/forms/ecomerce/checkout/index.js @@ -44,7 +44,7 @@ export default new Class({ } this.$.lot.assign({ - date: date, + date, method: row.deliveryMethod, agency: row.agencyModeFk, address: row.addressFk @@ -59,11 +59,21 @@ export default new Class({ async onConfirmClick() { this.disableButtons(true); - const query = 'CALL myBasket_configure(#date, #method, #agency, #address)'; + const id = this.$.params.$.id; + const params = Object.assign({}, this.$.lot.$); + + let query; + if (id) { + params.id = id; + query = 'CALL myOrder_configure(#id, #date, #method, #agency, #address)'; + } else { + query = 'CALL myOrder_create(@id, #date, #method, #agency, #address)'; + } + let resultSet; try { - resultSet = await this.conn.execQuery(query, this.$.lot.$); + resultSet = await this.conn.execQuery(query, params); } finally { this.disableButtons(false); } @@ -71,7 +81,7 @@ export default new Class({ if (!resultSet.fetchResult()) return; - if (this.$.orderForm.numRows > 0) + if (id) Htk.Toast.showMessage(_('OrderUpdated')); else Htk.Toast.showMessage(_('OrderStarted')); @@ -80,7 +90,7 @@ export default new Class({ }, onCancelClick() { - if (this.$.orderForm.numRows > 0) + if (this.$.params.$.id) window.history.back(); else this.hash.setAll({form: 'ecomerce/orders'}); diff --git a/forms/ecomerce/checkout/ui.xml b/forms/ecomerce/checkout/ui.xml index f9a32719..59eb31f1 100644 --- a/forms/ecomerce/checkout/ui.xml +++ b/forms/ecomerce/checkout/ui.xml @@ -1,4 +1,7 @@ + + + @@ -8,10 +11,11 @@ - + SELECT m.code deliveryMethod, o.sent, o.agencyModeFk, o.addressFk - FROM myBasket o + FROM myOrder o JOIN vn.deliveryMethod m ON m.id = o.deliveryMethodFk + WHERE o.id = #id + + + - - CALL myBasket_getTax; + + 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, t.*, c.credit, myClient_getDebt(NULL) debt - FROM myBasket o + FROM myOrder o 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 @@ -17,7 +20,8 @@ IFNULL(SUM(taxableBase), 0) taxableBase, IFNULL(SUM(tax), 0) tax FROM tmp.orderAmount - ) t; + ) t + WHERE o.id = #id; DROP TEMPORARY TABLE tmp.orderAmount, tmp.orderTax; @@ -37,7 +41,7 @@
ShippingInformation

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

Agency {{order.agency}} diff --git a/forms/ecomerce/orders/style.scss b/forms/ecomerce/orders/style.scss index 80318bed..6c4fb965 100644 --- a/forms/ecomerce/orders/style.scss +++ b/forms/ecomerce/orders/style.scss @@ -36,4 +36,3 @@ .orders .htk-list .total { float: right; } - diff --git a/forms/ecomerce/pending/index.js b/forms/ecomerce/pending/index.js new file mode 100644 index 00000000..d5e9a666 --- /dev/null +++ b/forms/ecomerce/pending/index.js @@ -0,0 +1,21 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml'), + + activate() { + this.$.orders.setInfo('o', 'myOrder', 'hedera', ['id'], 'id'); + }, + + async onRemoveOrderClick(form) { + if (confirm(_('AreYouSureDeleteOrder'))) + await form.deleteRow(); + }, + + loadOrder(id) { + localStorage.setItem('hederaBasket', id); + this.hash.setAll({form: 'ecomerce/catalog'}); + Htk.Toast.showMessage(_('OrderLoadedIntoBasket')); + } +}); diff --git a/forms/ecomerce/pending/locale/ca.yml b/forms/ecomerce/pending/locale/ca.yml new file mode 100644 index 00000000..dd862364 --- /dev/null +++ b/forms/ecomerce/pending/locale/ca.yml @@ -0,0 +1 @@ +Pending: Pendents diff --git a/forms/ecomerce/pending/locale/en.yml b/forms/ecomerce/pending/locale/en.yml new file mode 100644 index 00000000..eeb6d5a0 --- /dev/null +++ b/forms/ecomerce/pending/locale/en.yml @@ -0,0 +1 @@ +Pending: Pending diff --git a/forms/ecomerce/pending/locale/es.yml b/forms/ecomerce/pending/locale/es.yml new file mode 100644 index 00000000..6a3cfa3c --- /dev/null +++ b/forms/ecomerce/pending/locale/es.yml @@ -0,0 +1,8 @@ +Pending: Pendientes +PendingOrders: Pedidos pendientes +NewOrder: Nuevo pedido +ViewOrder: Ver pedido +RemoveOrder: Eliminar pedido +LoadOrderIntoCart: Cargar pedido en la cesta +AreYouSureDeleteOrder: ¿Seguro que quieres borrar el pedido? +OrderLoadedIntoBasket: ¡Pedido cargado en la cesta! \ No newline at end of file diff --git a/forms/ecomerce/pending/locale/fr.yml b/forms/ecomerce/pending/locale/fr.yml new file mode 100644 index 00000000..dd862364 --- /dev/null +++ b/forms/ecomerce/pending/locale/fr.yml @@ -0,0 +1 @@ +Pending: Pendents diff --git a/forms/ecomerce/pending/locale/pt.yml b/forms/ecomerce/pending/locale/pt.yml new file mode 100644 index 00000000..e79f9482 --- /dev/null +++ b/forms/ecomerce/pending/locale/pt.yml @@ -0,0 +1 @@ +Pending: Pendientes diff --git a/forms/ecomerce/pending/style.scss b/forms/ecomerce/pending/style.scss new file mode 100644 index 00000000..e69de29b diff --git a/forms/ecomerce/pending/ui.xml b/forms/ecomerce/pending/ui.xml new file mode 100644 index 00000000..e0c1fc15 --- /dev/null +++ b/forms/ecomerce/pending/ui.xml @@ -0,0 +1,54 @@ + +

+

PendingOrders

+
+
+ +
+
+ + + SELECT o.id, o.sent, o.deliveryMethodFk, o.total, + a.nickname, am.description agency + FROM myOrder o + JOIN myAddress a ON a.id = o.addressFk + JOIN vn.agencyMode am ON am.id = o.agencyModeFk + WHERE NOT o.isConfirmed + ORDER BY o.sent DESC + + + +
+

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

+

#{{iter.id}}

+

{{iter.nickname}}

+

{{iter.agency}}

+

{{Vn.Value.format(iter.total, '%.2d€')}}

+
+
+ + +
+
+
+
+
+ diff --git a/import.js b/import.js index 46c8f0d4..4b33cf30 100644 --- a/import.js +++ b/import.js @@ -70,7 +70,9 @@ export const routes = { orders: () => import('ecomerce/orders'), ticket: - () => import('ecomerce/ticket') + () => import('ecomerce/ticket'), + pending: + () => import('ecomerce/pending') }, news: { new: diff --git a/js/hedera/app.js b/js/hedera/app.js index 6e7ba1c2..8aa82737 100644 --- a/js/hedera/app.js +++ b/js/hedera/app.js @@ -9,6 +9,24 @@ module.exports = new Class({ ,get() { return this._conn; } + }, + hash: { + type: Vn.Hash + ,get() { + return this._hash; + } + }, + gui: { + type: Gui + ,get() { + return this._gui; + } + }, + login: { + type: Login + ,get() { + return this._login; + } } } @@ -35,6 +53,7 @@ module.exports = new Class({ ,showLogin() { const login = this._login = new Login({ + app: this, conn: this._conn, hash: this._hash }); @@ -47,6 +66,7 @@ module.exports = new Class({ if (this._gui) return; const gui = this._gui = new Gui({ + app: this, conn: this._conn, hash: this._hash }); diff --git a/js/hedera/basket-checker.js b/js/hedera/basket-checker.js deleted file mode 100644 index 29a6c841..00000000 --- a/js/hedera/basket-checker.js +++ /dev/null @@ -1,21 +0,0 @@ - -module.exports = { - async check(conn, hash) { - this.hash = hash; - const resultSet = await conn.execQuery('CALL myBasket_check'); - - const status = resultSet.fetchValue(); - if (!status) return; - - const isOk = status == 'UPDATED' || status == 'OK'; - - if (status == 'UPDATED') - Htk.Toast.showWarning(_('Order items updated')); - - if (!isOk) - this.hash.setAll({form: 'ecomerce/checkout'}); - - return isOk; - } -}; - diff --git a/js/hedera/basket.js b/js/hedera/basket.js new file mode 100644 index 00000000..deae7ec4 --- /dev/null +++ b/js/hedera/basket.js @@ -0,0 +1,42 @@ + +module.exports = class { + constructor(app) { + this.app = app; + let orderId = localStorage.getItem('hederaBasket'); + if (orderId) orderId = parseInt(orderId); + this.orderId = orderId; + } + async check(conn, hash) { + this.hash = hash; + const orderId = localStorage.getItem('hederaBasket'); + const resultSet = await this.app.conn.execQuery( + 'CALL myOrder_check(#id)', + {id: orderId} + ); + + const status = resultSet.fetchValue(); + if (!status) return; + + const isOk = status == 'updated' || status == 'ok'; + + if (status == 'updated') + Htk.Toast.showWarning(_('Order items updated')); + + if (!isOk) { + const params = {form: 'ecomerce/checkout'}; + if (orderId) params.id = orderId; + this.hash.setAll(params); + } + + return isOk; + } + async load(orderId) { + if (this.orderId != orderId) { + localStorage.setItem('hederaBasket', orderId); + this.orderId = orderId; + } + + await this.check() + } +}; + diff --git a/js/hedera/form.js b/js/hedera/form.js index 518cb3f9..8911fa6a 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -7,6 +7,7 @@ module.exports = new Class({ ,initialize(gui) { this.gui = gui; + this.app = gui.app; this.conn = gui.conn; this.hash = gui.hash; } diff --git a/js/hedera/hedera.js b/js/hedera/hedera.js index 5389daea..ab76578e 100644 --- a/js/hedera/hedera.js +++ b/js/hedera/hedera.js @@ -10,6 +10,6 @@ Hedera = module.exports = { ,Report : require('./report') ,App : require('./app') ,Tpv : require('./tpv') - ,BasketChecker : require('./basket-checker') + ,Basket : require('./basket') }; -- 2.40.1 From 67b6f77b12bf07d8c4b9eb2eb7bbd26249432ce2 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 15 Feb 2023 14:07:09 +0100 Subject: [PATCH 2/5] refs #5122 --- forms/ecomerce/basket/index.js | 25 +++++++++------- forms/ecomerce/basket/locale/ca.yml | 2 ++ forms/ecomerce/basket/locale/en.yml | 2 ++ forms/ecomerce/basket/locale/es.yml | 2 ++ forms/ecomerce/basket/locale/fr.yml | 2 ++ forms/ecomerce/basket/locale/pt.yml | 2 ++ forms/ecomerce/basket/ui.xml | 7 +++-- forms/ecomerce/catalog/index.js | 36 +++++++++++++++++----- forms/ecomerce/catalog/ui.xml | 26 ++++++++-------- forms/ecomerce/checkout/index.js | 21 +++++++++---- forms/ecomerce/confirm/index.js | 10 +++++-- forms/ecomerce/orders/locale/ca.yml | 2 +- forms/ecomerce/orders/locale/en.yml | 2 +- forms/ecomerce/orders/locale/es.yml | 2 +- forms/ecomerce/orders/locale/fr.yml | 2 +- forms/ecomerce/orders/locale/mn.yml | 37 ----------------------- forms/ecomerce/orders/locale/pt.yml | 2 +- forms/ecomerce/orders/style.scss | 2 +- forms/ecomerce/pending/index.js | 8 ++--- js/hedera/basket.js | 46 ++++++++++++++++------------- js/hedera/locale/ca.yml | 3 +- js/hedera/locale/en.yml | 3 +- js/hedera/locale/es.yml | 3 +- js/hedera/locale/fr.yml | 3 +- js/hedera/locale/pt.yml | 3 +- 25 files changed, 139 insertions(+), 114 deletions(-) delete mode 100644 forms/ecomerce/orders/locale/mn.yml diff --git a/forms/ecomerce/basket/index.js b/forms/ecomerce/basket/index.js index d1880829..e0583a24 100644 --- a/forms/ecomerce/basket/index.js +++ b/forms/ecomerce/basket/index.js @@ -6,18 +6,16 @@ export default new Class({ async open() { await Hedera.Form.prototype.open.call(this); + this.basket = new Hedera.Basket(this.app); - let orderId = this.$.params.$.id; - if (!orderId) - orderId = localStorage.getItem('hederaBasket'); - if (!orderId) - this.hash.setAll({form: 'ecomerce/pending'}); - else - await Hedera.Basket.check(this.conn, this.hash); - this.$.params.set('id', orderId); + this.orderId = this.$.params.$.id || this.basket.orderId; + if (!this.orderId) + return this.hash.setAll({form: 'ecomerce/checkout'}); + + this.$.lot.assign({id: this.orderId}); }, - activate() { + activate() { this.$.items.setInfo('bi', 'myBasketItem', 'hedera'); }, @@ -25,14 +23,19 @@ export default new Class({ Htk.Toast.showWarning(_('RememberReconfiguringImpact')); this.hash.setAll({ form: 'ecomerce/checkout', - id: this.$.params.$.id + id: this.orderId }); }, + async onCatalogClick() { + const basket = new Hedera.Basket(this.app); + await basket.load(this.orderId); + }, + onConfirmClick() { this.hash.setAll({ form: 'ecomerce/confirm', - id: this.$.params.$.id + id: this.orderId }); }, diff --git a/forms/ecomerce/basket/locale/ca.yml b/forms/ecomerce/basket/locale/ca.yml index d4a09b57..702db20f 100644 --- a/forms/ecomerce/basket/locale/ca.yml +++ b/forms/ecomerce/basket/locale/ca.yml @@ -1,4 +1,6 @@ ShoppingBasket: Cistella de la compra +Order: Encàrrec +ShippingInformation: Dades d'enviament Delete: Borrar encàrrec GoToCatalog: Anar al catàleg ConfigureOrder: Configurar encàrrec diff --git a/forms/ecomerce/basket/locale/en.yml b/forms/ecomerce/basket/locale/en.yml index d1b3271a..e82ebf7e 100644 --- a/forms/ecomerce/basket/locale/en.yml +++ b/forms/ecomerce/basket/locale/en.yml @@ -1,4 +1,6 @@ ShoppingBasket: Shopping basket +Order: Order +ShippingInformation: Shipping information Delete: Delete order GoToCatalog: Go to catalog ConfigureOrder: Configure order diff --git a/forms/ecomerce/basket/locale/es.yml b/forms/ecomerce/basket/locale/es.yml index 4069ca0d..d216da1d 100644 --- a/forms/ecomerce/basket/locale/es.yml +++ b/forms/ecomerce/basket/locale/es.yml @@ -1,4 +1,6 @@ ShoppingBasket: Cesta de la compra +Order: Pedido +ShippingInformation: Datos de envío Delete: Borrar pedido GoToCatalog: Ir al catálogo ConfigureOrder: Configurar pedido diff --git a/forms/ecomerce/basket/locale/fr.yml b/forms/ecomerce/basket/locale/fr.yml index dba6194b..74f4ad67 100644 --- a/forms/ecomerce/basket/locale/fr.yml +++ b/forms/ecomerce/basket/locale/fr.yml @@ -1,4 +1,6 @@ ShoppingBasket: Panier +Order: Commande +ShippingInformation: Informations sur la livraison Delete: Effacer GoToCatalog: Aller au catalogue ConfigureOrder: Définissez l'ordre diff --git a/forms/ecomerce/basket/locale/pt.yml b/forms/ecomerce/basket/locale/pt.yml index 0e3227b7..eab4e1e5 100644 --- a/forms/ecomerce/basket/locale/pt.yml +++ b/forms/ecomerce/basket/locale/pt.yml @@ -1,4 +1,6 @@ ShoppingBasket: Cesta da compra +Order: Encomenda +ShippingInformation: Dados de envio Delete: Eliminar encomenda GoToCatalog: Ir ao catálogo ConfigureOrder: Configurar encomenda diff --git a/forms/ecomerce/basket/ui.xml b/forms/ecomerce/basket/ui.xml index 29e08853..90a5ccaf 100644 --- a/forms/ecomerce/basket/ui.xml +++ b/forms/ecomerce/basket/ui.xml @@ -13,15 +13,16 @@ + on-click="this.onCatalogClick()"/>
+ - + SELECT o.id, o.sent, ag.description agency, v.code method, ad.nickname FROM myOrder o @@ -52,7 +53,7 @@
- + SELECT bi.id, bi.amount, bi.price, i.longName item, i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7, i.image, im.updated diff --git a/forms/ecomerce/catalog/index.js b/forms/ecomerce/catalog/index.js index d9ce71f5..211c40d2 100644 --- a/forms/ecomerce/catalog/index.js +++ b/forms/ecomerce/catalog/index.js @@ -8,18 +8,29 @@ const Catalog = new Class({ ,async open() { let isOk = true; + const basket = new Hedera.Basket(this.app); + this.orderId = basket.orderId; - if (!localStorage.getItem('hederaGuest')) - isOk = await Hedera.Basket.check(this.conn, this.hash); - else - await this.conn.execQuery('CALL mybasket_configureForGuest'); + if (!localStorage.getItem('hederaGuest')) { + if (!this.orderId) + return this.hash.setAll({form: 'ecomerce/checkout'}); + else + isOk = await basket.checkRedirect(this.orderId); + } else { + const resultSet = await this.conn.execQuery( + 'CALL myOrder_configureForGuest(@orderId); SELECT @orderId;'); + + resultSet.fetchResult(); + this.orderId = resultSet.fetchValue(); + } if (isOk) await Hedera.Form.prototype.open.call(this); } - + ,activate() { document.body.appendChild(this.$.rightPanel); this.$.items.setInfo('i', 'item', 'vn', ['id']); + this.$.orderLot.assign({orderId: this.orderId}); if (localStorage.getItem('hederaView')) this.setView(parseInt(localStorage.getItem('hederaView'))); @@ -98,6 +109,7 @@ const Catalog = new Class({ break; } + params.orderId = this.orderId; const refreshItems = hasTagFilter || params.search != null || params.type != null; @@ -245,7 +257,11 @@ const Catalog = new Class({ if (this.isGuest()) return; - this.hash.setAll({form: 'ecomerce/checkout'}); + this.hash.setAll({ + form: 'ecomerce/checkout', + id: this.orderId, + continue: 'catalog' + }); } ,onAddItemClick(event, form) { @@ -255,7 +271,10 @@ const Catalog = new Class({ this.onEraseClick(); this.$.$card.row = form.row; - this.$.cardLot.assign({item: form.$.id}); + this.$.cardLot.assign({ + item: form.$.id, + orderId: this.orderId + }); this.$.cardPopup.show(event.currentTarget); } @@ -284,7 +303,7 @@ const Catalog = new Class({ ,async onConfirmClick() { var sql = ''; - var query = new Sql.String({query: 'CALL myBasket_addItem(#warehouse, #item, #amount);'}); + var query = new Sql.String({query: 'CALL myOrder_addItem(#orderId, #warehouse, #item, #amount);'}); var amountSum = 0; for (var warehouse in this.items) { @@ -292,6 +311,7 @@ const Catalog = new Class({ amountSum += amount; const params = { + orderId: this.orderId, warehouse: warehouse, item: this.$.cardLot.$.item, amount: amount diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 5c2e3b6e..59bf2126 100644 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -91,12 +91,14 @@ param="producer"/> + - - SELECT b.id, b.sent, a.description agency, m.code method - FROM myBasket b - JOIN vn.agencyMode a ON a.id = b.agencyModeFk - JOIN vn.deliveryMethod m ON m.id = b.deliveryMethodFk + + SELECT o.id, o.sent, a.description agency, m.code method + FROM myOrder o + JOIN vn.agencyMode a ON a.id = o.agencyModeFk + JOIN vn.deliveryMethod m ON m.id = o.deliveryMethodFk + WHERE o.id = #orderId - CALL myBasket_getAvailable; + CALL myOrder_getAvailable(#orderId); SELECT DISTINCT t.id, l.name FROM vn.item i JOIN vn.itemType t ON t.id = i.typeFk @@ -283,7 +285,7 @@ property="model" auto-load="false" result-index="1"> - CALL myBasket_getAvailable; + CALL myOrder_getAvailable(#orderId); SELECT DISTINCT l.id, l.name FROM vn.item i JOIN vn.itemType t ON t.id = i.typeFk @@ -304,7 +306,7 @@ property="model" auto-load="false" result-index="1"> - CALL myBasket_getAvailable; + CALL myOrder_getAvailable(#orderId); SELECT DISTINCT p.id, p.name FROM vn.item i JOIN vn.itemType t ON t.id = i.typeFk @@ -325,7 +327,7 @@ property="model" auto-load="false" result-index="1"> - CALL myBasket_getAvailable; + CALL myOrder_getAvailable(#orderId); SELECT DISTINCT o.id, l.name, o.code FROM vn.item i JOIN vn.itemType t ON t.id = i.typeFk @@ -347,7 +349,7 @@ property="model" auto-load="false" result-index="1"> - CALL myBasket_getAvailable; + CALL myOrder_getAvailable(#orderId); SELECT DISTINCT i.category, i.category FROM vn.item i JOIN vn.itemType t ON t.id = i.typeFk @@ -466,7 +468,7 @@ result-index="1" on-status-changed-after="onCardLoad" lot="card-lot"> - CALL myBasket_calcCatalogFromItem(#item); + CALL myOrder_calcCatalogFromItem(#orderId, #item); SELECT l.warehouseFk, w.name warehouse, p.`grouping`, p.price, p.priceKg, p.rate, l.available FROM tmp.ticketLot l diff --git a/forms/ecomerce/checkout/index.js b/forms/ecomerce/checkout/index.js index d1402a58..24bb2f26 100644 --- a/forms/ecomerce/checkout/index.js +++ b/forms/ecomerce/checkout/index.js @@ -59,7 +59,7 @@ export default new Class({ async onConfirmClick() { this.disableButtons(true); - const id = this.$.params.$.id; + let id = this.$.params.$.id; const params = Object.assign({}, this.$.lot.$); let query; @@ -67,7 +67,7 @@ export default new Class({ params.id = id; query = 'CALL myOrder_configure(#id, #date, #method, #agency, #address)'; } else { - query = 'CALL myOrder_create(@id, #date, #method, #agency, #address)'; + query = 'CALL myOrder_create(@orderId, #date, #method, #agency, #address); SELECT @orderId;'; } let resultSet; @@ -81,12 +81,21 @@ export default new Class({ if (!resultSet.fetchResult()) return; - if (id) + if (id) { Htk.Toast.showMessage(_('OrderUpdated')); - else - Htk.Toast.showMessage(_('OrderStarted')); - this.hash.setAll({form: 'ecomerce/catalog'}); + switch(this.hash.$.continue) { + case 'catalog': + this.hash.setAll({form: 'ecomerce/catalog'}); + break; + default: + this.hash.setAll({form: 'ecomerce/basket', id}); + } + } else { + const basket = new Hedera.Basket(this.app); + basket.loadIntoBasket(resultSet.fetchValue()); + this.hash.setAll({form: 'ecomerce/catalog'}); + } }, onCancelClick() { diff --git a/forms/ecomerce/confirm/index.js b/forms/ecomerce/confirm/index.js index 277b0389..fc51c82c 100644 --- a/forms/ecomerce/confirm/index.js +++ b/forms/ecomerce/confirm/index.js @@ -5,8 +5,13 @@ export default new Class({ Template: require('./ui.xml'), async open() { - const isOk = await Hedera.Basket.check(this.conn, this.hash); - if (isOk) await Hedera.Form.prototype.open.call(this); + const basket = new Hedera.Basket(this.app); + try { + await basket.check(this.hash.$.id); + } catch (err) { + Htk.Toast.showError(err.message); + } + await Hedera.Form.prototype.open.call(this); }, onOrderReady(form) { @@ -117,6 +122,7 @@ export default new Class({ 'CALL myOrder_confirm(#id)', this.$.params.$ ); + Hedera.Basket.unload(); this.$.successDialog.show(); } finally { Vn.Node.disableInputs(this.node, false); diff --git a/forms/ecomerce/orders/locale/ca.yml b/forms/ecomerce/orders/locale/ca.yml index c93f4817..68ef7804 100644 --- a/forms/ecomerce/orders/locale/ca.yml +++ b/forms/ecomerce/orders/locale/ca.yml @@ -5,7 +5,7 @@ OrderNumber: N encàrrec DateMake: Data de creació DateExit: Data d'eixida SendMethod: Forma d'enviament -LastOrders: Últimes comandes +LastOrders: Comandes confirmades 'Balance:': 'Saldo:' PaymentInfo: >- La quantitat mostrada és el teu saldo pendent (negatiu) o favorable a dia diff --git a/forms/ecomerce/orders/locale/en.yml b/forms/ecomerce/orders/locale/en.yml index 4bb08ce7..b7fa58b5 100644 --- a/forms/ecomerce/orders/locale/en.yml +++ b/forms/ecomerce/orders/locale/en.yml @@ -5,7 +5,7 @@ OrderNumber: Order number DateMake: Creation date DateExit: Shipping date SendMethod: Delivery method -LastOrders: Last orders +LastOrders: Confirmed orders 'Balance:': 'Balance:' PaymentInfo: >- The amount shown is your slope (negative) or favorable balance today, it diff --git a/forms/ecomerce/orders/locale/es.yml b/forms/ecomerce/orders/locale/es.yml index b649cddf..d471178c 100644 --- a/forms/ecomerce/orders/locale/es.yml +++ b/forms/ecomerce/orders/locale/es.yml @@ -5,7 +5,7 @@ OrderNumber: Nº pedido DateMake: Fecha de creación DateExit: Fecha de salida SendMethod: Forma de envío -LastOrders: Últimos pedidos +LastOrders: Pedidos confirmados 'Balance:': 'Saldo:' PaymentInfo: >- La cantidad mostrada es tu saldo pendiente (negativa) o favorable a día de diff --git a/forms/ecomerce/orders/locale/fr.yml b/forms/ecomerce/orders/locale/fr.yml index e10b5d7c..32bd3c0d 100644 --- a/forms/ecomerce/orders/locale/fr.yml +++ b/forms/ecomerce/orders/locale/fr.yml @@ -5,7 +5,7 @@ OrderNumber: Numéro de commande DateMake: Date de creation DateExit: Date de sortie SendMethod: Typo -LastOrders: Les dernières commandes +LastOrders: Commandes confirmées 'Balance:': 'Balance:' PaymentInfo: >- Le montant indiqué est votre pente (négative) ou balance favorable diff --git a/forms/ecomerce/orders/locale/mn.yml b/forms/ecomerce/orders/locale/mn.yml deleted file mode 100644 index 207a0dac..00000000 --- a/forms/ecomerce/orders/locale/mn.yml +++ /dev/null @@ -1,37 +0,0 @@ -OpenOrders: Open orders -StartOrder: Start order -ContinueOrder: Continue order -OrderNumber: Order number -DateMake: Creation date -DateExit: Shipping date -SendMethod: Delivery method -LastOrders: Last orders -'Balance:': 'Balance:' -PaymentInfo: >- - Үзүүлсэн хэмжээ цаашид захиалга эзэлж биш, таны налуу (сөрөг), эсвэл - тааламжтай тэнцвэр нь өнөөдөр юм. Хэрэв та дүн арилгаж гэж хэлж байсан нь доош - нь төлбөр хийж, өөрийн хүссэн хэмжээгээр орж хүсэж байгаа бол таны захиалга - ирдэг бол авах, энэ хэмжээ тэнцүү буюу 0-ээс их байх ёстой. -MakePayment: Make payment -Company: Company -Pending: Pending -Pay: Pay -Basket: Basket -ShoppingBasket: Shopping basket -SeeOrder: Show details of the order -Delivery: Delivery -TicketNumber: Ticket number -SentAddress: Delivery address -Consignee: Consignee -Boxes: Bundles -TotalWithVAT: Total with VAT -PayOrder: Pay order -'AmountToPay:': 'Amount to pay (€):' -AmountError: >- - The amount must be a positive number less than or equal to the outstanding - amount -PayError: Failed to make the payment -An error has been in the payment: >- - It seems that there has been an error in the payment -Retry: Retry -Accept: Accept diff --git a/forms/ecomerce/orders/locale/pt.yml b/forms/ecomerce/orders/locale/pt.yml index ff127648..d638cf7e 100644 --- a/forms/ecomerce/orders/locale/pt.yml +++ b/forms/ecomerce/orders/locale/pt.yml @@ -5,7 +5,7 @@ OrderNumber: Nº pedido DateMake: Data de criação DateExit: Data de saída SendMethod: Forma de envío -LastOrders: Últimas encomendas +LastOrders: Encomendas confirmadas 'Balance:': 'Saldo:' PaymentInfo: >- A quantidade mostrada é seu saldo pendente (negativo) ou favorável a dia de diff --git a/forms/ecomerce/orders/style.scss b/forms/ecomerce/orders/style.scss index 6c4fb965..97761413 100644 --- a/forms/ecomerce/orders/style.scss +++ b/forms/ecomerce/orders/style.scss @@ -33,6 +33,6 @@ /* List */ -.orders .htk-list .total { +.hedera-orders .htk-list .total { float: right; } diff --git a/forms/ecomerce/pending/index.js b/forms/ecomerce/pending/index.js index d5e9a666..7364cba5 100644 --- a/forms/ecomerce/pending/index.js +++ b/forms/ecomerce/pending/index.js @@ -5,6 +5,7 @@ export default new Class({ Template: require('./ui.xml'), activate() { + this.basket = new Hedera.Basket(this.app); this.$.orders.setInfo('o', 'myOrder', 'hedera', ['id'], 'id'); }, @@ -13,9 +14,8 @@ export default new Class({ await form.deleteRow(); }, - loadOrder(id) { - localStorage.setItem('hederaBasket', id); - this.hash.setAll({form: 'ecomerce/catalog'}); - Htk.Toast.showMessage(_('OrderLoadedIntoBasket')); + async loadOrder(id) { + const basket = new Hedera.Basket(this.app); + await basket.load(id); } }); diff --git a/js/hedera/basket.js b/js/hedera/basket.js index deae7ec4..11b02538 100644 --- a/js/hedera/basket.js +++ b/js/hedera/basket.js @@ -6,37 +6,43 @@ module.exports = class { if (orderId) orderId = parseInt(orderId); this.orderId = orderId; } - async check(conn, hash) { - this.hash = hash; - const orderId = localStorage.getItem('hederaBasket'); + async check(orderId) { const resultSet = await this.app.conn.execQuery( 'CALL myOrder_check(#id)', {id: orderId} ); - - const status = resultSet.fetchValue(); - if (!status) return; - - const isOk = status == 'updated' || status == 'ok'; - - if (status == 'updated') - Htk.Toast.showWarning(_('Order items updated')); - - if (!isOk) { - const params = {form: 'ecomerce/checkout'}; - if (orderId) params.id = orderId; - this.hash.setAll(params); + resultSet.fetchValue(); + } + async checkRedirect(orderId) { + try { + await this.check(orderId); + return true; + } catch(err) { + Htk.Toast.showError(err.message); + this.app.hash.setAll({ + form: 'ecomerce/checkout', + id: orderId, + continue: 'catalog' + }); + return false; } - - return isOk; } async load(orderId) { + this.loadIntoBasket(orderId); + if (!await this.checkRedirect(orderId)) return; + this.app.hash.setAll({ + form: 'ecomerce/catalog' + }); + } + loadIntoBasket(orderId) { if (this.orderId != orderId) { localStorage.setItem('hederaBasket', orderId); this.orderId = orderId; + Htk.Toast.showMessage(_('OrderLoadedIntoBasket')); } - - await this.check() + } + static unload() { + localStorage.removeItem('hederaBasket'); } }; diff --git a/js/hedera/locale/ca.yml b/js/hedera/locale/ca.yml index fe0589df..326e90ec 100644 --- a/js/hedera/locale/ca.yml +++ b/js/hedera/locale/ca.yml @@ -38,7 +38,8 @@ AppName: Verdnatura Home: Inici Orders: Encàrrecs Basket: Cistella -Last orders: Últims comandes +Pending orders: Pendents +Last orders: Confirmades Invoices: Factures Catalog: Catàleg About: Coneix-nos diff --git a/js/hedera/locale/en.yml b/js/hedera/locale/en.yml index 88d354eb..f6add13c 100644 --- a/js/hedera/locale/en.yml +++ b/js/hedera/locale/en.yml @@ -34,7 +34,8 @@ AppName: Verdnatura Home: Home Orders: Orders Basket: Basket -Last orders: Last orders +Pending orders: Pending +Last orders: Confirmed Invoices: Invoices Catalog: Catalog About: About diff --git a/js/hedera/locale/es.yml b/js/hedera/locale/es.yml index de2766ed..9c6a656a 100644 --- a/js/hedera/locale/es.yml +++ b/js/hedera/locale/es.yml @@ -38,7 +38,8 @@ AppName: Verdnatura Home: Inicio Orders: Pedidos Basket: Cesta -Last orders: Últimos pedidos +Pending orders: Pendientes +Last orders: Confirmados Invoices: Facturas Catalog: Catálogo About: Conócenos diff --git a/js/hedera/locale/fr.yml b/js/hedera/locale/fr.yml index 4622bfeb..37811b10 100644 --- a/js/hedera/locale/fr.yml +++ b/js/hedera/locale/fr.yml @@ -38,7 +38,8 @@ AppName: Verdnatura Home: Accueil Orders: Commandes Basket: Panier -Last orders: Dernières commandes +Pending orders: En attente +Last orders: Confirmées Invoices: Facturas Catalog: Catalogue About: Nous diff --git a/js/hedera/locale/pt.yml b/js/hedera/locale/pt.yml index d1254b4b..f8ed38db 100644 --- a/js/hedera/locale/pt.yml +++ b/js/hedera/locale/pt.yml @@ -36,7 +36,8 @@ AppName: VerdNatura Home: Principio Orders: Encomendas Basket: Cesta -Last orders: Últimas encomendas +Pending orders: Pendentes +Last orders: Confirmados Invoices: Facturas Catalog: Catálogo About: Conheça-nos -- 2.40.1 From a632a152427de68d8d102dc7559c19997b5cd5e8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 15 Feb 2023 17:13:25 +0100 Subject: [PATCH 3/5] refs #5122 --- js/hedera/basket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/hedera/basket.js b/js/hedera/basket.js index 11b02538..517ed125 100644 --- a/js/hedera/basket.js +++ b/js/hedera/basket.js @@ -8,7 +8,7 @@ module.exports = class { } async check(orderId) { const resultSet = await this.app.conn.execQuery( - 'CALL myOrder_check(#id)', + 'CALL myOrder_checkConfig(#id)', {id: orderId} ); resultSet.fetchValue(); -- 2.40.1 From ca5f80f6c380e6d24c543c1ad1712fd60571cd65 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 15 Feb 2023 17:18:54 +0100 Subject: [PATCH 4/5] refs #5122 --- forms/ecomerce/basket/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms/ecomerce/basket/index.js b/forms/ecomerce/basket/index.js index e0583a24..16762bc3 100644 --- a/forms/ecomerce/basket/index.js +++ b/forms/ecomerce/basket/index.js @@ -16,7 +16,7 @@ export default new Class({ }, activate() { - this.$.items.setInfo('bi', 'myBasketItem', 'hedera'); + this.$.items.setInfo('bi', 'myOrderRow', 'hedera'); }, onConfigureClick() { -- 2.40.1 From 520e0c1eff7b93a581572e7d63f5fef33bf40217 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 16 Feb 2023 11:23:38 +0100 Subject: [PATCH 5/5] refs #5161 Version increased --- debian/changelog | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 389511fb..0b1a100e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (22.48.10) stable; urgency=low +hedera-web (23.6.1) stable; urgency=low * Initial Release. diff --git a/package.json b/package.json index 59043dd7..c9587a5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "22.48.10", + "version": "23.6.1", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { -- 2.40.1