From 4f3b7efcb3f2ba6c6812824ebafa3f8dd952b2d6 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 21 May 2019 16:16:27 +0200 Subject: [PATCH] SQL refactor --- debian/changelog | 2 +- forms/ecomerce/catalog/catalog.js | 426 ++++++++++------------- forms/ecomerce/checkout/checkout.js | 4 +- forms/ecomerce/confirm/ui.xml | 4 +- forms/ecomerce/orders/ui.xml | 2 +- forms/ecomerce/ticket/ticket.js | 2 +- forms/ecomerce/ticket/ui.xml | 6 +- js/hedera/basket-checker.js | 23 +- js/hedera/tpv.js | 2 +- package.json | 2 +- reports/delivery-note/ui.xml | 6 +- reports/items-report/ui.xml | 2 +- reports/shelves-report/shelves-report.js | 308 ++++++++-------- rest/tpv/tpv.php | 2 +- rest/tpv/transaction.php | 2 +- web/service.php | 4 +- 16 files changed, 347 insertions(+), 450 deletions(-) diff --git a/debian/changelog b/debian/changelog index 86b4581f..ff17cf75 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.406.46) stable; urgency=low +hedera-web (1.406.47) stable; urgency=low * Initial Release. diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index c0923b64..fa8c9900 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -1,66 +1,54 @@ -Hedera.Catalog = new Class -({ +Hedera.Catalog = new Class({ Extends: Hedera.Form ,_menuShown: false - ,open: function () - { - this.close (); + ,open: function() { + this.close(); this.isOpen = true; - if (!localStorage.getItem ('hederaGuest')) - { - Hedera.BasketChecker.check (this.conn, - this.onBasketCheck.bind (this)); - } - else - { - var query = 'CALL basketConfigureForGuest'; - this.conn.execQuery (query, this.loadUi.bind (this)); + if (!localStorage.getItem('hederaGuest')) { + Hedera.BasketChecker.check(this.conn, + this.onBasketCheck.bind(this)); + } else { + var query = 'CALL mybasket_configureForGuest'; + this.conn.execQuery(query, this.loadUi.bind(this)); } } - ,onBasketCheck: function (isOk) - { + ,onBasketCheck: function(isOk) { if (isOk) - this.loadUi (); + this.loadUi(); } - ,activate: function () - { - document.body.appendChild (this.$('right-panel')); + ,activate: function() { + document.body.appendChild(this.$('right-panel')); - this.$('items-model').setInfo ('i', 'item', 'vn', ['id']); + this.$('items-model').setInfo('i', 'item', 'vn', ['id']); - if (localStorage.getItem ('hederaView')) - this.setView (parseInt (localStorage.getItem ('hederaView'))); + if (localStorage.getItem('hederaView')) + this.setView(parseInt(localStorage.getItem('hederaView'))); else - this.setView (Hedera.Catalog.View.GRID); + this.setView(Hedera.Catalog.View.GRID); } - ,deactivate: function () - { - this.hideMenu (); + ,deactivate: function() { + this.hideMenu(); this.gui.$('top-bar').style.backgroundColor = ''; - Vn.Node.remove (this.$('right-panel')); + Vn.Node.remove(this.$('right-panel')); } - ,setView: function (view) - { - if (view === Hedera.Catalog.View.GRID) - { - this.$('view-button').setProperties ({ + ,setView: function(view) { + if (view === Hedera.Catalog.View.GRID) { + this.$('view-button').setProperties({ icon: 'view-list', tip: _('List view') }); this.view = Hedera.Catalog.View.GRID; var className = 'grid-view'; - } - else - { - this.$('view-button').setProperties ({ + } else { + this.$('view-button').setProperties({ icon: 'view-grid', tip: _('Grid view') }); @@ -70,92 +58,80 @@ Hedera.Catalog = new Class var node = this.$('grid-view').node; node.className = className; - localStorage.setItem ('hederaView', this.view); + localStorage.setItem('hederaView', this.view); } - ,onSwitchViewClick: function () - { - this.setView (this.view === Hedera.Catalog.View.LIST ? + ,onSwitchViewClick: function() { + this.setView(this.view === Hedera.Catalog.View.LIST ? Hedera.Catalog.View.GRID : Hedera.Catalog.View.LIST); } - ,onBasketReady: function (form) - { - if (form.get ('method') != 'PICKUP') - Vn.Node.setText (this.$('method'), _('Agency')); + ,onBasketReady: function(form) { + if (form.get('method') != 'PICKUP') + Vn.Node.setText(this.$('method'), _('Agency')); else - Vn.Node.setText (this.$('method'), _('Warehouse')); + Vn.Node.setText(this.$('method'), _('Warehouse')); } - ,onItemsChange: function (model, status) - { + ,onItemsChange: function(model, status) { if (status !== Db.Model.Status.CLEAN) this.$('order').style.display = 'block'; else this.$('order').style.display = 'none'; } - ,onOrderChange: function (e) - { + ,onOrderChange: function(e) { var value = e.target.value; - var sortField = value.substr (2); - var sortWay = value.charAt (0) === 'A' ? + var sortField = value.substr(2); + var sortWay = value.charAt(0) === 'A' ? Db.Model.SortWay.ASC : Db.Model.SortWay.DESC; if (sortField) - this.$('items-model').sortByName (sortField, sortWay); + this.$('items-model').sortByName(sortField, sortWay); - this.hideMenu (); + this.hideMenu(); } - ,onFilterChange: function (param, newValue) - { + ,onFilterChange: function(param, newValue) { if (newValue) - this.hideMenu (); + this.hideMenu(); } - ,realmRenderer: function (builder, form) - { + ,realmRenderer: function(builder, form) { var link = builder.$('link'); - link.href = this.hash.make ({ - 'form': this.hash.get ('form'), - 'realm': form.get ('id') + link.href = this.hash.make({ + 'form': this.hash.get('form'), + 'realm': form.get('id') }); var img = builder.$('image'); - img.src = 'image/family/light/'+ form.get ('id') +'.svg'; - img.title = form.get ('name'); + img.src = 'image/family/light/'+ form.get('id') +'.svg'; + img.title = form.get('name'); img.alt = img.title; } - ,onRealmChange: function (param, newValue) - { - if (newValue) - { + ,onRealmChange: function(param, newValue) { + if (newValue) { this.$('filters').style.display = 'block'; this.$('realm-msg').style.display = 'none'; - } - else - { + } else { this.$('filters').style.display = 'none'; this.$('realm-msg').style.display = 'block'; } - this.refreshTitleColor (); - this.refreshFilter (newValue, undefined); + this.refreshTitleColor(); + this.refreshFilter(newValue, undefined); } - ,onTypeChange: function (param, newValue) - { - this.onFilterChange (param, newValue); - this.refreshTitle (); - this.refreshFilter (undefined, newValue); + ,onTypeChange: function(param, newValue) { + this.onFilterChange(param, newValue); + this.refreshTitle(); + this.refreshFilter(undefined, newValue); } - ,refreshFilter: function (realm, type) - { + ,refreshFilter: function(realm, type) { var batch = this.$('filter-batch'); - batch.block (); + batch.block(); this.$('realm-value').value = realm; this.$('type-value').value = type; this.$('search').value = undefined; @@ -163,12 +139,11 @@ Hedera.Catalog = new Class this.$('origin').value = undefined; this.$('category').value = undefined; this.$('producer').value = undefined; - batch.unblock (); - batch.changed (); + batch.unblock(); + batch.changed(); } - ,refreshTitleColor: function () - { + ,refreshTitleColor: function() { var realms = this.$('realms-model'); if (!realms.ready) @@ -177,19 +152,17 @@ Hedera.Catalog = new Class var color = null; var realm = this.$('realm').value; - if (realm) - { - var row = realms.search ('id', realm); + if (realm) { + var row = realms.search('id', realm); if (row != -1) - color = '#'+ realms.get (row, 'color'); + color = '#'+ realms.get(row, 'color'); } this.gui.$('top-bar').style.backgroundColor = color; } - ,refreshTitle: function () - { + ,refreshTitle: function() { var types = this.$('types-model'); if (!types.ready) @@ -198,95 +171,84 @@ Hedera.Catalog = new Class var title = _('Catalog'); var type = this.$('type').value; - if (type) - { - var row = types.search ('id', type); + if (type) { + var row = types.search('id', type); if (row != -1) - title = types.get (row, 'name'); + title = types.get(row, 'name'); } - Vn.Node.setText (this.$('title-text'), title); + Vn.Node.setText(this.$('title-text'), title); } - ,onRightPanelClick: function (event) - { - event.stopPropagation (); + ,onRightPanelClick: function(event) { + event.stopPropagation(); } - ,onShowMenuClick: function (event) - { + ,onShowMenuClick: function(event) { this._menuShown = true; - event.stopPropagation (); - this.gui.showBackground (); - Vn.Node.addClass (this.$('right-panel'), 'show'); - this.hideMenuCallback = this.hideMenu.bind (this); - document.addEventListener ('click', this.hideMenuCallback); + event.stopPropagation(); + this.gui.showBackground(); + Vn.Node.addClass(this.$('right-panel'), 'show'); + this.hideMenuCallback = this.hideMenu.bind(this); + document.addEventListener('click', this.hideMenuCallback); } - ,hideMenu: function () - { + ,hideMenu: function() { if (!this._menuShown) return; - this.gui.hideBackground (); - Vn.Node.removeClass (this.$('right-panel'), 'show'); - document.removeEventListener ('click', this.hideMenuCallback); + this.gui.hideBackground(); + Vn.Node.removeClass(this.$('right-panel'), 'show'); + document.removeEventListener('click', this.hideMenuCallback); this.hideMenuCallback = null; } - ,isGuest: function () - { - if (localStorage.getItem ('hederaGuest')) - { - Htk.Toast.showError (_('YouMustBeLoggedIn')); + ,isGuest: function() { + if (localStorage.getItem('hederaGuest')) { + Htk.Toast.showError(_('YouMustBeLoggedIn')); return true; } return false; } - ,onBasketClick: function () - { - if (this.isGuest ()) + ,onBasketClick: function() { + if (this.isGuest()) return; - this.hash.set ({'form': 'ecomerce/basket'}); + this.hash.set({'form': 'ecomerce/basket'}); } - ,onConfigureClick: function () - { - if (this.isGuest ()) + ,onConfigureClick: function() { + if (this.isGuest()) return; - this.hash.set ({'form': 'ecomerce/checkout'}); + this.hash.set({'form': 'ecomerce/checkout'}); } - ,onAddItemClick: function (button, form) - { - if (this.isGuest ()) + ,onAddItemClick: function(button, form) { + if (this.isGuest()) return; - this.onEraseClick (); + this.onEraseClick(); this.$('card').row = form.row; - this.$('card-item').value = form.get ('id'); - this.$('card-popup').show (button.node); + this.$('card-item').value = form.get('id'); + this.$('card-popup').show(button.node); } - ,onAddLotClick: function (column, value, row) - { + ,onAddLotClick: function(column, value, row) { var model = this.$('item-lots'); - var grouping = model.get (row, 'grouping'); - var warehouse = model.get (row, 'warehouseFk'); - var available = model.get (row, 'available'); + var grouping = model.get(row, 'grouping'); + var warehouse = model.get(row, 'warehouseFk'); + var available = model.get(row, 'available'); var lotAmount = this.items[warehouse]; if (lotAmount === undefined) lotAmount = 0; - if (lotAmount < available) - { + if (lotAmount < available) { var newAmount = lotAmount + grouping; if (newAmount > available) @@ -294,70 +256,61 @@ Hedera.Catalog = new Class this.items[warehouse] = newAmount; this.$('amount').value += newAmount - lotAmount; - } - else - Htk.Toast.showError (_('NoMoreAmountAvailable')); + } else + Htk.Toast.showError(_('NoMoreAmountAvailable')); } - ,onConfirmClick: function () - { + ,onConfirmClick: function() { var sql = ''; - var batch = new Sql.Batch (); - var query = new Sql.String ({query: 'CALL basketAddItem (#warehouse, #item, #amount);'}); + var batch = new Sql.Batch(); + var query = new Sql.String({query: 'CALL myBasket_addItem(#warehouse, #item, #amount);'}); var amountSum = 0; - for (var warehouse in this.items) - { + for (var warehouse in this.items) { var amount = this.items[warehouse]; amountSum += amount; - batch.addValue ('warehouse', warehouse); - batch.addValue ('item', this.$('card-item').value); - batch.addValue ('amount', amount); - sql += query.render (batch); + batch.addValue('warehouse', warehouse); + batch.addValue('item', this.$('card-item').value); + batch.addValue('amount', amount); + sql += query.render(batch); } - if (amountSum > 0) - { - this.conn.execQuery (sql); + if (amountSum > 0) { + this.conn.execQuery(sql); - var itemName = this.$('card').get ('item'); - Htk.Toast.showMessage ( - sprintf (_('Added%dOf%s'), amountSum, itemName)); + var itemName = this.$('card').get('item'); + Htk.Toast.showMessage( + sprintf(_('Added%dOf%s'), amountSum, itemName)); } - this.$('card-popup').hide (); + this.$('card-popup').hide(); } - ,onEraseClick: function () - { + ,onEraseClick: function() { this.$('amount').value = 0; this.items = {}; } - ,onPopupClose: function () - { - this.onEraseClick (); + ,onPopupClose: function() { + this.onEraseClick(); this.$('card').row = -1; this.$('card-item').value = undefined; } - ,onCardLoad: function () - { - this.$('card-popup').reset (); + ,onCardLoad: function() { + this.$('card-popup').reset(); } }); -Hedera.Catalog.extend -({ +Hedera.Catalog.extend({ View: { LIST: 0, GRID: 1 } }); -Vn.Filter = new Class -({ +Vn.Filter = new Class({ Extends: Htk.Field ,Tag: 'vn-filter' ,Child: 'model' @@ -366,40 +319,34 @@ Vn.Filter = new Class model: { type: Db.Model - ,set: function (x) - { + ,set: function(x) { x.batch = this._batch; this._model = x; this._select.model = x; } - ,get: function () - { + ,get: function() { return this._model; } }, placeholder: { type: String - ,set: function (x) - { + ,set: function(x) { this._select.placeholder = x; this._placeholder = x; } - ,get: function () - { + ,get: function() { return this._placeholder; } }, filter: { type: Sql.Filter - ,set: function (x) - { + ,set: function(x) { this._filter = x; - this._batch.addObject ('filter', x); + this._batch.addObject('filter', x); } - ,get: function () - { + ,get: function() { return this._filter; } }, @@ -408,127 +355,112 @@ Vn.Filter = new Class ,_valueColumnIndex: 0 ,_showColumnIndex: 1 - ,initialize: function (props) - { - var node = this.createRoot ('div'); + ,initialize: function(props) { + var node = this.createRoot('div'); node.className = 'vn-filter'; - this._select = new Htk.Select (); - this._select.on ('mousedown', this._onMouseDown, this); - this._select.on ('changed', this._onChange, this); - this._select.on ('ready', this._onReady, this); - this.node.appendChild (this._select.node); + this._select = new Htk.Select(); + this._select.on('mousedown', this._onMouseDown, this); + this._select.on('changed', this._onChange, this); + this._select.on('ready', this._onReady, this); + this.node.appendChild(this._select.node); - this._ul = this.createElement ('ul'); - this.node.appendChild (this._ul); + this._ul = this.createElement('ul'); + this.node.appendChild(this._ul); - this._batch = new Sql.Batch (); - this.parent (props); + this._batch = new Sql.Batch(); + this.parent(props); } - ,_onMouseDown: function () - { + ,_onMouseDown: function() { if (this._model && this._model.status === Db.Model.Status.CLEAN) - this._model.refresh (); + this._model.refresh(); } - ,_onCloseClick: function () - { - this._removeSelectionNode (); - this._changeValue (undefined); + ,_onCloseClick: function() { + this._removeSelectionNode(); + this._changeValue(undefined); } - ,_removeSelectionNode: function () - { - if (this._lastLi) - { - Vn.Node.remove (this._lastLi); + ,_removeSelectionNode: function() { + if (this._lastLi) { + Vn.Node.remove(this._lastLi); this._lastLi = null; this._label = null; } } - ,_onChange: function () - { + ,_onChange: function() { if (this._select.value === null || this._select.value === undefined) return; - this._realSetValue (this._select.value); + this._realSetValue(this._select.value); } - ,_onReady: function () - { + ,_onReady: function() { if (this._emptyLabel) - this._refreshLabel (); + this._refreshLabel(); } - ,_changeValue: function (newValue) - { - this._batch.block (); + ,_changeValue: function(newValue) { + this._batch.block(); this.value = newValue; - this._batch.unblock (); + this._batch.unblock(); } - ,_onTimeout: function () - { + ,_onTimeout: function() { this._select.value = null; } - ,putValue: function (value) - { - this._onMouseDown (); - this._realSetValue (value); + ,putValue: function(value) { + this._onMouseDown(); + this._realSetValue(value); } - ,_realSetValue: function (value) - { - this._removeSelectionNode (); + ,_realSetValue: function(value) { + this._removeSelectionNode(); if (value === null || value === undefined) return; - var li = this._lastLi = this.createElement ('li'); - this._ul.appendChild (li); + var li = this._lastLi = this.createElement('li'); + this._ul.appendChild(li); - var button = this.createElement ('button'); - button.addEventListener ('click', - this._onCloseClick.bind (this, li)); - li.appendChild (button); + var button = this.createElement('button'); + button.addEventListener('click', + this._onCloseClick.bind(this, li)); + li.appendChild(button); - var icon = new Htk.Icon ({ + var icon = new Htk.Icon({ icon: 'close', alt: _('Close') }); - button.appendChild (icon.node); + button.appendChild(icon.node); - var text = this._label = this.createTextNode (''); - li.appendChild (text); + var text = this._label = this.createTextNode(''); + li.appendChild(text); - setTimeout (this._onTimeout.bind (this)); + setTimeout(this._onTimeout.bind(this)); - this._changeValue (value); - this._refreshLabel (); + this._changeValue(value); + this._refreshLabel(); } - ,_refreshLabel: function () - { + ,_refreshLabel: function() { if (!this._label) return; var row = -1; if (this._model.ready) - row = this._model.searchByIndex (this._valueColumnIndex, this._value); + row = this._model.searchByIndex(this._valueColumnIndex, this._value); - if (row != -1) - { - var label = this._model.getByIndex (row, this._showColumnIndex); + if (row != -1) { + var label = this._model.getByIndex(row, this._showColumnIndex); this._label.nodeValue = label; this._emptyLabel = false; - } - else - { + } else { this._emptyLabel = true; this._label.nodeValue = _('Loading...'); } diff --git a/forms/ecomerce/checkout/checkout.js b/forms/ecomerce/checkout/checkout.js index 61b368cf..1a9ea7bf 100644 --- a/forms/ecomerce/checkout/checkout.js +++ b/forms/ecomerce/checkout/checkout.js @@ -1,5 +1,5 @@ -Hedera.Checkout = new Class ({ +Hedera.Checkout = new Class({ Extends: Hedera.Form, activate: function() { @@ -59,7 +59,7 @@ Hedera.Checkout = new Class ({ onConfirmClick: function() { this.disableButtons(true); - var query = 'CALL basketConfigure(#date, #method, #agency, #address)'; + var query = 'CALL myBasket_configure(#date, #method, #agency, #address)'; var batch = new Sql.Batch(); batch.addParam('method', this.$('method')); diff --git a/forms/ecomerce/confirm/ui.xml b/forms/ecomerce/confirm/ui.xml index 90dcf285..6260a58d 100644 --- a/forms/ecomerce/confirm/ui.xml +++ b/forms/ecomerce/confirm/ui.xml @@ -2,7 +2,7 @@ - CALL basketGetTax; + CALL myBasket_getTax; SELECT o.id, o.sent, o.notes, o.companyFk, ag.description agency, v.code method, ad.nickname, ad.postalCode, ad.city, ad.street, @@ -23,7 +23,7 @@ - CALL basketConfirm + CALL myBasket_confirm
diff --git a/forms/ecomerce/orders/ui.xml b/forms/ecomerce/orders/ui.xml index 2c9992b7..265678d0 100644 --- a/forms/ecomerce/orders/ui.xml +++ b/forms/ecomerce/orders/ui.xml @@ -44,7 +44,7 @@ - CALL myTicketList (NULL, NULL); + CALL myTicket_list (NULL, NULL); diff --git a/forms/ecomerce/ticket/ticket.js b/forms/ecomerce/ticket/ticket.js index 11360995..ec442ee5 100644 --- a/forms/ecomerce/ticket/ticket.js +++ b/forms/ecomerce/ticket/ticket.js @@ -8,7 +8,7 @@ Hedera.Ticket = new Class({ var batch = new Sql.Batch(); batch.addValue('ticket', ticket.value); - this.conn.execQuery('CALL myTicketLogAccess(#ticket)', null, batch); + this.conn.execQuery('CALL myTicket_logAccess(#ticket)', null, batch); }, onTicketReady: function(form) { diff --git a/forms/ecomerce/ticket/ui.xml b/forms/ecomerce/ticket/ui.xml index 97f03ce2..b0a962b4 100644 --- a/forms/ecomerce/ticket/ui.xml +++ b/forms/ecomerce/ticket/ui.xml @@ -9,7 +9,7 @@ - CALL myTicketGet (#ticket) + CALL myTicket_get (#ticket) @@ -68,7 +68,7 @@ property="model" id="movements" batch="batch"> - CALL myTicketGetRows (#ticket) + CALL myTicket_getRows (#ticket)
@@ -112,7 +112,7 @@ property="model" on-status-changed="onPackagesChanged" batch="batch"> - CALL myTicketGetPackages (#ticket) + CALL myTicket_getPackages (#ticket)
diff --git a/js/hedera/basket-checker.js b/js/hedera/basket-checker.js index c67e0bd5..abde2365 100644 --- a/js/hedera/basket-checker.js +++ b/js/hedera/basket-checker.js @@ -1,15 +1,12 @@ -module.exports = -{ - check: function (conn, callback) - { - conn.execQuery ('CALL basketCheck', - this._onBasketCheck.bind (this, callback)); - } +module.exports = { + check: function(conn, callback) { + conn.execQuery('CALL myBasket_check', + this._onBasketCheck.bind(this, callback)); + }, - ,_onBasketCheck: function (callback, resultSet) - { - var status = resultSet.fetchValue (); + _onBasketCheck: function(callback, resultSet) { + var status = resultSet.fetchValue(); if (!status) return; @@ -17,11 +14,11 @@ module.exports = var isOk = status == 'UPDATED' || status == 'OK'; if (status == 'UPDATED') - Htk.Toast.showWarning (_('Order items updated')); + Htk.Toast.showWarning(_('Order items updated')); if (callback) - callback (isOk); + callback(isOk); if (!isOk) - Vn.Hash.set ({'form': 'ecomerce/checkout'}); + Vn.Hash.set({form: 'ecomerce/checkout'}); } }; diff --git a/js/hedera/tpv.js b/js/hedera/tpv.js index 19f2d9ac..ee59267d 100644 --- a/js/hedera/tpv.js +++ b/js/hedera/tpv.js @@ -15,7 +15,7 @@ module.exports = new Class batch.addValue('transaction', this.tpvOrder); batch.addValue('status', this.tpvStatus); - var query = 'CALL tpvTransactionEnd (#transaction, #status)'; + var query = 'CALL myTpvTransaction_end(#transaction, #status)'; this.conn.execQuery(query, null, batch); } diff --git a/package.json b/package.json index fb328904..b356cd6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.406.46", + "version": "1.406.47", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/reports/delivery-note/ui.xml b/reports/delivery-note/ui.xml index c6c8357e..56b09d54 100644 --- a/reports/delivery-note/ui.xml +++ b/reports/delivery-note/ui.xml @@ -2,7 +2,7 @@ - CALL myTicketGet (#ticket) + CALL myTicket_get (#ticket) @@ -38,7 +38,7 @@
- CALL myTicketGetRows (#ticket) + CALL myTicket_getRows (#ticket) @@ -64,7 +64,7 @@ conn="conn" batch="batch" on-status-changed="onPackagesChanged"> - CALL myTicketGetPackages (#ticket) + CALL myTicket_getPackages (#ticket) diff --git a/reports/items-report/ui.xml b/reports/items-report/ui.xml index 35b49e75..5eb2f1a9 100644 --- a/reports/items-report/ui.xml +++ b/reports/items-report/ui.xml @@ -9,7 +9,7 @@ batch="batch" conn="conn"> - CALL itemGetList(#warehouse, CURDATE(), #realm, #rate) + CALL item_getList(#warehouse, CURDATE(), #realm, #rate) 0) - { - var sheet = this.doc.createElement ('div'); + if (remainings.length > 0) { + var sheet = this.doc.createElement('div'); sheet.className = 'sheet'; - this.doc.body.appendChild (sheet); + this.doc.body.appendChild(sheet); - var title = this.doc.createElement ('h1'); + var title = this.doc.createElement('h1'); title.className = 'title'; - title.appendChild (this.doc.createTextNode (this.title)); - sheet.appendChild (title); + title.appendChild(this.doc.createTextNode(this.title)); + sheet.appendChild(title); - var subtitle = this.doc.createElement ('h2'); + var subtitle = this.doc.createElement('h2'); subtitle.className = 'subtitle'; - subtitle.appendChild (this.doc.createTextNode (_('Pallets'))); - sheet.appendChild (subtitle); + subtitle.appendChild(this.doc.createTextNode(_('Pallets'))); + sheet.appendChild(subtitle); - var ul = this.doc.createElement ('ul'); - sheet.appendChild (ul); + var ul = this.doc.createElement('ul'); + sheet.appendChild(ul); - for (var i = 0; i < remainings.length; i++) - { - var li = this.doc.createElement ('li'); - ul.appendChild (li); + for (var i = 0; i < remainings.length; i++) { + var li = this.doc.createElement('li'); + ul.appendChild(li); - var span = this.doc.createElement ('span'); + var span = this.doc.createElement('span'); span.className = 'item-id'; - span.appendChild (this.doc.createTextNode (remainings[i].id.toLocaleString ())); - li.appendChild (span); + span.appendChild(this.doc.createTextNode(remainings[i].id.toLocaleString())); + li.appendChild(span); - var span = this.doc.createElement ('span'); + var span = this.doc.createElement('span'); span.className = 'item'; - span.appendChild (this.doc.createTextNode (remainings[i].name)); - li.appendChild (span); + span.appendChild(this.doc.createTextNode(remainings[i].name)); + li.appendChild(span); if (this.showPacking) - span.appendChild (this.doc.createTextNode (' '+ remainings[i].packing)); + span.appendChild(this.doc.createTextNode(' '+ remainings[i].packing)); - var span = this.doc.createElement ('span'); + var span = this.doc.createElement('span'); span.className = 'amount'; - span.appendChild (this.doc.createTextNode (remainings[i].amount)); - li.appendChild (span); + span.appendChild(this.doc.createTextNode(remainings[i].amount)); + li.appendChild(span); } } // Draws the shelves - this.alloc.run (); - this.drawShelfRange (this.lastItem, false); + this.alloc.run(); + this.drawShelfRange(this.lastItem, false); } - ,drawShelf: function (allocator, item) - { + ,drawShelf: function(allocator, item) { var shelf = this.shelf; - var sheet = this.doc.createElement ('div'); + var sheet = this.doc.createElement('div'); sheet.className = 'sheet'; - this.doc.body.appendChild (sheet); + this.doc.body.appendChild(sheet); // Draws the title - var pageNumber = this.doc.createElement ('h1'); + var pageNumber = this.doc.createElement('h1'); pageNumber.className = 'page-number'; - pageNumber.appendChild (this.doc.createTextNode (allocator.currentShelf + 1)); - sheet.appendChild (pageNumber); + pageNumber.appendChild(this.doc.createTextNode(allocator.currentShelf + 1)); + sheet.appendChild(pageNumber); - var title = this.doc.createElement ('h1'); + var title = this.doc.createElement('h1'); title.className = 'title'; - title.appendChild (this.doc.createTextNode (this.title)); - sheet.appendChild (title); + title.appendChild(this.doc.createTextNode(this.title)); + sheet.appendChild(title); if (this.subtitles) - this.drawShelfRange (this.lastItem, false); + this.drawShelfRange(this.lastItem, false); - this.subtitles = this.doc.createElement ('div'); - sheet.appendChild (this.subtitles); + this.subtitles = this.doc.createElement('div'); + sheet.appendChild(this.subtitles); - this.drawShelfRange (item, true); + this.drawShelfRange(item, true); this.lastSubtitles = this.subtitles; // Draws the shelf @@ -202,58 +191,51 @@ Hedera.ShelvesReport = new Class var shelfHeight = shelf.trayHeight * (shelf.nTrays - 1) + shelf.topTrayHeight + (this.trayThickness + this.trayMargin) * shelf.nTrays; - var shelfDiv = this.shelfDiv = this.doc.createElement ('div'); + var shelfDiv = this.shelfDiv = this.doc.createElement('div'); shelfDiv.className = 'shelf'; - shelfDiv.style.width = this.mm (trayWidth); - shelfDiv.style.height = this.mm (shelfHeight); - sheet.appendChild (shelfDiv); + shelfDiv.style.width = this.mm(trayWidth); + shelfDiv.style.height = this.mm(shelfHeight); + sheet.appendChild(shelfDiv); // Draws trays - for (var i = 0; i < shelf.nTrays; i++) - { - var tray = this.doc.createElement ('div'); + for (var i = 0; i < shelf.nTrays; i++) { + var tray = this.doc.createElement('div'); tray.className = 'tray'; - tray.style.bottom = this.mm ((shelf.trayHeight + this.trayThickness + this.trayMargin) * i); - tray.style.width = this.mm (trayWidth); - tray.style.height = this.mm (this.trayThickness); - shelfDiv.appendChild (tray); + tray.style.bottom = this.mm((shelf.trayHeight + this.trayThickness + this.trayMargin) * i); + tray.style.width = this.mm(trayWidth); + tray.style.height = this.mm(this.trayThickness); + shelfDiv.appendChild(tray); } } - ,drawShelfRange: function (item, isFirst) - { + ,drawShelfRange: function(item, isFirst) { var labelText = isFirst ? _('Start') : _('End'); - var label = this.doc.createElement ('label'); + var label = this.doc.createElement('label'); label.className = 'range-label'; - label.appendChild (this.doc.createTextNode (labelText)); - this.subtitles.appendChild (label); + label.appendChild(this.doc.createTextNode(labelText)); + this.subtitles.appendChild(label); - var subtitle = this.doc.createElement ('h2'); + var subtitle = this.doc.createElement('h2'); subtitle.className = 'subtitle'; - subtitle.appendChild (this.doc.createTextNode (this.getItemLabel (item))); - this.subtitles.appendChild (subtitle); + subtitle.appendChild(this.doc.createTextNode(this.getItemLabel(item))); + this.subtitles.appendChild(subtitle); } - ,getItemLabel: function (item) - { - if (!this.useIds) - { + ,getItemLabel: function(item) { + if (!this.useIds) { var packing = this.showPacking ? (' x'+ item.packing) : ''; return item.name + packing; - } - else - return item.id.toLocaleString (); + } else + return item.id.toLocaleString(); } - ,mm: function (size) - { - return size.toFixed (2) +'mm'; + ,mm: function(size) { + return size.toFixed(2) +'mm'; } - ,drawBox: function (allocator, item, amount) - { + ,drawBox: function(allocator, item, amount) { if (item.boxWidth == 0 || item.boxHeight == 0) return; @@ -264,80 +246,71 @@ Hedera.ShelvesReport = new Class + this.trayMargin * allocator.currentTray + allocator.currentTray * (shelf.trayHeight + this.trayThickness); - var box = this.doc.createElement ('div'); + var box = this.doc.createElement('div'); box.className = 'box'; - this.shelfDiv.appendChild (box); + this.shelfDiv.appendChild(box); - box.style.left = this.mm (x); - box.style.bottom = this.mm (y); - box.style.width = this.mm (item.boxWidth); - box.style.height = this.mm (item.boxHeight); + box.style.left = this.mm(x); + box.style.bottom = this.mm(y); + box.style.width = this.mm(item.boxWidth); + box.style.height = this.mm(item.boxHeight); if (amount == 0) this.nItem++; var nColor = this.nItem % this.nColors; - Vn.Node.addClass (box, 'color'+ nColor); + Vn.Node.addClass(box, 'color'+ nColor); - if (amount == 0 || allocator.firstShelfBox) - { - var boxLabel = this.doc.createElement ('div'); + if (amount == 0 || allocator.firstShelfBox) { + var boxLabel = this.doc.createElement('div'); - if (this.useIds) - { + if (this.useIds) { var fontSize = item.boxWidth / 5.2; if (fontSize > item.boxHeight - 1) fontSize = item.boxHeight - 1; - boxLabel.style.fontSize = this.mm (fontSize); + boxLabel.style.fontSize = this.mm(fontSize); var cssClass = 'id'; - } - else + } else var cssClass = 'name'; boxLabel.className = 'box-label '+ cssClass; - var labelText = this.doc.createTextNode (this.getItemLabel (item)); - boxLabel.appendChild (labelText); + var labelText = this.doc.createTextNode(this.getItemLabel(item)); + boxLabel.appendChild(labelText); - box.appendChild (boxLabel); + box.appendChild(boxLabel); } this.lastItem = item; } }); -Vn.Allocator = new Class -({ - addShelf: function (item) - { +Vn.Allocator = new Class({ + addShelf: function(item) { this.currentShelf++; this.firstShelfBox = true; if (this.shelfFunc) - this.shelfFunc (this, item); + this.shelfFunc(this, item); } - ,addTray: function (item) - { - if (this.currentTray <= 0) - { - this.addShelf (item); + ,addTray: function(item) { + if (this.currentTray <= 0) { + this.addShelf(item); this.currentTray = this.nTrays - 1; - } - else + } else this.currentTray--; this.trayX = 0; } - ,addColumn: function (item) - { + ,addColumn: function(item) { if (this.trayX + this.columnWidth + item.boxWidth > this.width || this.currentTray == -1) - this.addTray (item); + this.addTray(item); else this.trayX += this.columnWidth; @@ -346,8 +319,7 @@ Vn.Allocator = new Class this.lastBoxWidth = item.boxWidth; } - ,addBox: function (item, amount) - { + ,addBox: function(item, amount) { var trayHeight = this.trayHeight; if (this.currentTray == this.nTrays - 1) @@ -356,10 +328,10 @@ Vn.Allocator = new Class if (this.trayY + item.boxHeight > trayHeight || item.boxWidth > this.lastBoxWidth || (!this.stack && amount == 0)) - this.addColumn (item); + this.addColumn(item); if (this.boxFunc) - this.boxFunc (this, item, amount); + this.boxFunc(this, item, amount); this.trayY += item.boxHeight; @@ -367,8 +339,7 @@ Vn.Allocator = new Class this.lastBoxWidth = item.boxWidth; } - ,run: function () - { + ,run: function() { this.firstShelfBox = false; this.currentShelf = -1; this.currentTray = -1; @@ -378,22 +349,19 @@ Vn.Allocator = new Class this.trayY = 0; this.remaining = false; - for (var i = 0; i < this.items.length; i++) - { + for (var i = 0; i < this.items.length; i++) { var item = this.items[i]; - var boxIncrement = Math.floor (this.depth / item.boxDepth); + var boxIncrement = Math.floor(this.depth / item.boxDepth); if (boxIncrement < 1) boxIncrement = 1; - for (var amount = 0; amount < item.amount; amount += boxIncrement) - { - this.addBox (item, amount); + for (var amount = 0; amount < item.amount; amount += boxIncrement) { + this.addBox(item, amount); this.firstShelfBox = false; } } return this.currentShelf + 1; } - }); diff --git a/rest/tpv/tpv.php b/rest/tpv/tpv.php index 81d6d7f3..652de159 100644 --- a/rest/tpv/tpv.php +++ b/rest/tpv/tpv.php @@ -18,7 +18,7 @@ class Tpv { $error = NULL; return $db->query( - 'CALL tpvTransactionConfirm(#, #, #, #, #, #)', + 'CALL tpvTransaction_confirm(#, #, #, #, #, #)', [ $params['Ds_Amount'] ,$params['Ds_Order'] diff --git a/rest/tpv/transaction.php b/rest/tpv/transaction.php index b152351d..c8c207de 100644 --- a/rest/tpv/transaction.php +++ b/rest/tpv/transaction.php @@ -10,7 +10,7 @@ class Transaction extends Vn\Web\JsonRequest { $amount =(int) $_REQUEST['amount']; $companyId = empty($_REQUEST['company']) ? NULL : $_REQUEST['company']; - $row = $db->getObject('CALL tpvTransactionStart(#, #)', + $row = $db->getObject('CALL myTpvTransaction_start(#, #)', [$amount, $companyId]); if (!isset($row)) diff --git a/web/service.php b/web/service.php index 588a345a..63158958 100644 --- a/web/service.php +++ b/web/service.php @@ -97,7 +97,7 @@ abstract class Service { $ip = ip2long($_SERVER['REMOTE_ADDR']); $row = $db->getRow( - 'CALL visitRegister(#, #, #, #, #, #, #, #, #)', + 'CALL visit_register(#, #, #, #, #, #, #, #, #)', [ nullIf($_COOKIE, 'vnVisit') ,nullIf($browser, 'platform') @@ -191,7 +191,7 @@ abstract class Service { if (isset($_SESSION['access']) && $userChanged) $db->query( - 'CALL visitUserNew(#, #)', + 'CALL visitUser_new(#, #)', [$_SESSION['access'], session_id()] ); }