0
1
Fork 0
This commit is contained in:
Juan Ferrer Toribio 2017-04-08 13:42:27 +02:00
parent 0be33631ca
commit 403845bf2b
38 changed files with 433 additions and 464 deletions

View File

@ -4,3 +4,4 @@ rules:
no-redeclare: 0
no-mixed-spaces-and-tabs: 0
no-console: 0
no-cond-assign: 0

View File

@ -12,7 +12,7 @@ Hedera.Address = new Class
,onStatusChange: function (form)
{
if (form.ready && this.$('address').value == 0)
if (form.ready && this.hash.get ('address') == 0)
form.insertRow ();
}

View File

@ -10,7 +10,7 @@
mode="ON_DEMAND"
lot="hash"
on-operations-done="onOperationsDone">
SELECT a.id, a.name, a.consignee, a.city, a.zip_code, a.province_id, c.Id country_id
SELECT a.id, a.name, a.consignee, a.city, a.zip_code, a.province_id, c.Id country
FROM address_view a
LEFT JOIN vn2008.province p ON p.province_id = a.province_id
JOIN vn2008.Paises c ON c.Id = p.Paises_Id
@ -56,7 +56,7 @@
id="country"
property="param"
lot="iter"
name="country_id"
name="country"
one-way="true"/>
<db-model property="model">
SELECT Id, Pais FROM vn2008.Paises
@ -67,7 +67,7 @@
<div>
<label><t>Province</t></label>
<htk-combo lot="iter" name="province_id">
<db-model property="model">
<db-model property="model" lot="iter">
SELECT province_id, name FROM vn2008.province
WHERE Paises_Id = #country
ORDER BY name

View File

@ -2,32 +2,26 @@
<vn-group>
<db-form id="password-form">
<db-model property="model">
<custom>
SELECT length, nAlpha, nUpper, nDigits, nPunct
FROM account.userPassword
</custom>
</db-model>
</db-form>
<db-form id="user">
<db-model property="model" id="user-model" updatable="true">
<custom>
SELECT u.id, u.name, u.recoverPass,
c.email, c.mail, c.user_id
FROM account.userView u
LEFT JOIN customer_view c
ON u.id = c.user_id
</custom>
</db-model>
</db-form>
<db-model id="addresses" updatable="true">
<custom>
SELECT a.id, a.consignee, p.name province,
a.zip_code, a.city, a.name, a.active, c.Pais country
FROM address_view a
LEFT JOIN vn2008.province p ON a.province_id = p.province_id
JOIN vn2008.Paises c ON c.Id = p.Paises_Id
WHERE active
</custom>
</db-model>
</vn-group>
<h1 id="title">

View File

@ -5,19 +5,20 @@ Hedera.Shelves = new Class
,activate: function ()
{
var set = this.$('set');
set.set ('date', new Date ());
set.set ('useIds', false);
this.$('lot').assign ({
date: new Date (),
useIds: false
});
}
,onConfigChange: function ()
{
this.$('set').assign (this.$('config'));
this.$('lot').assignLot (this.$('config'));
}
,onShowClick: function ()
{
this.gui.openReport ('shelves-report', this.$('set').params);
this.gui.openReport ('shelves-report', this.$('lot').params);
}
});

View File

@ -1,5 +1,5 @@
<vn>
<vn-basic-set id="set"/>
<vn-basic-set id="lot"/>
<h1 id="title">
<t>Shelves</t>
</h1>
@ -29,11 +29,11 @@
</div>
<div>
<label><t>Date</t></label>
<htk-date-chooser lot="set" name="date"/>
<htk-date-chooser lot="lot" name="date"/>
</div>
<div>
<label><t>Reign</t></label>
<htk-combo lot="set" name="realm" id="realm">
<htk-combo lot="lot" name="realm" id="realm">
<db-model property="model">
SELECT id, reino FROM vn2008.reinos
WHERE display != FALSE ORDER BY reino
@ -42,7 +42,7 @@
</div>
<div>
<label><t>Family</t></label>
<htk-combo lot="set" name="family">
<htk-combo lot="lot" name="family">
<db-model property="model" lot="config">
SELECT tipo_id, Tipo FROM vn2008.Tipos
WHERE reino_id = #realm ORDER BY Tipo
@ -51,7 +51,7 @@
</div>
<div>
<label><t>Store</t></label>
<htk-combo lot="set" name="warehouse">
<htk-combo lot="lot" name="warehouse">
<db-model property="model">
SELECT id, name FROM vn2008.warehouse
WHERE reserve ORDER BY name
@ -60,7 +60,7 @@
</div>
<div>
<label><t>Shelf</t></label>
<htk-combo lot="set" name="shelf">
<htk-combo lot="lot" name="shelf">
<db-model property="model">
SELECT id, name FROM shelf
</db-model>
@ -68,27 +68,27 @@
</div>
<div>
<label><t>Name prefix</t></label>
<htk-entry lot="set" name="namePrefix"/>
<htk-entry lot="lot" name="namePrefix"/>
</div>
<div>
<label><t>Limit amount per item</t></label>
<htk-entry lot="set" name="maxAmount"/>
<htk-entry lot="lot" name="maxAmount"/>
</div>
<div>
<label><t>Title</t></label>
<htk-entry lot="set" name="reportTitle"/>
<htk-entry lot="lot" name="reportTitle"/>
</div>
<div>
<label><t>Show packing</t></label>
<htk-check lot="set" name="showPacking"/>
<htk-check lot="lot" name="showPacking"/>
</div>
<div>
<label><t>Stack different items</t></label>
<htk-check lot="set" name="stack"/>
<htk-check lot="lot" name="stack"/>
</div>
<div>
<label><t>Use ids instead of names</t></label>
<htk-check lot="set" name="useIds"/>
<htk-check lot="lot" name="useIds"/>
</div>
</div>
</div>

