Display working plan on provider's calendar.

This commit is contained in:
alextselegidis@gmail.com 2013-07-05 16:20:33 +00:00
parent 756114685b
commit c4b7dc267e
5 changed files with 161 additions and 37 deletions

View file

@ -47,6 +47,10 @@ root {
#calendar-page #calendar-filter select { margin-top: 5px; } #calendar-page #calendar-filter select { margin-top: 5px; }
#calendar-page #calendar-actions { display: inline-block; float: right; margin-top: 4px; } #calendar-page #calendar-actions { display: inline-block; float: right; margin-top: 4px; }
#calendar-page #calendar { margin: 12px; } #calendar-page #calendar { margin: 12px; }
#calendar-page #calendar .fc-unavailable { background-image: url('../images/unavailable.jpg');
font-size: 24px; border: none; border-radius: 0; font-weight: bold; color: #333;
text-shadow: 0px 1px 0px #FFF;}
#calendar-page #calendar .fc-break { background-image: url('../images/break.jpg'); }
/* BACKEND CUSTOMERS PAGE /* BACKEND CUSTOMERS PAGE
-------------------------------------------------------------------- */ -------------------------------------------------------------------- */

BIN
src/assets/images/break.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View file

@ -497,7 +497,7 @@ var BackendCalendar = {
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings)); $('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings));
} }
// Add the appointments to the calendar. // :: ADD APPOINTMENTS TO CALENDAR
var calendarEvents = new Array(); var calendarEvents = new Array();
$.each(response, function(index, appointment){ $.each(response, function(index, appointment){
@ -518,36 +518,155 @@ var BackendCalendar = {
calendarHandle.fullCalendar('removeEvents'); calendarHandle.fullCalendar('removeEvents');
calendarHandle.fullCalendar('addEventSource', calendarEvents); calendarHandle.fullCalendar('addEventSource', calendarEvents);
// Add the provider's unavailable time periods. // :: ADD PROVIDER'S UNAVAILABLE TIME PERIODS
$.each(GlobalVariables.availalbeProviders, function(index, provider) { var calendarView = $('#calendar').fullCalendar('getView').name;
if (provider['id'] == recordId) { if (filterType === BackendCalendar.FILTER_TYPE_PROVIDER
var workingPlan = provider['settings']['working_plan']; && calendarView !== 'month') {
var start, end;
var calStart = ''; $.each(GlobalVariables.availableProviders, function(index, provider) {
var calEnd = ''; if (provider['id'] == recordId) {
var workingPlan = jQuery.parseJSON(provider['settings']['working_plan']);
$.each(workingPlan, function(index, workingDay) { var unavailablePeriod;
// Add before the work start an unavailable time period.
start = ''; switch(calendarView) {
end = ''; case 'agendaDay':
BackendCalendar.addUnavailableTimePeriod(start, end); var selDayName = $('#calendar').fullCalendar('getView')
.start.toString('dddd').toLowerCase();
// Add after the work end an unavailable time period.
// Add unavailable period before work starts.
var calendarDateStart = $('#calendar').fullCalendar('getView').start;
// Add the break time periods. var workDateStart = Date.parseExact(
calendarDateStart.toString('dd/MM/yyyy') + ' '
+ workingPlan[selDayName].start,
// @task Add custom unavailable time periods. 'dd/MM/yyyy HH:mm');
}); if (calendarDateStart < workDateStart) {
unavailablePeriod = {
return; // break $.each() 'title': 'Unavailable',
} 'start': calendarDateStart,
}); 'end': workDateStart,
'allDay': false,
'color': '#AAA',
'editable': false,
'className': 'fc-unavailable'
};
$('#calendar').fullCalendar('renderEvent', unavailablePeriod, true);
}
// Add unavailable period after work ends.
var calendarDateEnd = $('#calendar').fullCalendar('getView').end;
var workDateEnd = Date.parseExact(
calendarDateStart.toString('dd/MM/yyyy') + ' '
+ workingPlan[selDayName].end,
'dd/MM/yyyy HH:mm'); // Use calendarDateStart ***
if (calendarDateEnd > workDateEnd) {
var unavailablePeriod = {
'title': 'Unavailable',
'start': workDateEnd,
'end': calendarDateEnd,
'allDay': false,
'color': '#AAA',
'editable': false,
'className': 'fc-unavailable'
};
$('#calendar').fullCalendar('renderEvent', unavailablePeriod, true);
}
// Add unavailable periods for breaks.
var breakStart, breakEnd;
$.each(workingPlan[selDayName].breaks, function(index, currBreak) {
breakStart = Date.parseExact(calendarDateStart.toString('dd/MM/yyyy')
+ ' ' + currBreak.start, 'dd/MM/yyyy HH:mm');
breakEnd = Date.parseExact(calendarDateStart.toString('dd/MM/yyyy')
+ ' ' + currBreak.end, 'dd/MM/yyyy HH:mm');
var unavailablePeriod = {
'title': 'Break',
'start': breakStart,
'end': breakEnd,
'allDay': false,
'color': '#AAA',
'editable': false,
'className': 'fc-unavailable fc-break'
};
$('#calendar').fullCalendar('renderEvent', unavailablePeriod, true);
});
// @task Add custom unavailable periods.
break;
case 'agendaWeek':
var currDateStart = GeneralFunctions.clone($('#calendar').fullCalendar('getView').start);
var currDateEnd = GeneralFunctions.clone(currDateStart).addDays(1);
$.each(workingPlan, function(index, workingDay) {
var start, end;
// Add unavailable period before work starts.
start = Date.parseExact(currDateStart.toString('dd/MM/yyyy')
+ ' ' + workingDay.start, 'dd/MM/yyyy HH:mm');
if (currDateStart < start) {
unavailablePeriod = {
'title': 'Unavailable',
'start': GeneralFunctions.clone(currDateStart),
'end': GeneralFunctions.clone(start),
'allDay': false,
'color': '#AAA',
'editable': false,
'className': 'fc-unavailable'
};
$('#calendar').fullCalendar('renderEvent', unavailablePeriod,
true);
}
// Add unavailable period after work ends.
end = Date.parseExact(currDateStart.toString('dd/MM/yyyy')
+ ' ' + workingDay.end, 'dd/MM/yyyy HH:mm');
if (currDateEnd > end) {
unavailablePeriod = {
'title': 'Unavailable',
'start': GeneralFunctions.clone(end),
'end': GeneralFunctions.clone(currDateEnd),
'allDay': false,
'color': '#AAA',
'editable': false,
'className': 'fc-unavailable fc-brake'
};
$('#calendar').fullCalendar('renderEvent', unavailablePeriod, true);
}
// Add unavailable periods during day breaks.
var breakStart, breakEnd;
$.each(workingDay.breaks, function(index, currBreak) {
breakStart = Date.parseExact(currDateStart.toString('dd/MM/yyyy')
+ ' ' + currBreak.start, 'dd/MM/yyyy HH:mm');
breakEnd = Date.parseExact(currDateStart.toString('dd/MM/yyyy')
+ ' ' + currBreak.end, 'dd/MM/yyyy HH:mm');
var unavailablePeriod = {
'title': 'Break',
'start': breakStart,
'end': breakEnd,
'allDay': false,
'color': '#AAA',
'editable': false,
'className': 'fc-unavailable fc-break'
};
$('#calendar').fullCalendar('renderEvent', unavailablePeriod, true);
});
// @task Add custom unavailable periods.
currDateStart.addDays(1);
currDateEnd.addDays(1);
});
break;
}
}
});
}
}, 'json'); }, 'json');
}, },
@ -722,6 +841,10 @@ var BackendCalendar = {
calendarEventClick: function(event, jsEvent, view) { calendarEventClick: function(event, jsEvent, view) {
$('.popover').remove(); // Close all open popovers. $('.popover').remove(); // Close all open popovers.
if ($(jsEvent.target).hasClass('fc-unavailable')) {
return; // do not show popover on unavailable events
}
// Display a popover with the event details. // Display a popover with the event details.
var html = var html =
'<style type="text/css">' '<style type="text/css">'
@ -892,10 +1015,7 @@ var BackendCalendar = {
// Make an ajax call to the server in order to disable the setting // Make an ajax call to the server in order to disable the setting
// from the database. // from the database.
var postUrl = GlobalVariables.baseUrl + 'backend/ajax_disable_provider_sync'; var postUrl = GlobalVariables.baseUrl + 'backend/ajax_disable_provider_sync';
var postData = { 'provider_id' : providerId };
var postData = {
'provider_id' : providerId
};
$.post(postUrl, postData, function(response) { $.post(postUrl, postData, function(response) {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View file

@ -1,13 +1,13 @@
<?php <?php
class SystemConfiguration { class SystemConfiguration {
// General Settings // General Settings
public static $base_url = 'http://localhost/dev/easy_appointments/trunk/src/'; public static $base_url = 'http://localhost/dev/external/easy_appointments/trunk/src/';
// Database Settings // Database Settings
public static $db_host = 'localhost'; public static $db_host = 'localhost';
public static $db_name = 'easy_appointments'; public static $db_name = 'easy_appointments';
public static $db_username = 'root'; public static $db_username = 'root';
public static $db_password = 'root'; public static $db_password = '';
// Google Calendar API Settings // Google Calendar API Settings
public static $google_product_name = 'Easy!Appointments'; public static $google_product_name = 'Easy!Appointments';