test #26

Merged
juan merged 10 commits from test into dev 2023-02-23 19:28:46 +00:00
33 changed files with 197 additions and 80 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (23.6.1) stable; urgency=low
hedera-web (23.6.5) stable; urgency=low
* Initial Release.

View File

@ -5,20 +5,46 @@ export default new Class({
Template: require('./ui.xml'),
async open() {
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});
await this.loadOrder();
if (this.orderId) {
await Hedera.Form.prototype.open.call(this);
this.$.lot.assign({id: this.orderId});
}
},
activate() {
this.$.items.setInfo('bi', 'myOrderRow', 'hedera');
},
async onHashChange() {
if (!this.isOpen) return;
await this.loadOrder();
if (this.orderId)
this.$.lot.assign({id: this.orderId});
},
async loadOrder() {
const basket = new Hedera.Basket(this.app);
if (this.hash.$.id) {
this.orderId = this.hash.$.id;
} else if (await basket.check()) {
this.orderId = basket.orderId;
}
},
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({

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,4 @@
<vn>
<vn-lot-query id="params">
<vn-spec name="id" type="Number"/>
</vn-lot-query>
<div id="title">
<h1>{{_(params.$.id ? 'Order' : 'ShoppingBasket')}}</h1>
</div>
@ -20,14 +17,18 @@
on-click="this.onConfirmClick()"/>
</div>
<vn-group>
<vn-lot-query id="params" on-change="this.onHashChange()">
<vn-spec name="id" type="Number"/>
</vn-lot-query>
<vn-lot id="lot"/>
<db-form v-model="order">
<db-form v-model="order" on-ready="onOrderReady">
<db-model property="model" lot="lot">
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;
</db-model>
@ -37,12 +38,20 @@
<div class="box vn-w-sm vn-pa-lg">
<div class="head vn-pb-lg">
<h5>#{{order.id}}</h5>
<div class="vn-mt-md">
<div class="delivery">
<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>
<p>{{order.nickname}}</p>
<p>
<t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}}
</p>
<p>
<span id="method"><t>Agency</t></span> {{order.agency}}
</p>
</div>
<div id="address" class="address vn-mt-md">
<h6><t>DeliveryAddress</t></h6>
<p>{{order.street}}</p>
<p>{{order.postalCode}}, {{order.city}}</p>
</div>
<p class="total">
<t>Total</t>

View File

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

View File

@ -94,10 +94,9 @@
<vn-lot id="order-lot"/>
<db-form v-model="basket">
<db-model property="model" lot="order-lot">
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
</db-model>
</db-form>
@ -207,11 +206,8 @@
</div>
<div id="right-panel" class="catalog-panel right-panel side-panel" on-click="onRightPanelClick">
<div class="basket-info">
<p>{{basket.nickname}}</p>
<p>{{Vn.Value.format(basket.sent, '%D')}}</p>
<p>
{{_(basket.method != 'PICKUP' ? 'Agency' : 'Warehouse')}}
{{basket.agency}}
</p>
<button class="thin" on-click="this.onConfigureClick()">
<t>Modify</t>
</button>

View File

@ -81,21 +81,27 @@ export default new Class({
if (!resultSet.fetchResult())
return;
let redirect;
const basket = new Hedera.Basket(this.app);
if (id) {
Htk.Toast.showMessage(_('OrderUpdated'));
switch(this.hash.$.continue) {
case 'catalog':
this.hash.setAll({form: 'ecomerce/catalog'});
redirect = {form: 'ecomerce/catalog'};
break;
default:
this.hash.setAll({form: 'ecomerce/basket', id});
redirect = {form: 'ecomerce/basket'};
if (id !== basket.orderId)
redirect.id = id;
}
} else {
const basket = new Hedera.Basket(this.app);
basket.loadIntoBasket(resultSet.fetchValue());
this.hash.setAll({form: 'ecomerce/catalog'});
redirect = {form: 'ecomerce/catalog'};
}
this.hash.setAll(redirect);
},
onCancelClick() {

View File

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

View File

@ -6,9 +6,9 @@
<db-form v-model="order" on-ready="onOrderReady">
<db-model property="model" result-index="1" lot="params">
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 @@
<div class="vn-w-sm">
<div class="box vn-pa-lg summary">
<div>
<h5>#{{order.id}}</h5>
<div class="delivery">
<h6><t>ShippingInformation</t></h6>
<p>{{order.nickname}}</p>
<p>
<t>Delivery at</t> {{Vn.Value.format(order.sent, _('%D'))}}
</p>
@ -46,7 +48,6 @@
</div>
<div id="address" class="address vn-mt-md">
<h6><t>DeliveryAddress</t></h6>
<p>{{order.nickname}}</p>
<p>{{order.street}}</p>
<p>{{order.postalCode}}, {{order.city}}</p>
</div>

View File

@ -1 +1,8 @@
Pending: Pendents
PendingOrders: Comandes pendents
NewOrder: Nova comanda
ViewOrder: Veure comanda
RemoveOrder: Eliminar comanda
LoadOrderIntoCart: Carregar comanda a la cistella
AreYouSureDeleteOrder: Segur que vols esborrar la comanda?
OrderLoadedIntoBasket: Comanda carregada a la cistella!

View File

@ -1 +1,8 @@
Pending: Pending
PendingOrders: Pending orders
NewOrder: New order
ViewOrder: View order
RemoveOrder: Delete order
LoadOrderIntoCart: Load order into cart
AreYouSureDeleteOrder: Are you sure you want to delete the order?
OrderLoadedIntoBasket: Order loaded into basket!

View File

@ -5,4 +5,4 @@ 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!
OrderLoadedIntoBasket: ¡Pedido cargado en la cesta!

View File

@ -1 +1,8 @@
Pending: Pendents
Pending: En attente
PendingOrders: Commandes en attente
NewOrder: Nouvelle commande
ViewOrder: Afficher la commande
RemoveOrder: Supprimer la commande
LoadOrderIntoCart: Charger la commande dans le panier
AreYouSureDeleteOrder: Êtes-vous sûr de vouloir supprimer la commande?
OrderLoadedIntoBasket: Commande chargée dans le panier!

View File

@ -1 +1,8 @@
Pending: Pendientes
Pending: Pendentes
PendingOrders: Pedidos pendentes
NewOrder: Novo pedido
ViewOrder: Ver pedido
RemoveOrder: Excluir pedido
LoadOrderIntoCart: Carrega o pedido no carrinho
AreYouSureDeleteOrder: Tem certeza de que deseja excluir o pedido?
OrderLoadedIntoBasket: Pedido carregado na cesta!

View File

@ -6,33 +6,62 @@ 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(checkoutContinue) {
if (this.orderId) {
return await this.checkRedirect(checkoutContinue);
} else {
this.redirect();
return false;
}
}
async checkRedirect(checkoutContinue) {
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') {
switch(err.code) {
case 'orderConfirmed':
case 'orderNotOwnedByUser':
this.constructor.unload();
await this.redirect();
break;
default:
this.app.hash.setAll({
form: 'ecomerce/checkout',
id: this.orderId,
continue: checkoutContinue
});
Htk.Toast.showError(err.message);
}
return false;
} else
throw err;
}
}
async redirect() {
const resultSet = await this.app.conn.execQuery(
'SELECT COUNT(*) > 0 FROM myOrder');
if (resultSet.fetchValue()) {
this.app.hash.setAll({form: 'ecomerce/pending'});
Htk.Toast.showMessage(_('Load an order'));
} else {
this.app.hash.setAll({form: 'ecomerce/checkout'});
}
}
async load(orderId) {
this.loadIntoBasket(orderId);
if (!await this.checkRedirect(orderId)) return;
this.app.hash.setAll({
form: 'ecomerce/catalog'
});
if (await this.checkRedirect('catalog'))
this.app.hash.setAll({
form: 'ecomerce/catalog'
});
}
loadIntoBasket(orderId) {
if (this.orderId != orderId) {

View File

@ -63,3 +63,5 @@ Agencies: Agències
Configuration: Configuració
Account: Compte
Addresses: Adreces
Load an order: Si us plau carrega una comanda pendent a la cistella o en comença una de nova

View File

@ -59,3 +59,5 @@ Agencies: Agencies
Configuration: Configuration
Account: Account
Addresses: Addresses
Load an order: Please load a pending order to the cart or start a new one

View File

@ -63,3 +63,5 @@ Agencies: Agencias
Configuration: Configuración
Account: Cuenta
Addresses: Direcciones
Load an order: Por favor carga un pedido pendiente en la cesta o empieza uno nuevo

View File

@ -63,3 +63,5 @@ Agencies: Agences
Configuration: Configuration
Account: Compte
Addresses: Adresses
Load an order: Veuillez télécharger une commande en attente dans le panier ou en démarrer une nouvelle

View File

@ -61,3 +61,5 @@ Agencies: Agências
Configuration: Configuração
Account: Conta
Addresses: Moradas
Load an order: Carregue um pedido pendente no carrinho ou inicie um novo

View File

@ -55,7 +55,7 @@ module.exports =
,'Dec'
]
,tokenD: '%A, %B %e'
,tokenD: '%A, %B %e %Y'
,regexp: new RegExp('%[a-zA-Z]', 'g')
@ -101,7 +101,7 @@ module.exports =
// Year with 4 digits
case 'Y': return d.getFullYear();
// Complete date without year
// Complete date
case 'D': return _(this.tokenD).replace(this.regexp, this.regexpFunc.bind(this, d));
}