View File

@ -50,40 +50,40 @@ Hedera.Location = new Class
var div = this.$('form');
var gmap = new google.maps.Map (div, options);
var row;
if (this.locations)
while (this.locations.next ())
this.createMarker (this.locations, gmap);
while (row = this.locations.fetchObject ())
this.createMarker (row, gmap);
}
,createMarker: function (location, gmap)
,createMarker: function (row, gmap)
{
var div = document.createElement ('div');
div.className = 'marker';
var h = document.createElement ('h3');
h.appendChild (document.createTextNode (location.get ('title')));
h.appendChild (document.createTextNode (row.title));
div.appendChild (h);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (location.get ('address')));
p.appendChild (document.createTextNode (row.address));
div.appendChild (p);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (location.get ('postcode') +' '+ location.get ('city')));
p.appendChild (document.createTextNode (row.postcode +' '+ row.city));
div.appendChild (p);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (location.get ('province')));
p.appendChild (document.createTextNode (row.province));
div.appendChild (p);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (location.get ('phone')));
p.appendChild (document.createTextNode (row.phone));
div.appendChild (p);
var lat = new google.maps.LatLng (
location.get ('lat'),
location.get ('lng')
row.lat,
row.lng
);
var marker = new google.maps.Marker ({
@ -100,7 +100,7 @@ Hedera.Location = new Class
this.openInfoWindow.bind (this, infoWindow, gmap, marker));
if (Vn.Locale.language
&& Vn.Locale.language == location.get ('language'))
&& Vn.Locale.language == row.language)
this.openInfoWindow (infoWindow, gmap, marker);
}

View File

@ -127,10 +127,8 @@ Hedera.Checkout = new Class
this.$('calendar').goToSelectedMonth ();
break;
case 'agency':
this.$('agencies').refresh ();
break;
case 'pickup':
this.$('warehouses').refresh ();
this.$('agencies').refresh ();
break;
}

View File

@ -46,7 +46,6 @@
id="rg-method"
lot="lot"
name="method"
param="method"
on-changed="onFieldChange"/>
<div>
<htk-radio radio-group="rg-method" value="AGENCY"/>
@ -68,7 +67,8 @@
<htk-calendar
id="calendar"
class="thin-calendar"
param="date"
lot="lot"
name="date"
restrict-func="calendarRestrict"
on-changed="onFieldChange"/>
</div>
@ -121,7 +121,7 @@
lot="lot"
name="agency"
on-changed="onFieldChange"
model="warehouses"/>
model="agencies"/>
</div>
</div>
<div id="confirm-agency-step" class="confirm">
@ -129,7 +129,7 @@
<div class="answers target">
<p>
<t>Arrival</t>
<htk-text format="%D" param="date"/>
<htk-text format="%D" lot="lot" name="date"/>
</p>
<p>
<htk-text lot="address-form" name="name"/>
@ -149,7 +149,7 @@
<div class="answers target">
<p>
<t>Arrival</t>
<htk-text format="%D" param="date"/>
<htk-text format="%D" lot="lot" name="date"/>
</p>
<p>
<htk-text lot="address-form" name="name"/>
@ -168,7 +168,7 @@
<div class="answers target">
<p>
<t>Pickup</t>
<htk-text format="%D" param="date"/>
<htk-text format="%D" lot="lot" name="date"/>
</p>
<p>
<t>Warehouse</t>

View File

