DB refactor

This commit is contained in:
Juan Ferrer Toribio 2018-01-02 14:16:41 +01:00
parent bc083a94e6
commit 52a0b588ec
21 changed files with 98 additions and 127 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.405.58) stable; urgency=low hedera-web (1.405.59) stable; urgency=low
* Initial Release. * Initial Release.

View File

@ -5,15 +5,15 @@ Hedera.AddressList = new Class
,activate: function () ,activate: function ()
{ {
this.$('user-model').setInfo ('c', 'customer_view', 'hedera'); this.$('user-model').setInfo ('c', 'myClient', 'hedera');
this.$('addresses').setInfo ('a', 'address_view', 'hedera'); this.$('addresses').setInfo ('a', 'myAddress', 'hedera');
} }
,onAddAddressClick: function () ,onAddAddressClick: function ()
{ {
this.hash.set ({ this.hash.set ({
'form': 'account/address', form: 'account/address',
'address': 0 address: 0
}); });
} }
@ -34,8 +34,8 @@ Hedera.AddressList = new Class
,onEditAddressClick: function (button, form) ,onEditAddressClick: function (button, form)
{ {
this.hash.set ({ this.hash.set ({
'form': 'account/address', form: 'account/address',
'address': form.get ('id') address: form.get ('id')
}); });
} }
}); });

View File

@ -3,19 +3,19 @@
<db-form id="user-form"> <db-form id="user-form">
<db-model property="model" id="user-model" updatable="true"> <db-model property="model" id="user-model" updatable="true">
<custom> <custom>
SELECT user_id, default_address SELECT id, defaultAddressFk
FROM customer_view c FROM myClient c
</custom> </custom>
</db-model> </db-model>
</db-form> </db-form>
<db-model id="addresses" updatable="true"> <db-model id="addresses" updatable="true">
<custom> <custom>
SELECT a.id, a.consignee, p.name province, a.zip_code, SELECT a.id, a.nickname, p.name province, a.postalCode,
a.city, a.name, a.active, c.Pais country a.city, a.street, a.active, c.country
FROM address_view a FROM myAddress a
LEFT JOIN vn2008.province p ON a.province_id = p.province_id LEFT JOIN vn.province p ON p.id = a.provinceFk
JOIN vn2008.Paises c ON c.Id = p.Paises_Id JOIN vn.country c ON c.id = p.countryFk
WHERE active != FALSE WHERE a.active != FALSE
</custom> </custom>
</db-model> </db-model>
</vn-group> </vn-group>
@ -32,7 +32,7 @@
<div class="box"> <div class="box">
<htk-radio-group <htk-radio-group
id="default-address" id="default-address"
column="default_address" column="defaultAddressFk"
form="user-form"/> form="user-form"/>
<htk-repeater model="addresses" form-id="iter"> <htk-repeater model="addresses" form-id="iter">
<custom> <custom>
@ -57,13 +57,13 @@
on-click="onEditAddressClick"/> on-click="onEditAddressClick"/>
</div> </div>
<p class="important"> <p class="important">
<htk-text form="iter" column="consignee"/> <htk-text form="iter" column="nickname"/>
</p> </p>
<p> <p>
<htk-text form="iter" column="name"/> <htk-text form="iter" column="street"/>
</p> </p>
<p> <p>
<htk-text form="iter" column="zip_code"/>, <htk-text form="iter" column="postalCode"/>,
<htk-text form="iter" column="city"/> <htk-text form="iter" column="city"/>
</p> </p>
</div> </div>

View File

@ -5,8 +5,8 @@ Hedera.Address = new Class
,activate: function () ,activate: function ()
{ {
this.$('model').setInfo ('a', 'address_view', 'hedera', ['id'], 'id'); this.$('model').setInfo ('a', 'myAddress', 'hedera', ['id'], 'id');
this.$('model').setDefault ('customer_id', 'a', this.$('model').setDefault ('clientFk', 'a',
new Sql.Function ({schema: 'account', name: 'userGetId'})); new Sql.Function ({schema: 'account', name: 'userGetId'}));
} }

View File

