refs #5253 #22

Merged
juan merged 20 commits from test into master 2023-02-23 09:30:53 +00:00
25 changed files with 139 additions and 114 deletions
Showing only changes of commit 67b6f77b12 - Show all commits

View File

@ -6,15 +6,13 @@ 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() {
@ -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
});
},

View File

@ -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

View File

@ -1,4 +1,6 @@
ShoppingBasket: Shopping basket
Order: Order
ShippingInformation: Shipping information
Delete: Delete order
GoToCatalog: Go to catalog
ConfigureOrder: Configure order

View File

@ -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

View File

@ -1,4 +1,6 @@
ShoppingBasket: Panier
Order: Commande
ShippingInformation: Informations sur la livraison
Delete: Effacer
GoToCatalog: Aller au catalogue
ConfigureOrder: Définissez l'ordre

View File

@ -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

View File

@ -13,15 +13,16 @@
<htk-bar-button
icon="local_florist"
tip="_Catalog"
on-click="this.hash.setAll({form: 'ecomerce/catalog'})"/>
on-click="this.onCatalogClick()"/>
<htk-bar-button
icon="shopping_cart_checkout"
tip="_Checkout"
on-click="this.onConfirmClick()"/>
</div>
<vn-group>
<vn-lot id="lot"/>
<db-form v-model="order">
<db-model property="model" lot="params">
<db-model property="model" lot="lot">
SELECT o.id, o.sent,
ag.description agency, v.code method, ad.nickname
FROM myOrder o
@ -52,7 +53,7 @@
</div>
<div class="lines vn-pt-lg">
<htk-repeater form-id="iter">
<db-model id="items" property="model" lot="params" updatable="true">
<db-model id="items" property="model" lot="lot" updatable="true">
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

View File

@ -8,11 +8,21 @@ 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);
}
@ -20,6 +30,7 @@ const Catalog = new Class({
,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

View File

@ -91,12 +91,14 @@
param="producer"/>
</vn-group>
<vn-group>
<vn-lot id="order-lot"/>
<db-form v-model="basket">
<db-model property="model">
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
<db-model property="model" lot="order-lot">
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
</db-model>
</db-form>
<db-model
@ -112,7 +114,7 @@
FROM vn.item i
JOIN vn.itemType t ON t.id = i.typeFk
WHERE #filter;
CALL myBasket_calcCatalogFull;
CALL myOrder_calcCatalogFull(#orderId);
SELECT i.id, i.longName item, i.subName,
i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7,
i.relevancy, i.size, i.category,
@ -261,7 +263,7 @@
lot="params"
result-index="1"
on-status-changed="refreshTitle">
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

View File

@ -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() {

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -33,6 +33,6 @@
/* List */
.orders .htk-list .total {
.hedera-orders .htk-list .total {
float: right;
}

View File

@ -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);
}
});

View File

@ -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');
}
};

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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