0
1
Fork 0

Version aplha5 del bionic

This commit is contained in:
Juan Ferrer Toribio 2015-07-17 16:34:42 +02:00
parent e460b4595f
commit 06349730e8
20 changed files with 335 additions and 107 deletions

View File

@ -1,26 +1,59 @@
/* News panel */
.home
{
padding: 1em;
margin: .5em;
}
.home .column
.column
{
max-width: 40em;
max-width: 120em;
margin: 0 auto;
text-align: center;
}
/* New */
.new-container
{
display: inline-block;
vertical-align: top;
}/*
.new-container:nth-child(2n+0)
{
float: right;
}*/
@media screen and (min-width: 300px)
{
.new-container { width: 100%; }
}
@media screen and (min-width: 700px)
{
.new-container { width: 50%; }
}
@media screen and (min-width: 1300px)
{
.new-container { width: 33.3%; }
}
@media screen and (min-width: 2000px)
{
.new-container { width: 25%; }
}
.new
{
padding: 2em;
text-align: left;
background-color: white;
color: #222;
border: none;
border-radius: 0.1em;
box-shadow: 0 0.2em 0.2em #CCC;
margin-bottom: 1em;
margin: .5em;
}
.new .top
{
padding: 1.5em;
padding-bottom: 1em;
}
/* New */
.new h2
{
font-size: 1.6em;
@ -46,8 +79,7 @@
{
display: block;
margin: auto;
max-width: 92%;
padding-top: 1em;
width: 100%;
}
/* Survey */

View File

@ -1,7 +1,7 @@
<vn>
<vn-group>
<db-model id="news">
SELECT title, date_time, text, id FROM news
SELECT title, date_time, text, image, id FROM news
WHERE tag != 'course'
ORDER BY priority, date_time DESC
</db-model>
@ -9,15 +9,19 @@
<div id="form" class="home">
<div class="column" id="news-column">
<htk-repeater model="news" form-id="new">
<div class="new-container">
<div class="new">
<h2><htk-text form="new" column="title"/></h2>
<p class="new-info">
<htk-text format="_%a, %e %b %Y" form="new" column="date_time"/>
</p>
<div class="new-text">
<htk-html form="new" column="text"/>
<div class="top">
<h2><htk-text form="new" column="title"/></h2>
<p class="new-info">
<htk-text format="_%a, %e %b %Y" form="new" column="date_time"/>
</p>
<div class="new-text">
<htk-html form="new" column="text"/>
</div>
</div>
<htk-image directory="news/full" form="new" column="id"/>
<htk-image directory="news/full" form="new" column="image"/>
</div>
</div>
</htk-repeater>
</div>

View File

@ -1,27 +1,55 @@
/* News panel */
.training
{
padding: 1em;
margin: .5em;
}
.training .column
.column
{
max-width: 40em;
max-width: 120em;
margin: 0 auto;
text-align: center;
}
/* New */
.new-container
{
display: inline-block;
vertical-align: top;
}
@media screen and (min-width: 800px)
{
.new-container { width: 100%; }
}
@media screen and (min-width: 1000px)
{
.new-container { width: 50%; }
}
@media screen and (min-width: 1300px)
{
.new-container { width: 33.3%; }
}
@media screen and (min-width: 2000px)
{
.new-container { width: 25%; }
}
.new
{
padding: 2em;
text-align: left;
background-color: white;
color: #222;
border: none;
border-radius: 0.1em;
box-shadow: 0 0.2em 0.2em #CCC;
margin-bottom: 1em;
margin: .5em;
}
.new .top
{
padding: 1.5em;
padding-bottom: 1em;
}
/* New */
.new h2
{
font-size: 1.6em;
@ -47,6 +75,6 @@
{
display: block;
margin: auto;
max-width: 92%;
padding-top: 1em;
width: 100%;
}

View File

@ -1,23 +1,27 @@
<vn>
<vn-group>
<db-model id="news">
SELECT title, date_time, text, id FROM news
SELECT title, date_time, text, image, id FROM news
WHERE tag = 'course'
ORDER BY priority, date_time DESC
</db-model>
</vn-group>
<div id="form" class="training">
<div class="column" id="courses-column">
<htk-repeater model="news" form-id="course">
<div class="column" id="news-column">
<htk-repeater model="news" form-id="new">
<div class="new-container">
<div class="new">
<h2><htk-text form="course" column="title"/></h2>
<p class="new-info">
<htk-text format="_%a, %e %b %Y" form="course" column="date_time"/>
</p>
<div class="new-text">
<htk-html form="course" column="text"/>
<div class="top">
<h2><htk-text form="new" column="title"/></h2>
<p class="new-info">
<htk-text format="_%a, %e %b %Y" form="new" column="date_time"/>
</p>
<div class="new-text">
<htk-html form="new" column="text"/>
</div>
</div>
<htk-image directory="news/full" form="course" column="id"/>
<htk-image directory="news/full" form="new" column="image"/>
</div>
</div>
</htk-repeater>
</div>

View File

@ -45,7 +45,7 @@
<item name="order" param="order"/>
</sql-batch>
</db-model>
<htk-column-image column="Foto" directory="catalog" subdir="30x30" show-full="true"/>
<htk-column-image column="Foto" directory="catalog" subdir="50x50" show-full="true"/>
<htk-column-text title="_Item" column="Article"/>
<htk-column-text renderer="featuresRender"/>
<htk-column-text title="_Amount" column="amount" renderer="stemsRender"/>

View File

@ -31,7 +31,7 @@ Vn.Checkout = new Class
date.setTime (date.getTime () + 86400000);
}
this.$('delivery').value = date;
this.$('date').value = date;
this.$('method').value = i.get ('delivery_method');
this.$('agency').value = i.get ('agency_id');
this.$('address').value = i.get ('address_id');
@ -41,11 +41,11 @@ Vn.Checkout = new Class
,onConfirmClick: function ()
{
var query = 'CALL basket_configure (#delivery, #method, #agency, #address)';
var query = 'CALL basket_configure (#date, #method, #agency, #address)';
var batch = new Sql.Batch ();
batch.addParam ('method', this.$('method'));
batch.addParam ('delivery', this.$('delivery'));
batch.addParam ('date', this.$('date'));
batch.addParam ('agency', this.$('agency'));
batch.addParam ('address', this.$('address'));
@ -124,7 +124,7 @@ Vn.Checkout = new Class
this.$('agencies').refresh ();
break;
case 'pickup':
this.$('agencies').refresh ();
this.$('warehouses').refresh ();
break;
}
@ -159,7 +159,7 @@ Vn.Checkout = new Class
{
var now = new Date ();
now.setHours (0,0,0,0);
return date.getTime () >= now.getTime ()
&& date.getDay () != 0;
}

View File

@ -3,7 +3,7 @@
<vn-param id="order">
<vn-hash-link key="order"/>
</vn-param>
<vn-param id="delivery"/>
<vn-param id="date"/>
<vn-param id="method"/>
<vn-param id="agency"/>
<vn-param id="address"/>
@ -22,19 +22,32 @@
</db-model>
</db-form>
<db-model property="model" id="agencies" auto-load="false" result-index="1">
CALL agency_list_by_date (#delivery, #address);
CALL agency_list_by_date (#date, #address);
SELECT a.Id_Agencia, a.description
FROM t_agency t
JOIN vn2008.Agencias a ON a.Id_Agencia = t.agency_id
JOIN vn2008.Vistas v ON a.Vista = v.vista_id
WHERE a.web != FALSE
AND v.code = #method
AND v.code = 'AGENCY'
ORDER BY a.description;
DROP TEMPORARY TABLE t_agency;
<sql-batch property="batch">
<item name="address" param="address"/>
<item name="delivery" param="delivery"/>
<item name="method" param="method"/>
<item name="date" param="date"/>
</sql-batch>
</db-model>
<db-model property="model" id="warehouses" auto-load="false" result-index="1">
CALL agency_list_by_date (#date, NULL);
SELECT a.Id_Agencia, SUBSTR(a.description, 5) description
FROM t_agency t
JOIN vn2008.Agencias a ON a.Id_Agencia = t.agency_id
JOIN vn2008.Vistas v ON a.Vista = v.vista_id
WHERE a.web != FALSE
AND v.code = 'PICKUP'
ORDER BY a.description;
DROP TEMPORARY TABLE t_agency;
<sql-batch property="batch">
<item name="date" param="date"/>
</sql-batch>
</db-model>
</vn-group>
@ -84,7 +97,7 @@
<htk-calendar
id="calendar"
class="thin-calendar"
param="delivery"
param="date"
restrict-func="calendarRestrict"
on-changed="onFieldChange"/>
</div>
@ -128,7 +141,7 @@
id="warehouse-combo"
param="agency"
on-changed="onFieldChange"
model="agencies"/>
model="warehouses"/>
</div>
</div>
<div id="confirm-agency-step" class="confirm">
@ -136,7 +149,7 @@
<div class="answers target">
<p>
<t>Arrival</t>
<htk-text format="_%A, %e of %B" param="delivery"/>
<htk-text format="_%A, %e of %B" param="date"/>
</p>
<p>
<htk-text form="address-form" column="name"/>
@ -156,7 +169,7 @@
<div class="answers target">
<p>
<t>Arrival</t>
<htk-text format="_%A, %e of %B" param="delivery"/>
<htk-text format="_%A, %e of %B" param="date"/>
</p>
<p>
<htk-text form="address-form" column="name"/>
@ -175,7 +188,7 @@
<div class="answers target">
<p>
<t>Pickup</t>
<htk-text format="_%A, %e of %B" param="delivery"/>
<htk-text format="_%A, %e of %B" param="date"/>
</p>
<p>
<t>Warehouse</t>

View File

@ -8,7 +8,24 @@ Vn.Confirm = new Class
this.tpv = new Vn.Tpv (this.conn, this.hash);
}
,onStatusChange: function (form)
,onOrderReady: function (form)
{
if (form.row < 0)
return;
if (form.get ('method') != 'PICKUP')
{
this.$('address').style.display = 'block';
Vn.Node.setText (this.$('method'), _('Agency'));
}
else
{
this.$('address').style.display = 'none';
Vn.Node.setText (this.$('method'), _('Warehouse'));
}
}
,onImportReady: function (form)
{
if (form.row != -1)
this.$('total').value = form.get ('tax_base') + form.get ('vat');
@ -29,28 +46,25 @@ Vn.Confirm = new Class
,onConfirmClick: function ()
{
// var query = 'CALL order_confirm (#order)';
var query = 'SELECT TRUE ok, customer_get_debt() debt';
var batch = new Sql.Batch ();
batch.addParam ('order', this.$('order-id'));
this.conn.execQuery (query, this.confirmDone.bind (this), batch);
this.$('confirm-query').execute ();
}
,confirmDone: function (resultSet)
,onConfirm: function (query, resultSet)
{
var res = resultSet.fetchResult ();
var debt = resultSet.fetchValue ();
if (!(res && res.next()))
this.goBasket ();
Vn.Cookie.unset ('order');
this.pay = res.get ('debt') > this.$('order-form').get ('credit');
if (res)
{
Vn.Cookie.unset ('order');
this.pay = debt > this.$('order-form').get ('credit');
this.popup = new Htk.Popup ();
this.popup.setChildNode (this.$('success-dialog'));
this.popup.showCenter ();
this.popup = new Htk.Popup ();
this.popup.setChildNode (this.$('success-dialog'));
this.popup.showCenter ();
}
else
this.hash.set ({'form': 'ecomerce/basket'});
}
,onAcceptClick: function ()

View File

@ -3,14 +3,15 @@
<vn-param id="order-id">
<vn-hash-link key="order"/>
</vn-param>
<db-form id="order-form">
<db-model updatable="true">
SELECT o.id, o.date_send, o.delivery_method_id, o.note,
ag.description agency, o.company_id, ad.consignee, ad.zip_code,
ad.city, ad.name address, c.credit
<db-form id="order-form" on-ready="onOrderReady">
<db-model>
SELECT o.id, o.date_send, o.note, o.company_id,
ag.description agency, v.code method, c.credit,
ad.consignee, ad.zip_code, ad.city, ad.name address
FROM order_view o
JOIN vn2008.Agencias ag ON ag.Id_Agencia = o.agency_id
LEFT JOIN address_view ad ON ad.id = o.address_id
JOIN vn2008.Vistas v ON v.vista_id = o.delivery_method_id
JOIN customer_view c
WHERE o.id = #order
<sql-batch property="batch">
@ -18,10 +19,12 @@
</sql-batch>
</db-model>
</db-form>
<db-form id="total-form" on-iter-changed="onStatusChange">
<db-form id="total-form" on-ready="onImportReady">
<db-model result-index="1">
CALL order_get_vat (#order);
SELECT SUM(tax_base) tax_base, SUM(vat + surcharge) vat
SELECT
IFNULL(SUM(tax_base), 0) tax_base,
IFNULL(SUM(vat + surcharge), 0) vat
FROM t_order_vat;
DROP TEMPORARY TABLE t_order_vat;
<sql-batch property="batch">
@ -29,6 +32,13 @@
</sql-batch>
</db-model>
</db-form>
<db-query id="confirm-query" on-ready="onConfirm">
CALL order_confirm_bionic (#order);
SELECT customer_get_debt() debt;
<sql-batch property="batch">
<item name="order" param="order-id"/>
</sql-batch>
</db-query>
</vn-group>
<div id="form" class="confirm">
<div class="box">
@ -42,11 +52,11 @@
<htk-text format="_%A, %e of %B" form="order-form" column="date_send"/>
</p>
<p class="small">
<t>Agency</t>
<span id="method"><t>Agency</t></span>
<htk-text form="order-form" column="agency"/>
</p>
</div>
<div class="section">
<div id="address" class="section">
<p>
<htk-text form="order-form" column="consignee"/>
</p>

View File

@ -12,7 +12,7 @@
</div>
<htk-grid>
<db-model id="news-model" updatable="true">
SELECT n.id, c.Cliente, priority,
SELECT n.id, c.Cliente, priority, image,
CONCAT(LEFT(n.title, 25), '...') title
FROM news n
JOIN vn2008.Clientes c ON n.user_id = c.Id_Cliente
@ -24,9 +24,9 @@
image="image/edit.svg"
on-clicked="onEditClick"/>
<htk-column-image
column="id"
column="image"
directory="news"
subdir="30x30"
subdir="50x50"
show-full="true"
editable="true"/>
<htk-column-text title="_Title" column="title"/>

View File

@ -5,11 +5,11 @@
{
* { font-size: 8pt; }
}
@media screen and (min-device-width: 1150px)
@media screen and (min-width: 1150px)
{
* { font-size: 10pt; }
}
@media screen and (min-device-width: 1850px)
@media screen and (min-width: 1850px)
{
* { font-size: 12pt; }
}
@ -440,7 +440,8 @@ img.icon
}
.cell-image > img
{
min-height: 1.5em;
max-width: 2.5em;
max-height: 2.5em;
}
/* Repater */
@ -557,11 +558,6 @@ img.icon
box-shadow: 0 0.1em 0.1em #CCC;
}
.htk-date-chooser > button:hover
{
background-color: #EEE;
}
/* Full image */
.htk-full-image

View File

@ -11,6 +11,7 @@ Vn\Hedera\Js::includeLib ('db'
,'iterator'
,'form'
,'param'
,'query'
,'calc'
,'calc-sum'
);

View File

@ -38,7 +38,6 @@ Db.Model.implement
({
Extends: Vn.Object
,Tag: 'db-model'
,Child: 'query'
,Properties:
{
/**

View File

@ -0,0 +1,114 @@
Db.Query = new Class
({
Extends: Vn.Object
,Tag: 'db-query'
,Properties:
{
/**
* The connection used to execute the statement.
**/
conn:
{
type: Db.Conn
,set: function (x)
{
this._conn = x;
this.onChange ();
}
,get: function ()
{
return this._conn;
}
},
/**
* The model query.
**/
query:
{
type: String
,set: function (x)
{
this._stmt = new Sql.String ({query: x});
this.onChange ();
}
,get: function ()
{
return this._stmt.render (null);
}
},
/**
* The model select statement.
**/
stmt:
{
type: Sql.Stmt
,set: function (x)
{
this._stmt = x;
this.onChange ();
}
,get: function ()
{
return this._stmt;
}
},
/**
* The batch used to execute the statement.
**/
batch:
{
type: Sql.Batch
,set: function (x)
{
this.link ({_batch: x}, {'changed': this.onChange});
this.onChange ();
}
,get: function ()
{
return this._batch;
}
},
/**
* Wether to execute automatically de query que it's ready.
**/
autoLoad:
{
type: Boolean,
value: false
}
}
,initialize: function (props)
{
this.parent (props);
}
,loadXml: function (builder, node)
{
this.parent (builder, node);
var query = node.firstChild.nodeValue;
if (query)
this.query = query;
}
,execute: function ()
{
this._conn.execStmt (this._stmt,
this.onQueryDone.bind (this), this._batch);
}
,onQueryDone: function (resultSet)
{
this.signalEmit ('ready', resultSet);
}
,onChange: function ()
{
if (this.autoLoad && this._conn && this._stmt && this._batch)
this.execute ();
}
});

View File

@ -74,7 +74,7 @@ Htk.Calendar = new Class
var tr = document.createElement ('tr');
thead.appendChild (tr);
for (i = 1; i <= len; i++)
for (var i = 1; i <= len; i++)
{
var th = document.createElement ('th');
tr.appendChild (th);
@ -105,23 +105,21 @@ Htk.Calendar = new Class
th.addEventListener ('click', this.nextYearClicked.bind (this));
tr.appendChild (th);
*/
var td, div;
var tbody = document.createElement ('tbody');
table.appendChild (tbody);
for (i = 0; i < 6; i++)
for (var i = 0; i < 6; i++)
{
tr = document.createElement ('tr');
var tr = document.createElement ('tr');
tbody.appendChild (tr);
for (j = 0; j < len; j++)
for (var j = 0; j < len; j++)
{
td = document.createElement ('td');
var td = document.createElement ('td');
td.addEventListener ('click', this.dayClicked.bind (this, td, i*len+j));
tr.appendChild (td);
div = document.createElement ('div');
var div = document.createElement ('div');
td.appendChild (div);
this.cells.push ({
@ -185,7 +183,7 @@ Htk.Calendar = new Class
var firstWeekDay = (weekDay != 0) ? weekDay - 1 : 6;
var monthDays = this.getMonthDays ();
for (i = 0; i < this.cells.length; i++)
for (var i = 0; i < this.cells.length; i++)
{
var cell = this.cells[i];

View File

@ -45,6 +45,7 @@ Htk.Image = new Class
,render: function (force)
{
console.log (this._value);
if (this._value)
{
var url = '';
@ -59,9 +60,13 @@ Htk.Image = new Class
this.empty = false;
this.node.src = url;
this.node.style.display = '';
}
else
this.onImageError ();
{
delete this.node.src;
this.node.style.display = 'none';
}
}
,putValue: function (value)

View File

@ -112,6 +112,8 @@ Sql.Batch = new Class
,isReady: function ()
{
var id;
for (id in this.params)
if (!(this.params[id] && this.params[id].isReady ()))
return false;

View File

@ -73,10 +73,7 @@ Sql.Value = new Class
,isReady: function ()
{
if (this._value !== undefined && this._value !== null)
return true;
return false;
return this._value !== undefined;
}
,replaceFunc: function (token)

View File

@ -28,7 +28,13 @@ Vn.Object = new Class
* @param {Object} instance The instance
**/
,on: function (id, callback, instance)
{
{
if (!(callback instanceof Function))
{
console.warn ('Vn.Object: Invalid callback for signal \'%s\'', id);
return;
}
if (!this.signals[id])
this.signals[id] = [];

View File

@ -18,6 +18,11 @@ Vn.Module = new Class
for (var i = 0; i < models.length; i++)
models[i].conn = this.conn;
var queries = this.builder.getObjects ('db-query');
for (var i = 0; i < queries.length; i++)
queries[i].conn = this.conn;
var hashLinks = this.builder.getObjects ('vn-hash-link');
for (var i = 0; i < hashLinks.length; i++)