@ -10,11 +10,12 @@
mode="ON_DEMAND" mode="ON_DEMAND"
on-operations-done="onOperationsDone"> on-operations-done="onOperationsDone">
<custom> <custom>
SELECT a.id, a.name, a.consignee, a.city, a.zip_code, a.province_id, c.Id country_id SELECT a.id, a.street, a.nickname, a.city,
FROM address_view a a.postalCode, a.provinceFk, c.id countryFk
LEFT JOIN vn2008.province p ON p.province_id = a.province_id FROM myAddress a
JOIN vn2008.Paises c ON c.Id = p.Paises_Id LEFT JOIN vn.province p ON p.id = a.provinceFk
WHERE active != FALSE AND a.id = #address JOIN vn.country c ON c.id = p.countryFk
WHERE a.active AND a.id = #address
</custom> </custom>
<sql-batch property="batch"> <sql-batch property="batch">
<custom> <custom>
@ -42,11 +43,11 @@
<div class="form"> <div class="form">
<div class="form-group"> <div class="form-group">
<label><t>Name</t></label> <label><t>Name</t></label>
<htk-entry column="consignee" form="iter"/> <htk-entry column="nickname" form="iter"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>Address</t></label> <label><t>Address</t></label>
<htk-entry column="name" form="iter"/> <htk-entry column="street" form="iter"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>City</t></label> <label><t>City</t></label>
@ -54,7 +55,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>ZipCode</t></label> <label><t>ZipCode</t></label>
<htk-entry column="zip_code" form="iter"/> <htk-entry column="postalCode" form="iter"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>Country</t></label> <label><t>Country</t></label>
@ -63,23 +64,23 @@
id="country" id="country"
property="param" property="param"
form="iter" form="iter"
column="country_id" column="countryFk"
one-way="true"/> one-way="true"/>
<db-model property="model"> <db-model property="model">
<custom> <custom>
SELECT Id, Pais FROM vn2008.Paises SELECT id, country FROM vn.country
ORDER BY Pais ORDER BY country
</custom> </custom>
</db-model> </db-model>
</htk-combo> </htk-combo>
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>Province</t></label> <label><t>Province</t></label>
<htk-combo column="province_id" form="iter"> <htk-combo column="provinceFk" form="iter">
<db-model property="model"> <db-model property="model">
<custom> <custom>
SELECT province_id, name FROM vn2008.province SELECT id, name FROM vn.province
WHERE Paises_Id = #country WHERE countryFk = #country
ORDER BY name ORDER BY name
</custom> </custom>
<sql-batch property="batch"> <sql-batch property="batch">

View File

@ -5,8 +5,7 @@ Hedera.Conf = new Class
,activate: function () ,activate: function ()
{ {
this.$('user-model').setInfo ('c', 'customer_view', 'hedera'); this.$('user-model').setInfo ('c', 'myClient', 'hedera');
this.$('addresses').setInfo ('a', 'address_view', 'hedera');
} }
,onPassChangeClick: function () ,onPassChangeClick: function ()
@ -38,8 +37,8 @@ Hedera.Conf = new Class
throw new Error (_('Passwords doesn\'t match')); throw new Error (_('Passwords doesn\'t match'));
var params = { var params = {
'oldPassword': oldPassword, oldPassword: oldPassword,
'newPassword': newPassword newPassword: newPassword
}; };
this.conn.send ('core/change-password', params, this.conn.send ('core/change-password', params,
this._onPassChange.bind (this)); this._onPassChange.bind (this));
@ -72,7 +71,7 @@ Hedera.Conf = new Class
,onAddressesClick: function () ,onAddressesClick: function ()
{ {
this.hash.set ({'form': 'account/address-list'}); this.hash.set ({form: 'account/address-list'});
} }
}); });

View File

@ -12,23 +12,13 @@
<db-model property="model" id="user-model" updatable="true"> <db-model property="model" id="user-model" updatable="true">
<custom> <custom>
SELECT u.id, u.name, u.email, u.recoverPass, SELECT u.id, u.name, u.email, u.recoverPass,
u.nickname, u.lang, c.mail, c.user_id u.nickname, u.lang, c.isToBeMailed, c.id clientFk
FROM account.userView u FROM account.userView u
LEFT JOIN customer_view c LEFT JOIN myClient c
ON u.id = c.user_id ON u.id = c.id
</custom> </custom>
</db-model> </db-model>
</db-form> </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> </vn-group>
<div id="title"> <div id="title">
<h1><t>Configuration</t></h1> <h1><t>Configuration</t></h1>
@ -70,7 +60,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="mail"><t>Receive invoices by email</t></label> <label for="mail"><t>Receive invoices by email</t></label>
<htk-check form="user-form" column="mail"/> <htk-check form="user-form" column="isToBeMailed"/>
</div> </div>
</div> </div>
</div> </div>

View File

