From b87be634b40d38a2e46976ed0d1768cbad2ebcd5 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 9 Dec 2020 14:45:55 +0200 Subject: [PATCH] Applied same default data for both console and UI installation --- application/controllers/Console.php | 8 ++-- application/controllers/Installation.php | 59 ++++++++++++------------ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/application/controllers/Console.php b/application/controllers/Console.php index d34d6842..b2acee33 100644 --- a/application/controllers/Console.php +++ b/application/controllers/Console.php @@ -113,7 +113,7 @@ class Console extends EA_Controller { 'settings' => [ 'username' => 'administrator', 'password' => 'administrator', - 'notifications' => FALSE, + 'notifications' => TRUE, 'calendar_view' => CALENDAR_VIEW_DEFAULT ], ]); @@ -141,10 +141,10 @@ class Console extends EA_Controller { 'username' => 'janedoe', 'password' => 'janedoe', 'working_plan' => $this->settings_model->get_setting('company_working_plan'), - 'notifications' => FALSE, + 'notifications' => TRUE, 'google_sync' => FALSE, - 'sync_past_days' => 5, - 'sync_future_days' => 5, + 'sync_past_days' => 30, + 'sync_future_days' => 90, 'calendar_view' => CALENDAR_VIEW_DEFAULT ], ]); diff --git a/application/controllers/Installation.php b/application/controllers/Installation.php index a18d239b..e2ed6af7 100644 --- a/application/controllers/Installation.php +++ b/application/controllers/Installation.php @@ -29,6 +29,7 @@ class Installation extends EA_Controller { $this->load->model('settings_model'); $this->load->model('services_model'); $this->load->model('providers_model'); + $this->load->model('customers_model'); $this->load->library('migration'); $this->load->helper('installation'); $this->load->helper('string'); @@ -90,44 +91,44 @@ class Installation extends EA_Controller { $this->settings_model->set_setting('company_email', $company['company_email']); $this->settings_model->set_setting('company_link', $company['company_link']); - // Create sample records. - $services = [ - 'name' => 'Test Service', - 'duration' => 30, - 'price' => 50.0, - 'currency' => 'EUR', - 'description' => 'This is a test service automatically inserted by the installer.', + // Service + $service_id = $this->services_model->add([ + 'name' => 'Service', + 'duration' => '30', + 'price' => '0', + 'currency' => '', 'availabilities_type' => 'flexible', - 'attendants_number' => 1, - 'id_service_categories' => NULL - ]; - $services['id'] = $this->services_model->add($services); + 'attendants_number' => '1' + ]); - $salt = generate_salt(); - $password = random_string('alnum', 12); - - $sample_provider = [ - 'first_name' => 'John', + // Provider + $this->providers_model->add([ + 'first_name' => 'Jane', 'last_name' => 'Doe', - 'email' => 'john@example.org', - 'phone_number' => '0123456789', + 'email' => 'jane@example.org', + 'phone_number' => '+1 (000) 000-0000', 'services' => [ - $services['id'] + $service_id ], 'settings' => [ - 'username' => 'johndoe', - 'password' => hash_password($salt, $password), - 'salt' => $salt, - '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, + 'username' => 'janedoe', + 'password' => 'janedoe', + 'working_plan' => $this->settings_model->get_setting('company_working_plan'), + 'notifications' => TRUE, 'google_sync' => FALSE, - 'sync_past_days' => 5, - 'sync_future_days' => 5, + 'sync_past_days' => 30, + 'sync_future_days' => 90, 'calendar_view' => CALENDAR_VIEW_DEFAULT - ] - ]; + ], + ]); - $this->providers_model->add($sample_provider); + // Customer + $this->customers_model->add([ + 'first_name' => 'James', + 'last_name' => 'Doe', + 'email' => 'james@example.org', + 'phone_number' => '+1 (000) 000-0000', + ]); $response = AJAX_SUCCESS; }