diff --git a/.gitignore b/.gitignore index 25871d04..c3950df8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules build/ +config.php diff --git a/env.php b/env.php index 55bbbf13..7cefb9ad 100644 --- a/env.php +++ b/env.php @@ -8,6 +8,5 @@ $vnAutoloadMap['vn/web'] = __DIR__.'/web'; const _ENABLE_DEBUG = TRUE; const _DEV_MODE = TRUE; -const _CONFIG_DIR = __DIR__.'/../../.config'; const _LOG_DIR = '/tmp'; const _DATA_DIR = '/tmp'; diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index ee6d7a77..a7c57dd5 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -32,7 +32,7 @@ Hedera.Catalog = new Class { document.body.appendChild (this.$('right-panel')); - this.$('items-model').setInfo ('a', 'Articles', 'vn2008', ['item_id']); + this.$('items-model').setInfo ('i', 'item', 'vn', ['itemFk']); if (localStorage.getItem ('hederaView')) this.setView (parseInt (localStorage.getItem ('hederaView'))); @@ -200,7 +200,7 @@ Hedera.Catalog = new Class if (type) { - var row = types.search ('tipo_id', type); + var row = types.search ('id', type); if (row != -1) title = types.get (row, 'name'); @@ -269,15 +269,15 @@ Hedera.Catalog = new Class this.onEraseClick (); this.$('card').row = form.row; - this.$('card-item').value = form.get ('item_id'); + this.$('card-item').value = form.get ('itemFk'); this.$('card-popup').show (button.node); } - ,onAddLotClick: function (column, value, row, button) + ,onAddLotClick: function (column, value, row) { var model = this.$('item-lots'); var grouping = model.get (row, 'grouping'); - var warehouse = model.get (row, 'warehouse_id'); + var warehouse = model.get (row, 'warehouseFk'); var available = model.get (row, 'available'); var lotAmount = this.items[warehouse]; @@ -321,7 +321,7 @@ Hedera.Catalog = new Class { this.conn.execQuery (sql); - var itemName = this.$('card').get ('Article'); + var itemName = this.$('card').get ('item'); Htk.Toast.showMessage ( sprintf (_('Added%dOf%s'), amountSum, itemName)); } @@ -342,7 +342,7 @@ Hedera.Catalog = new Class this.$('card-item').value = undefined; } - ,onStatusChange: function (model) + ,onCardLoad: function () { this.$('card-popup').reset (); } @@ -426,13 +426,13 @@ Vn.Filter = new Class this.parent (props); } - ,_onMouseDown: function (e) + ,_onMouseDown: function () { if (this._model && this._model.status === Db.Model.Status.CLEAN) this._model.refresh (); } - ,_onCloseClick: function (li) + ,_onCloseClick: function () { this._removeSelectionNode (); this._changeValue (undefined); diff --git a/forms/ecomerce/catalog/style.css b/forms/ecomerce/catalog/style.css index d9a93979..699c0f85 100644 --- a/forms/ecomerce/catalog/style.css +++ b/forms/ecomerce/catalog/style.css @@ -175,6 +175,8 @@ padding-bottom: .1em; font-weight: normal; font-size: 1.1em; + text-overflow: ellipsis; + overflow: hidden; } .item-info > p { @@ -224,7 +226,6 @@ .item-card .top { padding: 1em; - border-bottom: 1px solid #DDD; } .item-card .item-info { @@ -245,6 +246,10 @@ margin-top: 1em; font-size: .9em; } +.item-card .lots-grid +{ + border-top: 1px solid #DDD; +} .item-card .lots-grid tr { height: 3em; @@ -319,9 +324,7 @@ .list-view .item-info > h2 { font-size: 1em; - text-overflow: ellipsis; white-space: nowrap; - overflow: hidden; } .list-view .item-info > .color { diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 33b6cc07..6405c4ed 100644 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -12,75 +12,67 @@ - + - + - + - + - + - + - + - - SELECT o.id, o.date_send, ag.description agency, v.code method - FROM basket o - JOIN vn2008.Agencias ag ON ag.Id_Agencia = o.agency_id - JOIN vn2008.Vistas v ON v.vista_id = o.delivery_method_id - + SELECT b.id, b.sent, a.description agency, m.code method + FROM myBasket b + JOIN vn.agencyMode a ON a.id = b.agencyModeFk + JOIN vn.deliveryMethod m ON m.id = b.deliveryMethodFk - - - SELECT item_id, warehouse_id, SUM(amount) amount - FROM basket_item - GROUP BY warehouse_id - - - - CREATE TEMPORARY TABLE tmp.bionic_calc - (INDEX (item_id)) - ENGINE=MEMORY - SELECT a.Id_Article item_id FROM vn2008.Articles a - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - WHERE #filter; - CALL bionic_calc (); - SELECT a.Id_Article item_id, a.description, b.available, b.price, - b.producer, a.Foto, a.Article, a.Categoria, a.Medida, - IF(a.Tallos > 1, a.Tallos, NULL) Tallos, c.name color - FROM tmp.bionic_item b - JOIN vn2008.Articles a ON a.Id_Article = b.item_id - LEFT JOIN vn2008.producer p ON p.producer_id = a.producer_id - LEFT JOIN vn.inkL10n c ON c.id = a.Color - LEFT JOIN vn.originL10n o ON o.id = a.id_origen - WHERE b.available > 0 - ORDER BY a.relevancy DESC, a.Article, a.Medida - LIMIT 400; - + CREATE TEMPORARY TABLE tmp.bionic_calc + (INDEX (item_id)) + ENGINE=MEMORY + SELECT i.id item_id + FROM vn.item i + JOIN vn.itemType t ON t.id = i.typeFk + WHERE #filter; + CALL bionic_calc (); + SELECT i.id itemFk, i.description, b.available, b.price, + b.producer, i.image, i.name item, i.category, i.size, + IF(i.stems > 1, i.stems, NULL) stems, c.name color, + t.tag1, t.val1, t.tag2, t.val2, t.tag3, t.val3 + FROM tmp.bionic_item b + JOIN vn.item i ON i.id = b.item_id + LEFT JOIN vn.itemTagArranged t ON t.itemFk = i.id + LEFT JOIN vn.producer p ON p.id = i.producerFk + LEFT JOIN vn.inkL10n c ON c.id = i.inkFk + LEFT JOIN vn.originL10n o ON o.id = i.originFk + WHERE b.available > 0 + ORDER BY i.relevancy DESC, i.name, i.size + LIMIT 400; @@ -93,33 +85,6 @@ - - - - SELECT a.description, o.name origin - FROM vn2008.Articles a - LEFT JOIN vn.originL10n o ON o.id = a.id_origen - WHERE a.Id_Article = #item - - - - - - CALL bionic_from_item (#item); - SELECT p.warehouse_id, w.name warehouse, p.grouping, p.price, p.rate, l.available - FROM tmp.bionic_lot l - JOIN tmp.bionic_price p ON p.warehouse_id = l.warehouse_id - JOIN vn2008.warehouse w ON w.id = p.warehouse_id - ORDER BY warehouse_id, grouping; - -

Catalog

@@ -152,7 +117,7 @@ directory="catalog" subdir="200x200" form="item" - column="Foto" + column="image" full-dir="900x900"/>

- +

- Size , - Category + , +

- Color - + +

@@ -194,7 +159,7 @@

- +

@@ -216,13 +181,11 @@ id="realms-model" property="model" on-status-changed="refreshTitleColor"> - - SELECT r.id, l.name, r.color - FROM vn2008.reinos r - JOIN vn.itemCategoryL10n l ON l.id = r.id - WHERE r.display != FALSE - ORDER BY name - + SELECT c.id, l.name, c.color + FROM vn.itemCategory c + JOIN vn.itemCategoryL10n l ON l.id = c.id + WHERE c.display + ORDER BY name @@ -247,20 +210,18 @@ conn="conn" result-index="1" on-status-changed="refreshTitle"> - - CALL item_available (); - SELECT DISTINCT t.tipo_id, l.name - FROM vn2008.Tipos t - JOIN vn2008.Articles a ON a.tipo_id = t.tipo_id - JOIN tmp.item_available i ON i.item_id = a.Id_Article - JOIN vn.itemTypeL10n l ON l.id = t.tipo_id - WHERE #filter - ORDER BY name - + CALL item_available (); + SELECT DISTINCT t.id, l.name + FROM vn.item i + JOIN vn.itemType t ON t.id = i.typeFk + JOIN tmp.item_available a ON a.item_id = i.id + JOIN vn.itemTypeL10n l ON l.id = t.id + WHERE #filter + ORDER BY name - + @@ -269,17 +230,15 @@ placeholder="_Color" param="color"> - - CALL item_available (); - SELECT DISTINCT c.Id_Tinta, l.name - FROM vn2008.Tintas c - JOIN vn2008.Articles a ON a.Color = c.Id_Tinta - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - JOIN vn.inkL10n l ON l.id = c.Id_Tinta - JOIN tmp.item_available i ON i.item_id = a.Id_Article - WHERE #filter - ORDER BY name - + CALL item_available (); + SELECT DISTINCT k.id, l.name + FROM vn.item i + JOIN vn.itemType t ON t.id = i.typeFk + JOIN tmp.item_available a ON a.item_id = i.id + JOIN vn.ink k ON k.id = i.inkFk + JOIN vn.inkL10n l ON l.id = i.id + WHERE #filter + ORDER BY name @@ -294,16 +253,14 @@ placeholder="_Producer" param="producer"> - - CALL item_available (); - SELECT DISTINCT p.producer_id, p.name - FROM vn2008.producer p - JOIN vn2008.Articles a ON a.producer_id = p.producer_id - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - JOIN tmp.item_available i ON i.item_id = a.Id_Article - WHERE #filter - ORDER BY name - + CALL item_available (); + SELECT DISTINCT p.id, p.name + FROM vn.item i + JOIN vn.itemType t ON t.id = i.typeFk + JOIN tmp.item_available a ON a.item_id = i.id + JOIN vn.producer p ON p.id = i.producerFk + WHERE #filter + ORDER BY name @@ -318,17 +275,15 @@ placeholder="_Origin" param="origin"> - - CALL item_available (); - SELECT DISTINCT o.id, l.name, o.Abreviatura - FROM vn2008.Origen o - JOIN vn2008.Articles a ON a.id_origen = o.id - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - JOIN vn.originL10n l ON l.id = o.id - JOIN tmp.item_available i ON i.item_id = a.Id_Article - WHERE #filter - ORDER BY name - + CALL item_available (); + SELECT DISTINCT o.id, l.name, o.code + FROM vn.item i + JOIN vn.itemType t ON t.id = i.typeFk + JOIN tmp.item_available a ON a.item_id = i.id + JOIN vn.origin o ON o.id = i.originFk + JOIN vn.originL10n l ON l.id = o.id + WHERE #filter + ORDER BY name @@ -343,15 +298,13 @@ placeholder="_Category" param="category"> - - CALL item_available (); - SELECT DISTINCT a.Categoria, a.Categoria category - FROM vn2008.Articles a - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - JOIN tmp.item_available i ON i.item_id = a.Id_Article - WHERE #filter - ORDER BY a.Categoria - + CALL item_available (); + SELECT DISTINCT i.category, i.category + FROM vn.item i + JOIN vn.itemType t ON t.id = i.typeFk + JOIN tmp.item_available a ON a.item_id = i.id + WHERE #filter + ORDER BY category @@ -369,7 +322,7 @@ - - - - - @@ -415,32 +368,43 @@ modal="true" on-closed="onPopupClose">

+ + + SELECT i.description, o.name origin + FROM vn.item i + LEFT JOIN vn.originL10n o ON o.id = i.originFk + WHERE i.id = #item + +

- +

- @ + @

- Size , - Category + Size , + Category

-

+

Color - +

Origin @@ -450,7 +414,37 @@

- + + + SELECT l.name, it.value + FROM vn.itemTag it + JOIN vn.tag t ON t.id = it.tagFk + JOIN vn.tagL10n l ON l.id = t.id + WHERE it.itemFk = #item + + +

+ +

+
+
+ + + CALL bionic_from_item (#item); + SELECT w.id warehouseFk, w.name warehouse, p.grouping, p.price, p.rate, l.available + FROM tmp.bionic_lot l + JOIN tmp.bionic_price p ON p.warehouse_id = l.warehouse_id + JOIN vn.warehouse w ON w.id = p.warehouse_id + ORDER BY warehouseFk, grouping; + diff --git a/js/db/model.js b/js/db/model.js index 0181257a..469140d7 100644 --- a/js/db/model.js +++ b/js/db/model.js @@ -255,6 +255,12 @@ Model.implement this._setStatus (Status.CLEAN); } + ,appendChild: function (child) + { + if (child.nodeType === Node.TEXT_NODE) + this.query = child.textContent; + } + ,loadXml: function (builder, node) { this.parent (builder, node); @@ -377,7 +383,7 @@ Model.implement } } - ,_cleanData: function (error) + ,_cleanData: function () { this.data = null; this.tables = null; diff --git a/js/htk/repeater.js b/js/htk/repeater.js index 8e7dc5ee..5b3f89f8 100644 --- a/js/htk/repeater.js +++ b/js/htk/repeater.js @@ -62,6 +62,22 @@ module.exports = new Class this._renderer; } } + /** + * Wether to show the model status. + **/ + ,showStatus: + { + type: Boolean + ,set: function (x) + { + this._showStatus = x; + this._onModelChange(); + } + ,get: function () + { + this._showStatus; + } + } /** * Message that should be displayed when source model is not ready. **/ @@ -74,6 +90,7 @@ module.exports = new Class ,_builder: null ,_formId: 'form' + ,_showStatus: true ,render: function () { @@ -172,14 +189,17 @@ module.exports = new Class this.signalEmit ('change'); } - ,_showNoRecordsFound: function (count) + ,_showNoRecordsFound: function () { if (this._model.numRows === 0) this._showMessage (_('EmptyList'), 'clean'); } ,_showMessage: function (message, src) - { + { + if (!this._showStatus) + return; + var div = this.createElement ('div'); div.className = 'message'; this._container.appendChild (div); @@ -213,7 +233,7 @@ module.exports = new Class this._showNoRecordsFound (); } - ,_onRowUpdate: function (model, row, columns) + ,_onRowUpdate: function (model, row) { this._childsData[row].set.iterChanged (); } diff --git a/js/vn/builder.js b/js/vn/builder.js index d44e3d0c..fd741cce 100644 --- a/js/vn/builder.js +++ b/js/vn/builder.js @@ -80,7 +80,7 @@ module.exports = new Class { var parser = new DOMParser (); var xmlDoc = parser.parseFromString (xmlString, 'text/xml'); - return this.loadFromXmlDoc (xmlDoc); + return this.loadFromXmlDoc (xmlDoc, dstDocument); } ,loadFromXmlDoc: function (xmlDoc, dstDocument) @@ -193,7 +193,7 @@ module.exports = new Class this._doc = dstDocument ? dstDocument : document; } - ,_compileEnd: function (node) + ,_compileEnd: function () { for (var i = this._links.length - 1; i >= 0; i--) { @@ -333,12 +333,9 @@ module.exports = new Class for (var i = 0; i < childNodes.length; i++) { var child = childNodes[i]; - - if (child.nodeType !== Node.ELEMENT_NODE) - continue; - + var isElement = child.nodeType === Node.ELEMENT_NODE; + var childTagName = isElement ? child.tagName.toLowerCase () : null; var childContext; - var childTagName = child.tagName.toLowerCase (); if (childTagName === 'pointer') { @@ -350,7 +347,7 @@ module.exports = new Class } else if (childContext = this._compileNode (child)) { - var prop = child.getAttribute ('property'); + var prop = isElement ? child.getAttribute ('property') : null; if (prop) { diff --git a/pages/production/ui.php b/pages/production/ui.php index 249f9603..d274f02b 100644 --- a/pages/production/ui.php +++ b/pages/production/ui.php @@ -10,8 +10,8 @@ - - + + Production diff --git a/pages/update-browser/ui.php b/pages/update-browser/ui.php index 49e6e1f5..b5faeb43 100644 --- a/pages/update-browser/ui.php +++ b/pages/update-browser/ui.php @@ -5,7 +5,7 @@ - + Verdnatura diff --git a/pages/version-menu/ui.php b/pages/version-menu/ui.php index 12be46ae..cd94eb69 100644 --- a/pages/version-menu/ui.php +++ b/pages/version-menu/ui.php @@ -5,7 +5,7 @@ - + Verdnatura diff --git a/web/html-service.php b/web/html-service.php index 1497e8b0..525d3966 100644 --- a/web/html-service.php +++ b/web/html-service.php @@ -103,8 +103,9 @@ class HtmlService extends Service //header ("Content-Security-Policy: default-src *; img-src *;"); } - function errorHandler () + function errorHandler ($err) { + error_log("{$err->getMessage()} {$err->getTraceAsString()}"); $this->printHeader (); include (__DIR__.'/unavailable.html'); exit (0); diff --git a/web/html.php b/web/html.php index f18b6e1b..2a3293ad 100644 --- a/web/html.php +++ b/web/html.php @@ -15,12 +15,12 @@ function getUrl ($fileName) function js ($fileName) { - return ''."\n"; + return ''."\n"; } function css ($fileName) { - return ''."\n"; + return ''."\n"; } function getWebpackAssets () diff --git a/web/rest-service.php b/web/rest-service.php index 68154412..04bb28b6 100644 --- a/web/rest-service.php +++ b/web/rest-service.php @@ -63,6 +63,9 @@ class RestService extends Service throw new UserException (s($e->getMessage ())); } + if ($method::SECURITY == Security::DEFINER) + $methodDb->query ('CALL account.userLogout ()'); + $db->query ('CALL account.userLogout ()'); return $res; diff --git a/web/service.php b/web/service.php index 14fc9093..a1e34607 100644 --- a/web/service.php +++ b/web/service.php @@ -227,7 +227,7 @@ abstract class Service /** * Creates or returns a database connection where the authenticated user - * is the current logged user. + * is the role of the current logged user. * * @return {Db\Conn} The database connection */ @@ -235,10 +235,23 @@ abstract class Service { if ($this->userDb) return $this->userDb; - - $password = $this->db->getValue ( - 'SELECT password FROM account.user WHERE name = #', [$user]); - return $this->userDb = $this->app->createConnection ($user, $password); + + $row = $this->db->getObject ( + 'SELECT r.name, rc.mysqlPassword, uc.loginKey + FROM account.user u + JOIN account.role r ON r.id = u.role + JOIN account.roleConfig rc ON TRUE + JOIN account.userConfig uc ON TRUE + WHERE u.name = #', + [$user] + ); + + $userName = "z-{$row->name}"; + $password = base64_decode ($row->mysqlPassword); + $userDb = $this->app->createConnection ($userName, $password, TRUE); + + $userDb->query ('CALL account.userLoginWithKey (#, #)', [$user, $row->loginKey]); + return $userDb; } /**