@ -24,7 +24,7 @@ Hedera.Orders = new Class
{ {
res.$('link').href = this.hash.make ({ res.$('link').href = this.hash.make ({
form: 'ecomerce/ticket', form: 'ecomerce/ticket',
ticket: form.get ('ticket_id') ticket: form.get ('id')
}); });
} }

View File

@ -44,7 +44,7 @@
<htk-repeater form-id="iter" renderer="repeaterFunc"> <htk-repeater form-id="iter" renderer="repeaterFunc">
<db-model property="model" id="tickets"> <db-model property="model" id="tickets">
<custom> <custom>
CALL ticket_list (); CALL myTicketList (NULL, NULL);
</custom> </custom>
</db-model> </db-model>
<custom> <custom>
@ -53,16 +53,16 @@
<htk-text form="iter" column="total" format="%.2d€"/> <htk-text form="iter" column="total" format="%.2d€"/>
</p> </p>
<p class="important"> <p class="important">
<htk-text form="iter" column="date" format="%D"/> <htk-text form="iter" column="landed" format="%D"/>
</p> </p>
<p> <p>
@<htk-text form="iter" column="ticket_id"/> @<htk-text form="iter" column="id"/>
</p> </p>
<p> <p>
<htk-text form="iter" column="consignee"/> <htk-text form="iter" column="nickname"/>
</p> </p>
<p> <p>
<htk-text form="iter" column="type"/> <htk-text form="iter" column="agency"/>
</p> </p>
<div class="clear"/> <div class="clear"/>
</a> </a>

View File

@ -5,6 +5,7 @@
,"Delivery": "Entrega" ,"Delivery": "Entrega"
,"Total": "Total" ,"Total": "Total"
,"Total + tax": "Total + IVA"
,"Tax base": "Base imposable" ,"Tax base": "Base imposable"
,"VAT": "IVA" ,"VAT": "IVA"

View File

@ -5,6 +5,7 @@
,"Delivery": "Delivery" ,"Delivery": "Delivery"
,"Total": "Total" ,"Total": "Total"
,"Total + tax": "Total + tax"
,"Tax base": "Tax base" ,"Tax base": "Tax base"
,"VAT": "VAT" ,"VAT": "VAT"

View File

@ -5,6 +5,7 @@
,"Delivery": "Entrega" ,"Delivery": "Entrega"
,"Total": "Total" ,"Total": "Total"
,"Total + tax": "Total + IVA"
,"Tax base": "Base imponible" ,"Tax base": "Base imponible"
,"VAT": "IVA" ,"VAT": "IVA"

View File

@ -5,6 +5,7 @@
,"Delivery": "Livraison" ,"Delivery": "Livraison"
,"Total": "Total" ,"Total": "Total"
,"Total + tax": "Total + impôt"
,"Tax base": "Imposable" ,"Tax base": "Imposable"
,"VAT": "TVA" ,"VAT": "TVA"

View File

@ -5,6 +5,7 @@
,"Delivery": "Delivery" ,"Delivery": "Delivery"
,"Total": "Total" ,"Total": "Total"
,"Total + tax": "Total + tax"
,"Tax base": "Tax base" ,"Tax base": "Tax base"
,"VAT": "VAT" ,"VAT": "VAT"

View File

@ -5,6 +5,7 @@
,"Delivery": "Entrega" ,"Delivery": "Entrega"
,"Total": "Total" ,"Total": "Total"
,"Total + tax": "Total + imposto"
,"Tax base": "Tributável" ,"Tax base": "Tributável"
,"VAT": "IVA" ,"VAT": "IVA"

View File

@ -10,10 +10,10 @@ Hedera.Ticket = new Class
var batch = new Sql.Batch (); var batch = new Sql.Batch ();
batch.addValue ('ticket', ticket.value); batch.addValue ('ticket', ticket.value);
this.conn.execQuery ('CALL ticketLog (#ticket)', null, batch); this.conn.execQuery ('CALL myTicketLogAccess (#ticket)', null, batch);
} }
,onPrintClick: function (event) ,onPrintClick: function ()
{ {
var batch = new Sql.Batch (); var batch = new Sql.Batch ();
batch.addValue ('ticket', this.$('ticket-id').value); batch.addValue ('ticket', this.$('ticket-id').value);
@ -34,11 +34,7 @@ Hedera.Ticket = new Class
{ {
var price = form.get ('price'); var price = form.get ('price');
var discount = form.get ('discount'); var discount = form.get ('discount');
return form.get ('quantity') * price * ((100 - discount) / 100);
if (price && form.get ('fixed'))
return form.get ('amount') * price * ((100 - discount) / 100);
else
return null;
} }
}); });

