SQL refactor
This commit is contained in:
parent
0882952dcf
commit
4f3b7efcb3
|
@ -1,4 +1,4 @@
|
||||||
hedera-web (1.406.46) stable; urgency=low
|
hedera-web (1.406.47) stable; urgency=low
|
||||||
|
|
||||||
* Initial Release.
|
* Initial Release.
|
||||||
|
|
||||||
|
|
|
@ -1,66 +1,54 @@
|
||||||
|
|
||||||
Hedera.Catalog = new Class
|
Hedera.Catalog = new Class({
|
||||||
({
|
|
||||||
Extends: Hedera.Form
|
Extends: Hedera.Form
|
||||||
|
|
||||||
,_menuShown: false
|
,_menuShown: false
|
||||||
|
|
||||||
,open: function ()
|
,open: function() {
|
||||||
{
|
this.close();
|
||||||
this.close ();
|
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
|
|
||||||
if (!localStorage.getItem ('hederaGuest'))
|
if (!localStorage.getItem('hederaGuest')) {
|
||||||
{
|
Hedera.BasketChecker.check(this.conn,
|
||||||
Hedera.BasketChecker.check (this.conn,
|
this.onBasketCheck.bind(this));
|
||||||
this.onBasketCheck.bind (this));
|
} else {
|
||||||
}
|
var query = 'CALL mybasket_configureForGuest';
|
||||||
else
|
this.conn.execQuery(query, this.loadUi.bind(this));
|
||||||
{
|
|
||||||
var query = 'CALL basketConfigureForGuest';
|
|
||||||
this.conn.execQuery (query, this.loadUi.bind (this));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
,onBasketCheck: function (isOk)
|
,onBasketCheck: function(isOk) {
|
||||||
{
|
|
||||||
if (isOk)
|
if (isOk)
|
||||||
this.loadUi ();
|
this.loadUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
,activate: function ()
|
,activate: function() {
|
||||||
{
|
document.body.appendChild(this.$('right-panel'));
|
||||||
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'))
|
if (localStorage.getItem('hederaView'))
|
||||||
this.setView (parseInt (localStorage.getItem ('hederaView')));
|
this.setView(parseInt(localStorage.getItem('hederaView')));
|
||||||
else
|
else
|
||||||
this.setView (Hedera.Catalog.View.GRID);
|
this.setView(Hedera.Catalog.View.GRID);
|
||||||
}
|
}
|
||||||
|
|
||||||
,deactivate: function ()
|
,deactivate: function() {
|
||||||
{
|
this.hideMenu();
|
||||||
this.hideMenu ();
|
|
||||||
this.gui.$('top-bar').style.backgroundColor = '';
|
this.gui.$('top-bar').style.backgroundColor = '';
|
||||||
Vn.Node.remove (this.$('right-panel'));
|
Vn.Node.remove(this.$('right-panel'));
|
||||||
}
|
}
|
||||||
|
|
||||||
,setView: function (view)
|
,setView: function(view) {
|
||||||
{
|
if (view === Hedera.Catalog.View.GRID) {
|
||||||
if (view === Hedera.Catalog.View.GRID)
|
this.$('view-button').setProperties({
|
||||||
{
|
|
||||||
this.$('view-button').setProperties ({
|
|
||||||
icon: 'view-list',
|
icon: 'view-list',
|
||||||
tip: _('List view')
|
tip: _('List view')
|
||||||
});
|
});
|
||||||
this.view = Hedera.Catalog.View.GRID;
|
this.view = Hedera.Catalog.View.GRID;
|
||||||
var className = 'grid-view';
|
var className = 'grid-view';
|
||||||
}
|
} else {
|
||||||
else
|
this.$('view-button').setProperties({
|
||||||
{
|
|
||||||
this.$('view-button').setProperties ({
|
|
||||||
icon: 'view-grid',
|
icon: 'view-grid',
|
||||||
tip: _('Grid view')
|
tip: _('Grid view')
|
||||||
});
|
});
|
||||||
|
@ -70,92 +58,80 @@ Hedera.Catalog = new Class
|
||||||
|
|
||||||
var node = this.$('grid-view').node;
|
var node = this.$('grid-view').node;
|
||||||
node.className = className;
|
node.className = className;
|
||||||
localStorage.setItem ('hederaView', this.view);
|
localStorage.setItem('hederaView', this.view);
|
||||||
}
|
}
|
||||||
|
|
||||||
,onSwitchViewClick: function ()
|
,onSwitchViewClick: function() {
|
||||||
{
|
this.setView(this.view === Hedera.Catalog.View.LIST ?
|
||||||
this.setView (this.view === Hedera.Catalog.View.LIST ?
|
|
||||||
Hedera.Catalog.View.GRID : Hedera.Catalog.View.LIST);
|
Hedera.Catalog.View.GRID : Hedera.Catalog.View.LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
,onBasketReady: function (form)
|
,onBasketReady: function(form) {
|
||||||
{
|
if (form.get('method') != 'PICKUP')
|
||||||
if (form.get ('method') != 'PICKUP')
|
Vn.Node.setText(this.$('method'), _('Agency'));
|
||||||
Vn.Node.setText (this.$('method'), _('Agency'));
|
|
||||||
else
|
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)
|
if (status !== Db.Model.Status.CLEAN)
|
||||||
this.$('order').style.display = 'block';
|
this.$('order').style.display = 'block';
|
||||||
else
|
else
|
||||||
this.$('order').style.display = 'none';
|
this.$('order').style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
,onOrderChange: function (e)
|
,onOrderChange: function(e) {
|
||||||
{
|
|
||||||
var value = e.target.value;
|
var value = e.target.value;
|
||||||
var sortField = value.substr (2);
|
var sortField = value.substr(2);
|
||||||
var sortWay = value.charAt (0) === 'A' ?
|
var sortWay = value.charAt(0) === 'A' ?
|
||||||
Db.Model.SortWay.ASC : Db.Model.SortWay.DESC;
|
Db.Model.SortWay.ASC : Db.Model.SortWay.DESC;
|
||||||
|
|
||||||
if (sortField)
|
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)
|
if (newValue)
|
||||||
this.hideMenu ();
|
this.hideMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
,realmRenderer: function (builder, form)
|
,realmRenderer: function(builder, form) {
|
||||||
{
|
|
||||||
var link = builder.$('link');
|
var link = builder.$('link');
|
||||||
link.href = this.hash.make ({
|
link.href = this.hash.make({
|
||||||
'form': this.hash.get ('form'),
|
'form': this.hash.get('form'),
|
||||||
'realm': form.get ('id')
|
'realm': form.get('id')
|
||||||
});
|
});
|
||||||
|
|
||||||
var img = builder.$('image');
|
var img = builder.$('image');
|
||||||
img.src = 'image/family/light/'+ form.get ('id') +'.svg';
|
img.src = 'image/family/light/'+ form.get('id') +'.svg';
|
||||||
img.title = form.get ('name');
|
img.title = form.get('name');
|
||||||
img.alt = img.title;
|
img.alt = img.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
,onRealmChange: function (param, newValue)
|
,onRealmChange: function(param, newValue) {
|
||||||
{
|
if (newValue) {
|
||||||
if (newValue)
|
|
||||||
{
|
|
||||||
this.$('filters').style.display = 'block';
|
this.$('filters').style.display = 'block';
|
||||||
this.$('realm-msg').style.display = 'none';
|
this.$('realm-msg').style.display = 'none';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
this.$('filters').style.display = 'none';
|
this.$('filters').style.display = 'none';
|
||||||
this.$('realm-msg').style.display = 'block';
|
this.$('realm-msg').style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refreshTitleColor ();
|
this.refreshTitleColor();
|
||||||
this.refreshFilter (newValue, undefined);
|
this.refreshFilter(newValue, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
,onTypeChange: function (param, newValue)
|
,onTypeChange: function(param, newValue) {
|
||||||
{
|
this.onFilterChange(param, newValue);
|
||||||
this.onFilterChange (param, newValue);
|
this.refreshTitle();
|
||||||
this.refreshTitle ();
|
this.refreshFilter(undefined, newValue);
|
||||||
this.refreshFilter (undefined, newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,refreshFilter: function (realm, type)
|
,refreshFilter: function(realm, type) {
|
||||||
{
|
|
||||||
var batch = this.$('filter-batch');
|
var batch = this.$('filter-batch');
|
||||||
batch.block ();
|
batch.block();
|
||||||
this.$('realm-value').value = realm;
|
this.$('realm-value').value = realm;
|
||||||
this.$('type-value').value = type;
|
this.$('type-value').value = type;
|
||||||
this.$('search').value = undefined;
|
this.$('search').value = undefined;
|
||||||
|
@ -163,12 +139,11 @@ Hedera.Catalog = new Class
|
||||||
this.$('origin').value = undefined;
|
this.$('origin').value = undefined;
|
||||||
this.$('category').value = undefined;
|
this.$('category').value = undefined;
|
||||||
this.$('producer').value = undefined;
|
this.$('producer').value = undefined;
|
||||||
batch.unblock ();
|
batch.unblock();
|
||||||
batch.changed ();
|
batch.changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
,refreshTitleColor: function ()
|
,refreshTitleColor: function() {
|
||||||
{
|
|
||||||
var realms = this.$('realms-model');
|
var realms = this.$('realms-model');
|
||||||
|
|
||||||
if (!realms.ready)
|
if (!realms.ready)
|
||||||
|
@ -177,19 +152,17 @@ Hedera.Catalog = new Class
|
||||||
var color = null;
|
var color = null;
|
||||||
var realm = this.$('realm').value;
|
var realm = this.$('realm').value;
|
||||||
|
|
||||||
if (realm)
|
if (realm) {
|
||||||
{
|
var row = realms.search('id', realm);
|
||||||
var row = realms.search ('id', realm);
|
|
||||||
|
|
||||||
if (row != -1)
|
if (row != -1)
|
||||||
color = '#'+ realms.get (row, 'color');
|
color = '#'+ realms.get(row, 'color');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.gui.$('top-bar').style.backgroundColor = color;
|
this.gui.$('top-bar').style.backgroundColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
,refreshTitle: function ()
|
,refreshTitle: function() {
|
||||||
{
|
|
||||||
var types = this.$('types-model');
|
var types = this.$('types-model');
|
||||||
|
|
||||||
if (!types.ready)
|
if (!types.ready)
|
||||||
|
@ -198,95 +171,84 @@ Hedera.Catalog = new Class
|
||||||
var title = _('Catalog');
|
var title = _('Catalog');
|
||||||
var type = this.$('type').value;
|
var type = this.$('type').value;
|
||||||
|
|
||||||
if (type)
|
if (type) {
|
||||||
{
|
var row = types.search('id', type);
|
||||||
var row = types.search ('id', type);
|
|
||||||
|
|
||||||
if (row != -1)
|
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)
|
,onRightPanelClick: function(event) {
|
||||||
{
|
event.stopPropagation();
|
||||||
event.stopPropagation ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,onShowMenuClick: function (event)
|
,onShowMenuClick: function(event) {
|
||||||
{
|
|
||||||
this._menuShown = true;
|
this._menuShown = true;
|
||||||
event.stopPropagation ();
|
event.stopPropagation();
|
||||||
this.gui.showBackground ();
|
this.gui.showBackground();
|
||||||
Vn.Node.addClass (this.$('right-panel'), 'show');
|
Vn.Node.addClass(this.$('right-panel'), 'show');
|
||||||
this.hideMenuCallback = this.hideMenu.bind (this);
|
this.hideMenuCallback = this.hideMenu.bind(this);
|
||||||
document.addEventListener ('click', this.hideMenuCallback);
|
document.addEventListener('click', this.hideMenuCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
,hideMenu: function ()
|
,hideMenu: function() {
|
||||||
{
|
|
||||||
if (!this._menuShown)
|
if (!this._menuShown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.gui.hideBackground ();
|
this.gui.hideBackground();
|
||||||
Vn.Node.removeClass (this.$('right-panel'), 'show');
|
Vn.Node.removeClass(this.$('right-panel'), 'show');
|
||||||
document.removeEventListener ('click', this.hideMenuCallback);
|
document.removeEventListener('click', this.hideMenuCallback);
|
||||||
this.hideMenuCallback = null;
|
this.hideMenuCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
,isGuest: function ()
|
,isGuest: function() {
|
||||||
{
|
if (localStorage.getItem('hederaGuest')) {
|
||||||
if (localStorage.getItem ('hederaGuest'))
|
Htk.Toast.showError(_('YouMustBeLoggedIn'));
|
||||||
{
|
|
||||||
Htk.Toast.showError (_('YouMustBeLoggedIn'));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
,onBasketClick: function ()
|
,onBasketClick: function() {
|
||||||
{
|
if (this.isGuest())
|
||||||
if (this.isGuest ())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.hash.set ({'form': 'ecomerce/basket'});
|
this.hash.set({'form': 'ecomerce/basket'});
|
||||||
}
|
}
|
||||||
|
|
||||||
,onConfigureClick: function ()
|
,onConfigureClick: function() {
|
||||||
{
|
if (this.isGuest())
|
||||||
if (this.isGuest ())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.hash.set ({'form': 'ecomerce/checkout'});
|
this.hash.set({'form': 'ecomerce/checkout'});
|
||||||
}
|
}
|
||||||
|
|
||||||
,onAddItemClick: function (button, form)
|
,onAddItemClick: function(button, form) {
|
||||||
{
|
if (this.isGuest())
|
||||||
if (this.isGuest ())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.onEraseClick ();
|
this.onEraseClick();
|
||||||
this.$('card').row = form.row;
|
this.$('card').row = form.row;
|
||||||
this.$('card-item').value = form.get ('id');
|
this.$('card-item').value = form.get('id');
|
||||||
this.$('card-popup').show (button.node);
|
this.$('card-popup').show(button.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
,onAddLotClick: function (column, value, row)
|
,onAddLotClick: function(column, value, row) {
|
||||||
{
|
|
||||||
var model = this.$('item-lots');
|
var model = this.$('item-lots');
|
||||||
var grouping = model.get (row, 'grouping');
|
var grouping = model.get(row, 'grouping');
|
||||||
var warehouse = model.get (row, 'warehouseFk');
|
var warehouse = model.get(row, 'warehouseFk');
|
||||||
var available = model.get (row, 'available');
|
var available = model.get(row, 'available');
|
||||||
|
|
||||||
var lotAmount = this.items[warehouse];
|
var lotAmount = this.items[warehouse];
|
||||||
|
|
||||||
if (lotAmount === undefined)
|
if (lotAmount === undefined)
|
||||||
lotAmount = 0;
|
lotAmount = 0;
|
||||||
|
|
||||||
if (lotAmount < available)
|
if (lotAmount < available) {
|
||||||
{
|
|
||||||
var newAmount = lotAmount + grouping;
|
var newAmount = lotAmount + grouping;
|
||||||
|
|
||||||
if (newAmount > available)
|
if (newAmount > available)
|
||||||
|
@ -294,70 +256,61 @@ Hedera.Catalog = new Class
|
||||||
|
|
||||||
this.items[warehouse] = newAmount;
|
this.items[warehouse] = newAmount;
|
||||||
this.$('amount').value += newAmount - lotAmount;
|
this.$('amount').value += newAmount - lotAmount;
|
||||||
}
|
} else
|
||||||
else
|
Htk.Toast.showError(_('NoMoreAmountAvailable'));
|
||||||
Htk.Toast.showError (_('NoMoreAmountAvailable'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,onConfirmClick: function ()
|
,onConfirmClick: function() {
|
||||||
{
|
|
||||||
var sql = '';
|
var sql = '';
|
||||||
var batch = new Sql.Batch ();
|
var batch = new Sql.Batch();
|
||||||
var query = new Sql.String ({query: 'CALL basketAddItem (#warehouse, #item, #amount);'});
|
var query = new Sql.String({query: 'CALL myBasket_addItem(#warehouse, #item, #amount);'});
|
||||||
var amountSum = 0;
|
var amountSum = 0;
|
||||||
|
|
||||||
for (var warehouse in this.items)
|
for (var warehouse in this.items) {
|
||||||
{
|
|
||||||
var amount = this.items[warehouse];
|
var amount = this.items[warehouse];
|
||||||
amountSum += amount;
|
amountSum += amount;
|
||||||
|
|
||||||
batch.addValue ('warehouse', warehouse);
|
batch.addValue('warehouse', warehouse);
|
||||||
batch.addValue ('item', this.$('card-item').value);
|
batch.addValue('item', this.$('card-item').value);
|
||||||
batch.addValue ('amount', amount);
|
batch.addValue('amount', amount);
|
||||||
sql += query.render (batch);
|
sql += query.render(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amountSum > 0)
|
if (amountSum > 0) {
|
||||||
{
|
this.conn.execQuery(sql);
|
||||||
this.conn.execQuery (sql);
|
|
||||||
|
|
||||||
var itemName = this.$('card').get ('item');
|
var itemName = this.$('card').get('item');
|
||||||
Htk.Toast.showMessage (
|
Htk.Toast.showMessage(
|
||||||
sprintf (_('Added%dOf%s'), amountSum, itemName));
|
sprintf(_('Added%dOf%s'), amountSum, itemName));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$('card-popup').hide ();
|
this.$('card-popup').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
,onEraseClick: function ()
|
,onEraseClick: function() {
|
||||||
{
|
|
||||||
this.$('amount').value = 0;
|
this.$('amount').value = 0;
|
||||||
this.items = {};
|
this.items = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
,onPopupClose: function ()
|
,onPopupClose: function() {
|
||||||
{
|
this.onEraseClick();
|
||||||
this.onEraseClick ();
|
|
||||||
this.$('card').row = -1;
|
this.$('card').row = -1;
|
||||||
this.$('card-item').value = undefined;
|
this.$('card-item').value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
,onCardLoad: function ()
|
,onCardLoad: function() {
|
||||||
{
|
this.$('card-popup').reset();
|
||||||
this.$('card-popup').reset ();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Hedera.Catalog.extend
|
Hedera.Catalog.extend({
|
||||||
({
|
|
||||||
View: {
|
View: {
|
||||||
LIST: 0,
|
LIST: 0,
|
||||||
GRID: 1
|
GRID: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Vn.Filter = new Class
|
Vn.Filter = new Class({
|
||||||
({
|
|
||||||
Extends: Htk.Field
|
Extends: Htk.Field
|
||||||
,Tag: 'vn-filter'
|
,Tag: 'vn-filter'
|
||||||
,Child: 'model'
|
,Child: 'model'
|
||||||
|
@ -366,40 +319,34 @@ Vn.Filter = new Class
|
||||||
model:
|
model:
|
||||||
{
|
{
|
||||||
type: Db.Model
|
type: Db.Model
|
||||||
,set: function (x)
|
,set: function(x) {
|
||||||
{
|
|
||||||
x.batch = this._batch;
|
x.batch = this._batch;
|
||||||
this._model = x;
|
this._model = x;
|
||||||
this._select.model = x;
|
this._select.model = x;
|
||||||
}
|
}
|
||||||
,get: function ()
|
,get: function() {
|
||||||
{
|
|
||||||
return this._model;
|
return this._model;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
placeholder:
|
placeholder:
|
||||||
{
|
{
|
||||||
type: String
|
type: String
|
||||||
,set: function (x)
|
,set: function(x) {
|
||||||
{
|
|
||||||
this._select.placeholder = x;
|
this._select.placeholder = x;
|
||||||
this._placeholder = x;
|
this._placeholder = x;
|
||||||
}
|
}
|
||||||
,get: function ()
|
,get: function() {
|
||||||
{
|
|
||||||
return this._placeholder;
|
return this._placeholder;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filter:
|
filter:
|
||||||
{
|
{
|
||||||
type: Sql.Filter
|
type: Sql.Filter
|
||||||
,set: function (x)
|
,set: function(x) {
|
||||||
{
|
|
||||||
this._filter = x;
|
this._filter = x;
|
||||||
this._batch.addObject ('filter', x);
|
this._batch.addObject('filter', x);
|
||||||
}
|
}
|
||||||
,get: function ()
|
,get: function() {
|
||||||
{
|
|
||||||
return this._filter;
|
return this._filter;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -408,127 +355,112 @@ Vn.Filter = new Class
|
||||||
,_valueColumnIndex: 0
|
,_valueColumnIndex: 0
|
||||||
,_showColumnIndex: 1
|
,_showColumnIndex: 1
|
||||||
|
|
||||||
,initialize: function (props)
|
,initialize: function(props) {
|
||||||
{
|
var node = this.createRoot('div');
|
||||||
var node = this.createRoot ('div');
|
|
||||||
node.className = 'vn-filter';
|
node.className = 'vn-filter';
|
||||||
|
|
||||||
this._select = new Htk.Select ();
|
this._select = new Htk.Select();
|
||||||
this._select.on ('mousedown', this._onMouseDown, this);
|
this._select.on('mousedown', this._onMouseDown, this);
|
||||||
this._select.on ('changed', this._onChange, this);
|
this._select.on('changed', this._onChange, this);
|
||||||
this._select.on ('ready', this._onReady, this);
|
this._select.on('ready', this._onReady, this);
|
||||||
this.node.appendChild (this._select.node);
|
this.node.appendChild(this._select.node);
|
||||||
|
|
||||||
this._ul = this.createElement ('ul');
|
this._ul = this.createElement('ul');
|
||||||
this.node.appendChild (this._ul);
|
this.node.appendChild(this._ul);
|
||||||
|
|
||||||
this._batch = new Sql.Batch ();
|
this._batch = new Sql.Batch();
|
||||||
this.parent (props);
|
this.parent(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onMouseDown: function ()
|
,_onMouseDown: function() {
|
||||||
{
|
|
||||||
if (this._model && this._model.status === Db.Model.Status.CLEAN)
|
if (this._model && this._model.status === Db.Model.Status.CLEAN)
|
||||||
this._model.refresh ();
|
this._model.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onCloseClick: function ()
|
,_onCloseClick: function() {
|
||||||
{
|
this._removeSelectionNode();
|
||||||
this._removeSelectionNode ();
|
this._changeValue(undefined);
|
||||||
this._changeValue (undefined);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,_removeSelectionNode: function ()
|
,_removeSelectionNode: function() {
|
||||||
{
|
if (this._lastLi) {
|
||||||
if (this._lastLi)
|
Vn.Node.remove(this._lastLi);
|
||||||
{
|
|
||||||
Vn.Node.remove (this._lastLi);
|
|
||||||
this._lastLi = null;
|
this._lastLi = null;
|
||||||
this._label = null;
|
this._label = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onChange: function ()
|
,_onChange: function() {
|
||||||
{
|
|
||||||
if (this._select.value === null
|
if (this._select.value === null
|
||||||
|| this._select.value === undefined)
|
|| this._select.value === undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._realSetValue (this._select.value);
|
this._realSetValue(this._select.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onReady: function ()
|
,_onReady: function() {
|
||||||
{
|
|
||||||
if (this._emptyLabel)
|
if (this._emptyLabel)
|
||||||
this._refreshLabel ();
|
this._refreshLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
,_changeValue: function (newValue)
|
,_changeValue: function(newValue) {
|
||||||
{
|
this._batch.block();
|
||||||
this._batch.block ();
|
|
||||||
this.value = newValue;
|
this.value = newValue;
|
||||||
this._batch.unblock ();
|
this._batch.unblock();
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onTimeout: function ()
|
,_onTimeout: function() {
|
||||||
{
|
|
||||||
this._select.value = null;
|
this._select.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
,putValue: function (value)
|
,putValue: function(value) {
|
||||||
{
|
this._onMouseDown();
|
||||||
this._onMouseDown ();
|
this._realSetValue(value);
|
||||||
this._realSetValue (value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,_realSetValue: function (value)
|
,_realSetValue: function(value) {
|
||||||
{
|
this._removeSelectionNode();
|
||||||
this._removeSelectionNode ();
|
|
||||||
|
|
||||||
if (value === null || value === undefined)
|
if (value === null || value === undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var li = this._lastLi = this.createElement ('li');
|
var li = this._lastLi = this.createElement('li');
|
||||||
this._ul.appendChild (li);
|
this._ul.appendChild(li);
|
||||||
|
|
||||||
var button = this.createElement ('button');
|
var button = this.createElement('button');
|
||||||
button.addEventListener ('click',
|
button.addEventListener('click',
|
||||||
this._onCloseClick.bind (this, li));
|
this._onCloseClick.bind(this, li));
|
||||||
li.appendChild (button);
|
li.appendChild(button);
|
||||||
|
|
||||||
var icon = new Htk.Icon ({
|
var icon = new Htk.Icon({
|
||||||
icon: 'close',
|
icon: 'close',
|
||||||
alt: _('Close')
|
alt: _('Close')
|
||||||
});
|
});
|
||||||
button.appendChild (icon.node);
|
button.appendChild(icon.node);
|
||||||
|
|
||||||
var text = this._label = this.createTextNode ('');
|
var text = this._label = this.createTextNode('');
|
||||||
li.appendChild (text);
|
li.appendChild(text);
|
||||||
|
|
||||||
setTimeout (this._onTimeout.bind (this));
|
setTimeout(this._onTimeout.bind(this));
|
||||||
|
|
||||||
this._changeValue (value);
|
this._changeValue(value);
|
||||||
this._refreshLabel ();
|
this._refreshLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
,_refreshLabel: function ()
|
,_refreshLabel: function() {
|
||||||
{
|
|
||||||
if (!this._label)
|
if (!this._label)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var row = -1;
|
var row = -1;
|
||||||
|
|
||||||
if (this._model.ready)
|
if (this._model.ready)
|
||||||
row = this._model.searchByIndex (this._valueColumnIndex, this._value);
|
row = this._model.searchByIndex(this._valueColumnIndex, this._value);
|
||||||
|
|
||||||
if (row != -1)
|
if (row != -1) {
|
||||||
{
|
var label = this._model.getByIndex(row, this._showColumnIndex);
|
||||||
var label = this._model.getByIndex (row, this._showColumnIndex);
|
|
||||||
this._label.nodeValue = label;
|
this._label.nodeValue = label;
|
||||||
this._emptyLabel = false;
|
this._emptyLabel = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
this._emptyLabel = true;
|
this._emptyLabel = true;
|
||||||
this._label.nodeValue = _('Loading...');
|
this._label.nodeValue = _('Loading...');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
Hedera.Checkout = new Class ({
|
Hedera.Checkout = new Class({
|
||||||
Extends: Hedera.Form,
|
Extends: Hedera.Form,
|
||||||
|
|
||||||
activate: function() {
|
activate: function() {
|
||||||
|
@ -59,7 +59,7 @@ Hedera.Checkout = new Class ({
|
||||||
onConfirmClick: function() {
|
onConfirmClick: function() {
|
||||||
this.disableButtons(true);
|
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();
|
var batch = new Sql.Batch();
|
||||||
batch.addParam('method', this.$('method'));
|
batch.addParam('method', this.$('method'));
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<vn-group>
|
<vn-group>
|
||||||
<db-form id="order-form" on-ready="onOrderReady">
|
<db-form id="order-form" on-ready="onOrderReady">
|
||||||
<db-model property="model" result-index="1">
|
<db-model property="model" result-index="1">
|
||||||
CALL basketGetTax;
|
CALL myBasket_getTax;
|
||||||
SELECT o.id, o.sent, o.notes, o.companyFk,
|
SELECT o.id, o.sent, o.notes, o.companyFk,
|
||||||
ag.description agency, v.code method,
|
ag.description agency, v.code method,
|
||||||
ad.nickname, ad.postalCode, ad.city, ad.street,
|
ad.nickname, ad.postalCode, ad.city, ad.street,
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
</db-model>
|
</db-model>
|
||||||
</db-form>
|
</db-form>
|
||||||
<db-query id="confirm-query" on-ready="onConfirm">
|
<db-query id="confirm-query" on-ready="onConfirm">
|
||||||
CALL basketConfirm
|
CALL myBasket_confirm
|
||||||
</db-query>
|
</db-query>
|
||||||
</vn-group>
|
</vn-group>
|
||||||
<div id="title">
|
<div id="title">
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<htk-repeater form-id="iter" renderer="repeaterFunc">
|
<htk-repeater form-id="iter" renderer="repeaterFunc">
|
||||||
<db-model property="model" id="tickets">
|
<db-model property="model" id="tickets">
|
||||||
<custom>
|
<custom>
|
||||||
CALL myTicketList (NULL, NULL);
|
CALL myTicket_list (NULL, NULL);
|
||||||
</custom>
|
</custom>
|
||||||
</db-model>
|
</db-model>
|
||||||
<custom>
|
<custom>
|
||||||
|
|
|
@ -8,7 +8,7 @@ Hedera.Ticket = new Class({
|
||||||
|
|
||||||
var batch = new Sql.Batch();
|
var batch = new Sql.Batch();
|
||||||
batch.addValue('ticket', ticket.value);
|
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) {
|
onTicketReady: function(form) {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</sql-batch>
|
</sql-batch>
|
||||||
<db-form id="ticket" on-ready="onTicketReady">
|
<db-form id="ticket" on-ready="onTicketReady">
|
||||||
<db-model id="ticket-data" property="model" batch="batch">
|
<db-model id="ticket-data" property="model" batch="batch">
|
||||||
CALL myTicketGet (#ticket)
|
CALL myTicket_get (#ticket)
|
||||||
</db-model>
|
</db-model>
|
||||||
</db-form>
|
</db-form>
|
||||||
</vn-group>
|
</vn-group>
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
property="model"
|
property="model"
|
||||||
id="movements"
|
id="movements"
|
||||||
batch="batch">
|
batch="batch">
|
||||||
CALL myTicketGetRows (#ticket)
|
CALL myTicket_getRows (#ticket)
|
||||||
</db-model>
|
</db-model>
|
||||||
<custom>
|
<custom>
|
||||||
<div class="line">
|
<div class="line">
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
property="model"
|
property="model"
|
||||||
on-status-changed="onPackagesChanged"
|
on-status-changed="onPackagesChanged"
|
||||||
batch="batch">
|
batch="batch">
|
||||||
CALL myTicketGetPackages (#ticket)
|
CALL myTicket_getPackages (#ticket)
|
||||||
</db-model>
|
</db-model>
|
||||||
<custom>
|
<custom>
|
||||||
<div class="line">
|
<div class="line">
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
|
|
||||||
module.exports =
|
module.exports = {
|
||||||
{
|
check: function(conn, callback) {
|
||||||
check: function (conn, callback)
|
conn.execQuery('CALL myBasket_check',
|
||||||
{
|
this._onBasketCheck.bind(this, callback));
|
||||||
conn.execQuery ('CALL basketCheck',
|
},
|
||||||
this._onBasketCheck.bind (this, callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
,_onBasketCheck: function (callback, resultSet)
|
_onBasketCheck: function(callback, resultSet) {
|
||||||
{
|
var status = resultSet.fetchValue();
|
||||||
var status = resultSet.fetchValue ();
|
|
||||||
|
|
||||||
if (!status)
|
if (!status)
|
||||||
return;
|
return;
|
||||||
|
@ -17,11 +14,11 @@ module.exports =
|
||||||
var isOk = status == 'UPDATED' || status == 'OK';
|
var isOk = status == 'UPDATED' || status == 'OK';
|
||||||
|
|
||||||
if (status == 'UPDATED')
|
if (status == 'UPDATED')
|
||||||
Htk.Toast.showWarning (_('Order items updated'));
|
Htk.Toast.showWarning(_('Order items updated'));
|
||||||
if (callback)
|
if (callback)
|
||||||
callback (isOk);
|
callback(isOk);
|
||||||
if (!isOk)
|
if (!isOk)
|
||||||
Vn.Hash.set ({'form': 'ecomerce/checkout'});
|
Vn.Hash.set({form: 'ecomerce/checkout'});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = new Class
|
||||||
batch.addValue('transaction', this.tpvOrder);
|
batch.addValue('transaction', this.tpvOrder);
|
||||||
batch.addValue('status', this.tpvStatus);
|
batch.addValue('status', this.tpvStatus);
|
||||||
|
|
||||||
var query = 'CALL tpvTransactionEnd (#transaction, #status)';
|
var query = 'CALL myTpvTransaction_end(#transaction, #status)';
|
||||||
this.conn.execQuery(query, null, batch);
|
this.conn.execQuery(query, null, batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hedera-web",
|
"name": "hedera-web",
|
||||||
"version": "1.406.46",
|
"version": "1.406.47",
|
||||||
"description": "Verdnatura web page",
|
"description": "Verdnatura web page",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<vn-group>
|
<vn-group>
|
||||||
<db-form id="ticket" on-ready="onTicketReady">
|
<db-form id="ticket" on-ready="onTicketReady">
|
||||||
<db-model property="model" id="ticket-data" conn="conn" batch="batch">
|
<db-model property="model" id="ticket-data" conn="conn" batch="batch">
|
||||||
CALL myTicketGet (#ticket)
|
CALL myTicket_get (#ticket)
|
||||||
</db-model>
|
</db-model>
|
||||||
</db-form>
|
</db-form>
|
||||||
</vn-group>
|
</vn-group>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
</div>
|
</div>
|
||||||
<htk-grid>
|
<htk-grid>
|
||||||
<db-model property="model" id="movements" conn="conn" batch="batch">
|
<db-model property="model" id="movements" conn="conn" batch="batch">
|
||||||
CALL myTicketGetRows (#ticket)
|
CALL myTicket_getRows (#ticket)
|
||||||
</db-model>
|
</db-model>
|
||||||
<htk-column-spin title="_Ref" column="itemFk"/>
|
<htk-column-spin title="_Ref" column="itemFk"/>
|
||||||
<htk-column-spin title="_Amount" column="quantity"/>
|
<htk-column-spin title="_Amount" column="quantity"/>
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
conn="conn"
|
conn="conn"
|
||||||
batch="batch"
|
batch="batch"
|
||||||
on-status-changed="onPackagesChanged">
|
on-status-changed="onPackagesChanged">
|
||||||
CALL myTicketGetPackages (#ticket)
|
CALL myTicket_getPackages (#ticket)
|
||||||
</db-model>
|
</db-model>
|
||||||
<htk-column-spin title="_Ref" column="id"/>
|
<htk-column-spin title="_Ref" column="id"/>
|
||||||
<htk-column-spin title="_Amount" column="quantity"/>
|
<htk-column-spin title="_Amount" column="quantity"/>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
batch="batch"
|
batch="batch"
|
||||||
conn="conn">
|
conn="conn">
|
||||||
<custom>
|
<custom>
|
||||||
CALL itemGetList(#warehouse, CURDATE(), #realm, #rate)
|
CALL item_getList(#warehouse, CURDATE(), #realm, #rate)
|
||||||
</custom>
|
</custom>
|
||||||
</db-model>
|
</db-model>
|
||||||
<htk-column-image
|
<htk-column-image
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
Hedera.ShelvesReport = new Class
|
Hedera.ShelvesReport = new Class({
|
||||||
({
|
|
||||||
Extends: Hedera.Report
|
Extends: Hedera.Report
|
||||||
|
|
||||||
,nItem: -1
|
,nItem: -1
|
||||||
|
@ -8,37 +7,35 @@ Hedera.ShelvesReport = new Class
|
||||||
,trayThickness: 2
|
,trayThickness: 2
|
||||||
,trayMargin: 5
|
,trayMargin: 5
|
||||||
|
|
||||||
,open: function (batch)
|
,open: function(batch) {
|
||||||
{
|
|
||||||
this.batch = batch;
|
this.batch = batch;
|
||||||
this.title = batch.getValue ('reportTitle');
|
this.title = batch.getValue('reportTitle');
|
||||||
this.maxAmount = batch.getValue ('maxAmount');
|
this.maxAmount = batch.getValue('maxAmount');
|
||||||
this.showPacking = batch.getValue ('showPacking');
|
this.showPacking = batch.getValue('showPacking');
|
||||||
this.stack = batch.getValue ('stack');
|
this.stack = batch.getValue('stack');
|
||||||
this.useIds = batch.getValue ('useIds');
|
this.useIds = batch.getValue('useIds');
|
||||||
|
|
||||||
var query =
|
var query =
|
||||||
'SELECT id, name, nTrays, topTrayHeight, trayHeight, width, depth '+
|
'SELECT id, name, nTrays, topTrayHeight, trayHeight, width, depth '+
|
||||||
'FROM shelf WHERE id = #shelf; '+
|
'FROM shelf WHERE id = #shelf; '+
|
||||||
'CALL itemAllocator (#warehouse, #date, #family, #namePrefix, #useIds)';
|
'CALL item_listAllocation(#warehouse, #date, #family, #namePrefix, #useIds)';
|
||||||
|
|
||||||
this.conn.execQuery (query, this.onQueryExec.bind (this), this.batch);
|
this.conn.execQuery(query, this.onQueryExec.bind(this), this.batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
,onQueryExec: function (resultSet)
|
,onQueryExec: function(resultSet) {
|
||||||
{
|
|
||||||
// Fetch query data
|
// Fetch query data
|
||||||
|
|
||||||
var res = resultSet.fetchResult ();
|
var res = resultSet.fetchResult();
|
||||||
res.next ();
|
res.next();
|
||||||
|
|
||||||
// Calculates the scale
|
// Calculates the scale
|
||||||
|
|
||||||
var maxWidth = 160;
|
var maxWidth = 160;
|
||||||
var maxHeight = 160;
|
var maxHeight = 160;
|
||||||
|
|
||||||
var shelfWidth = res.get ('width');
|
var shelfWidth = res.get('width');
|
||||||
var shelfHeight = res.get ('trayHeight') * (res.get ('nTrays') - 1) + res.get ('topTrayHeight');
|
var shelfHeight = res.get('trayHeight') * (res.get('nTrays') - 1) + res.get('topTrayHeight');
|
||||||
|
|
||||||
var scale = maxWidth / shelfWidth;
|
var scale = maxWidth / shelfWidth;
|
||||||
|
|
||||||
|
@ -49,56 +46,52 @@ Hedera.ShelvesReport = new Class
|
||||||
|
|
||||||
var shelf = this.shelf =
|
var shelf = this.shelf =
|
||||||
{
|
{
|
||||||
nTrays: res.get ('nTrays')
|
nTrays: res.get('nTrays')
|
||||||
,trayHeight: res.get ('trayHeight') * scale
|
,trayHeight: res.get('trayHeight') * scale
|
||||||
,topTrayHeight: res.get ('topTrayHeight') * scale
|
,topTrayHeight: res.get('topTrayHeight') * scale
|
||||||
,width: res.get ('width') * scale
|
,width: res.get('width') * scale
|
||||||
,depth: res.get ('depth') * scale
|
,depth: res.get('depth') * scale
|
||||||
};
|
};
|
||||||
|
|
||||||
// Gets the items
|
// Gets the items
|
||||||
|
|
||||||
var items = this.items = [];
|
var items = this.items = [];
|
||||||
var remainings = this.remainings = [];
|
var remainings = this.remainings = [];
|
||||||
var res = resultSet.fetchResult ();
|
var res = resultSet.fetchResult();
|
||||||
|
|
||||||
if (res.data.length == 0)
|
if (res.data.length == 0) {
|
||||||
{
|
Htk.Toast.showError(_('No items found, check that all fields are correct'));
|
||||||
Htk.Toast.showError (_('No items found, check that all fields are correct'));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var boxScale = scale * 10;
|
var boxScale = scale * 10;
|
||||||
|
|
||||||
while (res.next ())
|
while (res.next())
|
||||||
if (!this.maxAmount || res.get ('etiquetas') <= this.maxAmount)
|
if (!this.maxAmount || res.get('etiquetas') <= this.maxAmount) {
|
||||||
{
|
items.push({
|
||||||
items.push ({
|
id: res.get('Id_Article')
|
||||||
id: res.get ('Id_Article')
|
,name: res.get('Article')
|
||||||
,name: res.get ('Article')
|
,packing: res.get('packing')
|
||||||
,packing: res.get ('packing')
|
,amount: res.get('etiquetas')
|
||||||
,amount: res.get ('etiquetas')
|
,boxHeight: res.get('z') * boxScale
|
||||||
,boxHeight: res.get ('z') * boxScale
|
,boxWidth: res.get('x') * boxScale
|
||||||
,boxWidth: res.get ('x') * boxScale
|
,boxDepth: res.get('y') * boxScale
|
||||||
,boxDepth: res.get ('y') * boxScale
|
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else
|
remainings.push({
|
||||||
{
|
id: res.get('Id_Article')
|
||||||
remainings.push ({
|
,name: res.get('Article')
|
||||||
id: res.get ('Id_Article')
|
,packing: res.get('packing')
|
||||||
,name: res.get ('Article')
|
,amount: res.get('etiquetas')
|
||||||
,packing: res.get ('packing')
|
|
||||||
,amount: res.get ('etiquetas')
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Intializes the allocator
|
// Intializes the allocator
|
||||||
|
|
||||||
alloc = this.alloc = new Vn.Allocator ();
|
alloc = this.alloc = new Vn.Allocator();
|
||||||
alloc.items = items;
|
alloc.items = items;
|
||||||
alloc.shelfFunc = this.drawShelf.bind (this);
|
alloc.shelfFunc = this.drawShelf.bind(this);
|
||||||
alloc.boxFunc = this.drawBox.bind (this);
|
alloc.boxFunc = this.drawBox.bind(this);
|
||||||
alloc.stack = this.stack;
|
alloc.stack = this.stack;
|
||||||
alloc.nTrays = shelf.nTrays;
|
alloc.nTrays = shelf.nTrays;
|
||||||
alloc.width = shelf.width;
|
alloc.width = shelf.width;
|
||||||
|
@ -108,92 +101,88 @@ Hedera.ShelvesReport = new Class
|
||||||
|
|
||||||
// Opens the report
|
// Opens the report
|
||||||
|
|
||||||
this.createWindow ();
|
this.createWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
,onWindowCreate: function ()
|
,onWindowCreate: function() {
|
||||||
{
|
|
||||||
// Remaining amount
|
// Remaining amount
|
||||||
|
|
||||||
var remainings = this.remainings;
|
var remainings = this.remainings;
|
||||||
|
|
||||||
if (remainings.length > 0)
|
if (remainings.length > 0) {
|
||||||
{
|
var sheet = this.doc.createElement('div');
|
||||||
var sheet = this.doc.createElement ('div');
|
|
||||||
sheet.className = 'sheet';
|
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.className = 'title';
|
||||||
title.appendChild (this.doc.createTextNode (this.title));
|
title.appendChild(this.doc.createTextNode(this.title));
|
||||||
sheet.appendChild (title);
|
sheet.appendChild(title);
|
||||||
|
|
||||||
var subtitle = this.doc.createElement ('h2');
|
var subtitle = this.doc.createElement('h2');
|
||||||
subtitle.className = 'subtitle';
|
subtitle.className = 'subtitle';
|
||||||
subtitle.appendChild (this.doc.createTextNode (_('Pallets')));
|
subtitle.appendChild(this.doc.createTextNode(_('Pallets')));
|
||||||
sheet.appendChild (subtitle);
|
sheet.appendChild(subtitle);
|
||||||
|
|
||||||
var ul = this.doc.createElement ('ul');
|
var ul = this.doc.createElement('ul');
|
||||||
sheet.appendChild (ul);
|
sheet.appendChild(ul);
|
||||||
|
|
||||||
for (var i = 0; i < remainings.length; i++)
|
for (var i = 0; i < remainings.length; i++) {
|
||||||
{
|
var li = this.doc.createElement('li');
|
||||||
var li = this.doc.createElement ('li');
|
ul.appendChild(li);
|
||||||
ul.appendChild (li);
|
|
||||||
|
|
||||||
var span = this.doc.createElement ('span');
|
var span = this.doc.createElement('span');
|
||||||
span.className = 'item-id';
|
span.className = 'item-id';
|
||||||
span.appendChild (this.doc.createTextNode (remainings[i].id.toLocaleString ()));
|
span.appendChild(this.doc.createTextNode(remainings[i].id.toLocaleString()));
|
||||||
li.appendChild (span);
|
li.appendChild(span);
|
||||||
|
|
||||||
var span = this.doc.createElement ('span');
|
var span = this.doc.createElement('span');
|
||||||
span.className = 'item';
|
span.className = 'item';
|
||||||
span.appendChild (this.doc.createTextNode (remainings[i].name));
|
span.appendChild(this.doc.createTextNode(remainings[i].name));
|
||||||
li.appendChild (span);
|
li.appendChild(span);
|
||||||
|
|
||||||
if (this.showPacking)
|
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.className = 'amount';
|
||||||
span.appendChild (this.doc.createTextNode (remainings[i].amount));
|
span.appendChild(this.doc.createTextNode(remainings[i].amount));
|
||||||
li.appendChild (span);
|
li.appendChild(span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draws the shelves
|
// Draws the shelves
|
||||||
|
|
||||||
this.alloc.run ();
|
this.alloc.run();
|
||||||
this.drawShelfRange (this.lastItem, false);
|
this.drawShelfRange(this.lastItem, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
,drawShelf: function (allocator, item)
|
,drawShelf: function(allocator, item) {
|
||||||
{
|
|
||||||
var shelf = this.shelf;
|
var shelf = this.shelf;
|
||||||
|
|
||||||
var sheet = this.doc.createElement ('div');
|
var sheet = this.doc.createElement('div');
|
||||||
sheet.className = 'sheet';
|
sheet.className = 'sheet';
|
||||||
this.doc.body.appendChild (sheet);
|
this.doc.body.appendChild(sheet);
|
||||||
|
|
||||||
// Draws the title
|
// Draws the title
|
||||||
|
|
||||||
var pageNumber = this.doc.createElement ('h1');
|
var pageNumber = this.doc.createElement('h1');
|
||||||
pageNumber.className = 'page-number';
|
pageNumber.className = 'page-number';
|
||||||
pageNumber.appendChild (this.doc.createTextNode (allocator.currentShelf + 1));
|
pageNumber.appendChild(this.doc.createTextNode(allocator.currentShelf + 1));
|
||||||
sheet.appendChild (pageNumber);
|
sheet.appendChild(pageNumber);
|
||||||
|
|
||||||
var title = this.doc.createElement ('h1');
|
var title = this.doc.createElement('h1');
|
||||||
title.className = 'title';
|
title.className = 'title';
|
||||||
title.appendChild (this.doc.createTextNode (this.title));
|
title.appendChild(this.doc.createTextNode(this.title));
|
||||||
sheet.appendChild (title);
|
sheet.appendChild(title);
|
||||||
|
|
||||||
if (this.subtitles)
|
if (this.subtitles)
|
||||||
this.drawShelfRange (this.lastItem, false);
|
this.drawShelfRange(this.lastItem, false);
|
||||||
|
|
||||||
this.subtitles = this.doc.createElement ('div');
|
this.subtitles = this.doc.createElement('div');
|
||||||
sheet.appendChild (this.subtitles);
|
sheet.appendChild(this.subtitles);
|
||||||
|
|
||||||
this.drawShelfRange (item, true);
|
this.drawShelfRange(item, true);
|
||||||
this.lastSubtitles = this.subtitles;
|
this.lastSubtitles = this.subtitles;
|
||||||
|
|
||||||
// Draws the shelf
|
// Draws the shelf
|
||||||
|
@ -202,58 +191,51 @@ Hedera.ShelvesReport = new Class
|
||||||
var shelfHeight = shelf.trayHeight * (shelf.nTrays - 1) + shelf.topTrayHeight
|
var shelfHeight = shelf.trayHeight * (shelf.nTrays - 1) + shelf.topTrayHeight
|
||||||
+ (this.trayThickness + this.trayMargin) * shelf.nTrays;
|
+ (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.className = 'shelf';
|
||||||
shelfDiv.style.width = this.mm (trayWidth);
|
shelfDiv.style.width = this.mm(trayWidth);
|
||||||
shelfDiv.style.height = this.mm (shelfHeight);
|
shelfDiv.style.height = this.mm(shelfHeight);
|
||||||
sheet.appendChild (shelfDiv);
|
sheet.appendChild(shelfDiv);
|
||||||
|
|
||||||
// Draws trays
|
// Draws trays
|
||||||
|
|
||||||
for (var i = 0; i < shelf.nTrays; i++)
|
for (var i = 0; i < shelf.nTrays; i++) {
|
||||||
{
|
var tray = this.doc.createElement('div');
|
||||||
var tray = this.doc.createElement ('div');
|
|
||||||
tray.className = 'tray';
|
tray.className = 'tray';
|
||||||
tray.style.bottom = this.mm ((shelf.trayHeight + this.trayThickness + this.trayMargin) * i);
|
tray.style.bottom = this.mm((shelf.trayHeight + this.trayThickness + this.trayMargin) * i);
|
||||||
tray.style.width = this.mm (trayWidth);
|
tray.style.width = this.mm(trayWidth);
|
||||||
tray.style.height = this.mm (this.trayThickness);
|
tray.style.height = this.mm(this.trayThickness);
|
||||||
shelfDiv.appendChild (tray);
|
shelfDiv.appendChild(tray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
,drawShelfRange: function (item, isFirst)
|
,drawShelfRange: function(item, isFirst) {
|
||||||
{
|
|
||||||
var labelText = isFirst ? _('Start') : _('End');
|
var labelText = isFirst ? _('Start') : _('End');
|
||||||
|
|
||||||
var label = this.doc.createElement ('label');
|
var label = this.doc.createElement('label');
|
||||||
label.className = 'range-label';
|
label.className = 'range-label';
|
||||||
label.appendChild (this.doc.createTextNode (labelText));
|
label.appendChild(this.doc.createTextNode(labelText));
|
||||||
this.subtitles.appendChild (label);
|
this.subtitles.appendChild(label);
|
||||||
|
|
||||||
var subtitle = this.doc.createElement ('h2');
|
var subtitle = this.doc.createElement('h2');
|
||||||
subtitle.className = 'subtitle';
|
subtitle.className = 'subtitle';
|
||||||
subtitle.appendChild (this.doc.createTextNode (this.getItemLabel (item)));
|
subtitle.appendChild(this.doc.createTextNode(this.getItemLabel(item)));
|
||||||
this.subtitles.appendChild (subtitle);
|
this.subtitles.appendChild(subtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
,getItemLabel: function (item)
|
,getItemLabel: function(item) {
|
||||||
{
|
if (!this.useIds) {
|
||||||
if (!this.useIds)
|
|
||||||
{
|
|
||||||
var packing = this.showPacking ? (' x'+ item.packing) : '';
|
var packing = this.showPacking ? (' x'+ item.packing) : '';
|
||||||
return item.name + packing;
|
return item.name + packing;
|
||||||
}
|
} else
|
||||||
else
|
return item.id.toLocaleString();
|
||||||
return item.id.toLocaleString ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,mm: function (size)
|
,mm: function(size) {
|
||||||
{
|
return size.toFixed(2) +'mm';
|
||||||
return size.toFixed (2) +'mm';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,drawBox: function (allocator, item, amount)
|
,drawBox: function(allocator, item, amount) {
|
||||||
{
|
|
||||||
if (item.boxWidth == 0 || item.boxHeight == 0)
|
if (item.boxWidth == 0 || item.boxHeight == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -264,80 +246,71 @@ Hedera.ShelvesReport = new Class
|
||||||
+ this.trayMargin * allocator.currentTray
|
+ this.trayMargin * allocator.currentTray
|
||||||
+ allocator.currentTray * (shelf.trayHeight + this.trayThickness);
|
+ allocator.currentTray * (shelf.trayHeight + this.trayThickness);
|
||||||
|
|
||||||
var box = this.doc.createElement ('div');
|
var box = this.doc.createElement('div');
|
||||||
box.className = 'box';
|
box.className = 'box';
|
||||||
this.shelfDiv.appendChild (box);
|
this.shelfDiv.appendChild(box);
|
||||||
|
|
||||||
box.style.left = this.mm (x);
|
box.style.left = this.mm(x);
|
||||||
box.style.bottom = this.mm (y);
|
box.style.bottom = this.mm(y);
|
||||||
box.style.width = this.mm (item.boxWidth);
|
box.style.width = this.mm(item.boxWidth);
|
||||||
box.style.height = this.mm (item.boxHeight);
|
box.style.height = this.mm(item.boxHeight);
|
||||||
|
|
||||||
if (amount == 0)
|
if (amount == 0)
|
||||||
this.nItem++;
|
this.nItem++;
|
||||||
|
|
||||||
var nColor = this.nItem % this.nColors;
|
var nColor = this.nItem % this.nColors;
|
||||||
Vn.Node.addClass (box, 'color'+ nColor);
|
Vn.Node.addClass(box, 'color'+ nColor);
|
||||||
|
|
||||||
if (amount == 0 || allocator.firstShelfBox)
|
if (amount == 0 || allocator.firstShelfBox) {
|
||||||
{
|
var boxLabel = this.doc.createElement('div');
|
||||||
var boxLabel = this.doc.createElement ('div');
|
|
||||||
|
|
||||||
if (this.useIds)
|
if (this.useIds) {
|
||||||
{
|
|
||||||
var fontSize = item.boxWidth / 5.2;
|
var fontSize = item.boxWidth / 5.2;
|
||||||
|
|
||||||
if (fontSize > item.boxHeight - 1)
|
if (fontSize > item.boxHeight - 1)
|
||||||
fontSize = item.boxHeight - 1;
|
fontSize = item.boxHeight - 1;
|
||||||
|
|
||||||
boxLabel.style.fontSize = this.mm (fontSize);
|
boxLabel.style.fontSize = this.mm(fontSize);
|
||||||
|
|
||||||
var cssClass = 'id';
|
var cssClass = 'id';
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
var cssClass = 'name';
|
var cssClass = 'name';
|
||||||
|
|
||||||
boxLabel.className = 'box-label '+ cssClass;
|
boxLabel.className = 'box-label '+ cssClass;
|
||||||
|
|
||||||
var labelText = this.doc.createTextNode (this.getItemLabel (item));
|
var labelText = this.doc.createTextNode(this.getItemLabel(item));
|
||||||
boxLabel.appendChild (labelText);
|
boxLabel.appendChild(labelText);
|
||||||
|
|
||||||
box.appendChild (boxLabel);
|
box.appendChild(boxLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastItem = item;
|
this.lastItem = item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Vn.Allocator = new Class
|
Vn.Allocator = new Class({
|
||||||
({
|
addShelf: function(item) {
|
||||||
addShelf: function (item)
|
|
||||||
{
|
|
||||||
this.currentShelf++;
|
this.currentShelf++;
|
||||||
this.firstShelfBox = true;
|
this.firstShelfBox = true;
|
||||||
|
|
||||||
if (this.shelfFunc)
|
if (this.shelfFunc)
|
||||||
this.shelfFunc (this, item);
|
this.shelfFunc(this, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
,addTray: function (item)
|
,addTray: function(item) {
|
||||||
{
|
if (this.currentTray <= 0) {
|
||||||
if (this.currentTray <= 0)
|
this.addShelf(item);
|
||||||
{
|
|
||||||
this.addShelf (item);
|
|
||||||
this.currentTray = this.nTrays - 1;
|
this.currentTray = this.nTrays - 1;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
this.currentTray--;
|
this.currentTray--;
|
||||||
|
|
||||||
this.trayX = 0;
|
this.trayX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
,addColumn: function (item)
|
,addColumn: function(item) {
|
||||||
{
|
|
||||||
if (this.trayX + this.columnWidth + item.boxWidth > this.width
|
if (this.trayX + this.columnWidth + item.boxWidth > this.width
|
||||||
|| this.currentTray == -1)
|
|| this.currentTray == -1)
|
||||||
this.addTray (item);
|
this.addTray(item);
|
||||||
else
|
else
|
||||||
this.trayX += this.columnWidth;
|
this.trayX += this.columnWidth;
|
||||||
|
|
||||||
|
@ -346,8 +319,7 @@ Vn.Allocator = new Class
|
||||||
this.lastBoxWidth = item.boxWidth;
|
this.lastBoxWidth = item.boxWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
,addBox: function (item, amount)
|
,addBox: function(item, amount) {
|
||||||
{
|
|
||||||
var trayHeight = this.trayHeight;
|
var trayHeight = this.trayHeight;
|
||||||
|
|
||||||
if (this.currentTray == this.nTrays - 1)
|
if (this.currentTray == this.nTrays - 1)
|
||||||
|
@ -356,10 +328,10 @@ Vn.Allocator = new Class
|
||||||
if (this.trayY + item.boxHeight > trayHeight
|
if (this.trayY + item.boxHeight > trayHeight
|
||||||
|| item.boxWidth > this.lastBoxWidth
|
|| item.boxWidth > this.lastBoxWidth
|
||||||
|| (!this.stack && amount == 0))
|
|| (!this.stack && amount == 0))
|
||||||
this.addColumn (item);
|
this.addColumn(item);
|
||||||
|
|
||||||
if (this.boxFunc)
|
if (this.boxFunc)
|
||||||
this.boxFunc (this, item, amount);
|
this.boxFunc(this, item, amount);
|
||||||
|
|
||||||
this.trayY += item.boxHeight;
|
this.trayY += item.boxHeight;
|
||||||
|
|
||||||
|
@ -367,8 +339,7 @@ Vn.Allocator = new Class
|
||||||
this.lastBoxWidth = item.boxWidth;
|
this.lastBoxWidth = item.boxWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
,run: function ()
|
,run: function() {
|
||||||
{
|
|
||||||
this.firstShelfBox = false;
|
this.firstShelfBox = false;
|
||||||
this.currentShelf = -1;
|
this.currentShelf = -1;
|
||||||
this.currentTray = -1;
|
this.currentTray = -1;
|
||||||
|
@ -378,22 +349,19 @@ Vn.Allocator = new Class
|
||||||
this.trayY = 0;
|
this.trayY = 0;
|
||||||
this.remaining = false;
|
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 item = this.items[i];
|
||||||
var boxIncrement = Math.floor (this.depth / item.boxDepth);
|
var boxIncrement = Math.floor(this.depth / item.boxDepth);
|
||||||
|
|
||||||
if (boxIncrement < 1)
|
if (boxIncrement < 1)
|
||||||
boxIncrement = 1;
|
boxIncrement = 1;
|
||||||
|
|
||||||
for (var amount = 0; amount < item.amount; amount += boxIncrement)
|
for (var amount = 0; amount < item.amount; amount += boxIncrement) {
|
||||||
{
|
this.addBox(item, amount);
|
||||||
this.addBox (item, amount);
|
|
||||||
this.firstShelfBox = false;
|
this.firstShelfBox = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.currentShelf + 1;
|
return this.currentShelf + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Tpv {
|
||||||
$error = NULL;
|
$error = NULL;
|
||||||
|
|
||||||
return $db->query(
|
return $db->query(
|
||||||
'CALL tpvTransactionConfirm(#, #, #, #, #, #)',
|
'CALL tpvTransaction_confirm(#, #, #, #, #, #)',
|
||||||
[
|
[
|
||||||
$params['Ds_Amount']
|
$params['Ds_Amount']
|
||||||
,$params['Ds_Order']
|
,$params['Ds_Order']
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Transaction extends Vn\Web\JsonRequest {
|
||||||
$amount =(int) $_REQUEST['amount'];
|
$amount =(int) $_REQUEST['amount'];
|
||||||
$companyId = empty($_REQUEST['company']) ? NULL : $_REQUEST['company'];
|
$companyId = empty($_REQUEST['company']) ? NULL : $_REQUEST['company'];
|
||||||
|
|
||||||
$row = $db->getObject('CALL tpvTransactionStart(#, #)',
|
$row = $db->getObject('CALL myTpvTransaction_start(#, #)',
|
||||||
[$amount, $companyId]);
|
[$amount, $companyId]);
|
||||||
|
|
||||||
if (!isset($row))
|
if (!isset($row))
|
||||||
|
|
|
@ -97,7 +97,7 @@ abstract class Service {
|
||||||
$ip = ip2long($_SERVER['REMOTE_ADDR']);
|
$ip = ip2long($_SERVER['REMOTE_ADDR']);
|
||||||
|
|
||||||
$row = $db->getRow(
|
$row = $db->getRow(
|
||||||
'CALL visitRegister(#, #, #, #, #, #, #, #, #)',
|
'CALL visit_register(#, #, #, #, #, #, #, #, #)',
|
||||||
[
|
[
|
||||||
nullIf($_COOKIE, 'vnVisit')
|
nullIf($_COOKIE, 'vnVisit')
|
||||||
,nullIf($browser, 'platform')
|
,nullIf($browser, 'platform')
|
||||||
|
@ -191,7 +191,7 @@ abstract class Service {
|
||||||
|
|
||||||
if (isset($_SESSION['access']) && $userChanged)
|
if (isset($_SESSION['access']) && $userChanged)
|
||||||
$db->query(
|
$db->query(
|
||||||
'CALL visitUserNew(#, #)',
|
'CALL visitUser_new(#, #)',
|
||||||
[$_SESSION['access'], session_id()]
|
[$_SESSION['access'], session_id()]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue