forked from verdnatura/hedera-web
Version alpha3 del bionic
This commit is contained in:
parent
7355557164
commit
e460b4595f
|
@ -5,26 +5,31 @@ Vn.Basket = new Class
|
||||||
|
|
||||||
,activate: function ()
|
,activate: function ()
|
||||||
{
|
{
|
||||||
var query = 'CALL basket_check ()';
|
this.conn.execQuery ('CALL basket_check ()',
|
||||||
this.conn.execQuery (query, this.onBasketCheck.bind (this));
|
this.onBasketCheck.bind (this));
|
||||||
}
|
}
|
||||||
|
|
||||||
,onBasketCheck: function (resultSet)
|
,onBasketCheck: function (resultSet)
|
||||||
{
|
{
|
||||||
var res = resultSet.fetchResult ();
|
var res = resultSet.fetchResult ();
|
||||||
|
|
||||||
if (!res.next())
|
if (!res.next ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (res.get ('order_id'))
|
switch (res.get ('stat'))
|
||||||
{
|
{
|
||||||
if (res.get ('refresh') && res.get ('nrows') > 0)
|
case 'BAD_CONFIG':
|
||||||
|
case 'NOT_EXISTS':
|
||||||
|
this.onConfigureClick ();
|
||||||
|
break;
|
||||||
|
case 'UPDATED':
|
||||||
(new Htk.Toast ()).showWarning (_('OrderItemsUpdated'));
|
(new Htk.Toast ()).showWarning (_('OrderItemsUpdated'));
|
||||||
|
this.$('order').value = res.get ('order_id');
|
||||||
this.$('order').value = res.get ('order_id');
|
break;
|
||||||
|
case 'OK':
|
||||||
|
this.$('order').value = res.get ('order_id');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
this.hash.set ({'form': 'ecomerce/checkout'});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,onConfigureClick: function ()
|
,onConfigureClick: function ()
|
||||||
|
|
|
@ -20,12 +20,13 @@
|
||||||
</sql-filter>
|
</sql-filter>
|
||||||
<db-model result-index="1" id="items-model">
|
<db-model result-index="1" id="items-model">
|
||||||
CALL bionic_by_type (@calc, #type);
|
CALL bionic_by_type (@calc, #type);
|
||||||
SELECT t.warehouse_id, t.item_id, t.available, t.price,
|
SELECT t.item_id, SUM(t.available) available, MIN(t.price) price,
|
||||||
a.Foto, a.Article, a.Categoria, a.Medida, a.Tallos, a.Color, o.Abreviatura
|
a.Foto, a.Article, a.Categoria, a.Medida, a.Tallos, a.Color, o.Abreviatura
|
||||||
FROM cache.bionic t
|
FROM cache.bionic t
|
||||||
JOIN vn2008.Articles a ON a.Id_Article = t.item_id
|
JOIN vn2008.Articles a ON a.Id_Article = t.item_id
|
||||||
LEFT JOIN vn2008.Origen o ON a.id_origen = o.id
|
LEFT JOIN vn2008.Origen o ON a.id_origen = o.id
|
||||||
WHERE t.calc_id = @calc AND t.available > 0
|
WHERE t.calc_id = @calc AND t.available > 0
|
||||||
|
GROUP BY item_id
|
||||||
ORDER BY a.Article, a.Medida
|
ORDER BY a.Article, a.Medida
|
||||||
LIMIT 400;
|
LIMIT 400;
|
||||||
<sql-batch property="batch" id="batch">
|
<sql-batch property="batch" id="batch">
|
||||||
|
|
|
@ -6,79 +6,88 @@ Vn.Checkout = new Class
|
||||||
,activate: function ()
|
,activate: function ()
|
||||||
{
|
{
|
||||||
this.autoStepLocked = true;
|
this.autoStepLocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.$('order-model').setDefault ('customer_id', 'o',
|
,onValuesReady: function ()
|
||||||
new Sql.Func ({schema: 'account', name: 'user_get_id'}));
|
{
|
||||||
|
var orderForm = this.$('order-form');
|
||||||
|
var defaultsForm = this.$('defaults');
|
||||||
|
|
||||||
if (this.$('order').value == 0)
|
if (!(orderForm.ready && defaultsForm.ready))
|
||||||
this.$('defaults').refresh ();
|
return;
|
||||||
else
|
|
||||||
|
if (orderForm.numRows > 0)
|
||||||
|
{
|
||||||
(new Htk.Toast ()).showWarning (_('RememberReconfiguringImpact'));
|
(new Htk.Toast ()).showWarning (_('RememberReconfiguringImpact'));
|
||||||
}
|
var i = orderForm;
|
||||||
|
var date = i.get ('date_send');
|
||||||
,setDefaults: function ()
|
|
||||||
{
|
|
||||||
var o = this.$('order-form');
|
|
||||||
var d = this.$('defaults');
|
|
||||||
|
|
||||||
if (this.$('order').value == 0 && d.ready && o.ready)
|
|
||||||
{
|
|
||||||
o.insertRow ();
|
|
||||||
// o.set ('delivery_method_id', d.get ('delivery_method'));
|
|
||||||
o.set ('date_send', new Date ());
|
|
||||||
o.set ('agency_id', d.get ('agency_id'));
|
|
||||||
o.set ('address_id', d.get ('address_id'));
|
|
||||||
this.autoStepLocked = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
,onOrderReady: function ()
|
|
||||||
{
|
|
||||||
if (this.$('order').value != 0)
|
|
||||||
this.autoStepLocked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
,onOperationsDone: function ()
|
|
||||||
{
|
|
||||||
if (this.$('order').value == 0)
|
|
||||||
{
|
|
||||||
(new Htk.Toast ()).showMessage (_('OrderStarted'));
|
|
||||||
this.hash.set ({'form': 'ecomerce/catalog'});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.conn.execQuery ('CALL basket_update ()',
|
{
|
||||||
this.onBasketUpdated.bind (this));
|
var i = defaultsForm;
|
||||||
}
|
var date = new Date ();
|
||||||
|
|
||||||
,onBasketUpdated: function ()
|
if (i.get('delivery_method') != 'PICKUP')
|
||||||
{
|
date.setTime (date.getTime () + 86400000);
|
||||||
(new Htk.Toast ()).showMessage (_('OrderUpdated'));
|
}
|
||||||
window.history.back();
|
|
||||||
|
this.$('delivery').value = date;
|
||||||
|
this.$('method').value = i.get ('delivery_method');
|
||||||
|
this.$('agency').value = i.get ('agency_id');
|
||||||
|
this.$('address').value = i.get ('address_id');
|
||||||
|
|
||||||
|
this.autoStepLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
,onConfirmClick: function ()
|
,onConfirmClick: function ()
|
||||||
{
|
{
|
||||||
this.$('order-form').performOperations ();
|
var query = 'CALL basket_configure (#delivery, #method, #agency, #address)';
|
||||||
|
|
||||||
|
var batch = new Sql.Batch ();
|
||||||
|
batch.addParam ('method', this.$('method'));
|
||||||
|
batch.addParam ('delivery', this.$('delivery'));
|
||||||
|
batch.addParam ('agency', this.$('agency'));
|
||||||
|
batch.addParam ('address', this.$('address'));
|
||||||
|
|
||||||
|
this.conn.execQuery (query,
|
||||||
|
this.onBasketConfigured.bind (this), batch);
|
||||||
|
}
|
||||||
|
|
||||||
|
,onBasketConfigured: function (resultSet)
|
||||||
|
{
|
||||||
|
if (!resultSet.fetchResult ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.$('order-form').numRows > 0)
|
||||||
|
{
|
||||||
|
(new Htk.Toast ()).showMessage (_('OrderUpdated'));
|
||||||
|
window.history.back();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(new Htk.Toast ()).showMessage (_('OrderStarted'));
|
||||||
|
this.hash.set ({'form': 'ecomerce/catalog'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
,onCancelClick: function ()
|
,onCancelClick: function ()
|
||||||
{
|
{
|
||||||
if (this.$('order').value == 0)
|
if (this.$('order-form').numRows > 0)
|
||||||
this.hash.set ({'form': 'ecomerce/orders'});
|
|
||||||
else
|
|
||||||
this.hash.set ({'form': 'ecomerce/basket'});
|
this.hash.set ({'form': 'ecomerce/basket'});
|
||||||
|
else
|
||||||
|
this.hash.set ({'form': 'ecomerce/orders'});
|
||||||
}
|
}
|
||||||
|
|
||||||
,agencySteps: ['delivery', 'date', 'address', 'agency', 'confirm-agency']
|
,agencySteps: ['method', 'date', 'address', 'agency', 'confirm-agency']
|
||||||
,deliverySteps: ['delivery', 'date', 'address', null, 'confirm-delivery']
|
,deliverySteps: ['method', 'date', 'address', null, 'confirm-delivery']
|
||||||
,pickupSteps: ['delivery', 'date', 'pickup', null, 'confirm-pickup']
|
,pickupSteps: ['method', 'date', 'pickup', null, 'confirm-pickup']
|
||||||
|
|
||||||
,stepFunc: function (stepIndex)
|
,stepFunc: function (stepIndex)
|
||||||
{
|
{
|
||||||
var steps;
|
var steps;
|
||||||
var isDelivery;
|
var isDelivery;
|
||||||
|
|
||||||
switch (this.$('rg-delivery').value)
|
switch (this.$('rg-method').value)
|
||||||
{
|
{
|
||||||
case 'AGENCY':
|
case 'AGENCY':
|
||||||
steps = this.agencySteps;
|
steps = this.agencySteps;
|
||||||
|
@ -115,7 +124,7 @@ Vn.Checkout = new Class
|
||||||
this.$('agencies').refresh ();
|
this.$('agencies').refresh ();
|
||||||
break;
|
break;
|
||||||
case 'pickup':
|
case 'pickup':
|
||||||
this.$('warehouses').refresh ();
|
this.$('agencies').refresh ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,5 +154,14 @@ Vn.Checkout = new Class
|
||||||
{
|
{
|
||||||
this.$('assistant').moveNext ();
|
this.$('assistant').moveNext ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
,calendarRestrict: function (date)
|
||||||
|
{
|
||||||
|
var now = new Date ();
|
||||||
|
now.setHours (0,0,0,0);
|
||||||
|
|
||||||
|
return date.getTime () >= now.getTime ()
|
||||||
|
&& date.getDay () != 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
/* Step */
|
/* Step */
|
||||||
|
|
||||||
.answers button,
|
.answers button,
|
||||||
.answers span,
|
|
||||||
.answers p,
|
.answers p,
|
||||||
.radio > div
|
.radio > div
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,25 +3,40 @@
|
||||||
<vn-param id="order">
|
<vn-param id="order">
|
||||||
<vn-hash-link key="order"/>
|
<vn-hash-link key="order"/>
|
||||||
</vn-param>
|
</vn-param>
|
||||||
<db-form id="defaults" on-iter-changed="setDefaults">
|
<vn-param id="delivery"/>
|
||||||
<db-model auto-load="false">
|
<vn-param id="method"/>
|
||||||
SELECT delivery_method, address_id, agency_id
|
<vn-param id="agency"/>
|
||||||
|
<vn-param id="address"/>
|
||||||
|
<db-form id="defaults" on-ready="onValuesReady">
|
||||||
|
<db-model>
|
||||||
|
SELECT delivery_method, agency_id, address_id
|
||||||
FROM order_defaults_view
|
FROM order_defaults_view
|
||||||
</db-model>
|
</db-model>
|
||||||
</db-form>
|
</db-form>
|
||||||
<db-form id="order-form" on-status-changed="setDefaults" on-iter-changed-after="onOrderReady">
|
<db-form id="order-form" on-ready="onValuesReady">
|
||||||
<db-model id="order-model" updatable="true" mode="ON_DEMAND" on-operations-done="onOperationsDone">
|
<db-model>
|
||||||
SELECT id, delivery_method_id, date_send, agency_id, address_id, customer_id
|
SELECT v.code delivery_method, o.date_send, o.agency_id, o.address_id
|
||||||
FROM order_view o WHERE id = #id
|
FROM order_view o
|
||||||
<sql-batch property="batch">
|
JOIN vn2008.Vistas v ON o.delivery_method_id = v.vista_id
|
||||||
<item name="id" param="order"/>
|
LIMIT 1
|
||||||
</sql-batch>
|
|
||||||
</db-model>
|
</db-model>
|
||||||
<db-param column="date_send" id="date"/>
|
|
||||||
<db-param column="agency_id" id="agency"/>
|
|
||||||
<db-param column="address_id" id="address"/>
|
|
||||||
<db-param column="delivery_method_id" id="delivery"/>
|
|
||||||
</db-form>
|
</db-form>
|
||||||
|
<db-model property="model" id="agencies" auto-load="false" result-index="1">
|
||||||
|
CALL agency_list_by_date (#delivery, #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
|
||||||
|
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"/>
|
||||||
|
</sql-batch>
|
||||||
|
</db-model>
|
||||||
</vn-group>
|
</vn-group>
|
||||||
<div id="form" class="checkout">
|
<div id="form" class="checkout">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
@ -42,22 +57,23 @@
|
||||||
step-func="stepFunc"
|
step-func="stepFunc"
|
||||||
node="assistant-node"/>
|
node="assistant-node"/>
|
||||||
<div id="assistant-node">
|
<div id="assistant-node">
|
||||||
<div id="delivery-step">
|
<div id="method-step">
|
||||||
<h2><t>DeliveryOrPickupQuestion</t></h2>
|
<h2><t>DeliveryOrPickupQuestion</t></h2>
|
||||||
<div class="answers radio">
|
<div class="answers radio">
|
||||||
<htk-radio-group
|
<htk-radio-group
|
||||||
id="rg-delivery"
|
id="rg-method"
|
||||||
|
param="method"
|
||||||
on-changed="onFieldChange"/>
|
on-changed="onFieldChange"/>
|
||||||
<div>
|
<div>
|
||||||
<htk-radio radio-group="rg-delivery" value="AGENCY"/>
|
<htk-radio radio-group="rg-method" value="AGENCY"/>
|
||||||
<label><t>ReceiveThroughtAgency</t></label>
|
<label><t>ReceiveThroughtAgency</t></label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<htk-radio radio-group="rg-delivery" value="DELIVERY"/>
|
<htk-radio radio-group="rg-method" value="DELIVERY"/>
|
||||||
<label><t>ReceiveThroughtRoute</t></label>
|
<label><t>ReceiveThroughtRoute</t></label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<htk-radio radio-group="rg-delivery" value="PICKUP"/>
|
<htk-radio radio-group="rg-method" value="PICKUP"/>
|
||||||
<label><t>PickupInStore</t></label>
|
<label><t>PickupInStore</t></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -68,7 +84,8 @@
|
||||||
<htk-calendar
|
<htk-calendar
|
||||||
id="calendar"
|
id="calendar"
|
||||||
class="thin-calendar"
|
class="thin-calendar"
|
||||||
param="date"
|
param="delivery"
|
||||||
|
restrict-func="calendarRestrict"
|
||||||
on-changed="onFieldChange"/>
|
on-changed="onFieldChange"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -97,38 +114,21 @@
|
||||||
<div id="agency-step">
|
<div id="agency-step">
|
||||||
<h2><t>AgencyQuestion</t></h2>
|
<h2><t>AgencyQuestion</t></h2>
|
||||||
<div class="answers target">
|
<div class="answers target">
|
||||||
<htk-combo id="agency-combo" param="agency" on-changed="onFieldChange">
|
<htk-combo
|
||||||
<db-model property="model" id="agencies" auto-load="false" result-index="1">
|
id="agency-combo"
|
||||||
CALL agency_list_by_date (#date, #address);
|
param="agency"
|
||||||
SELECT a.Id_Agencia, a.description
|
on-changed="onFieldChange"
|
||||||
FROM t_agency t
|
model="agencies"/>
|
||||||
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 = 'AGENCY'
|
|
||||||
ORDER BY a.description;
|
|
||||||
DROP TEMPORARY TABLE t_agency;
|
|
||||||
<sql-batch property="batch">
|
|
||||||
<item name="address" param="address"/>
|
|
||||||
<item name="date" param="date"/>
|
|
||||||
</sql-batch>
|
|
||||||
</db-model>
|
|
||||||
</htk-combo>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="pickup-step">
|
<div id="pickup-step">
|
||||||
<h2><t>PickupWarehouseQuestion</t></h2>
|
<h2><t>PickupWarehouseQuestion</t></h2>
|
||||||
<div class="answers target">
|
<div class="answers target">
|
||||||
<htk-combo id="warehouse-combo" param="agency" on-changed="onFieldChange">
|
<htk-combo
|
||||||
<db-model property="model" id="warehouses" auto-load="false">
|
id="warehouse-combo"
|
||||||
SELECT a.Id_Agencia, SUBSTR(a.description, 5) description
|
param="agency"
|
||||||
FROM vn2008.Agencias a
|
on-changed="onFieldChange"
|
||||||
JOIN vn2008.Vistas v ON a.Vista = v.vista_id
|
model="agencies"/>
|
||||||
WHERE a.web != FALSE
|
|
||||||
AND v.code = 'PICKUP'
|
|
||||||
ORDER BY a.description
|
|
||||||
</db-model>
|
|
||||||
</htk-combo>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="confirm-agency-step" class="confirm">
|
<div id="confirm-agency-step" class="confirm">
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
<div class="answers target">
|
<div class="answers target">
|
||||||
<p>
|
<p>
|
||||||
<t>Arrival</t>
|
<t>Arrival</t>
|
||||||
<htk-text format="_%A, %e of %B" param="date"/>
|
<htk-text format="_%A, %e of %B" param="delivery"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<htk-text form="address-form" column="name"/>
|
<htk-text form="address-form" column="name"/>
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
<div class="answers target">
|
<div class="answers target">
|
||||||
<p>
|
<p>
|
||||||
<t>Arrival</t>
|
<t>Arrival</t>
|
||||||
<htk-text format="_%A, %e of %B" param="date"/>
|
<htk-text format="_%A, %e of %B" param="delivery"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<htk-text form="address-form" column="name"/>
|
<htk-text form="address-form" column="name"/>
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
<div class="answers target">
|
<div class="answers target">
|
||||||
<p>
|
<p>
|
||||||
<t>Pickup</t>
|
<t>Pickup</t>
|
||||||
<htk-text format="_%A, %e of %B" param="date"/>
|
<htk-text format="_%A, %e of %B" param="delivery"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<t>Warehouse</t>
|
<t>Warehouse</t>
|
||||||
|
|
|
@ -225,22 +225,6 @@ img.editable
|
||||||
height: 1.5em;
|
height: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Date chooser */
|
|
||||||
|
|
||||||
.htk-date-chooser button
|
|
||||||
{
|
|
||||||
border: 1px solid #CCD;
|
|
||||||
margin: 0.2em;
|
|
||||||
padding: 0.3em;
|
|
||||||
border-radius: 0.1em;
|
|
||||||
box-shadow: 0 0.1em 0.1em #CCC;
|
|
||||||
background-color: white;
|
|
||||||
color: black;
|
|
||||||
text-align: left;
|
|
||||||
min-width: 9em;
|
|
||||||
min-height: 2.3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Float */
|
/* Float */
|
||||||
|
|
||||||
.clear
|
.clear
|
||||||
|
@ -496,6 +480,10 @@ img.icon
|
||||||
text-align: center;
|
text-align: center;
|
||||||
height: 3em;
|
height: 3em;
|
||||||
}
|
}
|
||||||
|
.htk-calendar thead span
|
||||||
|
{
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
.htk-calendar thead tr
|
.htk-calendar thead tr
|
||||||
{
|
{
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
|
@ -507,7 +495,7 @@ img.icon
|
||||||
.htk-calendar th.button:hover
|
.htk-calendar th.button:hover
|
||||||
{
|
{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: #076;
|
background-color: rgba(1, 1, 1, 0.2);
|
||||||
}
|
}
|
||||||
.htk-calendar col
|
.htk-calendar col
|
||||||
{
|
{
|
||||||
|
@ -520,13 +508,58 @@ img.icon
|
||||||
.htk-calendar tbody td
|
.htk-calendar tbody td
|
||||||
{
|
{
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: 0.5em;
|
|
||||||
}
|
}
|
||||||
.htk-calendar td.highlight,
|
.htk-calendar tbody td > div
|
||||||
.htk-calendar td:hover
|
{
|
||||||
|
height: 2em;
|
||||||
|
width: 2em;
|
||||||
|
line-height: 2em;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 2em;
|
||||||
|
padding: 0.3em;
|
||||||
|
margin: 0 auto;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
.htk-calendar div.disabled
|
||||||
|
{
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
.htk-calendar div.today
|
||||||
|
{
|
||||||
|
font-weight: bold;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
.htk-calendar div.selected
|
||||||
|
{
|
||||||
|
color: white;
|
||||||
|
background-color: #009688;
|
||||||
|
}
|
||||||
|
.htk-calendar div.enabled:hover
|
||||||
{
|
{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: #DDE;
|
background-color: #DDD;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Date chooser */
|
||||||
|
|
||||||
|
.htk-date-chooser > button
|
||||||
|
{
|
||||||
|
margin: 0.2em;
|
||||||
|
padding: 0.3em;
|
||||||
|
background-color: white;
|
||||||
|
color: black;
|
||||||
|
text-align: left;
|
||||||
|
min-width: 9em;
|
||||||
|
min-height: 2.3em;
|
||||||
|
border: 1px solid #CCD;
|
||||||
|
border-radius: 0.1em;
|
||||||
|
box-shadow: 0 0.1em 0.1em #CCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
.htk-date-chooser > button:hover
|
||||||
|
{
|
||||||
|
background-color: #EEE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Full image */
|
/* Full image */
|
||||||
|
@ -728,4 +761,8 @@ img.icon
|
||||||
padding: 0.3em 0.2em;
|
padding: 0.3em 0.2em;
|
||||||
width: 1.3em;
|
width: 1.3em;
|
||||||
}
|
}
|
||||||
|
.htk-assistant-bar > div > img:hover
|
||||||
|
{
|
||||||
|
opacity: .7;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,9 @@ Db.Form = new Class
|
||||||
|
|
||||||
if (this._row == -1)
|
if (this._row == -1)
|
||||||
this.row = this.lastRow;
|
this.row = this.lastRow;
|
||||||
|
|
||||||
|
if (ready)
|
||||||
|
this.signalEmit ('ready');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ Db.Iterator = new Class
|
||||||
,iterChanged: function ()
|
,iterChanged: function ()
|
||||||
{
|
{
|
||||||
this.signalEmit ('iter-changed');
|
this.signalEmit ('iter-changed');
|
||||||
this.signalEmit ('iter-changed-after');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,10 +2,24 @@ Htk.Calendar = new Class
|
||||||
({
|
({
|
||||||
Extends: Htk.Field
|
Extends: Htk.Field
|
||||||
,Tag: 'htk-calendar'
|
,Tag: 'htk-calendar'
|
||||||
|
,Properties:
|
||||||
|
{
|
||||||
|
restrictFunc:
|
||||||
|
{
|
||||||
|
type: Function
|
||||||
|
,set: function (x)
|
||||||
|
{
|
||||||
|
this._restrictFunc = x;
|
||||||
|
}
|
||||||
|
,get: function (x)
|
||||||
|
{
|
||||||
|
return this._restrictFunc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
,tds: []
|
,cells: []
|
||||||
,selectedTd: null
|
,selectedCell: -1
|
||||||
,todayTd: null
|
|
||||||
,year: null
|
,year: null
|
||||||
,month: null
|
,month: null
|
||||||
|
|
||||||
|
@ -38,9 +52,18 @@ Htk.Calendar = new Class
|
||||||
th.addEventListener ('click', this.prevMonthClicked.bind (this));
|
th.addEventListener ('click', this.prevMonthClicked.bind (this));
|
||||||
tr.appendChild (th);
|
tr.appendChild (th);
|
||||||
|
|
||||||
var monthNode = document.createElement ('th');
|
var th = document.createElement ('th');
|
||||||
monthNode.colSpan = 5;
|
th.colSpan = 5;
|
||||||
tr.appendChild (monthNode);
|
tr.appendChild (th);
|
||||||
|
|
||||||
|
var monthNode = document.createElement ('span');
|
||||||
|
th.appendChild (monthNode);
|
||||||
|
|
||||||
|
var space = document.createTextNode (' ');
|
||||||
|
th.appendChild (space);
|
||||||
|
|
||||||
|
var yearNode = document.createElement ('span');
|
||||||
|
th.appendChild (yearNode);
|
||||||
|
|
||||||
var th = document.createElement ('th');
|
var th = document.createElement ('th');
|
||||||
th.appendChild (document.createTextNode ('>'));
|
th.appendChild (document.createTextNode ('>'));
|
||||||
|
@ -59,7 +82,7 @@ Htk.Calendar = new Class
|
||||||
var weekday = Vn.Date.AbrWDays [i%len];
|
var weekday = Vn.Date.AbrWDays [i%len];
|
||||||
th.appendChild (document.createTextNode (weekday));
|
th.appendChild (document.createTextNode (weekday));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
var tfoot = document.createElement ('tfoot');
|
var tfoot = document.createElement ('tfoot');
|
||||||
table.appendChild (tfoot);
|
table.appendChild (tfoot);
|
||||||
|
|
||||||
|
@ -81,6 +104,8 @@ Htk.Calendar = new Class
|
||||||
th.className = 'button';
|
th.className = 'button';
|
||||||
th.addEventListener ('click', this.nextYearClicked.bind (this));
|
th.addEventListener ('click', this.nextYearClicked.bind (this));
|
||||||
tr.appendChild (th);
|
tr.appendChild (th);
|
||||||
|
*/
|
||||||
|
var td, div;
|
||||||
|
|
||||||
var tbody = document.createElement ('tbody');
|
var tbody = document.createElement ('tbody');
|
||||||
table.appendChild (tbody);
|
table.appendChild (tbody);
|
||||||
|
@ -95,7 +120,15 @@ Htk.Calendar = new Class
|
||||||
td = document.createElement ('td');
|
td = document.createElement ('td');
|
||||||
td.addEventListener ('click', this.dayClicked.bind (this, td, i*len+j));
|
td.addEventListener ('click', this.dayClicked.bind (this, td, i*len+j));
|
||||||
tr.appendChild (td);
|
tr.appendChild (td);
|
||||||
this.tds.push (td);
|
|
||||||
|
div = document.createElement ('div');
|
||||||
|
td.appendChild (div);
|
||||||
|
|
||||||
|
this.cells.push ({
|
||||||
|
node: div,
|
||||||
|
enabled: false,
|
||||||
|
day: -1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,12 +137,6 @@ Htk.Calendar = new Class
|
||||||
this.goToCurrentMonth ();
|
this.goToCurrentMonth ();
|
||||||
}
|
}
|
||||||
|
|
||||||
,getFirstWeekDay: function ()
|
|
||||||
{
|
|
||||||
var weekDay = new Date (this.year, this.month, 1).getDay ();
|
|
||||||
return (weekDay != 0) ? weekDay - 1 : 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
,getMonthDays: function ()
|
,getMonthDays: function ()
|
||||||
{
|
{
|
||||||
if (this.month > 6)
|
if (this.month > 6)
|
||||||
|
@ -151,17 +178,37 @@ Htk.Calendar = new Class
|
||||||
Vn.Node.setText (this.yearNode, this.year);
|
Vn.Node.setText (this.yearNode, this.year);
|
||||||
Vn.Node.setText (this.monthNode, Vn.Date.Months[this.month]);
|
Vn.Node.setText (this.monthNode, Vn.Date.Months[this.month]);
|
||||||
|
|
||||||
var firstWeekDay = this.getFirstWeekDay ();
|
var day = 1;
|
||||||
|
var cellDate = new Date (this.year, this.month, 1);
|
||||||
|
|
||||||
|
var weekDay = cellDate.getDay ();
|
||||||
|
var firstWeekDay = (weekDay != 0) ? weekDay - 1 : 6;
|
||||||
var monthDays = this.getMonthDays ();
|
var monthDays = this.getMonthDays ();
|
||||||
|
|
||||||
var day = 1;
|
for (i = 0; i < this.cells.length; i++)
|
||||||
|
|
||||||
for (i = 0; i < this.tds.length; i++)
|
|
||||||
{
|
{
|
||||||
|
var cell = this.cells[i];
|
||||||
|
|
||||||
if (firstWeekDay <= i && day <= monthDays)
|
if (firstWeekDay <= i && day <= monthDays)
|
||||||
Vn.Node.setText (this.tds[i], day++);
|
{
|
||||||
|
Vn.Node.setText (cell.node, day);
|
||||||
|
cell.enabled = true;
|
||||||
|
cell.day = day++;
|
||||||
|
|
||||||
|
if (this._restrictFunc)
|
||||||
|
{
|
||||||
|
cell.enabled = this._restrictFunc (cellDate);
|
||||||
|
cellDate.setTime (cellDate.getTime () + 86400000);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Vn.Node.removeChilds (this.tds[i]);
|
{
|
||||||
|
Vn.Node.removeChilds (cell.node);
|
||||||
|
cell.enabled = false;
|
||||||
|
cell.day = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.node.className = cell.enabled ? 'enabled' : 'disabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marks the current day
|
// Marks the current day
|
||||||
|
@ -171,14 +218,8 @@ Htk.Calendar = new Class
|
||||||
if (this.year == today.getFullYear ()
|
if (this.year == today.getFullYear ()
|
||||||
&& this.month == today.getMonth ())
|
&& this.month == today.getMonth ())
|
||||||
{
|
{
|
||||||
var tdIndex = (firstWeekDay + today.getDate ()) - 1;
|
var cellIndex = (firstWeekDay + today.getDate ()) - 1;
|
||||||
this.tds[tdIndex].style.fontWeight = 'bold';
|
Vn.Node.addClass (this.cells[cellIndex].node, 'today');
|
||||||
this.todayTd = this.tds[tdIndex];
|
|
||||||
}
|
|
||||||
else if (this.todayTd)
|
|
||||||
{
|
|
||||||
this.todayTd.style.fontWeight = '';
|
|
||||||
this.todayTd = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marks the selected day
|
// Marks the selected day
|
||||||
|
@ -188,22 +229,25 @@ Htk.Calendar = new Class
|
||||||
if (date instanceof Date
|
if (date instanceof Date
|
||||||
&& this.year == date.getFullYear ()
|
&& this.year == date.getFullYear ()
|
||||||
&& this.month == date.getMonth ())
|
&& this.month == date.getMonth ())
|
||||||
{
|
this.selectCell ((firstWeekDay + date.getDate ()) - 1);
|
||||||
var tdIndex = (firstWeekDay + date.getDate ()) - 1;
|
|
||||||
this.selectTd (this.tds[tdIndex]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
this.selectTd (null);
|
this.selectCell (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
,selectTd: function (td)
|
,selectCell: function (cellIndex)
|
||||||
{
|
{
|
||||||
if (this.selectedTd)
|
if (this.selectedCell != -1)
|
||||||
this.selectedTd.className = '';
|
{
|
||||||
if (td)
|
var node = this.cells[this.selectedCell].node;
|
||||||
td.className = 'highlight';
|
Vn.Node.removeClass (node, 'selected');
|
||||||
|
}
|
||||||
|
if (cellIndex != -1)
|
||||||
|
{
|
||||||
|
var node = this.cells[cellIndex].node;
|
||||||
|
Vn.Node.addClass (node, 'selected');
|
||||||
|
}
|
||||||
|
|
||||||
this.selectedTd = td;
|
this.selectedCell = cellIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
,putValue: function (value)
|
,putValue: function (value)
|
||||||
|
@ -211,15 +255,15 @@ Htk.Calendar = new Class
|
||||||
this.goToSelectedMonth ();
|
this.goToSelectedMonth ();
|
||||||
}
|
}
|
||||||
|
|
||||||
,dayClicked: function (td, tdIndex)
|
,dayClicked: function (td, cellIndex)
|
||||||
{
|
{
|
||||||
var monthDay = (tdIndex - this.getFirstWeekDay ()) + 1;
|
var cell = this.cells[cellIndex];
|
||||||
|
|
||||||
if (monthDay >= 1 && monthDay <= this.getMonthDays ())
|
if (cell.enabled)
|
||||||
{
|
{
|
||||||
this.selectTd (td);
|
this.selectCell (cellIndex);
|
||||||
|
|
||||||
var newDate = new Date (this.year, this.month, monthDay);
|
var newDate = new Date (this.year, this.month, cell.day);
|
||||||
this.valueChanged (newDate);
|
this.valueChanged (newDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,7 +293,7 @@ Htk.Calendar = new Class
|
||||||
|
|
||||||
this.refresh ();
|
this.refresh ();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
,prevYearClicked: function ()
|
,prevYearClicked: function ()
|
||||||
{
|
{
|
||||||
this.year--;
|
this.year--;
|
||||||
|
@ -260,5 +304,5 @@ Htk.Calendar = new Class
|
||||||
{
|
{
|
||||||
this.year++;
|
this.year++;
|
||||||
this.refresh ();
|
this.refresh ();
|
||||||
}
|
}*/
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,7 +63,7 @@ Sql.Value = new Class
|
||||||
|
|
||||||
,onParamChange: function ()
|
,onParamChange: function ()
|
||||||
{
|
{
|
||||||
if (this.paramLock)
|
if (this.paramLock || !this._param)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.paramLock = true;
|
this.paramLock = true;
|
||||||
|
|
|
@ -23,6 +23,30 @@ Vn.Node =
|
||||||
if (text)
|
if (text)
|
||||||
node.appendChild (document.createTextNode (text));
|
node.appendChild (document.createTextNode (text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
,addClass: function (node, className)
|
||||||
|
{
|
||||||
|
/* var classes = node.className.split (' ');
|
||||||
|
|
||||||
|
if (classes.split (' ').indexOf (className) == -1)
|
||||||
|
*/ node.className = className +' '+ node.className;
|
||||||
|
}
|
||||||
|
|
||||||
|
,removeClass: function (node, className)
|
||||||
|
{
|
||||||
|
var index = 0;
|
||||||
|
var found = false;
|
||||||
|
var classes = node.className.split (' ');
|
||||||
|
|
||||||
|
while ((index = classes.indexOf (className, index)) != -1)
|
||||||
|
{
|
||||||
|
classes.splice (index, 1);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
node.className = classes.join (' ');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function $ (id)
|
function $ (id)
|
||||||
|
|
Loading…
Reference in New Issue