View File

@ -5,13 +5,7 @@
<db-form id="ticket"> <db-form id="ticket">
<db-model id="ticket-data" property="model"> <db-model id="ticket-data" property="model">
<custom> <custom>
SELECT t.id, date, a.Agencia, note, p.name province, CALL myTicketGet (#ticket)
zip_code, city, c.name, consignee, invoice, delivery
FROM ticket_view t
JOIN address_view c ON t.address_id = c.id
JOIN vn2008.Agencias a ON t.agency_id = a.Id_Agencia
JOIN vn2008.province p ON c.province_id = p.province_id
WHERE t.id = #ticket
</custom> </custom>
<sql-batch property="batch"> <sql-batch property="batch">
<custom> <custom>
@ -38,21 +32,21 @@
<htk-text column="id" form="ticket"/> <htk-text column="id" form="ticket"/>
</p> </p>
<p> <p>
<htk-text form="ticket" column="delivery" format="%D"/> <htk-text form="ticket" column="landed" format="%D"/>
</p> </p>
</div> </div>
<div> <div>
<p> <p>
<t>Delivery</t> <htk-text form="ticket" column="Agencia"/> <t>Delivery</t> <htk-text form="ticket" column="agency"/>
</p> </p>
<p> <p>
<htk-text form="ticket" column="consignee"/> <htk-text form="ticket" column="nickname"/>
</p> </p>
<p> <p>
<htk-text form="ticket" column="name"/> <htk-text form="ticket" column="street"/>
</p> </p>
<p> <p>
<htk-text form="ticket" column="zip_code"/> <htk-text form="ticket" column="postalCode"/>
<htk-text form="ticket" column="city"/> <htk-text form="ticket" column="city"/>
(<htk-text form="ticket" column="province"/>) (<htk-text form="ticket" column="province"/>)
</p> </p>
@ -60,23 +54,18 @@
<div> <div>
<p class="important total"> <p class="important total">
<t>Total</t> <t>Total</t>
<htk-text format="%.2d€"> <htk-text format="%.2d€" form="ticket" column="taxBase"/>
<db-calc-sum property="param" func="subtotal" model="movements"/> </p>
</htk-text> <p class="important total">
<t>Total + tax</t>
<htk-text format="%.2d€" form="ticket" column="total"/>
</p> </p>
</div> </div>
</div> </div>
<htk-repeater form-id="iter" renderer="repeaterFunc"> <htk-repeater form-id="iter" renderer="repeaterFunc">
<db-model property="model" id="movements"> <db-model property="model" id="movements">
<custom> <custom>
SELECT m.item_id, amount, concept, Categoria, Medida, Tallos, Color, CALL myTicketGetRows (#ticket)
Abreviatura, IF(fixed != FALSE, price, NULL) price, fixed, discount
FROM ticket_row_view m
INNER JOIN vn2008.Articles a
ON m.item_id = a.Id_Article AND ticket_id = #ticket
LEFT JOIN vn2008.Origen o
ON a.id_origen = o.id
ORDER BY concept
</custom> </custom>
<sql-batch property="batch"> <sql-batch property="batch">
<custom> <custom>
@ -88,11 +77,11 @@
<div class="line"> <div class="line">
<p class="concept"> <p class="concept">
<htk-text form="iter" column="concept"/> <htk-text form="iter" column="concept"/>
<htk-text form="iter" column="Medida"/> <htk-text form="iter" column="size"/>
<htk-text form="iter" column="Categoria"/> <htk-text form="iter" column="category"/>
</p> </p>
<p class="amount"> <p class="amount">
<htk-text form="iter" column="amount"/> x <htk-text form="iter" column="quantity"/> x
<htk-text form="iter" column="price" format="%.2d€"/> <htk-text form="iter" column="price" format="%.2d€"/>
</p> </p>
<p class="subtotal"> <p class="subtotal">

View File

@ -1,6 +1,6 @@
{ {
"name": "hedera-web", "name": "hedera-web",
"version": "1.405.58", "version": "1.405.59",
"description": "Verdnatura web page", "description": "Verdnatura web page",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {

View File

@ -12,10 +12,6 @@ Hedera.DeliveryNote = new Class
{ {
var price = form.get ('price'); var price = form.get ('price');
var discount = form.get ('discount'); var discount = form.get ('discount');
return form.get ('quantity') * price * ((100 - discount) / 100);
if (price && form.get ('fixed'))
return form.get ('amount') * price * ((100 - discount) / 100);
else
return null;
} }
}); });

View File

@ -21,13 +21,16 @@ h2
text-align: right; text-align: right;
margin: .1em 0; margin: .1em 0;
} }
.footer .important
{ {
font-size: 1.2em; font-size: 1.2em;
font-weight: bold; font-weight: bold;
text-align: right;
}
.footer
{
margin-top: .2em; margin-top: .2em;
border-top: 1px solid #333; border-top: 1px solid #333;
padding-top: .3em; padding-top: .3em;
text-align: right;
} }

