diff --git a/doc/translations.xls b/doc/translations.xls
index 552dc5a7..27b5869e 100644
Binary files a/doc/translations.xls and b/doc/translations.xls differ
diff --git a/src/application/controllers/backend_api.php b/src/application/controllers/backend_api.php
index 2b73d9db..51f335b3 100644
--- a/src/application/controllers/backend_api.php
+++ b/src/application/controllers/backend_api.php
@@ -1072,6 +1072,30 @@ class Backend_api extends CI_Controller {
));
}
}
+
+ /**
+ * This method will return a list of the available google calendars.
+ *
+ * The user will need to select a specific calendar from this list to sync his
+ * appointments with. Google access must be already granted for the specific
+ * provider.
+ *
+ * @param string $_POST['provider_id'] Provider record id.
+ */
+ public function ajax_get_google_calendars() {
+ try {
+ $this->load->library('google_sync');
+ $this->load->model('providers_model');
+
+ $calendars = $this->google_sync->get_google_calendars($_POST['provider_id']);
+ echo json_encode($calendars);
+
+ } catch(Exception $exc) {
+ echo json_encode(array(
+ 'exceptions' => array(exceptionToJavaScript($exc))
+ ));
+ }
+ }
}
/* End of file backend_api.php */
diff --git a/src/application/controllers/google.php b/src/application/controllers/google.php
index 8dc0f5a3..1bb5f520 100644
--- a/src/application/controllers/google.php
+++ b/src/application/controllers/google.php
@@ -58,6 +58,8 @@ class Google extends CI_Controller {
$_SESSION['oauth_provider_id']);
$this->providers_model->set_setting('google_token', $token,
$_SESSION['oauth_provider_id']);
+ $this->providers_model->set_setting('google_calendar', 'primary',
+ $_SESSION['oath_provider_id']);
} else {
echo '
Sync provider id not specified!
';
diff --git a/src/application/language/english/translations_lang.php b/src/application/language/english/translations_lang.php
index 45907558..f735c1d9 100644
--- a/src/application/language/english/translations_lang.php
+++ b/src/application/language/english/translations_lang.php
@@ -262,3 +262,5 @@ $lang['select_time'] = 'Select Time';
$lang['time'] = 'Time';
$lang['hour'] = 'Hour';
$lang['minute'] = 'Minute';
+$lang['google_sync_completed'] = 'Google synchronization completed successfully!';
+$lang['google_sync_failed'] = 'Google synchronization failed: Could not establish server connection.';
diff --git a/src/application/language/german/translations_lang.php b/src/application/language/german/translations_lang.php
index 902fe637..a45d5344 100644
--- a/src/application/language/german/translations_lang.php
+++ b/src/application/language/german/translations_lang.php
@@ -261,4 +261,6 @@ $lang['now'] = 'Jetzt';
$lang['select_time'] = 'Zeit Wählen';
$lang['time'] = 'Zeit';
$lang['hour'] = 'Uhr';
-$lang['minute'] = 'Minute';
\ No newline at end of file
+$lang['minute'] = 'Minute';
+$lang['google_sync_completed'] = 'Google Synchronisation erfolgreich beendet!';
+$lang['google_sync_failed'] = 'Google Synchronisation fehlgeschlagen: Serververbindung konnte nicht hergestellt werden.';
\ No newline at end of file
diff --git a/src/application/language/greek/translations_lang.php b/src/application/language/greek/translations_lang.php
index 159c7e99..1cb838e1 100644
--- a/src/application/language/greek/translations_lang.php
+++ b/src/application/language/greek/translations_lang.php
@@ -261,4 +261,6 @@ $lang['now'] = 'Τώρα';
$lang['select_time'] = 'Επιλέξτε Ώρα';
$lang['time'] = 'Χρόνος';
$lang['hour'] = 'Ώρα';
-$lang['minute'] = 'Λεπτά';
\ No newline at end of file
+$lang['minute'] = 'Λεπτά';
+$lang['google_sync_completed'] = 'Ο συγχρονισμός με την Google ολοκληρώθηκε επιτυχώς!';
+$lang['google_sync_failed'] = 'Ο συγχρονισμός με την Google απέτυχε: Δεν μπόρεσε να πραγματοποιηθεί σύνδεση με τον server.';
\ No newline at end of file
diff --git a/src/application/libraries/google_sync.php b/src/application/libraries/google_sync.php
index 6e9efe16..fce96097 100644
--- a/src/application/libraries/google_sync.php
+++ b/src/application/libraries/google_sync.php
@@ -9,7 +9,8 @@ require_once dirname(dirname(dirname(__FILE__))) . '/configuration.php';
* Google Synchronization Class
*
* This class implements all the core synchronization between the Google Calendar
- * and the Easy!Appointments system.
+ * and the Easy!Appointments system. Do not place any model handling inside this
+ * library.
*/
class Google_Sync {
private $CI;
@@ -293,6 +294,19 @@ class Google_Sync {
return $this->service->events->listEvents('primary', $params);
}
+
+ /**
+ * Return available google calendars for specific user.
+ *
+ * The given user's token must already exist in db in order to get access to his
+ * Google Calendar account.
+ *
+ * @param numeric $provider_id The provider's record id.
+ * @return array Returns an array with the available calendars.
+ */
+ public function get_google_calendars($provider_id) {
+
+ }
}
/* End of file google_sync.php */
diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php
index b208ab16..1eb4e5f4 100644
--- a/src/application/views/appointments/book.php
+++ b/src/application/views/appointments/book.php
@@ -81,10 +81,12 @@
};
var EALang = lang->language); ?>;
+ var availableLanguages = config->item('available_languages')); ?>;
$(document).ready(function() {
FrontendBook.initialize(true, GlobalVariables.manageMode);
GeneralFunctions.centerElementOnPage($('#book-appointment-wizard'));
+ GeneralFunctions.enableLanguageSelection($('#select-language'));
});
@@ -368,6 +370,10 @@
Easy!Appointments
+ |
+
+ config->item('language')); ?>
+
diff --git a/src/application/views/user/login.php b/src/application/views/user/login.php
index 8259b77e..0c5fdc6e 100644
--- a/src/application/views/user/login.php
+++ b/src/application/views/user/login.php
@@ -24,6 +24,10 @@
rel="stylesheet"
type="text/css"
href="config->base_url(); ?>assets/css/libs/bootstrap/bootstrap-responsive.css">
+
@@ -67,8 +71,11 @@
};
var EALang = lang->language); ?>;
+ var availableLanguages = config->item('available_languages')); ?>;
$(document).ready(function() {
+ GeneralFunctions.enableLanguageSelection($('#select-language'));
+
/**
* Event: Login Button "Click"
*
@@ -112,16 +119,30 @@
diff --git a/src/assets/js/backend_calendar.js b/src/assets/js/backend_calendar.js
index 778d0252..fd609aad 100644
--- a/src/assets/js/backend_calendar.js
+++ b/src/assets/js/backend_calendar.js
@@ -287,23 +287,24 @@ var BackendCalendar = {
if (response.exceptions) {
response.exceptions = GeneralFunctions.parseExceptions(response.exceptions);
- GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE, GeneralFunctions.EXCEPTIONS_MESSAGE);
+ GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE,
+ GeneralFunctions.EXCEPTIONS_MESSAGE);
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions));
return;
}
if (response.warnings) {
response.warnings = GeneralFunctions.parseExceptions(response.warnings);
- GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE, GeneralFunctions.WARNINGS_MESSAGE);
+ GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE,
+ GeneralFunctions.WARNINGS_MESSAGE);
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings));
}
- Backend.displayNotification('Google synchronization completed successfully!');
+ Backend.displayNotification(EALang['google_sync_completed']);
$('#reload-appointments').trigger('click');
},
'error': function(jqXHR, textStatus, errorThrown) {
- Backend.displayNotification('Google synchronization failed: Could not establish '
- + 'server connection.');
+ Backend.displayNotification(EALang['google_sync_failed']);
}
});
});
@@ -706,6 +707,9 @@ var BackendCalendar = {
$('#enable-sync span').text(EALang['disable_sync']);
$('#google-sync').prop('disabled', false);
$('#select-filter-item option:selected').attr('google-sync', 'true');
+
+ // Display the calendar selection dialog.
+
}
}
}, 100);
diff --git a/src/assets/js/frontend_book.js b/src/assets/js/frontend_book.js
index e1e9cbb6..bb48e088 100644
--- a/src/assets/js/frontend_book.js
+++ b/src/assets/js/frontend_book.js
@@ -324,9 +324,9 @@ var FrontendBook = {
var ajaxurl = GlobalVariables.baseUrl + 'appointments/ajax_get_available_hours';
jQuery.post(ajaxurl, postData, function(response) {
///////////////////////////////////////////////////////////////
- //console.log('Get Available Hours JSON Response:', response);
+ console.log('Get Available Hours JSON Response:', response);
///////////////////////////////////////////////////////////////
-
+
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
// The response contains the available hours for the selected provider and
diff --git a/src/assets/sql/structure.sql b/src/assets/sql/structure.sql
index 9bafd599..fd1d7497 100644
--- a/src/assets/sql/structure.sql
+++ b/src/assets/sql/structure.sql
@@ -173,6 +173,7 @@ CREATE TABLE IF NOT EXISTS `ea_user_settings` (
`notifications` tinyint(4) DEFAULT '0',
`google_sync` tinyint(4) DEFAULT '0',
`google_token` text,
+ `google_calendar` varchar(128) DEFAULT NULL,
`sync_past_days` int(11) DEFAULT '5',
`sync_future_days` int(11) DEFAULT '5',
PRIMARY KEY (`id_users`)
@@ -234,4 +235,4 @@ INSERT INTO `ea_roles` (`id`, `name`, `slug`, `is_admin`, `appointments`, `custo
INSERT INTO `ea_settings` (`name`, `value`) VALUES
('company_working_plan', '{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"saturday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"sunday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}}'),
-('book_advance_timeout', '30');
\ No newline at end of file
+('book_advance_timeout', '30');