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