View File

@ -36,7 +36,7 @@ Sep: Set
Oct: Oct
Nov: Nov
Dec: Des
'%A, %B %e': '%A, %e de %B'
'%A, %B %e %Y': '%A, %e de %B de %Y'
Something went wrong: Alguna cosa ha anat malament
'The server does not respond, please check your Internet connection': 'El servidor no respon, si us plau comprova la teva connexió a Internet'
Accept: Acceptar

View File

@ -36,6 +36,6 @@ Sep: Sep
Oct: Oct
Nov: Nov
Dec: Dic
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Something went wrong
'The server does not respond, please check your Internet connection': 'The server does not respond, please check you Internet connection'

View File

@ -36,7 +36,7 @@ Sep: Sep
Oct: Oct
Nov: Nov
Dec: Dic
'%A, %B %e': '%A, %e de %B'
'%A, %B %e %Y': '%A, %e de %B de %Y'
Something went wrong: Algo salió mal
'The server does not respond, please check your Internet connection': 'El servidor no responde, por favor comprueba tu conexión a Internet'
Accept: Aceptar

View File

@ -36,7 +36,7 @@ Sep: Sep
Oct: Oct
Nov: Nov
Dec: Déc
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Quelque-chose s'est mal passé
'The server does not respond, please check your Internet connection': 'Le serveur ne répond pas, s''il vous plaît vérifier votre connexion Internet'
Accept: Accepter

View File

@ -36,6 +36,6 @@ Sep: Есд
Oct: Ара
Nov: Арв
Dec: Арв
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Something went wrong
'The server does not respond, please check your Internet connection': 'The server does not respond, please check you Internet connection'

View File

@ -36,7 +36,7 @@ Sep: Set
Oct: Out
Nov: Nov
Dec: Dez
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Algo deu errado
'The server does not respond, please check your Internet connection': 'O servidor não responde, por favor, verifique sua conexão com a Internet'
Accept: Aceitar

View File

@ -1,6 +1,6 @@
{
"name": "hedera-web",
"version": "23.6.1",
"version": "23.6.5",
"description": "Verdnatura web page",
"license": "GPL-3.0",
"repository": {

View File

@ -48,13 +48,13 @@ class JsonService extends RestService {
$json = new JsonException();
if (_ENABLE_DEBUG || $errno & $eUser)
if (_ENABLE_DEBUG || $errno & $eUser) {
$json->message = $message;
else
$json->code = $errno;
} else
$json->message = s('Something went wrong');
if (_ENABLE_DEBUG) {
$json->code = $errno;
$json->file = $file;
$json->line = $line;
}
@ -79,13 +79,13 @@ class JsonService extends RestService {
if (_ENABLE_DEBUG || $e instanceof Lib\UserException) {
$json->exception = get_class($e);
$json->message = $e->getMessage();
$json->code = $e->getCode();
} else {
$json->exception = 'Exception';
$json->message = s('Something went wrong');
}
if (_ENABLE_DEBUG) {
$json->code = $e->getCode();
$json->file = $e->getFile();
$json->line = $e->getLine();
$json->trace = $e->getTrace();