diff --git a/forms/ecomerce/checkout/checkout.js b/forms/ecomerce/checkout/checkout.js
index defd2fe2..1021bf16 100644
--- a/forms/ecomerce/checkout/checkout.js
+++ b/forms/ecomerce/checkout/checkout.js
@@ -1,3 +1,22 @@
+(function () {
+
+var methodsData = {
+ AGENCY: {
+ steps: ['method', 'date', 'address', 'agency', 'confirm'],
+ isDelivery: true,
+ textId: 'agencyText'
+ },
+ DELIVERY: {
+ steps: ['method', 'date', 'address', null, 'confirm'],
+ isDelivery: true,
+ textId: 'deliveryText'
+ },
+ PICKUP: {
+ steps: ['method', 'date', 'address', 'pickup', 'confirm'],
+ isDelivery: false,
+ textId: 'pickupText'
+ }
+};
Hedera.Checkout = new Class
({
@@ -28,7 +47,7 @@ Hedera.Checkout = new Class
if (orderForm.numRows > 0)
{
var i = orderForm;
- date = i.get ('date_send');
+ date = i.$.date_send;
}
else
var i = defaultsForm;
@@ -37,7 +56,7 @@ Hedera.Checkout = new Class
{
date = new Date ();
- if (i.get('delivery_method') != 'PICKUP')
+ if (i.$.delivery_method != 'PICKUP')
date.setDate (date.getDate () + 1);
date.setHours (0, 0, 0, 0);
@@ -45,18 +64,16 @@ Hedera.Checkout = new Class
this.$.lot.assign ({
date: date,
- method: i.get ('delivery_method'),
- agency: i.get ('agency_id'),
- address: i.get ('address_id')
+ method: i.$.delivery_method,
+ agency: i.$.agency_id,
+ address: i.$.address_id
});
this.autoStepLocked = false;
}
,disableButtons: function (disable)
{
- this.$.confirmAgency.disabled = disable;
- this.$.confirmDelivery.disabled = disable;
- this.$.confirmPickup.disabled = disable;
+ this.$.confirmButton.disabled = disable;
}
,onConfirmClick: function ()
@@ -75,10 +92,8 @@ Hedera.Checkout = new Class
if (!resultSet.fetchResult ())
return;
- if (this.$.orderForm.numRows > 0)
- Htk.Toast.showMessage (_('OrderUpdated'));
- else
- Htk.Toast.showMessage (_('OrderStarted'));
+ var isUpdated = this.$.orderForm.numRows > 0;
+ Htk.Toast.showMessage (_(isUpdated ? 'OrderUpdated' : 'OrderStarted'));
this.hash.setAll ({form: 'ecomerce/catalog'});
}
@@ -88,55 +103,45 @@ Hedera.Checkout = new Class
if (this.$.orderForm.numRows > 0)
window.history.back();
else
- this.hash.setAll ({'form': 'ecomerce/orders'});
+ this.hash.setAll ({form: 'ecomerce/orders'});
}
- ,agencySteps: ['method', 'date', 'address', 'agency', 'confirm-agency']
- ,deliverySteps: ['method', 'date', 'address', null, 'confirm-delivery']
- ,pickupSteps: ['method', 'date', 'address', 'pickup', 'confirm-pickup']
-
,stepFunc: function (stepIndex)
{
- var steps;
- var isDelivery;
-
- switch (this.$.rgMethod.value)
- {
- case 'AGENCY':
- steps = this.agencySteps;
- isDelivery = true;
- break;
- case 'DELIVERY':
- steps = this.deliverySteps;
- isDelivery = true;
- break;
- case 'PICKUP':
- default:
- steps = this.pickupSteps;
- isDelivery = false;
- break;
- }
+ var method = this.$.rgMethod.value;
+ var methodData = methodsData[method];
+ var stepName;
- var stepId = steps[stepIndex];
-
- if (!stepId)
+ if (methodData !== undefined)
+ stepName = methodData.steps[stepIndex];
+ else
+ stepName = 'method';
+
+ if (!stepName)
return null;
- switch (stepId)
+ switch (stepName)
{
case 'date':
- Vn.Node.setText (this.$.dateQuestion, isDelivery ?
- _('OrderDateDeliveryQuestion'):
- _('OrderDatePickupQuestion'));
+ var dateQuestion = methodData.isDelivery ?
+ 'OrderDateDeliveryQuestion' : 'OrderDatePickupQuestion';
+ Vn.Node.setText (_(dateQuestion));
this.$.calendar.goToSelectedMonth ();
break;
case 'agency':
case 'pickup':
this.$.agencies.refresh ();
break;
+ case 'confirm':
+ for (var myMethod in methodsData)
+ {
+ var display = myMethod == method ? 'block': 'none';
+ this.$[methodsData[myMethod].textId].style.display = display;
+ }
+ break;
}
- return this.$[stepId +'Step'];
+ return stepName;
}
,onFieldChange: function ()
@@ -153,7 +158,7 @@ Hedera.Checkout = new Class
,addressRenderer: function (builder, form)
{
builder.$.address.addEventListener ('click',
- this.onAddressClick.bind (this, form.get ('id')));
+ this.onAddressClick.bind (this, form.$.id));
}
,onAddressClick: function (addressId)
@@ -167,7 +172,7 @@ Hedera.Checkout = new Class
if (this.selectedNode)
Vn.Node.removeClass (this.selectedNode, 'selected');
- var row = this.$.addresses.search ('id', this.$.lot.get ('address'));
+ var row = this.$.addresses.search ('id', this.$.lot.$.address);
if (row != -1)
{
@@ -198,3 +203,4 @@ Hedera.Checkout = new Class
}
});
+})();
diff --git a/forms/ecomerce/checkout/style.css b/forms/ecomerce/checkout/style.css
index 69afe227..37ed975d 100644
--- a/forms/ecomerce/checkout/style.css
+++ b/forms/ecomerce/checkout/style.css
@@ -71,15 +71,11 @@
.thin-calendar
{
width: inherit;
- max-width: 24em;
+ max-width: 22em;
margin: 0 auto;
box-shadow: 0 0.1em 0.3em #ccc;
font-size: .7em;
}
-.thin-calendar tr > th
-{
- color: white;
-}
.htk-assistant .thin
{
float: right;
diff --git a/forms/ecomerce/checkout/ui.xml b/forms/ecomerce/checkout/ui.xml
index b0ee96e6..25c71ca3 100755
--- a/forms/ecomerce/checkout/ui.xml
+++ b/forms/ecomerce/checkout/ui.xml
@@ -14,6 +14,15 @@
JOIN vn.deliveryMethod d ON d.id = o.delivery_method_id
+
+
+ SELECT a.id, a.consignee, p.name province, a.zip_code, a.city, a.name, a.active, c.Pais country
+ FROM address_view a
+ LEFT JOIN vn2008.province p ON a.province_id = p.province_id
+ JOIN vn2008.Paises c ON c.Id = p.Paises_Id
+ WHERE active != FALSE
+
+
-
-
+ step-func="stepFunc">
+
_DeliveryOrPickupQuestion
_PickupInStore
-
-
+
+
_OrderDateDeliveryQuestion
-
-
+
+
_AddressQuestion
-
-
- SELECT a.id, a.consignee, p.name province, a.zip_code, a.city, a.name, a.active, c.Pais country
- FROM address_view a
- LEFT JOIN vn2008.province p ON a.province_id = p.province_id
- JOIN vn2008.Paises c ON c.Id = p.Paises_Id
- WHERE active != FALSE
-
+ renderer="addressRenderer"
+ model="addresses">