From 918903de624ec20dbb5dfae85b2e383533c2b64e Mon Sep 17 00:00:00 2001 From: "alextselegidis@gmail.com" Date: Tue, 16 Apr 2013 21:37:36 +0000 Subject: [PATCH] =?UTF-8?q?=CE=A5=CE=BB=CE=BF=CF=80=CE=BF=CE=AF=CE=B7?= =?UTF-8?q?=CF=83=CE=B7=20=CE=BA=CF=8D=CF=81=CE=B9=CE=B1=CF=82=20=CE=BB?= =?UTF-8?q?=CE=B5=CE=B9=CF=84=CE=BF=CF=85=CF=81=CE=B3=CE=AF=CE=B1=CF=82=20?= =?UTF-8?q?=CF=84=CF=89=CE=BD=20=CF=84=CE=B5=CF=83=CF=83=CE=AC=CF=81=CF=89?= =?UTF-8?q?=CE=BD=20=CE=B2=CE=B7=CE=BC=CE=AC=CF=84=CF=89=CE=BD=20=CF=84?= =?UTF-8?q?=CE=B7=CF=82=20=CE=BA=CF=81=CE=AC=CF=84=CE=B7=CF=83=CE=B7=CF=82?= =?UTF-8?q?=20=CF=81=CE=B1=CE=BD=CF=84=CE=B5=CE=B2=CE=BF=CF=8D.=20=CE=9B?= =?UTF-8?q?=CE=B5=CE=AF=CF=80=CE=BF=CF=85=CE=BD=20=CE=B5=CF=80=CE=B9=CF=80?= =?UTF-8?q?=CE=BB=CE=AD=CE=BF=CE=BD=20=CE=BB=CE=B5=CE=B9=CF=84=CE=BF=CF=85?= =?UTF-8?q?=CF=81=CE=B3=CE=AF=CE=B5=CF=82=20=CE=B5=CE=BB=CE=AD=CF=87=CE=B3?= =?UTF-8?q?=CE=BF=CF=85=20=CF=84=CF=89=CE=BD=20=CE=B4=CE=B5=CE=B4=CE=BF?= =?UTF-8?q?=CE=BC=CE=AD=CE=BD=CF=89=CE=BD=20=CE=BA=CE=B1=CE=B9=20=CE=B7=20?= =?UTF-8?q?=CE=BC=CE=BF=CF=81=CF=86=CE=BF=CF=80=CE=BF=CE=AF=CE=B7=CF=83?= =?UTF-8?q?=CE=B7=20=CF=84=CE=B7=CF=82=20=CF=83=CE=B5=CE=BB=CE=AF=CE=B4?= =?UTF-8?q?=CE=B1=CF=82.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/application/controllers/appointments.php | 38 ++- src/application/models/providers.php | 49 +++- src/application/models/services.php | 6 +- src/application/models/settings.php | 1 - src/application/views/appointments/book.php | 229 ++++++++++++++++-- .../images/ui-bg_glass_55_fcf0ba_1x400.png | Bin 0 -> 333 bytes .../ui-bg_gloss-wave_100_ece8da_500x100.png | Bin 0 -> 5759 bytes .../ui-bg_highlight-hard_100_f5f3e5_1x100.png | Bin 0 -> 336 bytes .../ui-bg_highlight-hard_100_fafaf4_1x100.png | Bin 0 -> 321 bytes .../ui-bg_highlight-hard_15_459e00_1x100.png | Bin 0 -> 328 bytes .../ui-bg_highlight-hard_95_cccccc_1x100.png | Bin 0 -> 252 bytes .../ui-bg_highlight-soft_25_67b021_1x100.png | Bin 0 -> 353 bytes .../ui-bg_highlight-soft_95_ffedad_1x100.png | Bin 0 -> 351 bytes .../ui-bg_inset-soft_15_2b2922_1x100.png | Bin 0 -> 349 bytes .../jquery/images/ui-icons_808080_256x240.png | Bin 0 -> 7005 bytes .../jquery/images/ui-icons_847e71_256x240.png | Bin 0 -> 4549 bytes .../jquery/images/ui-icons_8DC262_256x240.png | Bin 0 -> 4549 bytes .../jquery/images/ui-icons_cd0a0a_256x240.png | Bin 0 -> 4549 bytes .../jquery/images/ui-icons_eeeeee_256x240.png | Bin 0 -> 6916 bytes src/assets/css/libs/jquery/jquery-ui.min.css | 6 +- src/assets/css/style.css | 42 ++-- src/assets/js/libs/jquery/jquery.qtip.min.js | 9 +- 22 files changed, 333 insertions(+), 47 deletions(-) create mode 100644 src/assets/css/libs/jquery/images/ui-bg_glass_55_fcf0ba_1x400.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_gloss-wave_100_ece8da_500x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_highlight-hard_100_f5f3e5_1x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_highlight-hard_100_fafaf4_1x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_highlight-hard_15_459e00_1x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_highlight-hard_95_cccccc_1x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_highlight-soft_25_67b021_1x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_highlight-soft_95_ffedad_1x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-bg_inset-soft_15_2b2922_1x100.png create mode 100644 src/assets/css/libs/jquery/images/ui-icons_808080_256x240.png create mode 100644 src/assets/css/libs/jquery/images/ui-icons_847e71_256x240.png create mode 100644 src/assets/css/libs/jquery/images/ui-icons_8DC262_256x240.png create mode 100644 src/assets/css/libs/jquery/images/ui-icons_cd0a0a_256x240.png create mode 100644 src/assets/css/libs/jquery/images/ui-icons_eeeeee_256x240.png diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index 00830ece..3d6a4618 100644 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -5,11 +5,45 @@ class Appointments extends CI_Controller { * This page displays the book appointment wizard * for the customers. */ - public function index() - { + public function index() { + // Get business name. $this->load->model('Settings'); $viewData['businessName'] = $this->Settings->getSetting('business_name'); + // Get the available services and providers. + $this->load->model('Services'); + $viewData['availableServices'] = $this->Services->getAvailableServices(); + + $this->load->model('Providers'); + $viewData['availableProviders'] = $this->Providers->getAvailableProviders(); // Provider rows contain an array of which services they can provide. + + // Load the book appointment view. $this->load->view('appointments/book', $viewData); } + + /** + * This method answers to an AJAX request. It calculates the + * available hours for the given service, provider and date. + * + * @param array $_POST['postData'] An associative array that + * contains the user selected service, provider and date. + */ + public function getAvailableHours() { + /*** CHECK BUSINESS WORKING HOURS ***/ + /*** CHECK PROVIDERS WORKING HOURS ***/ + /*** CHECK ALREADY BOOKED APPOINTMENTS ***/ + /*** RETURN AVAILABLE HOURS ***/ + + // ------------------------------------------------------------------ + // For now we just need to return a sample array. Dynamic calculation + // will be adding in future development. + $startTime = strtotime($_POST['selectedDate'] . ' 08:00') / 60; // Convert to minutes + $endTime = strtotime($_POST['selectedDate'] . ' 16:00') / 60; // Convert to minutes + + for ($i=0; ($startTime*60 + $i*60)<=($endTime*60); $i+=intval($_POST['serviceDuration'])) { + $availableHours[] = date('H:i', $startTime * 60 + $i * 60); + } + + echo json_encode($availableHours); + } } diff --git a/src/application/models/providers.php b/src/application/models/providers.php index b6eddc13..7182fe3e 100644 --- a/src/application/models/providers.php +++ b/src/application/models/providers.php @@ -1,7 +1,44 @@ +class Providers extends CI_Model { + public function __construct() { + parent::__construct(); + } + + /** + * This method returns the available providers and + * the services that can provide. + * + * @return array Returns an array with the providers + * data. + */ + public function getAvailableProviders() { + $sql = ' + SELECT ea_users.* + FROM ea_users + INNER JOIN ea_roles + ON ea_users.id_roles = ea_roles.id + WHERE ea_roles.slug = "provider"'; + + $providers = $this->db->query($sql)->result_array(); + + foreach($providers as &$provider) { + $sql = ' + SELECT id_services + FROM ea_services_providers + WHERE id_users = ' . $this->db->escape($provider['id']); + + $providerServices = $this->db->query($sql)->result_array(); + + if (!isset($provider['services'])) { + $provider['services'] = array(); + } + + foreach($providerServices as $providerService) { + $provider['services'][] = $providerService['id_services']; + } + } + + return $providers; + } +} +?> \ No newline at end of file diff --git a/src/application/models/services.php b/src/application/models/services.php index fac32b90..800acf33 100644 --- a/src/application/models/services.php +++ b/src/application/models/services.php @@ -10,10 +10,8 @@ class Services extends CI_Model { * @return array Returns an object array with all the * database services. */ - function getAllServices() { - $query = $this->db->query('SELECT *'); - - return $this->db->get('ea_services'); + function getAvailableServices() { + return $this->db->get('ea_services')->result_array(); } } ?> diff --git a/src/application/models/settings.php b/src/application/models/settings.php index f46f368d..92955290 100644 --- a/src/application/models/settings.php +++ b/src/application/models/settings.php @@ -27,7 +27,6 @@ class Settings extends CI_Model { * * @param string $name The setting name. * @param type $value The setting value. - * * @return bool Returns the operation success - failure * result. */ diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php index a7e46c7e..f4c7d206 100644 --- a/src/application/views/appointments/book.php +++ b/src/application/views/appointments/book.php @@ -1,6 +1,8 @@ + + @@ -13,13 +15,151 @@ + @@ -51,35 +191,96 @@

Select Service & Provider

- + - +
+ +
-
- - + -
+ -
- +