@ -23,7 +23,9 @@ Hedera.Confirm = new Class
if (form.row < 0)
return;
if (form.get ('method') != 'PICKUP')
var order = form.params;
if (order.method != 'PICKUP')
{
Vn.Node.show (this.$('address'));
Vn.Node.setText (this.$('method'), _('Agency'));
@ -34,34 +36,26 @@ Hedera.Confirm = new Class
Vn.Node.setText (this.$('method'), _('Warehouse'));
}
var total = form.get ('tax_base') + form.get ('vat');
var total = order.taxBase + order.vat;
if (total === null)
total = 0;
var credit = form.get ('credit');
var debt = form.get ('debt');
var totalDebt = debt + total;
var exceededCredit = totalDebt - credit;
var totalDebt = order.debt + total;
var exceededCredit = totalDebt - order.credit;
var creditExceededCond = exceededCredit > 0;
if (creditExceededCond)
Htk.Toast.showWarning (
_('You have exceeded your credit.'));
this.$('lot').assign ({
debt: debt,
var lot = {
totalDebt: totalDebt,
totalAmount: totalDebt,
creditExcess: exceededCredit,
excessAmount: exceededCredit,
exceededCredit: exceededCredit,
payAmount: 'ALL'
});
};
this.$('pay-amount').value = 'ALL';
if (credit > 0)
if (order.credit > 0)
{
this.$('credit-info').style.display = 'table-row';
@ -69,7 +63,7 @@ Hedera.Confirm = new Class
{
this.$('amount-selector').style.display = 'block';
this.$('exceeded-info').style.display = 'table-row';
lot.assign ({payAmount: 'EXCEEDED'});
lot.payAmount = 'EXCEEDED';
}
}
@ -78,7 +72,7 @@ Hedera.Confirm = new Class
if (totalDebt <= 0)
{
methods = ['balance'];
selectedMethod = 'BALANCE';
lot.payMethod = 'BALANCE';
}
else
{
@ -87,16 +81,16 @@ Hedera.Confirm = new Class
if (!creditExceededCond)
{
methods.push ('credit');
selectedMethod = 'CREDIT';
lot.payMethod = 'CREDIT';
}
else
selectedMethod = 'CARD';
lot.payMethod = 'CARD';
}
for (var i = 0; i < methods.length; i++)
this.$(methods[i] +'-method').style.display = 'block';
lot.assign ({payAmount: selectedMethod});
this.$('lot').assign (lot);
}
,onPayMethodChange: function (payMethod)
@ -143,6 +137,7 @@ Hedera.Confirm = new Class
,onConfirmClick: function ()
{
console.log (this.$('lot').params);
this.disableButtons (true);
this.$('confirm-query').execute ();
}
@ -152,29 +147,28 @@ Hedera.Confirm = new Class
this.disableButtons (false);
if (resultSet.fetchResult ())
{
Vn.Cookie.unset ('order');
this.$('success-dialog').show ();
}
}
,onDialogResponse: function ()
{
var lot = this.$('lot').params;
if (this.$('pay-method').value === 'CARD')
{
if (this.$('pay-amount').value === 'EXCEEDED')
var payAmount = this.$('excess-amount').value;
var payAmount = lot.exceededCredit;
else
var payAmount = this.$('total-amount').value;
var payAmount = lot.totalDebt;
var tpv = new Hedera.Tpv ({
conn: this.conn,
hash: this.hash
});
tpv.pay (payAmount, this.$('order-form').get ('company_id'));
tpv.pay (payAmount, this.$('order').get ('company'));
}
else
this.hash.setAll ({'form': 'ecomerce/orders'});
this.hash.params = {form: 'ecomerce/orders'};
}
});

View File

@ -1,12 +1,12 @@
<vn>
<vn-group>
<vn-basic-set id="lot"/>
<db-form id="order-form" on-ready="onOrderReady">
<db-form id="order" on-ready="onOrderReady">
<db-model property="model" result-index="1">
CALL basket_get_vat ();
SELECT o.id, o.date_send, o.note, o.company_id,
SELECT o.id, o.date_send sendDate, o.note, o.company_id company,
ag.description agency, v.code method,
ad.consignee, ad.zip_code, ad.city, ad.name address,
ad.consignee, ad.zip_code zipCode, ad.city, ad.name address,
t.*, c.credit, clientGetDebt() debt
FROM basket o
JOIN vn2008.Agencias ag ON ag.Id_Agencia = o.agency_id
@ -15,7 +15,7 @@
JOIN customer_view c
JOIN (
SELECT
IFNULL(SUM(tax_base), 0) tax_base,
IFNULL(SUM(tax_base), 0) taxBase,
IFNULL(SUM(vat + surcharge), 0) vat
FROM t_order_vat
) t;
@ -35,23 +35,23 @@
<div class="delivery">
<p>
<t>Delivery at</t>
<htk-text format="%D" lot="order-form" name="date_send"/>
<htk-text format="%D" lot="order" name="sendDate"/>
</p>
<p>
<span id="method"><t>Agency</t></span>
<htk-text lot="order-form" name="agency"/>
<htk-text lot="order" name="agency"/>
</p>
</div>
<div id="address" class="address">
<p>
<htk-text lot="order-form" name="consignee"/>
<htk-text lot="order" name="consignee"/>
</p>
<p>
<htk-text lot="order-form" name="address"/>
<htk-text lot="order" name="address"/>
</p>
<p>
<htk-text lot="order-form" name="zip_code"/>,
<htk-text lot="order-form" name="city"/>
<htk-text lot="order" name="zipCode"/>,
<htk-text lot="order" name="city"/>
</p>
</div>
</div>
@ -65,7 +65,7 @@
<t>Previous balance</t>
</td>
<td class="currency">
<htk-text format="%.2d€" lot="lot" name="debt"/>
<htk-text format="%.2d€" lot="order" name="debt"/>
</td>
</tr>
<tr>
@ -73,7 +73,7 @@
<t>Order total</t>
</td>
<td class="currency">
<htk-text format="%.2d€" lot="order-form" name="tax_base"/>
<htk-text format="%.2d€" lot="order" name="taxBase"/>
</td>
</tr>
<tr>
@ -81,7 +81,7 @@
<t>Order VAT</t>
</td>
<td class="currency">
<htk-text format="%.2d€" lot="order-form" name="vat"/>
<htk-text format="%.2d€" lot="order" name="vat"/>
</td>
</tr>
<tr class="total-debt sum-total">
@ -97,7 +97,7 @@
<t>Credit</t>
</td>
<td class="currency">
<htk-text format="%.2d€" lot="order-form" name="credit"/>
<htk-text format="%.2d€" lot="order" name="credit"/>
</td>
</tr>
<tr id="exceeded-info" class="exceeded-info sum-total">
@ -105,7 +105,7 @@
<t>Exceeded credit</t>
</td>
<td class="currency">
<htk-text format="%.2d€" lot="lot" name="creditExcess"/>
<htk-text format="%.2d€" lot="lot" name="exceededCredit"/>
</td>
</tr>
</tbody>
@ -117,19 +117,21 @@
</h2>
<div class="radio">
<htk-radio-group
id="pay-amount"/>
id="pay-amount"
lot="lot"
name="payAmount"/>
<div>
<htk-radio radio-group="pay-amount" value="ALL"/>
<label>
<t>Total debt</t>,
<htk-text format="%.2d€" lot="lot" name="totalAmount"/>
<htk-text format="%.2d€" lot="lot" name="totalDebt"/>
</label>
</div>
<div>
<htk-radio radio-group="pay-amount" value="EXCEEDED"/>
<label>
<t>Exceeded credit</t>,
<htk-text format="%.2d€" lot="lot" name="excessAmount"/>
<htk-text format="%.2d€" lot="lot" name="exceededCredit"/>
</label>
</div>
</div>
@ -141,6 +143,7 @@
<div class="pay-methods radio">
<htk-radio-group
lot="lot"
id="pay-method"
name="payMethod"
on-changed="onPayMethodChange"/>
<div id="balance-method">
@ -171,10 +174,8 @@
<t>Make a transfer to one account.</t>
<htk-repeater form-id="iter">
<db-model property="model">
<custom>
SELECT description, iban, entity_id, office, dc, number
FROM vn2008.account_customer c
</custom>
</db-model>
<custom>
<div class="transfer-account">