View File

@ -3,13 +3,7 @@
<db-form id="ticket"> <db-form id="ticket">
<db-model property="model" id="ticket-data" conn="conn" batch="batch"> <db-model property="model" id="ticket-data" conn="conn" batch="batch">
<custom> <custom>
SELECT t.id, date, a.Agencia, note, p.name province, CALL myTicketGet (#ticket)
zip_code, city, c.name, consignee, invoice
FROM ticket_view t
JOIN address_view c ON t.address_id = c.id
JOIN vn2008.Agencias a ON t.agency_id = a.Id_Agencia
JOIN vn2008.province p ON c.province_id = p.province_id
WHERE t.id = #ticket
</custom> </custom>
</db-model> </db-model>
</db-form> </db-form>
@ -20,48 +14,45 @@
</h2> </h2>
<div class="header"> <div class="header">
<p> <p>
<htk-text form="ticket" column="consignee"/> <htk-text form="ticket" column="nickname"/>
</p> </p>
<p> <p>
<htk-text form="ticket" column="date" format="%D"/> <htk-text form="ticket" column="landed" format="%D"/>
</p> </p>
<p> <p>
<htk-text form="ticket" column="name"/> <htk-text form="ticket" column="street"/>
</p> </p>
<p> <p>
<htk-text form="ticket" column="zip_code"/> <htk-text form="ticket" column="postalCode"/>
<htk-text form="ticket" column="city"/> <htk-text form="ticket" column="city"/>
(<htk-text form="ticket" column="province"/>) (<htk-text form="ticket" column="province"/>) aaa
</p> </p>
<p> <p>
<t>Delivery</t> <htk-text form="ticket" column="Agencia"/> <t>Delivery</t> <htk-text form="ticket" column="agency"/>
</p> </p>
</div> </div>
<htk-grid> <htk-grid>
<db-model property="model" id="movements" conn="conn" batch="batch"> <db-model property="model" id="movements" conn="conn" batch="batch">
<custom> <custom>
SELECT m.item_id, amount, concept, Categoria, Medida, Tallos, Color, CALL myTicketGetRows (#ticket)
Abreviatura, IF(fixed != FALSE, price, NULL) price, fixed, discount
FROM ticket_row_view m
INNER JOIN vn2008.Articles a
ON m.item_id = a.Id_Article AND ticket_id = #ticket
LEFT JOIN vn2008.Origen o
ON a.id_origen = o.id
ORDER BY concept
</custom> </custom>
</db-model> </db-model>
<htk-column-spin title="_Ref" column="item_id"/> <htk-column-spin title="_Ref" column="itemFk"/>
<htk-column-spin title="_Amount" column="amount"/> <htk-column-spin title="_Amount" column="quantity"/>
<htk-column-text title="_Item" column="concept"/> <htk-column-text title="_Item" column="concept"/>
<htk-column-text title="_S1" column="Medida"/> <htk-column-text title="_S1" column="size"/>
<htk-column-text title="_Cat" column="Categoria"/> <htk-column-text title="_Cat" column="category"/>
<htk-column-spin title="_Price" column="price" unit="€" digits="2"/> <htk-column-spin title="_Price" column="price" unit="€" digits="2"/>
<htk-column-spin title="_Subtotal" unit="€" digits="2" renderer="subtotalRenderer"/> <htk-column-spin title="_Subtotal" unit="€" digits="2" renderer="subtotalRenderer"/>
</htk-grid> </htk-grid>
<p class="footer"> <p class="footer important">
<htk-text format="%.2d€"> <htk-text format="%.2d€">
<db-calc-sum property="param" func="subtotal" model="movements"/> <db-calc-sum property="param" func="subtotal" model="movements"/>
</htk-text> </htk-text>
</p> </p>
<p class="important">
<t>Total + tax</t>
<htk-text format="%.2d€" form="ticket" column="total"/>
</p>
</div> </div>
</vn> </vn>