Applied same default data for both console and UI installation

This commit is contained in:
Alex Tselegidis 2020-12-09 14:45:55 +02:00
parent 4252bc8d0b
commit b87be634b4
2 changed files with 34 additions and 33 deletions

View file

@ -113,7 +113,7 @@ class Console extends EA_Controller {
'settings' => [ 'settings' => [
'username' => 'administrator', 'username' => 'administrator',
'password' => 'administrator', 'password' => 'administrator',
'notifications' => FALSE, 'notifications' => TRUE,
'calendar_view' => CALENDAR_VIEW_DEFAULT 'calendar_view' => CALENDAR_VIEW_DEFAULT
], ],
]); ]);
@ -141,10 +141,10 @@ class Console extends EA_Controller {
'username' => 'janedoe', 'username' => 'janedoe',
'password' => 'janedoe', 'password' => 'janedoe',
'working_plan' => $this->settings_model->get_setting('company_working_plan'), 'working_plan' => $this->settings_model->get_setting('company_working_plan'),
'notifications' => FALSE, 'notifications' => TRUE,
'google_sync' => FALSE, 'google_sync' => FALSE,
'sync_past_days' => 5, 'sync_past_days' => 30,
'sync_future_days' => 5, 'sync_future_days' => 90,
'calendar_view' => CALENDAR_VIEW_DEFAULT 'calendar_view' => CALENDAR_VIEW_DEFAULT
], ],
]); ]);

View file

@ -29,6 +29,7 @@ class Installation extends EA_Controller {
$this->load->model('settings_model'); $this->load->model('settings_model');
$this->load->model('services_model'); $this->load->model('services_model');
$this->load->model('providers_model'); $this->load->model('providers_model');
$this->load->model('customers_model');
$this->load->library('migration'); $this->load->library('migration');
$this->load->helper('installation'); $this->load->helper('installation');
$this->load->helper('string'); $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_email', $company['company_email']);
$this->settings_model->set_setting('company_link', $company['company_link']); $this->settings_model->set_setting('company_link', $company['company_link']);
// Create sample records. // Service
$services = [ $service_id = $this->services_model->add([
'name' => 'Test Service', 'name' => 'Service',
'duration' => 30, 'duration' => '30',
'price' => 50.0, 'price' => '0',
'currency' => 'EUR', 'currency' => '',
'description' => 'This is a test service automatically inserted by the installer.',
'availabilities_type' => 'flexible', 'availabilities_type' => 'flexible',
'attendants_number' => 1, 'attendants_number' => '1'
'id_service_categories' => NULL ]);
];
$services['id'] = $this->services_model->add($services);
$salt = generate_salt(); // Provider
$password = random_string('alnum', 12); $this->providers_model->add([
'first_name' => 'Jane',
$sample_provider = [
'first_name' => 'John',
'last_name' => 'Doe', 'last_name' => 'Doe',
'email' => 'john@example.org', 'email' => 'jane@example.org',
'phone_number' => '0123456789', 'phone_number' => '+1 (000) 000-0000',
'services' => [ 'services' => [
$services['id'] $service_id
], ],
'settings' => [ 'settings' => [
'username' => 'johndoe', 'username' => 'janedoe',
'password' => hash_password($salt, $password), 'password' => 'janedoe',
'salt' => $salt, 'working_plan' => $this->settings_model->get_setting('company_working_plan'),
'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' => TRUE,
'notifications' => FALSE,
'google_sync' => FALSE, 'google_sync' => FALSE,
'sync_past_days' => 5, 'sync_past_days' => 30,
'sync_future_days' => 5, 'sync_future_days' => 90,
'calendar_view' => CALENDAR_VIEW_DEFAULT '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; $response = AJAX_SUCCESS;
} }