+
OrderDateDeliveryQuestion
@@ -96,13 +87,20 @@
AgencyQuestion
-
+
+ CALL agency_list_by_date (#date, #address);
SELECT a.Id_Agencia, a.description
- FROM vn2008.Agencias a
+ FROM t_agency t
+ JOIN vn2008.Agencias a ON a.Id_Agencia = t.agency_id
JOIN vn2008.Vistas v ON a.Vista = v.vista_id
WHERE a.web != FALSE
AND v.code = 'AGENCY'
- ORDER BY a.description
+ ORDER BY a.description;
+ DROP TEMPORARY TABLE t_agency;
+
+
+
+
@@ -137,7 +135,7 @@
@@ -156,7 +154,7 @@
ReceiveThroughtRoute
@@ -173,7 +171,7 @@
diff --git a/package/usr/share/hedera-web/forms/ecomerce/confirm/confirm.js b/package/usr/share/hedera-web/forms/ecomerce/confirm/confirm.js
new file mode 100755
index 00000000..8adcacd7
--- /dev/null
+++ b/package/usr/share/hedera-web/forms/ecomerce/confirm/confirm.js
@@ -0,0 +1,166 @@
+
+Vn.Confirm = new Class
+({
+ Extends: Vn.Module
+
+ ,activate: function ()
+ {
+ this.tpv = new Vn.Tpv (this.conn, this.hash);
+ }
+
+ ,onStatusChange: function (form)
+ {
+ if (form.row != -1)
+ this.$('total').value = form.get ('tax_base') + form.get ('vat');
+ else
+ this.$('total').value = null;
+ }
+
+ ,disableButtons: function (disable)
+ {
+ this.$('modify').disabled = disable;
+ this.$('confirm').disabled = disable;
+ }
+
+ ,onModifyClick: function ()
+ {
+ window.history.back();
+ }
+
+ ,onConfirmClick: function ()
+ {
+// var query = 'CALL order_confirm (#order)';
+ var query = 'SELECT TRUE ok, customer_get_debt() debt';
+
+ var batch = new Sql.Batch ();
+ batch.addParam ('order', this.$('order-id'));
+
+ this.conn.execQuery (query, this.confirmDone.bind (this), batch);
+ }
+
+ ,confirmDone: function (resultSet)
+ {
+ var res = resultSet.fetchResult ();
+
+ if (!(res && res.next()))
+ this.goBasket ();
+
+ Vn.Cookie.unset ('order');
+ this.pay = res.get ('debt') > this.$('order-form').get ('credit');
+
+ this.popup = new Htk.Popup ();
+ this.popup.setChildNode (this.$('success-dialog'));
+ this.popup.showCenter ();
+ }
+
+ ,onAcceptClick: function ()
+ {
+ this.popup.hide ();
+
+ if (this.pay)
+ this.tpv.pay (this.$('total').value,
+ this.$('order-form').get ('company_id'));
+ else
+ this.hash.set ({'form': 'ecomerce/orders'});
+ }
+});
+
+Vn.Tpv = new Class
+({
+ initialize: function (conn, hash)
+ {
+ this.conn = conn;
+ this.hash = hash;
+
+ var tpvStatus = this.hash.get ('tpv_status');
+
+ if (tpvStatus)
+ {
+ var batch = new Sql.Batch ();
+ batch.addValue ('transaction', this.hash.get ('tpv_order'));
+ batch.addValue ('status', tpvStatus);
+
+ var query = 'CALL transaction_end (#transaction, #status)';
+
+ this.conn.execQuery (query, null, batch);
+ }
+ }
+
+ ,pay: function (amount, company)
+ {
+ if (amount > 0)
+ {
+ var query = 'CALL transaction_start (#company, #amount)';
+
+ var batch = new Sql.Batch ();
+ batch.addValue ('company', company);
+ batch.addValue ('amount', parseInt (amount * 100));
+
+ this.conn.execQuery (query,
+ this.onTransactionStart.bind (this), batch);
+ }
+ else if (!isNaN (amount))
+ (new Htk.Toast ()).showError (_('AmountError'));
+ }
+
+ ,onTransactionStart: function (resultSet)
+ {
+ var res = resultSet.fetchResult ();
+
+ if (res && res.next ())
+ {
+ var form = document.createElement ('form');
+ form.method = 'post';
+ form.action = res.get ('url');
+ document.body.appendChild (form);
+
+ var fieldsMap =
+ {
+ 'Ds_Merchant_Amount': 'amount'
+ ,'Ds_Merchant_Order': 'ds_order'
+ ,'Ds_Merchant_MerchantCode': 'id'
+ ,'Ds_Merchant_Currency': 'currency'
+ ,'Ds_Merchant_TransactionType': 'transaction_type'
+ ,'Ds_Merchant_Terminal': 'terminal'
+ ,'Ds_Merchant_MerchantURL': 'merchant_url'
+ ,'Ds_Merchant_MerchantSignature': 'signature'
+ ,'Ds_Merchant_UrlOK': null
+ ,'Ds_Merchant_UrlKO': null
+ };
+
+ for (var field in fieldsMap)
+ {
+ var input = document.createElement ('input');
+ input.type = 'hidden';
+ input.name = field;
+ form.appendChild (input);
+
+ if (fieldsMap[field])
+ input.value = res.get (fieldsMap[field]);
+ }
+
+ var transactionId = res.get ('ds_order');
+ form['Ds_Merchant_UrlOK'].value = this.makeUrl ('ok', transactionId);
+ form['Ds_Merchant_UrlKO'].value = this.makeUrl ('ko', transactionId);
+
+ form.submit ();
+ }
+ else
+ alert (_('PayError'));
+ }
+
+ ,makeUrl: function (status, order)
+ {
+ var path = location.protocol +'//'+ location.host;
+ path += location.port ? ':'+ location.port : '';
+ path += location.pathname;
+ path += location.search ? location.search : '';
+ path += this.hash.make ({
+ 'tpv_status': status,
+ 'tpv_order': order
+ }, true);
+
+ return path;
+ }
+});
+
diff --git a/package/usr/share/hedera-web/forms/ecomerce/confirm/shipping.js b/package/usr/share/hedera-web/forms/ecomerce/confirm/shipping.js
deleted file mode 100755
index e57b6fdb..00000000
--- a/package/usr/share/hedera-web/forms/ecomerce/confirm/shipping.js
+++ /dev/null
@@ -1,126 +0,0 @@
-
-Vn.Shipping = new Class
-({
- Extends: Vn.Module
-
- ,activate: function ()
- {
- // Loading order
-
- this.orderId = this.$('order-id');
-
- if (!this.orderId.value)
- {
- var orderId = Vn.Cookie.getInt ('order');
-
- if (!orderId)
- {
- var sql = 'INSERT INTO order_view (date_send) VALUES (CURDATE());'
- +'SELECT LAST_INSERT_ID();';
- this.conn.execQuery (sql, this.orderCreated.bind (this));
- }
- else
- this.orderId.value = orderId;
- }
-
- this.onDeliveryChange ();
- }
-
- ,onStatusChange: function (form)
- {
- if (this.$('address').value == 0)
- form.insertRow ();
- }
-
- ,onOperationsDone: function ()
- {
- this.onReturnClick ();
- }
-
- ,onAcceptClick: function ()
- {
- this.$('iter').performOperations ();
- }
-
- ,onReturnClick: function ()
- {
- window.history.back();
- }
-
- ,goBasket: function ()
- {
- this.hash.set ({
- 'form': 'ecomerce/basket',
- 'order': this.$('order-id').value
- });
- }
-
- ,onDeliveryChange: function ()
- {
- var showAgencies = false;
- var showAdresses = false;
- var showStores = false;
- var deliveryMethod = parseInt (this.$('delivery').value);
-
- switch (deliveryMethod)
- {
- case 1: // AGENCY
- var showAgencies = true;
- var showAdresses = true;
- break;
- case 2: // DELIVERY
- var showAdresses = true;
- break;
- case 3: // PICKUP
- var showStores = true;
- break;
- }
-
- this.$('agencies-div').style.display = showAgencies ? '' : 'none';
- this.$('addresses-div').style.display = showAdresses ? '' : 'none';
- this.$('stores-div').style.display = showStores ? '' : 'none';
- }
-
- ,onConfirmClick: function ()
- {
- if (!confirm (_('SureConfirmOrder')))
- return;
-
- var query = 'CALL order_confirm (#order)';
-
- var batch = new Sql.Batch ();
- batch.addParam ('order', this.$('order-id'));
-
- this.conn.execQuery (query, this.confirmDone.bind (this), batch);
- }
-
- ,confirmDone: function (resultSet)
- {
- if (resultSet.fetchResult ())
- {
- Vn.Cookie.unset ('order');
- this.hash.set ({'form': 'ecomerce/orders'});
-
- (new Htk.Toast ()).showMessage (_('OrderConfirmed'));
- }
- else
- this.goBasket ();
- }
-
- ,onAddAddressClick: function ()
- {
- this.hash.set ({
- 'form': 'account/address',
- 'address': 0
- });
- }
-
- ,onEditAddressClick: function (button, form)
- {
- this.hash.set ({
- 'form': 'account/address',
- 'address': form.get ('id')
- });
- }
-});
-
diff --git a/package/usr/share/hedera-web/forms/ecomerce/confirm/style.css b/package/usr/share/hedera-web/forms/ecomerce/confirm/style.css
index d9d62b95..7676263c 100755
--- a/package/usr/share/hedera-web/forms/ecomerce/confirm/style.css
+++ b/package/usr/share/hedera-web/forms/ecomerce/confirm/style.css
@@ -1,87 +1,84 @@
-.shipping
+.confirm
{
padding: 1em;
-}
-.shipping
-{
- max-width: 70em;
+ max-width: 40em;
margin: 0 auto;
}
-
-table.form td.label
+.confirm h2
{
- width: 30%;
+ padding: 0;
+ font-size: 1.6em;
+ color: black;
+ margin: 0 3em;
}
-
-/* Checkout */
-
-.checkout .form
+.confirm .form
{
margin: 0 auto;
- max-width: 25em;
+ padding: 3em 4em;
+ color: #555;
+}
+.confirm .form p,
+.confirm .form select,
+.confirm .form button
+{
+ font-size: 1.4em;
+}
+.confirm .form > div.section
+{
+ margin-bottom: 1.5em;
+}
+.confirm .form p
+{
+ margin: .2em 0;
+}
+.confirm .form p.small
+{
+ font-size: 1em;
+}
+.button-bar
+{
+ margin-top: 2em;
+}
+.modify-order
+{
+ float: left;
+}
+.confirm-order
+{
+ float: right;
+}
+
+/* Success dialog */
+
+.success-dialog
+{
padding: 2em;
+ min-width: 30em;
+ max-width: 35em;
+}
+.success-dialog *
+{
+ font-weight: normal;
+ color: #555;
+}
+.success-dialog p,
+.success-dialog button
+{
+ font-size: 1.4em;
+}
+.success-dialog img
+{
+ float: left;
+ height: 3em;
+ margin-top: 0;
+ margin-right: 1.5em;
+}
+.success-dialog p
+{
+ padding: 0;
+}
+.success-dialog > button
+{
+ margin-top: 0.5em;
}
-/* Form */
-
-.form-group
-{
- padding: 0.4em;
-}
-.form-group > label
-{
- display: block;
- margin-bottom: 0.5em;
-}
-.form-group > input[type=text],
-.form-group > input[type=password],
-.form-group > select,
-.form-group > textarea
-{
- margin: 0;
- width: 100%;
-}
-
-/* Delivery method */
-
-ul.delivery
-{
- list-style-type: none;
- margin: 0;
- padding-top: 0.8em;
- padding-left: 1em;
-}
-ul.delivery > li
-{
- margin: 0.2em 0;
-}
-ul.delivery input
-{
- margin-right: 0.4em;
-}
-
-/* Addresses */
-
-div.addresses
-{
- margin-top: 1em;
-}
-
-.addresses > .form
-{
- margin: 0 auto;
- padding: 2em;
- max-width: 25em;
-}
-.address
-{
- margin-bottom: 1em;
-}
-.address p
-{
- margin: 0.2em 0;
-}
-.address .actions
-{
- text-align: right;
-}
diff --git a/package/usr/share/hedera-web/forms/ecomerce/confirm/ui.xml b/package/usr/share/hedera-web/forms/ecomerce/confirm/ui.xml
index 9dd233a2..60e8e1fc 100755
--- a/package/usr/share/hedera-web/forms/ecomerce/confirm/ui.xml
+++ b/package/usr/share/hedera-web/forms/ecomerce/confirm/ui.xml
@@ -3,148 +3,91 @@
-
+
- SELECT id, delivery_method_id, agency_id, address_id, note
- FROM order_view WHERE id = #id
+ SELECT o.id, o.date_send, o.delivery_method_id, o.note,
+ ag.description agency, o.company_id, ad.consignee, ad.zip_code,
+ ad.city, ad.name address, c.credit
+ FROM order_view o
+ JOIN vn2008.Agencias ag ON ag.Id_Agencia = o.agency_id
+ LEFT JOIN address_view ad ON ad.id = o.address_id
+ JOIN customer_view c
+ WHERE o.id = #order
-
+
+
+
+
+
+
+ CALL order_get_vat (#order);
+ SELECT SUM(tax_base) tax_base, SUM(vat + surcharge) vat
+ FROM t_order_vat;
+ DROP TEMPORARY TABLE t_order_vat;
+
+
-
-
-
-
- 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
-
-