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-redeclare: 0
no-mixed-spaces-and-tabs: 0 no-mixed-spaces-and-tabs: 0
no-console: 0 no-console: 0
no-cond-assign: 0

View File

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

View File

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

View File

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

View File

@ -5,19 +5,20 @@ Hedera.Shelves = new Class
,activate: function () ,activate: function ()
{ {
var set = this.$('set'); this.$('lot').assign ({
set.set ('date', new Date ()); date: new Date (),
set.set ('useIds', false); useIds: false
});
} }
,onConfigChange: function () ,onConfigChange: function ()
{ {
this.$('set').assign (this.$('config')); this.$('lot').assignLot (this.$('config'));
} }
,onShowClick: function () ,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>
<vn-basic-set id="set"/> <vn-basic-set id="lot"/>
<h1 id="title"> <h1 id="title">
<t>Shelves</t> <t>Shelves</t>
</h1> </h1>
@ -29,11 +29,11 @@
</div> </div>
<div> <div>
<label><t>Date</t></label> <label><t>Date</t></label>
<htk-date-chooser lot="set" name="date"/> <htk-date-chooser lot="lot" name="date"/>
</div> </div>
<div> <div>
<label><t>Reign</t></label> <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"> <db-model property="model">
SELECT id, reino FROM vn2008.reinos SELECT id, reino FROM vn2008.reinos
WHERE display != FALSE ORDER BY reino WHERE display != FALSE ORDER BY reino
@ -42,7 +42,7 @@
</div> </div>
<div> <div>
<label><t>Family</t></label> <label><t>Family</t></label>
<htk-combo lot="set" name="family"> <htk-combo lot="lot" name="family">
<db-model property="model" lot="config"> <db-model property="model" lot="config">
SELECT tipo_id, Tipo FROM vn2008.Tipos SELECT tipo_id, Tipo FROM vn2008.Tipos
WHERE reino_id = #realm ORDER BY Tipo WHERE reino_id = #realm ORDER BY Tipo
@ -51,7 +51,7 @@
</div> </div>
<div> <div>
<label><t>Store</t></label> <label><t>Store</t></label>
<htk-combo lot="set" name="warehouse"> <htk-combo lot="lot" name="warehouse">
<db-model property="model"> <db-model property="model">
SELECT id, name FROM vn2008.warehouse SELECT id, name FROM vn2008.warehouse
WHERE reserve ORDER BY name WHERE reserve ORDER BY name
@ -60,7 +60,7 @@
</div> </div>
<div> <div>
<label><t>Shelf</t></label> <label><t>Shelf</t></label>
<htk-combo lot="set" name="shelf"> <htk-combo lot="lot" name="shelf">
<db-model property="model"> <db-model property="model">
SELECT id, name FROM shelf SELECT id, name FROM shelf
</db-model> </db-model>
@ -68,27 +68,27 @@
</div> </div>
<div> <div>
<label><t>Name prefix</t></label> <label><t>Name prefix</t></label>
<htk-entry lot="set" name="namePrefix"/> <htk-entry lot="lot" name="namePrefix"/>
</div> </div>
<div> <div>
<label><t>Limit amount per item</t></label> <label><t>Limit amount per item</t></label>
<htk-entry lot="set" name="maxAmount"/> <htk-entry lot="lot" name="maxAmount"/>
</div> </div>
<div> <div>
<label><t>Title</t></label> <label><t>Title</t></label>
<htk-entry lot="set" name="reportTitle"/> <htk-entry lot="lot" name="reportTitle"/>
</div> </div>
<div> <div>
<label><t>Show packing</t></label> <label><t>Show packing</t></label>
<htk-check lot="set" name="showPacking"/> <htk-check lot="lot" name="showPacking"/>
</div> </div>
<div> <div>
<label><t>Stack different items</t></label> <label><t>Stack different items</t></label>
<htk-check lot="set" name="stack"/> <htk-check lot="lot" name="stack"/>
</div> </div>
<div> <div>
<label><t>Use ids instead of names</t></label> <label><t>Use ids instead of names</t></label>
<htk-check lot="set" name="useIds"/> <htk-check lot="lot" name="useIds"/>
</div> </div>
</div> </div>
</div> </div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -73,6 +73,21 @@ module.exports = new Class
{ {
return this._ready; 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 module.exports = new Class
({ ({
Properties: Implements: Vn.Lot
,Properties:
{ {
/** /**
* The model associated to this form. * The model associated to this form.
@ -26,6 +27,30 @@ module.exports = new Class
{ {
type: Number 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. * Checks if the form data is ready.
*/ */
@ -44,14 +69,6 @@ module.exports = new Class
this._model.refresh (); this._model.refresh ();
} }
/**
* Emits the 'change' signal on the form.
*/
,changed: function ()
{
this.signalEmit ('change');
}
/** /**
* Get the index of the column from its name. * Get the index of the column from its name.
* *
@ -95,7 +112,10 @@ module.exports = new Class
*/ */
,get: function (columnName) ,get: function (columnName)
{ {
return this._model.get (this._row, columnName); if (this._model)
return this._model.get (this._row, columnName);
return undefined;
} }
/** /**
@ -133,10 +153,24 @@ module.exports = new Class
,keys: function () ,keys: function ()
{ {
if (this._model) if (this._model && this._model.ready)
return Object.keys (this._model.columnMap); return Object.keys (this._model.columnMap);
return []; 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); 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) ,appendChild: function (child)
{ {
if (child.nodeType === Node.TEXT_NODE) if (child.nodeType === Node.TEXT_NODE)
@ -316,10 +303,13 @@ Model.implement
if (!this._lot) if (!this._lot)
return false; return false;
var lotParams = this._lot.params; var params = this._lot.params;
if (!params)
return false;
for (var i = 0; i < ids.length; i++) for (var i = 0; i < ids.length; i++)
if (lotParams[ids[i]] === undefined) if (params[ids[i]] === undefined)
return false; return false;
return true; return true;

View File

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

View File

@ -60,6 +60,21 @@ module.exports = new Class
return null; 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. * Fetchs the first row from the next resultset.
* *

View File

@ -8,10 +8,12 @@ module.exports = new Class
*/ */
initialize: function (result) initialize: function (result)
{ {
this.data = result.data; Object.assign (this, {
this.tables = result.tables; data: result.data,
this.columns = result.columns; tables: result.tables,
this.row = -1; columns: result.columns,
row: -1
});
if (this.columns) if (this.columns)
{ {
@ -36,6 +38,36 @@ module.exports = new Class
return this.data[this.row][columnIndex]; 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. * Resets the result iterator.
*/ */

View File

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

View File

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

View File

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

View File

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

View File

@ -106,6 +106,21 @@ module.exports = new Class
{ {
return this._notNull; 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 () ,clear: function ()
{ {
this.name = Math.random ().toString (); this.radioName = Math.random ().toString ();
this.buttons = []; this.buttons = [];
} }
@ -38,7 +38,9 @@ module.exports = new Class
,createButton: function (value) ,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.value = value;
radio.checked = value == this.value; radio.checked = value == this.value;
radio.addEventListener ('change', this._onRadioChange.bind (this, value)); radio.addEventListener ('change', this._onRadioChange.bind (this, value));

View File

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

View File

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

View File

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

View File

@ -54,5 +54,13 @@ module.exports = new Class
{ {
return Object.keys (this._params); 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) ,set: function (key, value)
{ {
var map = {}; var object = {};
map[key] = value; object[key] = value;
this.assign (map); this.assign (object);
} }
/** /**
* Sets the hash part of the URL, respecting the current hash variables. * 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) for (var key in object)
newMap[key] = map[key]; newObject[key] = object[key];
this.setAll (newMap); this.setAll (newObject);
} }
/** /**
* Sets the hash part of the URL. * 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) if (object)
for (var key in map) for (var key in object)
if (map[key] === null || map[key] === undefined) if (object[key] === null || object[key] === undefined)
delete map[key]; delete object[key];
var newHash = this.make (map); var newHash = this.make (object);
if (!map) if (!object)
map = {}; object = {};
if (newHash !== this._hash) if (newHash !== this._hash)
{ {
this._hashMap = map; this._hashMap = object;
this._hash = newHash; this._hash = newHash;
this._blockChanged = true; this._blockChanged = true;
@ -108,25 +108,25 @@ module.exports = new Class
/** /**
* Creates a URL with the given hash data. * Creates a URL with the given hash data.
* *
* @param {Object} map A key-value map * @param {Object} object A key-value object
* @param {boolean} add %true to combine with the current map, %false otherwise * @param {boolean} add %true to combine with the current params, %false otherwise
* @return {String} The URL * @return {String} The URL
*/ */
,make: function (map, add) ,make: function (object, add)
{ {
var hash = '#!'; var hash = '#!';
if (add && map) if (add && object)
for (var key in this._hashMap) for (var key in this._hashMap)
if (!map[key]) if (!object[key])
map[key] = this._hashMap[key]; object[key] = this._hashMap[key];
for (var key in map) for (var key in object)
{ {
if (hash.length > 2) if (hash.length > 2)
hash += '&'; hash += '&';
hash += encodeURIComponent (key) +'='+ this.renderValue (map[key]); hash += encodeURIComponent (key) +'='+ this.renderValue (object[key]);
} }
return hash; 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'); var JsonException = require ('./json-exception');
/** /**
@ -7,7 +7,7 @@ var JsonException = require ('./json-exception');
*/ */
module.exports = new Class module.exports = new Class
({ ({
Extends: Object Extends: VnObject
,_connected: false ,_connected: false
,_requestsCount: 0 ,_requestsCount: 0
@ -54,9 +54,9 @@ module.exports = new Class
if (user !== null && user !== undefined) if (user !== null && user !== undefined)
{ {
var params = { var params = {
'user': user user: user,
,'password': pass password: pass,
,'remember': remember remember: remember
}; };
} }
else else
@ -130,7 +130,7 @@ module.exports = new Class
this._onUserSupplant.bind (this, callback)); this._onUserSupplant.bind (this, callback));
} }
,_onUserSupplant: function (callback, json, error) ,_onUserSupplant: function (callback, json)
{ {
if (json) if (json)
this.token = json; this.token = json;
@ -278,12 +278,14 @@ module.exports = new Class
.replace (/^Vn\.Web\./, ''); .replace (/^Vn\.Web\./, '');
var ex = new JsonException (); var ex = new JsonException ();
ex.exception = exception; Object.assign (ex, {
ex.message = jsData.message; exception: exception,
ex.code = jsData.code; message: jsData.message,
ex.file = jsData.file; code: jsData.code,
ex.line = jsData.line; file: jsData.file,
ex.trace = jsData.trace; line: jsData.line,
trace: jsData.trace
});
throw ex; throw ex;
} }
} }
@ -294,15 +296,15 @@ module.exports = new Class
} }
if (callback) if (callback)
try { // try {
callback (data, error); callback (data, error);
error = null; /* error = null;
} }
catch (e) catch (e)
{ {
error = e; error = e;
} }
*/
if (error) if (error)
{ {
if (error.exception == 'SessionExpired') if (error.exception == 'SessionExpired')

View File

@ -46,18 +46,19 @@ module.exports = new Class
/** /**
* Copies all values from another set. * 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) for (var key in object)
keys = source.keys (); this.set (key, object[key]);
for (var i = 0; i < keys.length; i++) this.changed ();
{ }
var key = keys[i];
this.set (key, source.get (key)); ,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 ('mootools');
require ('./mutators');
require ('./polyfills');
Vn = module.exports = { Vn = module.exports = {
Locale : require ('./locale') Locale : require ('./locale')
,Enum : require ('./enum') ,Enum : require ('./enum')
,Type : require ('./type') ,Type : require ('./type')
,Object : require ('./object') ,Object : require ('./object')
,Browser : require ('./browser')
,Cookie : require ('./cookie') ,Cookie : require ('./cookie')
,Date : require ('./date') ,Date : require ('./date')
,Value : require ('./value') ,Value : require ('./value')
,Url : require ('./url') ,Url : require ('./url')
,Mutators : require ('./mutators')
,Lot : require ('./lot') ,Lot : require ('./lot')
,BasicLot : require ('./basic-lot') ,BasicLot : require ('./basic-lot')
,Hash : require ('./hash') ,Hash : require ('./hash')

View File

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