From 06349730e85eb92380b44c48782b552642a83438 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 17 Jul 2015 16:34:42 +0200 Subject: [PATCH] Version aplha5 del bionic --- .../share/hedera-web/forms/cms/home/style.css | 52 ++++++-- .../share/hedera-web/forms/cms/home/ui.xml | 20 +-- .../hedera-web/forms/cms/training/style.css | 48 ++++++-- .../hedera-web/forms/cms/training/ui.xml | 24 ++-- .../hedera-web/forms/ecomerce/basket/ui.xml | 2 +- .../forms/ecomerce/checkout/checkout.js | 10 +- .../hedera-web/forms/ecomerce/checkout/ui.xml | 33 +++-- .../forms/ecomerce/confirm/confirm.js | 48 +++++--- .../hedera-web/forms/ecomerce/confirm/ui.xml | 28 +++-- .../share/hedera-web/forms/news/news/ui.xml | 6 +- package/usr/share/hedera-web/global/style.css | 12 +- package/usr/share/hedera-web/js/db/main.php | 1 + package/usr/share/hedera-web/js/db/model.js | 1 - package/usr/share/hedera-web/js/db/query.js | 114 ++++++++++++++++++ .../share/hedera-web/js/htk/field/calendar.js | 16 ++- .../share/hedera-web/js/htk/field/image.js | 7 +- package/usr/share/hedera-web/js/sql/batch.js | 2 + package/usr/share/hedera-web/js/sql/value.js | 5 +- package/usr/share/hedera-web/js/vn/object.js | 8 +- .../usr/share/hedera-web/pages/web/module.js | 5 + 20 files changed, 335 insertions(+), 107 deletions(-) create mode 100644 package/usr/share/hedera-web/js/db/query.js diff --git a/package/usr/share/hedera-web/forms/cms/home/style.css b/package/usr/share/hedera-web/forms/cms/home/style.css index b82f1ec6..629b19f7 100755 --- a/package/usr/share/hedera-web/forms/cms/home/style.css +++ b/package/usr/share/hedera-web/forms/cms/home/style.css @@ -1,26 +1,59 @@ + /* News panel */ + .home { - padding: 1em; + margin: .5em; } -.home .column +.column { - max-width: 40em; + max-width: 120em; margin: 0 auto; + text-align: center; +} + +/* New */ + +.new-container +{ + display: inline-block; + vertical-align: top; +}/* +.new-container:nth-child(2n+0) +{ + float: right; +}*/ +@media screen and (min-width: 300px) +{ + .new-container { width: 100%; } +} +@media screen and (min-width: 700px) +{ + .new-container { width: 50%; } +} +@media screen and (min-width: 1300px) +{ + .new-container { width: 33.3%; } +} +@media screen and (min-width: 2000px) +{ + .new-container { width: 25%; } } .new { - padding: 2em; + text-align: left; background-color: white; color: #222; border: none; border-radius: 0.1em; box-shadow: 0 0.2em 0.2em #CCC; - margin-bottom: 1em; + margin: .5em; +} +.new .top +{ + padding: 1.5em; + padding-bottom: 1em; } - -/* New */ - .new h2 { font-size: 1.6em; @@ -46,8 +79,7 @@ { display: block; margin: auto; - max-width: 92%; - padding-top: 1em; + width: 100%; } /* Survey */ diff --git a/package/usr/share/hedera-web/forms/cms/home/ui.xml b/package/usr/share/hedera-web/forms/cms/home/ui.xml index 1451f739..d2239004 100755 --- a/package/usr/share/hedera-web/forms/cms/home/ui.xml +++ b/package/usr/share/hedera-web/forms/cms/home/ui.xml @@ -1,7 +1,7 @@ - SELECT title, date_time, text, id FROM news + SELECT title, date_time, text, image, id FROM news WHERE tag != 'course' ORDER BY priority, date_time DESC @@ -9,15 +9,19 @@
+
-

-

- -

-
- +
+

+

+ +

+
+ +
- + +
diff --git a/package/usr/share/hedera-web/forms/cms/training/style.css b/package/usr/share/hedera-web/forms/cms/training/style.css index 8d0f0c3a..1f6d4e64 100755 --- a/package/usr/share/hedera-web/forms/cms/training/style.css +++ b/package/usr/share/hedera-web/forms/cms/training/style.css @@ -1,27 +1,55 @@ + /* News panel */ .training { - padding: 1em; + margin: .5em; } -.training .column +.column { - max-width: 40em; + max-width: 120em; margin: 0 auto; + text-align: center; +} + +/* New */ + +.new-container +{ + display: inline-block; + vertical-align: top; +} +@media screen and (min-width: 800px) +{ + .new-container { width: 100%; } +} +@media screen and (min-width: 1000px) +{ + .new-container { width: 50%; } +} +@media screen and (min-width: 1300px) +{ + .new-container { width: 33.3%; } +} +@media screen and (min-width: 2000px) +{ + .new-container { width: 25%; } } .new { - padding: 2em; + text-align: left; background-color: white; color: #222; border: none; border-radius: 0.1em; box-shadow: 0 0.2em 0.2em #CCC; - margin-bottom: 1em; + margin: .5em; +} +.new .top +{ + padding: 1.5em; + padding-bottom: 1em; } - -/* New */ - .new h2 { font-size: 1.6em; @@ -47,6 +75,6 @@ { display: block; margin: auto; - max-width: 92%; - padding-top: 1em; + width: 100%; } + diff --git a/package/usr/share/hedera-web/forms/cms/training/ui.xml b/package/usr/share/hedera-web/forms/cms/training/ui.xml index b337a82c..add0b6f3 100755 --- a/package/usr/share/hedera-web/forms/cms/training/ui.xml +++ b/package/usr/share/hedera-web/forms/cms/training/ui.xml @@ -1,23 +1,27 @@ - SELECT title, date_time, text, id FROM news + SELECT title, date_time, text, image, id FROM news WHERE tag = 'course' ORDER BY priority, date_time DESC
-
- +
+ +
-

-

- -

-
- +
+

+

+ +

+
+ +
- + +
diff --git a/package/usr/share/hedera-web/forms/ecomerce/basket/ui.xml b/package/usr/share/hedera-web/forms/ecomerce/basket/ui.xml index 4960551a..e531dba8 100755 --- a/package/usr/share/hedera-web/forms/ecomerce/basket/ui.xml +++ b/package/usr/share/hedera-web/forms/ecomerce/basket/ui.xml @@ -45,7 +45,7 @@ - + diff --git a/package/usr/share/hedera-web/forms/ecomerce/checkout/checkout.js b/package/usr/share/hedera-web/forms/ecomerce/checkout/checkout.js index 94a3f4df..a9ee6027 100755 --- a/package/usr/share/hedera-web/forms/ecomerce/checkout/checkout.js +++ b/package/usr/share/hedera-web/forms/ecomerce/checkout/checkout.js @@ -31,7 +31,7 @@ Vn.Checkout = new Class date.setTime (date.getTime () + 86400000); } - this.$('delivery').value = date; + this.$('date').value = date; this.$('method').value = i.get ('delivery_method'); this.$('agency').value = i.get ('agency_id'); this.$('address').value = i.get ('address_id'); @@ -41,11 +41,11 @@ Vn.Checkout = new Class ,onConfirmClick: function () { - var query = 'CALL basket_configure (#delivery, #method, #agency, #address)'; + var query = 'CALL basket_configure (#date, #method, #agency, #address)'; var batch = new Sql.Batch (); batch.addParam ('method', this.$('method')); - batch.addParam ('delivery', this.$('delivery')); + batch.addParam ('date', this.$('date')); batch.addParam ('agency', this.$('agency')); batch.addParam ('address', this.$('address')); @@ -124,7 +124,7 @@ Vn.Checkout = new Class this.$('agencies').refresh (); break; case 'pickup': - this.$('agencies').refresh (); + this.$('warehouses').refresh (); break; } @@ -159,7 +159,7 @@ Vn.Checkout = new Class { var now = new Date (); now.setHours (0,0,0,0); - + return date.getTime () >= now.getTime () && date.getDay () != 0; } diff --git a/package/usr/share/hedera-web/forms/ecomerce/checkout/ui.xml b/package/usr/share/hedera-web/forms/ecomerce/checkout/ui.xml index 75cddd23..7c92a833 100755 --- a/package/usr/share/hedera-web/forms/ecomerce/checkout/ui.xml +++ b/package/usr/share/hedera-web/forms/ecomerce/checkout/ui.xml @@ -3,7 +3,7 @@ - + @@ -22,19 +22,32 @@ - CALL agency_list_by_date (#delivery, #address); + CALL agency_list_by_date (#date, #address); SELECT a.Id_Agencia, a.description 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 = #method + AND v.code = 'AGENCY' ORDER BY a.description; DROP TEMPORARY TABLE t_agency; - - + + + + + CALL agency_list_by_date (#date, NULL); + SELECT a.Id_Agencia, SUBSTR(a.description, 5) description + 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 = 'PICKUP' + ORDER BY a.description; + DROP TEMPORARY TABLE t_agency; + + @@ -84,7 +97,7 @@
@@ -128,7 +141,7 @@ id="warehouse-combo" param="agency" on-changed="onFieldChange" - model="agencies"/> + model="warehouses"/>
@@ -136,7 +149,7 @@

Arrival - +

@@ -156,7 +169,7 @@

Arrival - +

@@ -175,7 +188,7 @@

Pickup - +

Warehouse diff --git a/package/usr/share/hedera-web/forms/ecomerce/confirm/confirm.js b/package/usr/share/hedera-web/forms/ecomerce/confirm/confirm.js index 1462e019..5e237567 100755 --- a/package/usr/share/hedera-web/forms/ecomerce/confirm/confirm.js +++ b/package/usr/share/hedera-web/forms/ecomerce/confirm/confirm.js @@ -8,7 +8,24 @@ Vn.Confirm = new Class this.tpv = new Vn.Tpv (this.conn, this.hash); } - ,onStatusChange: function (form) + ,onOrderReady: function (form) + { + if (form.row < 0) + return; + + if (form.get ('method') != 'PICKUP') + { + this.$('address').style.display = 'block'; + Vn.Node.setText (this.$('method'), _('Agency')); + } + else + { + this.$('address').style.display = 'none'; + Vn.Node.setText (this.$('method'), _('Warehouse')); + } + } + + ,onImportReady: function (form) { if (form.row != -1) this.$('total').value = form.get ('tax_base') + form.get ('vat'); @@ -29,28 +46,25 @@ Vn.Confirm = new Class ,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); + this.$('confirm-query').execute (); } - ,confirmDone: function (resultSet) + ,onConfirm: function (query, resultSet) { var res = resultSet.fetchResult (); + var debt = resultSet.fetchValue (); - if (!(res && res.next())) - this.goBasket (); - - Vn.Cookie.unset ('order'); - this.pay = res.get ('debt') > this.$('order-form').get ('credit'); + if (res) + { + Vn.Cookie.unset ('order'); + this.pay = debt > this.$('order-form').get ('credit'); - this.popup = new Htk.Popup (); - this.popup.setChildNode (this.$('success-dialog')); - this.popup.showCenter (); + this.popup = new Htk.Popup (); + this.popup.setChildNode (this.$('success-dialog')); + this.popup.showCenter (); + } + else + this.hash.set ({'form': 'ecomerce/basket'}); } ,onAcceptClick: function () 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 60e8e1fc..f2362404 100755 --- a/package/usr/share/hedera-web/forms/ecomerce/confirm/ui.xml +++ b/package/usr/share/hedera-web/forms/ecomerce/confirm/ui.xml @@ -3,14 +3,15 @@ - - - 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 + + + SELECT o.id, o.date_send, o.note, o.company_id, + ag.description agency, v.code method, c.credit, + ad.consignee, ad.zip_code, ad.city, ad.name address 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 vn2008.Vistas v ON v.vista_id = o.delivery_method_id JOIN customer_view c WHERE o.id = #order @@ -18,10 +19,12 @@ - + CALL order_get_vat (#order); - SELECT SUM(tax_base) tax_base, SUM(vat + surcharge) vat + SELECT + IFNULL(SUM(tax_base), 0) tax_base, + IFNULL(SUM(vat + surcharge), 0) vat FROM t_order_vat; DROP TEMPORARY TABLE t_order_vat; @@ -29,6 +32,13 @@ + + CALL order_confirm_bionic (#order); + SELECT customer_get_debt() debt; + + + +

