-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookings.htm
359 lines (340 loc) · 14.9 KB
/
bookings.htm
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
{% extends master.master %}
{% block title %}{% if data.Local.Resource != null %} {{ data.Local.Resource.Name }} | {% endif %}{% T Events and bookings %} | {{ data.Business.Name }}{% endblock %}
{% block main %}
{% assign type = '' %}
{% assign qsType = data.QueryString["type"] %}
{% if qsType != null %}{% assign type = qsType %}{% endif %}
{% assign showMemberDetails = data.Setting_Calendars_ShowMemberDetailsInFeed %}
{% assign defaultView = data.Setting_Calendars_DefaultView %}
{% assign resourceInAgendaView = 6 %}
{% if defaultView == 1 and data.Local.Resources.size > resourceInAgendaView %}{% assign defaultView = 'timelineDay' %}{% endif %}
{% if defaultView == 1 and data.Local.Resources.size <= resourceInAgendaView %}{% assign defaultView = 'agendaDay' %}{% endif %}
{% if defaultView == 2 %}{% assign defaultView = 'agendaWeek' %}{% endif %}
{% if defaultView == 3 %}{% assign defaultView = 'month' %}{% endif %}
{% if defaultView == 4 %}{% assign defaultView = 'list' %}{% endif %}
{% if data.Local.ShowAll == false %}{% assign defaultView = 'list' %}{% endif %}
{% if data.Local.OnlyEvents == true %}{% assign defaultView = 'month' %}{% endif %}
{% assign qsView = data.QueryString["view"] %}
{% if qsView != null %}{% assign defaultView = qsView %}{% endif %}
<div class="container">
<!-- BREADCRUMBS -->
<ol class="breadcrumb">
<li><a href="{{ data.Business.HomeUrl }}">{% T Home %}</a></li>
{% if data.Local.ShowAll %}
<li class="active">{% T Bookings %}</li>
{% else %}
<li class="active">{% T My Bookings %}</li>
{% endif %}
</ol>
<!-- END BREADCRUMBS -->
<div class="alert alert-danger" role="alert" id="rotate_device_alert">
<script>
if(window.addEventListener) {
window.addEventListener("orientationchange", function() {
location.reload();
});
}
</script>
<style>
@media only screen and (min-width: 600px) {
#rotate_device_alert {
display: none;
}
}
</style>
<strong>{% T Heads up! %}</strong>
{% T Rotate your device to a horizontal position to see the full calendar %}
</div>
<!-- PAGE HEADER -->
<div class="page-header page-header--flex">
<div class="page-header--flex__item">
{% if data.Local.ShowAll %}
<h1>{% T Bookings %}</h1>
{% else %}
<h1>{% T My Bookings %}</h1>
{% endif %}
</div>
<div class="page-header--flex__item">
<div class="btn-toolbar">
{% if data.Coworker != null %}
<a href="{% Url Bookings, My %}" class="btn btn--secondary">{% T My bookings %}</a>
{% endif %}
<a href="#" onclick="bookingManager.createBooking(); return false;" class="btn btn--primary">{% T Make a booking %}</a>
</div>
</div>
</div>
<!-- END PAGE HEADER -->
<!-- FILTERS -->
<div class="filters">
<ul class="nav filters__nav">
{% include bookings_resources_menu.htm %}
<li class="active pull-right">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
{% T Location %}: {{ data.Business.Name }} <span class="caret"></span>
</a>
{% include core_locations_list.htm %}
</li>
</ul>
</div>
<!-- END FILTERS -->
<!-- BOOKINGS -->
<div class="bookings">
<!-- BOOKINGS CALENDAR -->
<div id="calendar" class="fc fc-ltr fc-unthemed">
<div class="calendar-loading-bar hide">
<div class="progress" style="width: 100%">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
<span class="sr-only">{% T Loading... %}</span>
</div>
</div>
</div>
</div>
<!-- END BOOKINGS CALENDAR -->
<!-- MODAL DIALOGS -->
{% include bookings_registration_form.htm %}
{% include bookings_booking_form.htm %}
{% include bookings_carousel.htm %}
<!-- END MODAL DIALOGS -->
</div>
<!-- END BOOKINGS -->
</div>
{% endblock %}
{% block scripts %}
<script>
var resources = [
{% if data.Local.Resource == null %}
{% for resource in data.Local.Resources %}
{% assign resourceGroupKey = resource.GroupName | Clean %}
{% assign resourceGroupName = resource.GroupName %}
{% if resourceGroupKey == '' %}
{% assign resourceGroupKey = 'resources' %}
{% assign resourceGroupName = 'Resources' %}
{% endif %}
{% if type == resourceGroupKey or type == '' %}
{
id:{{ resource.Id }},
UniqueId: '{{ resource.UniqueId }}',
imageUrl: '{% if resource.HasImage %}{% Url PublicResources, GetImage, id: resource.Id, h: 200, w: 312 %}{% else %}http://placehold.it/312x200?text=?{% endif %}',
thumbUrl: '{% if resource.HasImage %}{% Url PublicResources, GetImage, id: resource.Id, h: 32, w: 32 %}{% else %}http://placehold.it/32x32?text=?{% endif %}',
groupName: '{% T resourceGroupName %}',
title:'{{ resource.Name | Replace: "'", "\'" }}',
resourceTypeName:'{{ resource.ResourceTypeName | Replace: "'", "\'" }}',
eventColor: getColurFromName('{{ resource.Name | Replace: "'", "\'" }}')},
{% endif %}
{% endfor %}
{% else %}
{
id:{{ data.Local.Resource.Id }},
imageUrl: '{% if data.Local.Resource.HasImage %}{% Url PublicResources, GetImage, id: data.Local.Resource.Id, h: 200, w: 312 %}{% else %}http://placehold.it/312x200?text=?{% endif %}',
thumbUrl: '{% if data.Local.Resource.HasImage %}{% Url PublicResources, GetImage, id: data.Local.Resource.Id, h: 32, w:32 %}{% else %}http://placehold.it/32x32?text=?{% endif %}',
groupName: '{% T resourceGroupName %}',
title:'{{ data.Local.Resource.Name | Replace: "'", "\'" }}',
resourceTypeName:'{{ data.Local.Resource.ResourceTypeName | Replace: "'", "\'" }}',
eventColor: getColurFromName('{{ data.Local.Resource.Name | Replace: "'", "\'" }}')}
{% endif %}
];
var bookingManager = new BookingManager({
dateTimeFormat: 'D, dd MM yyyy - HH:ii P',
resources: resources,
roundMinutesTo: 30,
coworker: {
Id: {% if data.Coworker != null %}{{data.Coworker.Id}}{% else %}null{% endif %}
},
guestBookings: {% if data.Setting_Bookings_EnableGuestBookings %}true{% else %}false{% endif %},
loginUrl: '{% Url Login, Index, lang: data.Language %}&returnUrl={{ data.URL }}',
availableUrl: '{% Url Bookings, GetBookingPrice %}',
dayAvailableUrl: '{% Url Bookings, GetAvailabilityAt %}',
productsUrl: '{% Url Bookings, GetResourceProducts %}',
newBookingUrl: '{% Url Bookings, NewBookingJson %}',
updateBookingUrl: '{% Url Bookings, BookingJson %}',
visitorsUrl: '{% Url Bookings, GetBookingVisitors %}',
bookingUrl: '{% Url Bookings, BookingJson %}',
deleteBookingUrl: '{% Url Bookings, DeleteJson %}',
paymentUrl: '{% Url Bookings, Pay %}'
});
bookingManager.getBalance();
bookingManager.applyBindings();
var fc = $('#calendar').fullCalendar({
schedulerLicenseKey: '0011856468-fcs-1444557994',
lang: '{{ data.Language }}',
allDaySlot: false,
titleFormat: $(window).width() >= 768 ? 'ddd, MMM Do YYYY' : 'MMM DD' ,
scrollTime: '06:00',
minTime:'06:00',
aspectRatio: 1.8,
height: 'auto',
firstDay: 1,
editable: false,
selectable: true,
selectHelper: true,
select: function(start, end, allDay, view, resourceObj) {
var calendar = $('#calendar');
if(resourceObj)
$('#Booking_Resource').val(resourceObj.id);
else
$('#Booking_Resource').val(null);
start = start.clone().local();
end = end.clone().local();
if(start.hours() == 0) start.hours(8);
if(end.hours() == 0) end = null;
{% if data.Coworker != null %}
bookingManager.createBooking({
resourceId: resourceObj ? resourceObj.id : null,
date: start.toDate(),
endDate: end != null ? end.toDate() : null
});
{% elseif data.Setting_Bookings_EnableGuestBookings %}
bookingManager.createBooking({
resourceId: resourceObj ? resourceObj.id : null,
date: start.toDate(),
endDate: end != null ? end.toDate() : null
});
{% else %}
app.showMessage("{% T Login to make a booking %}");
{% endif %}
calendar.fullCalendar('unselect');
},
resourceLabelText: '{{ data.Business.Name | Replace: "'", "\'" }}',
resourceGroupField: 'groupName',
viewRender: function (view) {
//Update all links with data-url parameter so when clicked they preserve the current date and view of the calendar.
var date = view.intervalStart.format('YYYY-MM-DD');
$('a[data-url]').each(function(){
var url = $(this).attr('data-url');
var newUrl = url + (url.indexOf('?') > -1 ? '&' : '?') +'date=' + date + '&view=' + view.name + '&showAll={{ data.Local.ShowAll }}';
$(this).attr('href', newUrl);
});
//Store the current URL in the calendar element. This is used by several scripts to be able to
//reload the current calendar state.
var currentUrl = window.location.href;
var calendarUrl = currentUrl.replace(/(date=)[^\&]+/, '');
calendarUrl = calendarUrl.replace(/(view=)[^\&]+/, '');
calendarUrl = calendarUrl + (calendarUrl.indexOf('?') > -1 ? '' : '?') +'date=' + date + '&view=' + view.name;
$('#calendar').attr('data-calendar-url', calendarUrl);
},
resources: resources,
eventClick: function(calEvent, jsEvent, view) {
if(calEvent.url)
window.location = calEvent.url;
else if(calEvent.private) {
app.showMessage("{% T You cannot view this booking %}", "{% T This booking was made by another user and you cannot see its details. %}");
return false;
}
else
{
bookingManager.showBooking(calEvent);
return false;
}
},
dayClick: function(date, evData, jsEvent, resourceObj ) {
date = date.clone().local().toDate();
bookingManager.createBooking({
resourceId: resourceObj ? resourceObj.id : null,
date: date
});
},
defaultView: $(window).width() < 768 ? 'list' : '{% if data.Local.Resource.Id > 0 %}agendaDay{% else %}{{defaultView}}{% endif %}',
editable: true,
displayEventEnd: true,
defaultDate: moment('{{ data.Local.CurrentDate | FormatDate: 'yyyy-MM-dd' }}'),
header: {
left: 'title',
center: $(window).width() < 768 ? null : 'month,agendaWeek,{% if data.Local.Resource.Id > 0 or data.Resources.size <= resourceInAgendaView %}agendaDay{% else %}timelineDay{% endif %},list',
right: $(window).width() < 768 ? 'prev,next' : 'today prev,next'
},
resourceRender: function(resourceObj, dataTds, eventTd) {
{% for resource in data.Resources %}
{% if resource.HasImage %}
if(resourceObj.id == {{ resource.Id }}){
dataTds.find('.fc-cell-text').prepend('<img data-toggle="lightbox" href="#resource-image-{{resource.Id}}" style="cursor: pointer; display: inline; margin-right: 10px; border: 1px solid rgb(51, 51, 51)" src="{% Url PublicResources, GetImage, id: resource.Id, h: 20, w: 20 %}" />');
$('#calendar').append('<div id="resource-image-{{resource.Id}}" class="lightbox hide fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="lightbox-content"><img src="{% Url PublicResources, GetImage, id: resource.Id, h: 600, w: 800 %}"/><div class="lightbox-caption"><p>{{ resource.Name }}</p></div></div></div>');
}
{% endif %}
{% endfor %}
},
eventRender: function (event, element) {
var color = 'black';
if(event.teamBooking) color = '#484848';
if(event.url) color = '#a1a1a1';
if(event.private) color = getColurFromName(event.resourceName);
if(event.coworkerFullName){
$(element).attr("data-original-title", event.coworkerFullName)
$(element).tooltip({ container: "body"})
}
element.css('background-color', color);
element.css('border-color', color);
element.find('div.fc-title').html(element.find('div.fc-title').text());
},
loading: function( isLoading, view ) {
if(isLoading) {
$('.calendar-loading-bar').removeClass('hide');
} else {
$('.calendar-loading-bar').addClass('hide');
}
},
eventSources: [
{% if data.Local.OnlyEvents == false %}
{
url: '{% Url Bookings, FullCalendarBookings %}',
type: 'POST',
data: {
resourcetypeid: '{{ data.Local.SelectedResourceType.Id }}',
resourceId: '{{ data.Local.Resource.Id }}',
showAllBookings: '{{ data.Local.ShowAllBookings }}',
showMemberDetails: '{{ showMemberDetails }}',
myBookingsColor: 'black',
group: '{{ data.Local.Group | Clean }}',
showAll: '{{ data.Local.ShowAll }}'
},
error: function() {
app.showMessage('We could not load the booking calendar');
},
},
{% endif %}
{
url: '{% Url Bookings, FullCalendarEvents %}',
type: 'POST',
data: {
resourcetypeid: '{{ data.Local.SelectedResourceType.Id }}',
resourceId: '{{ data.Local.Resource.Id }}',
showAllBookings: '{{ data.Local.ShowAllBookings }}',
showMemberDetails: '{{ showMemberDetails }}',
},
color: '#c0392b',
error: function() {
app.showMessage('We could not load the events calendar');
},
},
]
});
function getColurFromName(name){
var colors = [
"#1abc9c",
"#2ecc71",
"#3498db",
"#9b59b6",
"#16a085",
"#27ae60",
"#2980b9",
"#8e44ad",
"#f1c40f",
"#e67e22",
"#e74c3c",
"#f39c12",
"#d35400",
"#c0392b"
];
// Generate a Hash for the String
var hash = function(word) {
var hash = 0;
for (var i = 0; i < word.length; i++) {
var charCode = word.charCodeAt(i);
hash += charCode;
}
return hash;
};
var index = hash(name) % colors.length;
return colors[index];
}
</script>
{% endblock %}