forked from verdnatura/hedera-web
Backup
This commit is contained in:
parent
403845bf2b
commit
22ee7e5020
|
@ -5,16 +5,17 @@ Hedera.Items = new Class
|
|||
|
||||
,activate: function ()
|
||||
{
|
||||
var set = this.$('set');
|
||||
set.set ('warehouse', 7);
|
||||
set.set ('realm', null);
|
||||
this.$('lot').assign ({
|
||||
warehouse: 7,
|
||||
realm: null
|
||||
});
|
||||
}
|
||||
|
||||
,onShowClick: function ()
|
||||
{
|
||||
var set = this.$('set');
|
||||
set.set ('rate', this.$('rate').value);
|
||||
this.gui.openReport ('items-report', set.params);
|
||||
var lot = this.$('lot');
|
||||
lot.assign ({rate: this.$('rate').value});
|
||||
this.gui.openReport ('items-report', lot.params);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<vn>
|
||||
<vn-basic-set id="set"/>
|
||||
<vn-basic-set id="lot"/>
|
||||
<h1 id="title">
|
||||
<t>Item list</t>
|
||||
</h1>
|
||||
|
@ -13,23 +13,19 @@
|
|||
<div class="card form">
|
||||
<div>
|
||||
<label><t>Store</t></label>
|
||||
<htk-combo lot="set" name="warehouse">
|
||||
<htk-combo lot="lot" name="warehouse">
|
||||
<db-model property="model">
|
||||
<custom>
|
||||
SELECT id, name FROM vn2008.warehouse
|
||||
WHERE reserve ORDER BY name
|
||||
</custom>
|
||||
SELECT id, name FROM vn2008.warehouse
|
||||
WHERE reserve ORDER BY name
|
||||
</db-model>
|
||||
</htk-combo>
|
||||
</div>
|
||||
<div>
|
||||
<label><t>Realm</t></label>
|
||||
<htk-combo lot="set" name="realm" not-null="false">
|
||||
<htk-combo lot="lot" name="realm" not-null="false">
|
||||
<db-model property="model">
|
||||
<custom>
|
||||
SELECT id, reino FROM vn2008.reinos
|
||||
WHERE display != FALSE ORDER BY reino
|
||||
</custom>
|
||||
SELECT id, reino FROM vn2008.reinos
|
||||
WHERE display != FALSE ORDER BY reino
|
||||
</db-model>
|
||||
</htk-combo>
|
||||
</div>
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
id="config"
|
||||
placeholder="_Select config"
|
||||
model="configs-model"
|
||||
lot="hash"
|
||||
name="config"
|
||||
on-changed="onConfigChange"
|
||||
on-ready="onConfigChange">
|
||||
<db-model property="model" id="configs-model">
|
||||
|
@ -43,7 +45,7 @@
|
|||
<div>
|
||||
<label><t>Family</t></label>
|
||||
<htk-combo lot="lot" name="family">
|
||||
<db-model property="model" lot="config">
|
||||
<db-model property="model" lot="lot">
|
||||
SELECT tipo_id, Tipo FROM vn2008.Tipos
|
||||
WHERE reino_id = #realm ORDER BY Tipo
|
||||
</db-model>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
.balance
|
||||
{
|
||||
margin-top: 1.2em;
|
||||
margin-right: .5em;
|
||||
}
|
||||
.balance > *
|
||||
{
|
||||
|
@ -26,6 +25,7 @@
|
|||
cursor: pointer;
|
||||
height: 1.2em;
|
||||
cursor: pointer;
|
||||
margin: 0 .3em;
|
||||
}
|
||||
.balance > .negative
|
||||
{
|
||||
|
|
|
@ -26,7 +26,11 @@
|
|||
<t>Balance:</t>
|
||||
</span>
|
||||
<span class="amount" id="balance">
|
||||
<htk-text lot="debt" name="debt" format="%.2d€"/>
|
||||
<htk-text
|
||||
lot="debt"
|
||||
name="debt"
|
||||
format="%.2d€"
|
||||
conditional-func="balanceConditionalFunc"/>
|
||||
</span>
|
||||
<img
|
||||
src="image/icon/dark/info.svg"
|
||||
|
@ -44,7 +48,7 @@
|
|||
</div>
|
||||
<div class="card list">
|
||||
<htk-repeater form-id="iter" renderer="repeaterFunc">
|
||||
<db-model property="model" id="tickets" lot="hash">
|
||||
<db-model property="model" lot="hash">
|
||||
CALL clientTicketList (#from, NULL)
|
||||
</db-model>
|
||||
<custom>
|
||||
|
|
|
@ -72,7 +72,12 @@ Connection.implement
|
|||
*/
|
||||
,execQuery: function (query, callback, params)
|
||||
{
|
||||
this.execStmt (new Sql.String ({query: query}), callback, params);
|
||||
this.execSql (this.renderQuery (query, params), callback);
|
||||
}
|
||||
|
||||
,renderQuery: function (query, params)
|
||||
{
|
||||
return new Sql.String ({query: query}).render (params);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -109,8 +109,8 @@ Model.implement
|
|||
type: Vn.Lot
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_lot: x}, {'change': this._autoLoad});
|
||||
this._autoLoad ();
|
||||
this.link ({_lot: x}, {'change': this._onLotChange});
|
||||
this._onLotChange ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
|
@ -242,6 +242,7 @@ Model.implement
|
|||
,_conn: null
|
||||
,_resultIndex: 0
|
||||
,_batch: null
|
||||
,_lot: null
|
||||
,_stmt: null
|
||||
,_status: Status.CLEAN
|
||||
,data: null
|
||||
|
@ -276,7 +277,34 @@ Model.implement
|
|||
if (child.nodeType === Node.TEXT_NODE)
|
||||
this.query = child.textContent;
|
||||
}
|
||||
|
||||
|
||||
,_getParams: function ()
|
||||
{
|
||||
if (!this._stmt)
|
||||
return null;
|
||||
|
||||
var ids = this._stmt.findHolders ();
|
||||
|
||||
if (!ids)
|
||||
return null;
|
||||
|
||||
var lotParams = this._lot ? this._lot.params : {};
|
||||
var params = {};
|
||||
|
||||
for (var i = 0; i < ids.length; i++)
|
||||
params[ids[i]] = lotParams[ids[i]];
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
,_onLotChange: function ()
|
||||
{
|
||||
var params = this._getParams ();
|
||||
|
||||
if (!Vn.Value.equals (params, this._lastParams))
|
||||
this._autoLoad ();
|
||||
}
|
||||
|
||||
,_autoLoad: function ()
|
||||
{
|
||||
if (this.autoLoad)
|
||||
|
@ -285,31 +313,15 @@ Model.implement
|
|||
this.clean ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks wether the model is ready to execute its query.
|
||||
*
|
||||
* @return {Boolean} %true if its ready, %false otherwise
|
||||
*/
|
||||
,isReady: function ()
|
||||
,_isReady: function (params)
|
||||
{
|
||||
if (!this._stmt || !this._conn)
|
||||
return false;
|
||||
|
||||
var ids = this._stmt.findHolders ();
|
||||
|
||||
if (!ids)
|
||||
if (!params)
|
||||
return true;
|
||||
|
||||
if (!this._lot)
|
||||
return false;
|
||||
|
||||
var params = this._lot.params;
|
||||
|
||||
if (!params)
|
||||
return false;
|
||||
|
||||
for (var i = 0; i < ids.length; i++)
|
||||
if (params[ids[i]] === undefined)
|
||||
for (var key in params)
|
||||
if (params[key] === undefined)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -320,9 +332,11 @@ Model.implement
|
|||
*/
|
||||
,refresh: function ()
|
||||
{
|
||||
if (this.isReady ())
|
||||
var params = this._getParams ();
|
||||
|
||||
if (this._isReady (params))
|
||||
{
|
||||
var params = this._lot ? this._lot.params : null;
|
||||
this._lastParams = params;
|
||||
this._setStatus (Status.LOADING);
|
||||
this._conn.execStmt (this._stmt, this._selectDone.bind (this), params);
|
||||
}
|
||||
|
@ -396,7 +410,7 @@ Model.implement
|
|||
}
|
||||
}
|
||||
|
||||
,_cleanData: function (error)
|
||||
,_cleanData: function ()
|
||||
{
|
||||
this.data = null;
|
||||
this.tables = null;
|
||||
|
|
|
@ -237,8 +237,8 @@ module.exports = new Class
|
|||
childData.set.unref ();
|
||||
childData.builder.unref ();
|
||||
}
|
||||
|
||||
,destroy: function ()
|
||||
|
||||
,_destroy: function ()
|
||||
{
|
||||
this._freeChildsData ();
|
||||
this.parent ();
|
||||
|
|
|
@ -19,18 +19,21 @@ module.exports = new Class
|
|||
|
||||
,render: function (params)
|
||||
{
|
||||
var object;
|
||||
|
||||
if (params && (object = params[this.id]))
|
||||
if (params)
|
||||
{
|
||||
if (!(object instanceof SqlObject))
|
||||
var object = params[this.id];
|
||||
|
||||
if (object != null)
|
||||
{
|
||||
var sqlValue = new Value ();
|
||||
sqlValue.value = object;
|
||||
return sqlValue.render ();
|
||||
if (!(object instanceof SqlObject))
|
||||
{
|
||||
var sqlValue = new Value ();
|
||||
sqlValue.value = object;
|
||||
return sqlValue.render ();
|
||||
}
|
||||
else
|
||||
return object.render (params);
|
||||
}
|
||||
else
|
||||
return object.render (params);
|
||||
}
|
||||
|
||||
return '#'+ this.id;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
var Object = require ('./object');
|
||||
var VnObject = require ('./object');
|
||||
var Type = require ('./type');
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@ var Type = require ('./type');
|
|||
*/
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Object
|
||||
Extends: VnObject
|
||||
,_addedMap: {}
|
||||
,_contexts: null
|
||||
|
||||
|
@ -577,7 +577,7 @@ module.exports = new Class
|
|||
|
||||
var BuilderResult = new Class
|
||||
({
|
||||
Extends: Object
|
||||
Extends: VnObject
|
||||
|
||||
,initialize: function (builder, objects)
|
||||
{
|
||||
|
@ -615,7 +615,7 @@ var BuilderResult = new Class
|
|||
var objects = this.objects;
|
||||
|
||||
for (var i = 0; i < objects.length; i++)
|
||||
if (objects[i] instanceof Object)
|
||||
if (objects[i] instanceof VnObject)
|
||||
objects[i].unref ();
|
||||
|
||||
this.parent ();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
var VnObject = require ('./object');
|
||||
var VnDate = require ('./date');
|
||||
var Lot = require ('./lot');
|
||||
var Value = require ('./value');
|
||||
|
||||
/**
|
||||
* Class to handle the URL.
|
||||
|
@ -48,9 +49,9 @@ module.exports = new Class
|
|||
this.parent (props);
|
||||
}
|
||||
|
||||
,get: function (key, type)
|
||||
,get: function (key)
|
||||
{
|
||||
return this.parseValue (this._hashMap[key], type);
|
||||
return this._hashMap[key];
|
||||
}
|
||||
|
||||
,set: function (key, value)
|
||||
|
@ -67,8 +68,10 @@ module.exports = new Class
|
|||
*/
|
||||
,assign: function (object)
|
||||
{
|
||||
var newObject = this._hashMap;
|
||||
var newObject = {};
|
||||
|
||||
for (var key in this._hashMap)
|
||||
newObject[key] = this._hashMap[key];
|
||||
for (var key in object)
|
||||
newObject[key] = object[key];
|
||||
|
||||
|
@ -92,7 +95,7 @@ module.exports = new Class
|
|||
if (!object)
|
||||
object = {};
|
||||
|
||||
if (newHash !== this._hash)
|
||||
if (!Value.equals (this._hashMap, object))
|
||||
{
|
||||
this._hashMap = object;
|
||||
this._hash = newHash;
|
||||
|
@ -135,8 +138,8 @@ module.exports = new Class
|
|||
,_hashChanged: function ()
|
||||
{
|
||||
var newHash = location.hash;
|
||||
|
||||
if (this._blockChanged || newHash === this._hash)
|
||||
|
||||
if (this._blockChanged || this._hash == newHash)
|
||||
return;
|
||||
|
||||
var newMap = hashMap = {};
|
||||
|
@ -147,12 +150,15 @@ module.exports = new Class
|
|||
var kvPair = kvPairs[i].split ('=', 2);
|
||||
|
||||
if (kvPair[0])
|
||||
newMap[decodeURIComponent (kvPair[0])] = decodeURIComponent (kvPair[1]);
|
||||
newMap[decodeURIComponent (kvPair[0])] = this.parseValue (kvPair[1]);
|
||||
}
|
||||
|
||||
this._hashMap = newMap;
|
||||
this._hash = newHash;
|
||||
this.changed ();
|
||||
if (!Value.equals (this._hashMap, newMap))
|
||||
{
|
||||
this._hashMap = newMap;
|
||||
this._hash = newHash;
|
||||
this.changed ();
|
||||
}
|
||||
}
|
||||
|
||||
,renderValue: function (v)
|
||||
|
@ -160,36 +166,70 @@ module.exports = new Class
|
|||
switch (typeof v)
|
||||
{
|
||||
case 'number':
|
||||
return v;
|
||||
return '(Number)'+ v;
|
||||
case 'boolean':
|
||||
return (v) ? 'true' : 'false';
|
||||
return '(Boolean)'+ (v ? 'true' : 'false');
|
||||
case 'object':
|
||||
if (v instanceof Date)
|
||||
return VnDate.strftime (v, '%Y-%m-%d');
|
||||
return '(Date)'+ VnDate.strftime (v, '%Y-%m-%d');
|
||||
else
|
||||
return '(Object)'+ JSON.stringify (v)
|
||||
}
|
||||
|
||||
switch (v.charAt (0))
|
||||
{
|
||||
case '(':
|
||||
case '\\':
|
||||
return '\\'+ v;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
,parseValue: function (v, type)
|
||||
,parseValue: function (v)
|
||||
{
|
||||
if (v == null)
|
||||
return v;
|
||||
|
||||
v = decodeURIComponent (v);
|
||||
|
||||
if (v === '')
|
||||
return v;
|
||||
|
||||
var typeStr;
|
||||
|
||||
switch (v.charAt(0))
|
||||
{
|
||||
case '(':
|
||||
var index = v.indexOf (')');
|
||||
typeStr = v.substr (1, index - 1);
|
||||
v = v.substr (index + 1);
|
||||
break;
|
||||
case '\\':
|
||||
v = v.substr (1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (v === '')
|
||||
return null;
|
||||
if (!typeStr)
|
||||
return v;
|
||||
|
||||
if (type && v !== undefined && v !== null)
|
||||
switch (type)
|
||||
switch (typeStr)
|
||||
{
|
||||
case Boolean:
|
||||
case 'Boolean':
|
||||
return (/^(true|1)$/i).test (v);
|
||||
case Number:
|
||||
case 'Number':
|
||||
return 0 + new Number (v);
|
||||
case Date:
|
||||
case 'Date':
|
||||
var date = new Date (v);
|
||||
date.setHours (0, 0, 0, 0);
|
||||
return date;
|
||||
case 'Object':
|
||||
return JSON.parse (v);
|
||||
default:
|
||||
return v;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
,_destroy: function ()
|
||||
|
|
|
@ -156,8 +156,8 @@ module.exports = new Class
|
|||
return;
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++)
|
||||
if (callbacks[i].callback == callback
|
||||
&& callbacks[i].instance == instance)
|
||||
if (callbacks[i].callback === callback
|
||||
&& callbacks[i].instance === instance)
|
||||
callbacks.splice (i--, 1);
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ module.exports = new Class
|
|||
var callbacks = signals[signalId];
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++)
|
||||
if (callbacks[i].instance == instance)
|
||||
if (callbacks[i].instance === instance)
|
||||
callbacks.splice (i--, 1);
|
||||
}
|
||||
}
|
||||
|
@ -195,10 +195,16 @@ module.exports = new Class
|
|||
var links = this._signalData.links;
|
||||
|
||||
for (var key in links)
|
||||
links[key].disconnectByInstance (this);
|
||||
this._unlink (links[key]);
|
||||
|
||||
this._signalData = null;
|
||||
}
|
||||
|
||||
,_unlink: function (object)
|
||||
{
|
||||
object.disconnectByInstance (this);
|
||||
object.unref ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Links the object with another object.
|
||||
|
@ -217,10 +223,7 @@ module.exports = new Class
|
|||
var oldObject = this[key];
|
||||
|
||||
if (oldObject)
|
||||
{
|
||||
oldObject.disconnectByInstance (this);
|
||||
oldObject.unref ();
|
||||
}
|
||||
this._unlink (oldObject);
|
||||
|
||||
this[key] = newObject;
|
||||
|
||||
|
|
|
@ -1,11 +1,43 @@
|
|||
|
||||
var VnDate = require ('./date');
|
||||
|
||||
/**
|
||||
* Checks if two values are equal, it also checks objects. Basic
|
||||
* values are compared using the non-strict equality operator.
|
||||
*
|
||||
* @param {*} a Value to compare to
|
||||
* @param {*} b Value to compare with
|
||||
* @return {Boolean} %true if they are equal, %false otherwise
|
||||
*/
|
||||
function equals (a, b)
|
||||
{
|
||||
if (a == b)
|
||||
return true;
|
||||
if (a instanceof Date && b instanceof Date)
|
||||
return a.getTime () === b.getTime ();
|
||||
if (a && b && (typeof a === 'object') && (typeof b === 'object'))
|
||||
{
|
||||
for (var key in a)
|
||||
if (!equals (a[key], b[key]))
|
||||
return false;
|
||||
|
||||
for (var key in b)
|
||||
if (a[key] === undefined && b[key] != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports =
|
||||
{
|
||||
regexpNumber: /%\.([0-9]+)d/g
|
||||
,regexpString: /%s/g
|
||||
|
||||
,equals: equals
|
||||
|
||||
,compare: function (a, b)
|
||||
{
|
||||
if (a === b)
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
<db-model property="model" id="movements" conn="conn" lot="hash">
|
||||
CALL clientTicketRowGet(#ticket)
|
||||
</db-model>
|
||||
<htk-column-spin title="_Ref" name="item"/>
|
||||
<htk-column-spin title="_Amount" name="amount"/>
|
||||
<htk-column-text title="_Item" name="concept"/>
|
||||
<htk-column-text title="_S1" name="Medida"/>
|
||||
<htk-column-text title="_Cat" name="Categoria"/>
|
||||
<htk-column-text title="_Color" name="Color"/>
|
||||
<htk-column-spin title="_Price" name="price" unit="€" digits="2"/>
|
||||
<htk-column-spin title="_Ref" column="item"/>
|
||||
<htk-column-spin title="_Amount" column="amount"/>
|
||||
<htk-column-text title="_Item" column="concept"/>
|
||||
<htk-column-text title="_S1" column="Medida"/>
|
||||
<htk-column-text title="_Cat" column="Categoria"/>
|
||||
<htk-column-text title="_Color" column="Color"/>
|
||||
<htk-column-spin title="_Price" column="price" unit="€" digits="2"/>
|
||||
<htk-column-spin title="_Import" unit="€" digits="2" renderer="subtotalRenderer"/>
|
||||
</htk-grid>
|
||||
<div class="footer">
|
||||
|
|
|
@ -17,20 +17,14 @@ Hedera.ShelvesReport = new Class
|
|||
showPacking: params.showPacking,
|
||||
stack: params.stack,
|
||||
useIds: params.useIds
|
||||
})
|
||||
});
|
||||
|
||||
var params = {
|
||||
warehouse: params.warehouse,
|
||||
|
||||
}
|
||||
|
||||
var query =
|
||||
'SELECT id, name, nTrays, topTrayHeight, trayHeight, width, depth '+
|
||||
'FROM shelf WHERE id = #shelf; '+
|
||||
'CALL itemAllocator (#warehouse, #date, #family, #namePrefix, #useIds)';
|
||||
|
||||
this.conn.execQuery (query,
|
||||
this.onQueryExec.bind (this), lot);
|
||||
this.onQueryExec.bind (this), params);
|
||||
}
|
||||
|
||||
,onQueryExec: function (resultSet)
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
}
|
||||
.report .box-label
|
||||
{
|
||||
font-size: .25em;
|
||||
font-size: .65em;
|
||||
word-wrap: break-word;
|
||||
box-sizing: border-box;
|
||||
padding: 1% 2%;
|
||||
|
|
Loading…
Reference in New Issue