refs #5253 #22

Merged
juan merged 20 commits from test into master 2023-02-23 09:30:53 +00:00
40 changed files with 362 additions and 127 deletions
Showing only changes of commit d1ff6889af - Show all commits

View File

@ -5,8 +5,14 @@ export default new Class({
Template: require('./ui.xml'), Template: require('./ui.xml'),
async open() { async open() {
const isOk = await Hedera.BasketChecker.check(this.conn, this.hash); await Hedera.Form.prototype.open.call(this);
if (isOk) await Hedera.Form.prototype.open.call(this); this.basket = new Hedera.Basket(this.app);
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() {
@ -15,7 +21,22 @@ export default new Class({
onConfigureClick() { onConfigureClick() {
Htk.Toast.showWarning(_('RememberReconfiguringImpact')); Htk.Toast.showWarning(_('RememberReconfiguringImpact'));
this.hash.setAll({form: 'ecomerce/checkout'}); this.hash.setAll({
form: 'ecomerce/checkout',
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.orderId
});
}, },
onDeleteClick(form) { onDeleteClick(form) {

View File

@ -1,4 +1,6 @@
ShoppingBasket: Cistella de la compra ShoppingBasket: Cistella de la compra
Order: Encàrrec
ShippingInformation: Dades d'enviament
Delete: Borrar encàrrec Delete: Borrar encàrrec
GoToCatalog: Anar al catàleg GoToCatalog: Anar al catàleg
ConfigureOrder: Configurar encàrrec ConfigureOrder: Configurar encàrrec

View File

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

View File

@ -1,4 +1,6 @@
ShoppingBasket: Cesta de la compra ShoppingBasket: Cesta de la compra
Order: Pedido
ShippingInformation: Datos de envío
Delete: Borrar pedido Delete: Borrar pedido
GoToCatalog: Ir al catálogo GoToCatalog: Ir al catálogo
ConfigureOrder: Configurar pedido ConfigureOrder: Configurar pedido

View File

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

View File

@ -1,4 +1,6 @@
ShoppingBasket: Cesta da compra ShoppingBasket: Cesta da compra
Order: Encomenda
ShippingInformation: Dados de envio
Delete: Eliminar encomenda Delete: Eliminar encomenda
GoToCatalog: Ir ao catálogo GoToCatalog: Ir ao catálogo
ConfigureOrder: Configurar encomenda ConfigureOrder: Configurar encomenda

View File

@ -2,13 +2,29 @@
.hedera-basket { .hedera-basket {
.head { .head {
border-bottom: 1px solid #DDD; border-bottom: 1px solid #DDD;
}
.head p { & > div > div {
font-weight: bold; margin: 15px 0;
margin: 0; }
padding: 0; & > div > div:first-child {
font-size: 1.4rem; margin: 0;
text-align: right; }
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 { .form > p {
margin: 0; margin: 0;

View File

@ -1,6 +1,9 @@
<vn> <vn>
<vn-lot-query id="params">
<vn-spec name="id" type="Number"/>
</vn-lot-query>
<div id="title"> <div id="title">
<h1><t>ShoppingBasket</t></h1> <h1>{{_(params.$.id ? 'Order' : 'ShoppingBasket')}}</h1>
</div> </div>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button
@ -10,16 +13,38 @@
<htk-bar-button <htk-bar-button
icon="local_florist" icon="local_florist"
tip="_Catalog" tip="_Catalog"
on-click="this.hash.setAll({form: 'ecomerce/catalog'})"/> on-click="this.onCatalogClick()"/>
<htk-bar-button <htk-bar-button
icon="shopping_cart_checkout" icon="shopping_cart_checkout"
tip="_Checkout" tip="_Checkout"
on-click="this.hash.setAll({form: 'ecomerce/confirm'})"/> on-click="this.onConfirmClick()"/>
</div> </div>
<vn-group>
<vn-lot id="lot"/>
<db-form v-model="order">
<db-model property="model" lot="lot">
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;
</db-model>
</db-form>
</vn-group>
<div id="form" class="hedera-basket"> <div id="form" class="hedera-basket">
<div class="box vn-w-sm vn-pa-lg"> <div class="box vn-w-sm vn-pa-lg">
<div class="head vn-pb-lg"> <div class="head vn-pb-lg">
<p> <h5>#{{order.id}}</h5>
<div class="vn-mt-md">
<h6><t>ShippingInformation</t></h6>
<p></p>
<p><t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}}</p>
<p><span id="method"><t>Agency</t></span> {{order.agency}}</p>
<p>{{order.nickname}}</p>
</div>
<p class="total">
<t>Total</t> <t>Total</t>
<htk-text format="%.2d€"> <htk-text format="%.2d€">
<db-calc-sum property="param" func="subtotal" model="items"/> <db-calc-sum property="param" func="subtotal" model="items"/>
@ -28,15 +53,16 @@
</div> </div>
<div class="lines vn-pt-lg"> <div class="lines vn-pt-lg">
<htk-repeater form-id="iter"> <htk-repeater form-id="iter">
<db-model id="items" property="model" updatable="true"> <db-model id="items" property="model" lot="lot" updatable="true">
SELECT bi.id, bi.amount, bi.price, i.longName item, SELECT bi.id, bi.amount, bi.price, i.longName item,
i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7, i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7,
i.image, im.updated i.image, im.updated
FROM myBasketItem bi FROM myOrderRow bi
JOIN vn.item i ON i.id = bi.itemFk JOIN vn.item i ON i.id = bi.itemFk
LEFT JOIN image im LEFT JOIN image im
ON im.collectionFk = 'catalog' ON im.collectionFk = 'catalog'
AND im.name = i.image AND im.name = i.image
WHERE orderFk = #id
</db-model> </db-model>
<custom> <custom>
<div class="line"> <div class="line">

View File

@ -8,11 +8,21 @@ const Catalog = new Class({
,async open() { ,async open() {
let isOk = true; let isOk = true;
const basket = new Hedera.Basket(this.app);
this.orderId = basket.orderId;
if (!localStorage.getItem('hederaGuest')) if (!localStorage.getItem('hederaGuest')) {
isOk = await Hedera.BasketChecker.check(this.conn, this.hash); if (!this.orderId)
else return this.hash.setAll({form: 'ecomerce/checkout'});
await this.conn.execQuery('CALL mybasket_configureForGuest'); 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); if (isOk) await Hedera.Form.prototype.open.call(this);
} }
@ -20,6 +30,7 @@ const Catalog = new Class({
,activate() { ,activate() {
document.body.appendChild(this.$.rightPanel); document.body.appendChild(this.$.rightPanel);
this.$.items.setInfo('i', 'item', 'vn', ['id']); this.$.items.setInfo('i', 'item', 'vn', ['id']);
this.$.orderLot.assign({orderId: this.orderId});
if (localStorage.getItem('hederaView')) if (localStorage.getItem('hederaView'))
this.setView(parseInt(localStorage.getItem('hederaView'))); this.setView(parseInt(localStorage.getItem('hederaView')));
@ -98,6 +109,7 @@ const Catalog = new Class({
break; break;
} }
params.orderId = this.orderId;
const refreshItems = hasTagFilter const refreshItems = hasTagFilter
|| params.search != null || params.search != null
|| params.type != null; || params.type != null;
@ -245,7 +257,11 @@ const Catalog = new Class({
if (this.isGuest()) if (this.isGuest())
return; return;
this.hash.setAll({form: 'ecomerce/checkout'}); this.hash.setAll({
form: 'ecomerce/checkout',
id: this.orderId,
continue: 'catalog'
});
} }
,onAddItemClick(event, form) { ,onAddItemClick(event, form) {
@ -255,7 +271,10 @@ const Catalog = new Class({
this.onEraseClick(); this.onEraseClick();
this.$.$card.row = form.row; 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); this.$.cardPopup.show(event.currentTarget);
} }
@ -284,7 +303,7 @@ const Catalog = new Class({
,async onConfirmClick() { ,async onConfirmClick() {
var sql = ''; 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; var amountSum = 0;
for (var warehouse in this.items) { for (var warehouse in this.items) {
@ -292,6 +311,7 @@ const Catalog = new Class({
amountSum += amount; amountSum += amount;
const params = { const params = {
orderId: this.orderId,
warehouse: warehouse, warehouse: warehouse,
item: this.$.cardLot.$.item, item: this.$.cardLot.$.item,
amount: amount amount: amount

View File

@ -91,12 +91,14 @@
param="producer"/> param="producer"/>
</vn-group> </vn-group>
<vn-group> <vn-group>
<vn-lot id="order-lot"/>
<db-form v-model="basket"> <db-form v-model="basket">
<db-model property="model"> <db-model property="model" lot="order-lot">
SELECT b.id, b.sent, a.description agency, m.code method SELECT o.id, o.sent, a.description agency, m.code method
FROM myBasket b FROM myOrder o
JOIN vn.agencyMode a ON a.id = b.agencyModeFk JOIN vn.agencyMode a ON a.id = o.agencyModeFk
JOIN vn.deliveryMethod m ON m.id = b.deliveryMethodFk JOIN vn.deliveryMethod m ON m.id = o.deliveryMethodFk
WHERE o.id = #orderId
</db-model> </db-model>
</db-form> </db-form>
<db-model <db-model
@ -112,7 +114,7 @@
FROM vn.item i FROM vn.item i
JOIN vn.itemType t ON t.id = i.typeFk JOIN vn.itemType t ON t.id = i.typeFk
WHERE #filter; WHERE #filter;
CALL myBasket_calcCatalogFull; CALL myOrder_calcCatalogFull(#orderId);
SELECT i.id, i.longName item, i.subName, SELECT i.id, i.longName item, i.subName,
i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7, i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7,
i.relevancy, i.size, i.category, i.relevancy, i.size, i.category,
@ -261,7 +263,7 @@
lot="params" lot="params"
result-index="1" result-index="1"
on-status-changed="refreshTitle"> on-status-changed="refreshTitle">
CALL myBasket_getAvailable; CALL myOrder_getAvailable(#orderId);
SELECT DISTINCT t.id, l.name SELECT DISTINCT t.id, l.name
FROM vn.item i FROM vn.item i
JOIN vn.itemType t ON t.id = i.typeFk JOIN vn.itemType t ON t.id = i.typeFk
@ -283,7 +285,7 @@
property="model" property="model"
auto-load="false" auto-load="false"
result-index="1"> result-index="1">
CALL myBasket_getAvailable; CALL myOrder_getAvailable(#orderId);
SELECT DISTINCT l.id, l.name SELECT DISTINCT l.id, l.name
FROM vn.item i FROM vn.item i
JOIN vn.itemType t ON t.id = i.typeFk JOIN vn.itemType t ON t.id = i.typeFk
@ -304,7 +306,7 @@
property="model" property="model"
auto-load="false" auto-load="false"
result-index="1"> result-index="1">
CALL myBasket_getAvailable; CALL myOrder_getAvailable(#orderId);
SELECT DISTINCT p.id, p.name SELECT DISTINCT p.id, p.name
FROM vn.item i FROM vn.item i
JOIN vn.itemType t ON t.id = i.typeFk JOIN vn.itemType t ON t.id = i.typeFk
@ -325,7 +327,7 @@
property="model" property="model"
auto-load="false" auto-load="false"
result-index="1"> result-index="1">
CALL myBasket_getAvailable; CALL myOrder_getAvailable(#orderId);
SELECT DISTINCT o.id, l.name, o.code SELECT DISTINCT o.id, l.name, o.code
FROM vn.item i FROM vn.item i
JOIN vn.itemType t ON t.id = i.typeFk JOIN vn.itemType t ON t.id = i.typeFk
@ -347,7 +349,7 @@
property="model" property="model"
auto-load="false" auto-load="false"
result-index="1"> result-index="1">
CALL myBasket_getAvailable; CALL myOrder_getAvailable(#orderId);
SELECT DISTINCT i.category, i.category SELECT DISTINCT i.category, i.category
FROM vn.item i FROM vn.item i
JOIN vn.itemType t ON t.id = i.typeFk JOIN vn.itemType t ON t.id = i.typeFk
@ -466,7 +468,7 @@
result-index="1" result-index="1"
on-status-changed-after="onCardLoad" on-status-changed-after="onCardLoad"
lot="card-lot"> lot="card-lot">
CALL myBasket_calcCatalogFromItem(#item); CALL myOrder_calcCatalogFromItem(#orderId, #item);
SELECT l.warehouseFk, w.name warehouse, p.`grouping`, SELECT l.warehouseFk, w.name warehouse, p.`grouping`,
p.price, p.priceKg, p.rate, l.available p.price, p.priceKg, p.rate, l.available
FROM tmp.ticketLot l FROM tmp.ticketLot l

View File

@ -44,7 +44,7 @@ export default new Class({
} }
this.$.lot.assign({ this.$.lot.assign({
date: date, date,
method: row.deliveryMethod, method: row.deliveryMethod,
agency: row.agencyModeFk, agency: row.agencyModeFk,
address: row.addressFk address: row.addressFk
@ -59,11 +59,21 @@ export default new Class({
async onConfirmClick() { async onConfirmClick() {
this.disableButtons(true); this.disableButtons(true);
const query = 'CALL myBasket_configure(#date, #method, #agency, #address)'; let 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(@orderId, #date, #method, #agency, #address); SELECT @orderId;';
}
let resultSet; let resultSet;
try { try {
resultSet = await this.conn.execQuery(query, this.$.lot.$); resultSet = await this.conn.execQuery(query, params);
} finally { } finally {
this.disableButtons(false); this.disableButtons(false);
} }
@ -71,16 +81,25 @@ export default new Class({
if (!resultSet.fetchResult()) if (!resultSet.fetchResult())
return; return;
if (this.$.orderForm.numRows > 0) if (id) {
Htk.Toast.showMessage(_('OrderUpdated')); 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() { onCancelClick() {
if (this.$.orderForm.numRows > 0) if (this.$.params.$.id)
window.history.back(); window.history.back();
else else
this.hash.setAll({form: 'ecomerce/orders'}); this.hash.setAll({form: 'ecomerce/orders'});

View File

@ -1,4 +1,7 @@
<vn> <vn>
<vn-lot-query id="params">
<vn-spec name="id" type="Number"/>
</vn-lot-query>
<vn-group> <vn-group>
<vn-lot id="lot" on-change="this.onAddressChange()"/> <vn-lot id="lot" on-change="this.onAddressChange()"/>
<db-form id="defaults" on-ready="onValuesReady"> <db-form id="defaults" on-ready="onValuesReady">
@ -8,10 +11,11 @@
</db-model> </db-model>
</db-form> </db-form>
<db-form id="order-form" on-ready="onValuesReady"> <db-form id="order-form" on-ready="onValuesReady">
<db-model property="model"> <db-model property="model" lot="params">
SELECT m.code deliveryMethod, o.sent, o.agencyModeFk, o.addressFk 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 JOIN vn.deliveryMethod m ON m.id = o.deliveryMethodFk
WHERE o.id = #id
</db-model> </db-model>
</db-form> </db-form>
<db-model id="agencies" <db-model id="agencies"

View File

@ -5,8 +5,13 @@ export default new Class({
Template: require('./ui.xml'), Template: require('./ui.xml'),
async open() { async open() {
const isOk = await Hedera.BasketChecker.check(this.conn, this.hash); const basket = new Hedera.Basket(this.app);
if (isOk) await Hedera.Form.prototype.open.call(this); try {
await basket.check(this.hash.$.id);
} catch (err) {
Htk.Toast.showError(err.message);
}
await Hedera.Form.prototype.open.call(this);
}, },
onOrderReady(form) { onOrderReady(form) {
@ -113,7 +118,11 @@ export default new Class({
async onConfirmClick() { async onConfirmClick() {
Vn.Node.disableInputs(this.node); Vn.Node.disableInputs(this.node);
try { try {
await this.conn.execQuery('CALL myBasket_confirm'); await this.conn.execQuery(
'CALL myOrder_confirm(#id)',
this.$.params.$
);
Hedera.Basket.unload();
this.$.successDialog.show(); this.$.successDialog.show();
} finally { } finally {
Vn.Node.disableInputs(this.node, false); Vn.Node.disableInputs(this.node, false);

View File

@ -1,13 +1,16 @@
<vn> <vn>
<vn-lot-query id="params">
<vn-spec name="id" type="Number"/>
</vn-lot-query>
<vn-group> <vn-group>
<db-form v-model="order" on-ready="onOrderReady"> <db-form v-model="order" on-ready="onOrderReady">
<db-model property="model" result-index="1"> <db-model property="model" result-index="1" lot="params">
CALL myBasket_getTax; CALL myOrder_getTax(#id);
SELECT o.id, o.sent, o.notes, o.companyFk, SELECT o.id, o.sent, o.notes, o.companyFk,
ag.description agency, v.code method, ag.description agency, v.code method,
ad.nickname, ad.postalCode, ad.city, ad.street, ad.nickname, ad.postalCode, ad.city, ad.street,
t.*, c.credit, myClient_getDebt(NULL) debt t.*, c.credit, myClient_getDebt(NULL) debt
FROM myBasket o FROM myOrder o
JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk JOIN vn.agencyMode ag ON ag.id = o.agencyModeFk
LEFT JOIN myAddress ad ON ad.id = o.addressFk LEFT JOIN myAddress ad ON ad.id = o.addressFk
JOIN vn.deliveryMethod v ON v.id = o.deliveryMethodFk JOIN vn.deliveryMethod v ON v.id = o.deliveryMethodFk
@ -17,7 +20,8 @@
IFNULL(SUM(taxableBase), 0) taxableBase, IFNULL(SUM(taxableBase), 0) taxableBase,
IFNULL(SUM(tax), 0) tax IFNULL(SUM(tax), 0) tax
FROM tmp.orderAmount FROM tmp.orderAmount
) t; ) t
WHERE o.id = #id;
DROP TEMPORARY TABLE DROP TEMPORARY TABLE
tmp.orderAmount, tmp.orderAmount,
tmp.orderTax; tmp.orderTax;
@ -34,7 +38,7 @@
<div class="delivery"> <div class="delivery">
<h6><t>ShippingInformation</t></h6> <h6><t>ShippingInformation</t></h6>
<p> <p>
<t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}} <t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}}
</p> </p>
<p> <p>
<span id="method"><t>Agency</t></span> {{order.agency}} <span id="method"><t>Agency</t></span> {{order.agency}}

View File

@ -5,7 +5,7 @@ OrderNumber: N encàrrec
DateMake: Data de creació DateMake: Data de creació
DateExit: Data d'eixida DateExit: Data d'eixida
SendMethod: Forma d'enviament SendMethod: Forma d'enviament
LastOrders: Últimes comandes LastOrders: Comandes confirmades
'Balance:': 'Saldo:' 'Balance:': 'Saldo:'
PaymentInfo: >- PaymentInfo: >-
La quantitat mostrada és el teu saldo pendent (negatiu) o favorable a dia 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 DateMake: Creation date
DateExit: Shipping date DateExit: Shipping date
SendMethod: Delivery method SendMethod: Delivery method
LastOrders: Last orders LastOrders: Confirmed orders
'Balance:': 'Balance:' 'Balance:': 'Balance:'
PaymentInfo: >- PaymentInfo: >-
The amount shown is your slope (negative) or favorable balance today, it 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 DateMake: Fecha de creación
DateExit: Fecha de salida DateExit: Fecha de salida
SendMethod: Forma de envío SendMethod: Forma de envío
LastOrders: Últimos pedidos LastOrders: Pedidos confirmados
'Balance:': 'Saldo:' 'Balance:': 'Saldo:'
PaymentInfo: >- PaymentInfo: >-
La cantidad mostrada es tu saldo pendiente (negativa) o favorable a día de 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 DateMake: Date de creation
DateExit: Date de sortie DateExit: Date de sortie
SendMethod: Typo SendMethod: Typo
LastOrders: Les dernières commandes LastOrders: Commandes confirmées
'Balance:': 'Balance:' 'Balance:': 'Balance:'
PaymentInfo: >- PaymentInfo: >-
Le montant indiqué est votre pente (négative) ou balance favorable 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 DateMake: Data de criação
DateExit: Data de saída DateExit: Data de saída
SendMethod: Forma de envío SendMethod: Forma de envío
LastOrders: Últimas encomendas LastOrders: Encomendas confirmadas
'Balance:': 'Saldo:' 'Balance:': 'Saldo:'
PaymentInfo: >- PaymentInfo: >-
A quantidade mostrada é seu saldo pendente (negativo) ou favorável a dia de A quantidade mostrada é seu saldo pendente (negativo) ou favorável a dia de

View File

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

View File

@ -0,0 +1,21 @@
import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml'),
activate() {
this.basket = new Hedera.Basket(this.app);
this.$.orders.setInfo('o', 'myOrder', 'hedera', ['id'], 'id');
},
async onRemoveOrderClick(form) {
if (confirm(_('AreYouSureDeleteOrder')))
await form.deleteRow();
},
async loadOrder(id) {
const basket = new Hedera.Basket(this.app);
await basket.load(id);
}
});

View File

@ -0,0 +1 @@
Pending: Pendents

View File

@ -0,0 +1 @@
Pending: Pending

View File

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

View File

@ -0,0 +1 @@
Pending: Pendents

View File

@ -0,0 +1 @@
Pending: Pendientes

View File

View File

@ -0,0 +1,54 @@
<vn>
<div id="title">
<h1><t>PendingOrders</t></h1>
</div>
<div id="actions">
<htk-bar-button
class="start-order"
icon="add_shopping_cart"
tip="_NewOrder"
on-click="hash.setAll({form: 'ecomerce/checkout'})"/>
</div>
<div id="form" class="hedera-pending">
<htk-repeater
class="htk-list box confirmed vn-w-sm"
form-id="iter">
<db-model property="model" id="orders">
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
</db-model>
<custom>
<a class="item"
title="{{_('ViewOrder')}}"
href="{{'#!form=ecomerce/basket&amp;id='+iter.id}}">
<div class="content">
<p class="important">
{{Vn.Value.format(iter.sent, '%D')}}
</p>
<p>#{{iter.id}}</p>
<p>{{iter.nickname}}</p>
<p>{{iter.agency}}</p>
<p>{{Vn.Value.format(iter.total, '%.2d€')}}</p>
</div>
<div
class="actions"
on-click="$event.preventDefault()">
<htk-button
icon="delete"
tip="_RemoveOrder"
on-click="this.onRemoveOrderClick($iter)"/>
<htk-button
icon="shopping_bag"
tip="_LoadOrderIntoCart"
on-click="this.loadOrder(iter.id)"/>
</div>
</a>
</custom>
</htk-repeater>
</div>
</vn>

View File

@ -70,7 +70,9 @@ export const routes = {
orders: orders:
() => import('ecomerce/orders'), () => import('ecomerce/orders'),
ticket: ticket:
() => import('ecomerce/ticket') () => import('ecomerce/ticket'),
pending:
() => import('ecomerce/pending')
}, },
news: { news: {
new: new:

View File

@ -9,6 +9,24 @@ module.exports = new Class({
,get() { ,get() {
return this._conn; 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() { ,showLogin() {
const login = this._login = new Login({ const login = this._login = new Login({
app: this,
conn: this._conn, conn: this._conn,
hash: this._hash hash: this._hash
}); });
@ -47,6 +66,7 @@ module.exports = new Class({
if (this._gui) return; if (this._gui) return;
const gui = this._gui = new Gui({ const gui = this._gui = new Gui({
app: this,
conn: this._conn, conn: this._conn,
hash: this._hash hash: this._hash
}); });

View File

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

48
js/hedera/basket.js Normal file
View File

@ -0,0 +1,48 @@
module.exports = class {
constructor(app) {
this.app = app;
let orderId = localStorage.getItem('hederaBasket');
if (orderId) orderId = parseInt(orderId);
this.orderId = orderId;
}
async check(orderId) {
const resultSet = await this.app.conn.execQuery(
'CALL myOrder_checkConfig(#id)',
{id: orderId}
);
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;
}
}
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'));
}
}
static unload() {
localStorage.removeItem('hederaBasket');
}
};

View File

@ -7,6 +7,7 @@ module.exports = new Class({
,initialize(gui) { ,initialize(gui) {
this.gui = gui; this.gui = gui;
this.app = gui.app;
this.conn = gui.conn; this.conn = gui.conn;
this.hash = gui.hash; this.hash = gui.hash;
} }

View File

@ -10,6 +10,6 @@ Hedera = module.exports = {
,Report : require('./report') ,Report : require('./report')
,App : require('./app') ,App : require('./app')
,Tpv : require('./tpv') ,Tpv : require('./tpv')
,BasketChecker : require('./basket-checker') ,Basket : require('./basket')
}; };

View File

@ -38,7 +38,8 @@ AppName: Verdnatura
Home: Inici Home: Inici
Orders: Encàrrecs Orders: Encàrrecs
Basket: Cistella Basket: Cistella
Last orders: Últims comandes Pending orders: Pendents
Last orders: Confirmades
Invoices: Factures Invoices: Factures
Catalog: Catàleg Catalog: Catàleg
About: Coneix-nos About: Coneix-nos

View File

@ -34,7 +34,8 @@ AppName: Verdnatura
Home: Home Home: Home
Orders: Orders Orders: Orders
Basket: Basket Basket: Basket
Last orders: Last orders Pending orders: Pending
Last orders: Confirmed
Invoices: Invoices Invoices: Invoices
Catalog: Catalog Catalog: Catalog
About: About About: About

View File

@ -38,7 +38,8 @@ AppName: Verdnatura
Home: Inicio Home: Inicio
Orders: Pedidos Orders: Pedidos
Basket: Cesta Basket: Cesta
Last orders: Últimos pedidos Pending orders: Pendientes
Last orders: Confirmados
Invoices: Facturas Invoices: Facturas
Catalog: Catálogo Catalog: Catálogo
About: Conócenos About: Conócenos

View File

@ -38,7 +38,8 @@ AppName: Verdnatura
Home: Accueil Home: Accueil
Orders: Commandes Orders: Commandes
Basket: Panier Basket: Panier
Last orders: Dernières commandes Pending orders: En attente
Last orders: Confirmées
Invoices: Facturas Invoices: Facturas
Catalog: Catalogue Catalog: Catalogue
About: Nous About: Nous

View File

@ -36,7 +36,8 @@ AppName: VerdNatura
Home: Principio Home: Principio
Orders: Encomendas Orders: Encomendas
Basket: Cesta Basket: Cesta
Last orders: Últimas encomendas Pending orders: Pendentes
Last orders: Confirmados
Invoices: Facturas Invoices: Facturas
Catalog: Catálogo Catalog: Catálogo
About: Conheça-nos About: Conheça-nos