View File

@ -28,7 +28,7 @@ Hedera.Orders = new Class
,onBasketClick: function ()
{
this.hash.setAll ({'form': 'ecomerce/basket'});
this.hash.setAll ({form: 'ecomerce/basket'});
}
,repeaterFunc: function (res, form)

View File

@ -15,7 +15,7 @@ Hedera.Ticket = new Class
,onPrintClick: function ()
{
var params = {ticket: this.$('ticket-id').value};
var params = {ticket: this.hash.get ('ticket')};
this.gui.openReport ('delivery-note', params);
}

View File

@ -73,6 +73,21 @@ module.exports = new Class
{
return this._ready;
}
},
/**
* The current row parameters.
*/
params:
{
type: Object
,set: function (x)
{
this.assign (x);
}
,get: function ()
{
return this.getParams ();
}
}
}

View File

@ -3,7 +3,8 @@ var Model = require ('./model');
module.exports = new Class
({
Properties:
Implements: Vn.Lot
,Properties:
{
/**
* The model associated to this form.
@ -26,6 +27,30 @@ module.exports = new Class
{
type: Number
},
/**
* The current row parameters.
*/
params:
{
type: Object
,set: function (x)
{
this.assign (x);
}
,get: function ()
{
var params = {};
var keys = this.keys ();
for (var i = 0; i < keys.length; i++)
{
var key = keys[i];
params[key] = this.get (key);
}
return params;
}
},
/**
* Checks if the form data is ready.
*/
@ -44,14 +69,6 @@ module.exports = new Class
this._model.refresh ();
}
/**
* Emits the 'change' signal on the form.
*/
,changed: function ()
{
this.signalEmit ('change');
}
/**
* Get the index of the column from its name.
*
@ -95,7 +112,10 @@ module.exports = new Class
*/
,get: function (columnName)
{
if (this._model)
return this._model.get (this._row, columnName);
return undefined;
}
/**
@ -133,10 +153,24 @@ module.exports = new Class
,keys: function ()
{
if (this._model)
if (this._model && this._model.ready)
return Object.keys (this._model.columnMap);
return [];
}
,getParams: function ()
{
var params = {};
var keys = this.keys ();
for (var i = 0; i < keys.length; i++)
{
var key = keys[i];
params[key] = this.get (key);
}
return params;
}
});

View File

@ -271,19 +271,6 @@ Model.implement
this._setStatus (Status.CLEAN);
}
/**
* Deprecated.
*/
,loadXml: function (builder, node)
{
this.parent (builder, node);
var query = node.firstChild.nodeValue;
if (query)
this.query = query;
}
,appendChild: function (child)
{
if (child.nodeType === Node.TEXT_NODE)
@ -316,10 +303,13 @@ Model.implement
if (!this._lot)
return false;
var lotParams = this._lot.params;
var params = this._lot.params;
if (!params)
return false;
for (var i = 0; i < ids.length; i++)
if (lotParams[ids[i]] === undefined)
if (params[ids[i]] === undefined)
return false;
return true;

View File

@ -81,14 +81,10 @@ module.exports = new Class
}
}
,loadXml: function (builder, node)
,appendChild: function (child)
{
this.parent (builder, node);
var query = node.firstChild.nodeValue;
if (query)
this.query = query;
if (child.nodeType === Node.TEXT_NODE)
this.query = child.textContent;
}
,execute: function ()

View File

@ -60,6 +60,21 @@ module.exports = new Class
return null;
}
/**
* Fetchs the first row from the next resultset as an object.
*
* @return {Object} the row if success, %null otherwise
*/
,fetchObject: function ()
{
var result = this.fetchResult ();
if (result instanceof Result)
return result.fetchObject ();
return null;
}
/**
* Fetchs the first row from the next resultset.
*

View File

@ -8,10 +8,12 @@ module.exports = new Class
*/
initialize: function (result)
{
this.data = result.data;
this.tables = result.tables;
this.columns = result.columns;
this.row = -1;
Object.assign (this, {
data: result.data,
tables: result.tables,
columns: result.columns,
row: -1
});
if (this.columns)
{
@ -36,6 +38,36 @@ module.exports = new Class
return this.data[this.row][columnIndex];
}
/**
* Moves the pointer to the next row and returns it as an object.
*
* @return {Object} The row or %null if there are no more rows
*/
,fetchObject: function ()
{
if (!this.next ())
return null;
return this.getObject ();
}
/**
* Returns the current row as an object.
*
* @return {Object} The row or %null if there are no more rows
*/
,getObject: function ()
{
var row = this.data[this.row];
var cols = this.columns;
var object = {};
for (var i = 0; i < cols.length; i++)
object[cols[i].name] = row[i];
return object;
}
/**
* Resets the result iterator.
*/

View File

@ -68,6 +68,21 @@ module.exports = new Class
return false;
}
},
/**
* The current row parameters.
*/
params:
{
type: Object
,set: function (x)
{
this.assign (x);
}
,get: function ()
{
return this.getParams ();
}
}
}
});

