Anonymous     JavaScript     02 Sep 2011    
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var offer_dates = {};
var offer_dates_array = new Array();
{% for offer_date in offer.offer_dates.all %}
var date_obj = new Date({{ offer_date.date.year }}, {{ offer_date.date.month }} - 1, {{ offer_date.date.day }});
var date_str = '{{ offer_date.date.year }}-{{ offer_date.date.month }}-{{ offer_date.date.day }}';
{# alert('Array length: ' + offer_dates_array.length + offer_dates_array); #}
{# alert($.inArray(date_str, offer_dates_array)); #}
if ($.inArray(date_str, offer_dates_array) > -1) {
offer_dates[date_obj]['quantity'] = offer_dates[date_obj]['quantity'] + {{ offer_date.quantity_available }};
{# alert('increment quantity with ' + {{ offer_date.quantity_available }} + ' to ' + offer_dates[date_obj]['quantity']); #}
}
else {
offer_dates_array.push(date_str);
{# alert('create new offer_date: ' + date_str); #}
offer_dates[date_obj] = {
'quantity': {{ offer_date.quantity_available }},
'selectable_offer_dates': new Array()
};
}
offer_dates[date_obj]['selectable_offer_dates'].push({
'id': {{ offer_date.id }},
'name': "{{ offer_date.allotment.name }}",
'quantity': {{ offer_date.quantity_available }},
'price': "€{{ offer_date.offer_price|floatformat:2|currency_nl_format }}"
});
{% endfor %}
var max_persons = {{ offer.max_persons }};
var max_adults = {{ offer.max_adults }};
var max_children = {{ max_children }};
var min_date = new Date({{ offer.offer_dates.all.0.date.year }}, {{ offer.offer_dates.all.0.date.month }} - 1, 1);
var first_offer_date = new Date({{ offer.offer_dates.all.0.date.year }}, {{ offer.offer_dates.all.0.date.month }}, {{ offer.offer_dates.all.0.date.day }});
var whitelabel_referral_name = '{{ whitelabel_referral.name }}';
var offer_options = new Array();
var offer_children = new Array();
{% for child in offer.offer_children.active %}
var offer_child = new Array();
offer_child['id'] = '{{ child.id }}';
offer_child['no_person_count'] = {% if child.no_person_count %}true{% else %}false{% endif %};
offer_children['id-{{ child.id }}'] = offer_child;
{% endfor %}