@@ -42,11 +52,11 @@

- Agency + Agency

-
+

diff --git a/package/usr/share/hedera-web/forms/news/news/ui.xml b/package/usr/share/hedera-web/forms/news/news/ui.xml index bcab3908..bef968bd 100755 --- a/package/usr/share/hedera-web/forms/news/news/ui.xml +++ b/package/usr/share/hedera-web/forms/news/news/ui.xml @@ -12,7 +12,7 @@
- SELECT n.id, c.Cliente, priority, + SELECT n.id, c.Cliente, priority, image, CONCAT(LEFT(n.title, 25), '...') title FROM news n JOIN vn2008.Clientes c ON n.user_id = c.Id_Cliente @@ -24,9 +24,9 @@ image="image/edit.svg" on-clicked="onEditClick"/> diff --git a/package/usr/share/hedera-web/global/style.css b/package/usr/share/hedera-web/global/style.css index b11e6a0d..26c5a33b 100755 --- a/package/usr/share/hedera-web/global/style.css +++ b/package/usr/share/hedera-web/global/style.css @@ -5,11 +5,11 @@ { * { font-size: 8pt; } } -@media screen and (min-device-width: 1150px) +@media screen and (min-width: 1150px) { * { font-size: 10pt; } } -@media screen and (min-device-width: 1850px) +@media screen and (min-width: 1850px) { * { font-size: 12pt; } } @@ -440,7 +440,8 @@ img.icon } .cell-image > img { - min-height: 1.5em; + max-width: 2.5em; + max-height: 2.5em; } /* Repater */ @@ -557,11 +558,6 @@ img.icon box-shadow: 0 0.1em 0.1em #CCC; } -.htk-date-chooser > button:hover -{ - background-color: #EEE; -} - /* Full image */ .htk-full-image diff --git a/package/usr/share/hedera-web/js/db/main.php b/package/usr/share/hedera-web/js/db/main.php index 3744cab7..0a284f2c 100755 --- a/package/usr/share/hedera-web/js/db/main.php +++ b/package/usr/share/hedera-web/js/db/main.php @@ -11,6 +11,7 @@ Vn\Hedera\Js::includeLib ('db' ,'iterator' ,'form' ,'param' + ,'query' ,'calc' ,'calc-sum' ); diff --git a/package/usr/share/hedera-web/js/db/model.js b/package/usr/share/hedera-web/js/db/model.js index daaad890..863f6525 100755 --- a/package/usr/share/hedera-web/js/db/model.js +++ b/package/usr/share/hedera-web/js/db/model.js @@ -38,7 +38,6 @@ Db.Model.implement ({ Extends: Vn.Object ,Tag: 'db-model' - ,Child: 'query' ,Properties: { /** diff --git a/package/usr/share/hedera-web/js/db/query.js b/package/usr/share/hedera-web/js/db/query.js new file mode 100644 index 00000000..5b0daae0 --- /dev/null +++ b/package/usr/share/hedera-web/js/db/query.js @@ -0,0 +1,114 @@ + +Db.Query = new Class +({ + Extends: Vn.Object + ,Tag: 'db-query' + ,Properties: + { + /** + * The connection used to execute the statement. + **/ + conn: + { + type: Db.Conn + ,set: function (x) + { + this._conn = x; + this.onChange (); + } + ,get: function () + { + return this._conn; + } + }, + /** + * The model query. + **/ + query: + { + type: String + ,set: function (x) + { + this._stmt = new Sql.String ({query: x}); + this.onChange (); + } + ,get: function () + { + return this._stmt.render (null); + } + }, + /** + * The model select statement. + **/ + stmt: + { + type: Sql.Stmt + ,set: function (x) + { + this._stmt = x; + this.onChange (); + } + ,get: function () + { + return this._stmt; + } + }, + /** + * The batch used to execute the statement. + **/ + batch: + { + type: Sql.Batch + ,set: function (x) + { + this.link ({_batch: x}, {'changed': this.onChange}); + this.onChange (); + } + ,get: function () + { + return this._batch; + } + }, + /** + * Wether to execute automatically de query que it's ready. + **/ + autoLoad: + { + type: Boolean, + value: false + } + } + + ,initialize: function (props) + { + this.parent (props); + } + + ,loadXml: function (builder, node) + { + this.parent (builder, node); + + var query = node.firstChild.nodeValue; + + if (query) + this.query = query; + } + + ,execute: function () + { + this._conn.execStmt (this._stmt, + this.onQueryDone.bind (this), this._batch); + } + + ,onQueryDone: function (resultSet) + { + this.signalEmit ('ready', resultSet); + } + + ,onChange: function () + { + if (this.autoLoad && this._conn && this._stmt && this._batch) + this.execute (); + } +}); + diff --git a/package/usr/share/hedera-web/js/htk/field/calendar.js b/package/usr/share/hedera-web/js/htk/field/calendar.js index 67d498ef..bf758330 100755 --- a/package/usr/share/hedera-web/js/htk/field/calendar.js +++ b/package/usr/share/hedera-web/js/htk/field/calendar.js @@ -74,7 +74,7 @@ Htk.Calendar = new Class var tr = document.createElement ('tr'); thead.appendChild (tr); - for (i = 1; i <= len; i++) + for (var i = 1; i <= len; i++) { var th = document.createElement ('th'); tr.appendChild (th); @@ -105,23 +105,21 @@ Htk.Calendar = new Class th.addEventListener ('click', this.nextYearClicked.bind (this)); tr.appendChild (th); */ - var td, div; - var tbody = document.createElement ('tbody'); table.appendChild (tbody); - for (i = 0; i < 6; i++) + for (var i = 0; i < 6; i++) { - tr = document.createElement ('tr'); + var tr = document.createElement ('tr'); tbody.appendChild (tr); - for (j = 0; j < len; j++) + for (var j = 0; j < len; j++) { - td = document.createElement ('td'); + var td = document.createElement ('td'); td.addEventListener ('click', this.dayClicked.bind (this, td, i*len+j)); tr.appendChild (td); - div = document.createElement ('div'); + var div = document.createElement ('div'); td.appendChild (div); this.cells.push ({ @@ -185,7 +183,7 @@ Htk.Calendar = new Class var firstWeekDay = (weekDay != 0) ? weekDay - 1 : 6; var monthDays = this.getMonthDays (); - for (i = 0; i < this.cells.length; i++) + for (var i = 0; i < this.cells.length; i++) { var cell = this.cells[i]; diff --git a/package/usr/share/hedera-web/js/htk/field/image.js b/package/usr/share/hedera-web/js/htk/field/image.js index 054650a8..e356184c 100755 --- a/package/usr/share/hedera-web/js/htk/field/image.js +++ b/package/usr/share/hedera-web/js/htk/field/image.js @@ -45,6 +45,7 @@ Htk.Image = new Class ,render: function (force) { + console.log (this._value); if (this._value) { var url = ''; @@ -59,9 +60,13 @@ Htk.Image = new Class this.empty = false; this.node.src = url; + this.node.style.display = ''; } else - this.onImageError (); + { + delete this.node.src; + this.node.style.display = 'none'; + } } ,putValue: function (value) diff --git a/package/usr/share/hedera-web/js/sql/batch.js b/package/usr/share/hedera-web/js/sql/batch.js index 8aa322af..21a15c5b 100755 --- a/package/usr/share/hedera-web/js/sql/batch.js +++ b/package/usr/share/hedera-web/js/sql/batch.js @@ -112,6 +112,8 @@ Sql.Batch = new Class ,isReady: function () { + var id; + for (id in this.params) if (!(this.params[id] && this.params[id].isReady ())) return false; diff --git a/package/usr/share/hedera-web/js/sql/value.js b/package/usr/share/hedera-web/js/sql/value.js index 0e2ce97e..60e0d7a3 100755 --- a/package/usr/share/hedera-web/js/sql/value.js +++ b/package/usr/share/hedera-web/js/sql/value.js @@ -73,10 +73,7 @@ Sql.Value = new Class ,isReady: function () { - if (this._value !== undefined && this._value !== null) - return true; - - return false; + return this._value !== undefined; } ,replaceFunc: function (token) diff --git a/package/usr/share/hedera-web/js/vn/object.js b/package/usr/share/hedera-web/js/vn/object.js index ea40b22e..641bc739 100755 --- a/package/usr/share/hedera-web/js/vn/object.js +++ b/package/usr/share/hedera-web/js/vn/object.js @@ -28,7 +28,13 @@ Vn.Object = new Class * @param {Object} instance The instance **/ ,on: function (id, callback, instance) - { + { + if (!(callback instanceof Function)) + { + console.warn ('Vn.Object: Invalid callback for signal \'%s\'', id); + return; + } + if (!this.signals[id]) this.signals[id] = []; diff --git a/package/usr/share/hedera-web/pages/web/module.js b/package/usr/share/hedera-web/pages/web/module.js index 01f005d3..b9f4553a 100755 --- a/package/usr/share/hedera-web/pages/web/module.js +++ b/package/usr/share/hedera-web/pages/web/module.js @@ -18,6 +18,11 @@ Vn.Module = new Class for (var i = 0; i < models.length; i++) models[i].conn = this.conn; + var queries = this.builder.getObjects ('db-query'); + + for (var i = 0; i < queries.length; i++) + queries[i].conn = this.conn; + var hashLinks = this.builder.getObjects ('vn-hash-link'); for (var i = 0; i < hashLinks.length; i++)