Default agency when none is available

This commit is contained in:
Juan 2018-09-14 15:13:28 +02:00
parent 8cc05e174e
commit 28146b08ef
4 changed files with 37 additions and 6 deletions

2
debian/changelog vendored
View File

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

View File

@ -27,9 +27,21 @@ Hedera.Checkout = new Class ({
if (!date || date.getTime() < (new Date()).getTime()) {
date = new Date();
var addDays = 0;
switch(date.getDay()) {
case 6: // Saturday
addDays += 2;
break;
case 0: // Sunday
addDays++;
break;
}
if (i.get('deliveryMethod') != 'PICKUP')
date.setTime(date.getTime() + 86400000);
addDays++;
date.setTime(date.getTime() + addDays * 86400000);
}
this.$('date').value = date;
@ -175,7 +187,26 @@ Hedera.Checkout = new Class ({
},
onAgenciesReady: function(model) {
if (model.ready && model.numRows == 0)
if (!model.ready) return;
if (model.numRows > 0) {
var agency;
var defaults = [
this.$('order-form').get('agencyModeFk'),
this.$('defaults').get('agencyModeFk'),
this.$('defaults').get('defaultAgencyFk')
];
for (var i = 0; i < defaults.length; i++) {
agency = defaults[i];
if (model.search('id', agency) !== -1)
break;
}
this.autoStepLocked = true;
this.$('agency').value = agency;
this.autoStepLocked = false;
} else
Htk.Toast.showError(_('NoAgeciesAvailableForDate'));
},

View File

@ -6,7 +6,7 @@
<vn-param id="address" on-changed="onAddressChange"/>
<db-form id="defaults" on-ready="onValuesReady">
<db-model property="model">
SELECT deliveryMethod, agencyModeFk, addressFk
SELECT deliveryMethod, agencyModeFk, addressFk, defaultAgencyFk
FROM myBasketDefaults
</db-model>
</db-form>

View File

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