From e69f7ca6344228225b97bd421f7c777004bc6cd4 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 1 Jan 2016 16:45:01 +0100 Subject: [PATCH] Add sample service and provider after the installation completes successfully. --- src/application/controllers/installation.php | 10 ++++ .../helpers/installation_helper.php | 52 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/application/controllers/installation.php b/src/application/controllers/installation.php index 9ab2c5eb..168056c6 100644 --- a/src/application/controllers/installation.php +++ b/src/application/controllers/installation.php @@ -100,6 +100,16 @@ class Installation extends CI_Controller { $this->settings_model->set_setting('company_email', $company['company_email']); $this->settings_model->set_setting('company_link', $company['company_link']); + // Create sample records. + $this->load->model('services_model'); + $this->load->model('providers_model'); + + $sample_service = get_sample_service(); + $sample_service['id'] = $this->services_model->add($sample_service); + $sample_provider = get_sample_provider(); + $sample_provider['services'][] = $sample_service['id']; + $this->providers_model->add($sample_provider); + echo json_encode(AJAX_SUCCESS); } catch (Exception $exc) { diff --git a/src/application/helpers/installation_helper.php b/src/application/helpers/installation_helper.php index 78e8af83..109c4f1c 100644 --- a/src/application/helpers/installation_helper.php +++ b/src/application/helpers/installation_helper.php @@ -1,5 +1,16 @@ + * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.1.0 + * ---------------------------------------------------------------------------- */ + /** * Check if Easy!Appointments is installed. * @@ -16,3 +27,44 @@ function is_ea_installed() { $ci =& get_instance(); return $ci->db->table_exists('ea_users'); } + +/** + * Get the data of a sample service. + * + * @return array + */ +function get_sample_service() { + return array( + 'name' => 'Test Service', + 'duration' => 30, + 'price' => 50.0, + 'currency' => 'Euro', + 'description' => 'This is a test service automatically inserted by the installer.', + 'id_service_categories' => NULL + ); +} + +/** + * Get the data of a sample provider. + * + * @return array + */ +function get_sample_provider() { + return array( + 'first_name' => 'John', + 'last_name' => 'Doe', + 'email' => 'john@doe.com', + 'phone_number' => '0123456789', + 'services' => array(), + 'settings' => array( + 'username' => 'johndoe', + 'password' => '59fe9d073a9c3c606a7e01e402dca4b49b6aa517bd0fdf940c46cb13a7b63dd0', + 'salt' => 'dc5570debc71fc1fe94b1b0aee444fcde5b8cb83d62a6a2b736ead6557d7a2e1', + 'working_plan' => '{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"saturday":null,"sunday":null}', + 'notifications' => FALSE, + 'google_sync' => FALSE, + 'sync_past_days' => 5, + 'sync_future_days' => 5 + ) + ); +}