View File

@ -74,12 +74,11 @@ module.exports = new Class
if (Vn.isMobile ())
{
this._onScrollHandler = this._onScroll.bind (this);
window.addEventListener ('scroll', this._onScrollHandler );
window.addEventListener ('scroll', this._onScrollHandler);
}
this.formParam = new Vn.Param ({
lot: this.hash,
type: String,
name: 'form',
});
this.formParam.on ('changed', this._onFormChange, this);
@ -140,20 +139,15 @@ module.exports = new Class
// Retrieving configuration parameters
var res = resultSet.fetchResult ();
var columns = res.columns;
if (res.next ())
for (var i = 0; i < res.columns.length; i++)
Vn.Config[columns[i].name] = res.get (columns[i].name);
Object.assign (Vn.Config, resultSet.fetchObject ());
// Retrieving configuration parameters
var res = resultSet.fetchResult ();
var row = resultSet.fetchObject ();
if (res.next () && res.get ('test_domain'))
if (row && row.test_domain)
{
if (location.host != res.get ('production_domain'))
if (location.host != row.production_domain)
{
var linkText = 'ReturnToOldWebsite';
var linkField = 'production_domain';
@ -165,7 +159,7 @@ module.exports = new Class
}
Vn.Node.setText (this.$('test-link'), _(linkText));
this.$('test-link').href = '//'+ res.get (linkField);
this.$('test-link').href = '//'+ row[linkField];
}
else
Vn.Node.hide (this.$('test-link'));
@ -185,13 +179,14 @@ module.exports = new Class
{
// Retrieving menu sections
var row;
var res = resultSet.fetchResult ();
var sectionMap = {};
if (res)
for (var i = 0; res.next (); i++)
for (var i = 0; row = res.fetchObject (); i++)
{
var parent = res.get ('parent');
var parent = row.parent;
if (!sectionMap[parent])
sectionMap[parent] = [];
@ -212,25 +207,26 @@ module.exports = new Class
for (var i = 0; i < sections.length; i++)
{
res.row = sections[i];
var row = res.getObject ();
var li = this.createElement ('li');
ul.appendChild (li);
var text = this.createTextNode (_(res.get ('description')));
var text = this.createTextNode (_(row.description));
var a = this.createElement ('a');
a.className = 'clickable';
if (res.get ('path'))
if (row.path)
{
a.href = this.hash.make ({'form': res.get ('path')});
this.menuOptions[res.get ('path')] = a;
a.href = this.hash.make ({'form': row.path});
this.menuOptions[row.path] = a;
}
a.appendChild (text);
li.appendChild (a);
var formId = res.get ('id');
var formId = row.id;
if (sectionMap[formId])
{
@ -320,7 +316,7 @@ module.exports = new Class
return;
var navbar = this.$('top-bar');
var yOffset = Vn.Browser.getPageYOffset ();
var yOffset = window.pageYOffset;
var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight;
if (showNavbar !== this._navbarVisible)
@ -478,7 +474,7 @@ module.exports = new Class
form: 'preview',
report: reportName
};
this.hash.setAll (Object.assign (hashParams, params));
this.hash.params = Object.assign (hashParams, params);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Supplant

View File

@ -8,17 +8,17 @@ module.exports = new Class
this.renderReport ();
}
,open: function (batch, body)
,open: function (hash, body)
{
this.batch = batch;
this.hash = hash;
this.body = body;
this.reportWindow = body.ownerDocument.defaultView;
this.activate (batch, body);
this.activate (hash, body);
}
,openIframe: function (batch)
,openIframe: function (hash)
{
this.batch = batch;
this.hash = hash;
var iframe = this.iframe = this.createElement ('iframe');
iframe.src = 'js/hedera/report.html';
@ -47,7 +47,7 @@ module.exports = new Class
{
var builder = new Vn.Builder ();
builder.signalData = this;
builder.add ('batch', this.batch);
builder.add ('hash', this.hash);
builder.add ('conn', this.conn);
builder.loadXml ('reports/'+ this.info.path +'/ui.xml');

View File

@ -56,19 +56,20 @@ module.exports = new Class
{
Vn.Node.removeChilds (this._node);
var res = resultSet.fetchResult ();
var row;
while (res.next ())
while (row = res.fetchObject ())
{
var a = this.createElement ('a');
a.href = res.get ('link');
a.href = row.link;
a.target = '_blank';
a.className = 'clickable-img';
this._node.appendChild (a);
var img = this.createElement ('img');
img.src = 'image/social/'+ res.get ('icon');
img.alt = res.get ('title');
img.title = res.get ('title');
img.src = 'image/social/'+ row.icon;
img.alt = row.title;
img.title = row.title;
a.appendChild (img);
}
}

View File

@ -94,10 +94,10 @@ module.exports = new Class
,_onRetryPayDone: function (resultSet)
{
var res = resultSet.fetchResult ();
var row = resultSet.fetchObject ();
if (res.next ())
this._realPpay (res.get ('amount'), res.get ('company_id'));
if (row)
this._realPpay (row.amount, row.company_id);
else
Htk.Toast.showError (_('AmountError'));
}

View File

@ -106,6 +106,21 @@ module.exports = new Class
{
return this._notNull;
}
},
/**
* The current row parameters.
*/
params:
{
type: Object
,set: function (x)
{
this.assign (x);
}
,get: function ()
{
return this.getParams ();
}
}
}

View File

@ -15,7 +15,7 @@ module.exports = new Class
,clear: function ()
{
this.name = Math.random ().toString ();
this.radioName = Math.random ().toString ();
this.buttons = [];
}
@ -38,7 +38,9 @@ module.exports = new Class
,createButton: function (value)
{
var radio = Vn.Browser.createRadio (this.name, this.doc);
var radio = this.doc.createElement ('input');
radio.type = 'radio';
radio.name = this.radioName;
radio.value = value;
radio.checked = value == this.value;
radio.addEventListener ('change', this._onRadioChange.bind (this, value));

View File

@ -22,7 +22,7 @@ module.exports = new Class
,set: function (x)
{
this.link ({_radioGroup: x}, {'changed': this._onRadioGroupChange});
this.node.name = x.name
this.node.name = x.radioName
this._onRadioGroupChange ();
}
,get: function ()
@ -36,7 +36,9 @@ module.exports = new Class
,render: function ()
{
var radio = Vn.Browser.createRadio ('', this.doc);
var radio = this.doc.createElement ('input');
radio.type = 'radio';
radio.name = '';
radio.checked = false;
radio.addEventListener ('change', this._onChange.bind (this));
this._node = radio;

View File

@ -7,7 +7,6 @@ module.exports = new Class
,render: function ()
{
var input = this.createRoot ('input');
//setInputTypeNumber (input);
this.node.type = 'number';
input.addEventListener ('change', this._onChange.bind (this));

View File

@ -53,8 +53,8 @@ module.exports = new Class
var scale = null;
var width = img.width;
var height = img.height;
var innerWidth = Vn.Browser.getInnerWidth () - 50;
var innerHeight = Vn.Browser.getInnerHeight () - 50;
var innerWidth = window.innerWidth - 50;
var innerHeight = window.innerHeight - 50;
if (width > innerWidth)
{

View File

@ -54,5 +54,13 @@ module.exports = new Class
{
return Object.keys (this._params);
}
,assign: function (object)
{
for (var key in object)
this._params[key] = object[key];
this.changed ();
}
});

View File

@ -1,42 +0,0 @@
module.exports =
{
getPageYOffset: function ()
{
return window.pageYOffset;
},
getPageXOffset: function ()
{
return window.pageXOffset;
},
getInnerHeight: function ()
{
return window.innerHeight;
},
getInnerWidth: function ()
{
return window.innerWidth;
},
createRadio: function (uid, doc)
{
var radio = doc.createElement ('input');
radio.type = 'radio';
radio.name = uid;
return radio;
},
setInputTypeNumber: function (input)
{
input.type = 'number';
}
};
if (!console.warn)
{
console.log (1);
console.warn = console.log;
}

View File

@ -55,46 +55,46 @@ module.exports = new Class
,set: function (key, value)
{
var map = {};
map[key] = value;
this.assign (map);
var object = {};
object[key] = value;
this.assign (object);
}
/**
* Sets the hash part of the URL, respecting the current hash variables.
*
* @param {Object} map A key-value map
* @param {Object} object A key-value object
*/
,assign: function (map)
,assign: function (object)
{
var newMap = this._hashMap;
var newObject = this._hashMap;
for (var key in map)
newMap[key] = map[key];
for (var key in object)
newObject[key] = object[key];
this.setAll (newMap);
this.setAll (newObject);
}
/**
* Sets the hash part of the URL.
*
* @param {Object} map A key-value map
* @param {Object} object A key-value object
*/
,setAll: function (map)
,setAll: function (object)
{
if (map)
for (var key in map)
if (map[key] === null || map[key] === undefined)
delete map[key];
if (object)
for (var key in object)
if (object[key] === null || object[key] === undefined)
delete object[key];
var newHash = this.make (map);
var newHash = this.make (object);
if (!map)
map = {};
if (!object)
object = {};
if (newHash !== this._hash)
{
this._hashMap = map;
this._hashMap = object;
this._hash = newHash;
this._blockChanged = true;
@ -108,25 +108,25 @@ module.exports = new Class
/**
* Creates a URL with the given hash data.
*
* @param {Object} map A key-value map
* @param {boolean} add %true to combine with the current map, %false otherwise
* @param {Object} object A key-value object
* @param {boolean} add %true to combine with the current params, %false otherwise
* @return {String} The URL
*/
,make: function (map, add)
,make: function (object, add)
{
var hash = '#!';
if (add && map)
if (add && object)
for (var key in this._hashMap)
if (!map[key])
map[key] = this._hashMap[key];
if (!object[key])
object[key] = this._hashMap[key];
for (var key in map)
for (var key in object)
{
if (hash.length > 2)
hash += '&';
hash += encodeURIComponent (key) +'='+ this.renderValue (map[key]);
hash += encodeURIComponent (key) +'='+ this.renderValue (object[key]);
}
return hash;

View File

@ -1,139 +0,0 @@
module.exports =
{
getPageYOffset: function ()
{
if (document.documentElement.scrollTop)
return document.documentElement.scrollTop;
else
return document.body.scrollTop;
},
getPageXOffset: function ()
{
if (document.documentElement.scrollLeft)
return document.documentElement.scrollLeft;
else
return document.body.scrollLeft;
},
getInnerHeight: function ()
{
if (document.documentElement.clientHeight)
return document.documentElement.clientHeight;
else
return document.body.clientHeight;
},
getInnerWidth: function ()
{
if (document.documentElement.clientWidth)
return document.documentElement.clientWidth;
else
return document.body.clientWidth;
},
createRadio: function (radioName)
{
var radio;
try {
radio = document.createElement ('<input type="radio" name="' + radioName + '">');
}
catch (e)
{
radio = document.createElement ('input');
radio.type = 'radio';
radio.name = radioName;
}
return radio;
},
setInputTypeNumber: function (input)
{
input.type = 'text';
}
};
if (!Function.bind)
{
Function.prototype.bind = function ()
{
var bindFunc = this;
var bindThis = arguments[0];
var bindArgs = arguments;
var IE_bind = function ()
{
var args = new Array ();
for (var i = 1; i < bindArgs.length; i++)
args.push (bindArgs[i]);
for (var i = 0; i < arguments.length; i++)
args.push (arguments[i]);
bindFunc.apply (bindThis, args);
}
return IE_bind;
}
}
// attachEvent -> addEventListener
if (window.attachEvent && !window.addEventListener)
{
function IE_addEventListener (signal, func, capture)
{
var obj = this;
func.IE_eventHandler = function (event)
{
event.target = event.srcElement;
event.layerY = event.clientY;
event.layerX = event.clientX;
event.pageX = event.offsetX;
event.pageY = event.offsetY;
event.stopPropagation = function ()
{
this.cancelBubble = true;
}
func.call (obj, event);
}
this.attachEvent ('on' + signal, func.IE_eventHandler);
}
function IE_removeEventListener (signal, func, capture)
{
this.detachEvent ('on' + signal, func.IE_eventHandler);
}
window.addEventListener = IE_addEventListener;
window.removeEventListener = IE_removeEventListener;
document.addEventListener = IE_addEventListener;
document.removeEventListener = IE_removeEventListener;
var IE_createElement = document.createElement;
document.createElement = function (tagName)
{
var node = IE_createElement (tagName);
node.addEventListener = IE_addEventListener;
node.removeEventListener = IE_removeEventListener;
return node;
}
}
// ActiveXObject ('Microsoft.XMLHTTP') -> XMLHttpRequest
if (!window.XMLHttpRequest && window.ActiveXObject)
{
function XMLHttpRequest ()
{
return new ActiveXObject ('Microsoft.XMLHTTP');
}
}

View File

@ -1,5 +1,5 @@
var Object = require ('./object');
var VnObject = require ('./object');
var JsonException = require ('./json-exception');
/**
@ -7,7 +7,7 @@ var JsonException = require ('./json-exception');
*/
module.exports = new Class
({
Extends: Object
Extends: VnObject
,_connected: false
,_requestsCount: 0
@ -54,9 +54,9 @@ module.exports = new Class
if (user !== null && user !== undefined)
{
var params = {
'user': user
,'password': pass
,'remember': remember
user: user,
password: pass,
remember: remember
};
}
else
@ -130,7 +130,7 @@ module.exports = new Class
this._onUserSupplant.bind (this, callback));
}
,_onUserSupplant: function (callback, json, error)
,_onUserSupplant: function (callback, json)
{
if (json)
this.token = json;
@ -278,12 +278,14 @@ module.exports = new Class
.replace (/^Vn\.Web\./, '');
var ex = new JsonException ();
ex.exception = exception;
ex.message = jsData.message;
ex.code = jsData.code;
ex.file = jsData.file;
ex.line = jsData.line;
ex.trace = jsData.trace;
Object.assign (ex, {
exception: exception,
message: jsData.message,
code: jsData.code,
file: jsData.file,
line: jsData.line,
trace: jsData.trace
});
throw ex;
}
}
@ -294,15 +296,15 @@ module.exports = new Class
}
if (callback)
try {
// try {
callback (data, error);
error = null;
/* error = null;
}
catch (e)
{
error = e;
}
*/
if (error)
{
if (error.exception == 'SessionExpired')

View File

@ -46,18 +46,19 @@ module.exports = new Class
/**
* Copies all values from another set.
*
* @param {Set} source The source set
* @param {Object} object The source object
*/
,assign: function (source, keys)
,assign: function (object)
{
if (!keys)
keys = source.keys ();
for (var key in object)
this.set (key, object[key]);
for (var i = 0; i < keys.length; i++)
{
var key = keys[i];
this.set (key, source.get (key));
this.changed ();
}
,assignLot: function (lot)
{
this.assign (lot.params);
}
});

29
js/vn/polyfills.js Normal file
View File

@ -0,0 +1,29 @@
/**
* Browser polyfills.
*/
if (!console.warn)
console.warn = console.log;
if (typeof Object.assign != 'function')
{
Object.assign = function (target)
{
if (target == null)
throw new TypeError ('Cannot convert undefined or null to object');
var to = Object (target);
for (var i = 1; i < arguments.length; i++)
{
var source = arguments[i];
if (source)
for (var key in source)
if (source.hasOwnProperty (key))
to[key] = nextSource[key];
}
return to;
};
}

View File

@ -1,17 +1,17 @@
require ('mootools');
require ('./mutators');
require ('./polyfills');
Vn = module.exports = {
Locale : require ('./locale')
,Enum : require ('./enum')
,Type : require ('./type')
,Object : require ('./object')
,Browser : require ('./browser')
,Cookie : require ('./cookie')
,Date : require ('./date')
,Value : require ('./value')
,Url : require ('./url')
,Mutators : require ('./mutators')
,Lot : require ('./lot')
,BasicLot : require ('./basic-lot')
,Hash : require ('./hash')

View File

@ -10,11 +10,19 @@ Hedera.ShelvesReport = new Class
,activate: function (lot)
{
this.title = lot.get ('reportTitle');
this.maxAmount = lot.get ('maxAmount');
this.showPacking = lot.get ('showPacking');
this.stack = lot.get ('stack');
this.useIds = lot.get ('useIds');
var params = lot.params;
Object.assign (this, {
title: params.reportTitle,
maxAmount: params.maxAmount,
showPacking: params.showPacking,
stack: params.stack,
useIds: params.useIds
})
var params = {
warehouse: params.warehouse,
}
var query =
'SELECT id, name, nTrays, topTrayHeight, trayHeight, width, depth '+
@ -29,16 +37,15 @@ Hedera.ShelvesReport = new Class
{
// Fetch query data
var res = resultSet.fetchResult ();
res.next ();
var row = resultSet.fetchObject ();
// Calculates the scale
var maxWidth = 160;
var maxHeight = 160;
var shelfWidth = res.get ('width');
var shelfHeight = res.get ('trayHeight') * (res.get ('nTrays') - 1) + res.get ('topTrayHeight');
var shelfWidth = row.width;
var shelfHeight = row.trayHeight * (row.nTrays - 1) + row.topTrayHeight;
var scale = maxWidth / shelfWidth;
@ -49,11 +56,11 @@ Hedera.ShelvesReport = new Class
var shelf = this.shelf =
{
nTrays: res.get ('nTrays')
,trayHeight: res.get ('trayHeight') * scale
,topTrayHeight: res.get ('topTrayHeight') * scale
,width: res.get ('width') * scale
,depth: res.get ('depth') * scale
nTrays: row.nTrays
,trayHeight: row.trayHeight * scale
,topTrayHeight: row.topTrayHeight * scale
,width: row.width * scale
,depth: row.depth * scale
};
// Gets the items
@ -70,41 +77,43 @@ Hedera.ShelvesReport = new Class
var boxScale = scale * 10;
while (res.next ())
if (!this.maxAmount || res.get ('etiquetas') <= this.maxAmount)
while (row = res.fetchObject ())
if (!this.maxAmount || row.etiquetas <= this.maxAmount)
{
items.push ({
id: res.get ('Id_Article')
,name: res.get ('Article')
,packing: res.get ('packing')
,amount: res.get ('etiquetas')
,boxHeight: res.get ('z') * boxScale
,boxWidth: res.get ('x') * boxScale
,boxDepth: res.get ('y') * boxScale
id: row.Id_Article
,name: row.Article
,packing: row.packing
,amount: row.etiquetas
,boxHeight: row.z * boxScale
,boxWidth: row.x * boxScale
,boxDepth: row.y * boxScale
});
}
else
{
remainings.push ({
id: res.get ('Id_Article')
,name: res.get ('Article')
,packing: res.get ('packing')
,amount: res.get ('etiquetas')
id: row.Id_Article
,name: row.Article
,packing: row.packing
,amount: row.etiquetas
});
}
// Intializes the allocator
alloc = this.alloc = new Vn.Allocator ();
alloc.items = items;
alloc.shelfFunc = this.drawShelf.bind (this);
alloc.boxFunc = this.drawBox.bind (this);
alloc.stack = this.stack;
alloc.nTrays = shelf.nTrays;
alloc.width = shelf.width;
alloc.depth = shelf.depth;
alloc.trayHeight = shelf.trayHeight;
alloc.topTrayHeight = shelf.topTrayHeight;
Object.assign (alloc, {
items: items,
shelfFunc: this.drawShelf.bind (this),
boxFunc: this.drawBox.bind (this),
stack: this.stack,
nTrays: shelf.nTrays,
width: shelf.width,
depth: shelf.depth,
trayHeight: shelf.trayHeight,
topTrayHeight: shelf.topTrayHeight,
});
// Opens the report