2020-04-22 22:48:56 +03:00
|
|
|
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
2015-10-18 20:18:02 +03:00
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
2024-01-01 01:14:38 +03:00
|
|
|
|
* MaketRandevu - MAKET Randevu Portalı
|
2015-10-18 20:18:02 +03:00
|
|
|
|
*
|
|
|
|
|
* @package EasyAppointments
|
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2021-12-18 19:43:45 +03:00
|
|
|
|
* @copyright Copyright (c) Alex Tselegidis
|
2020-11-14 22:36:25 +03:00
|
|
|
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
|
* @link https://easyappointments.org
|
2015-10-18 20:18:02 +03:00
|
|
|
|
* @since v1.1.0
|
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
2021-11-06 18:21:27 +03:00
|
|
|
|
* Installation controller.
|
2015-10-18 20:18:02 +03:00
|
|
|
|
*
|
2021-10-28 15:01:17 +03:00
|
|
|
|
* Handles the installation related operations.
|
2020-04-22 22:48:56 +03:00
|
|
|
|
*
|
2015-10-18 20:18:02 +03:00
|
|
|
|
* @package Controllers
|
|
|
|
|
*/
|
2023-11-29 12:24:09 +03:00
|
|
|
|
class Installation extends EA_Controller
|
|
|
|
|
{
|
2015-10-18 21:00:01 +03:00
|
|
|
|
/**
|
2020-12-02 21:04:06 +03:00
|
|
|
|
* Installation constructor.
|
2015-10-18 21:00:01 +03:00
|
|
|
|
*/
|
2017-09-15 14:36:37 +03:00
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2015-10-18 21:00:01 +03:00
|
|
|
|
parent::__construct();
|
2023-11-29 12:24:09 +03:00
|
|
|
|
|
2020-12-05 12:55:09 +03:00
|
|
|
|
$this->load->model('admins_model');
|
|
|
|
|
$this->load->model('settings_model');
|
|
|
|
|
$this->load->model('services_model');
|
|
|
|
|
$this->load->model('providers_model');
|
2020-12-09 15:45:55 +03:00
|
|
|
|
$this->load->model('customers_model');
|
2023-11-29 12:24:09 +03:00
|
|
|
|
|
2021-10-29 11:44:01 +03:00
|
|
|
|
$this->load->library('instance');
|
2015-10-18 21:00:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-18 20:18:02 +03:00
|
|
|
|
/**
|
|
|
|
|
* Display the installation page.
|
|
|
|
|
*/
|
2017-09-15 14:36:37 +03:00
|
|
|
|
public function index()
|
|
|
|
|
{
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (is_app_installed()) {
|
2023-03-13 11:06:18 +03:00
|
|
|
|
redirect();
|
2015-10-18 21:00:01 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-10 11:07:10 +03:00
|
|
|
|
$this->load->view('pages/installation', [
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'base_url' => config('base_url'),
|
2017-09-15 14:36:37 +03:00
|
|
|
|
]);
|
2015-10-18 20:18:02 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-12-09 15:46:27 +03:00
|
|
|
|
* Installs Easy!Appointments on the server.
|
2015-10-18 20:18:02 +03:00
|
|
|
|
*/
|
2021-12-10 11:07:10 +03:00
|
|
|
|
public function perform()
|
2017-09-15 14:36:37 +03:00
|
|
|
|
{
|
2023-11-29 12:24:09 +03:00
|
|
|
|
try {
|
|
|
|
|
if (is_app_installed()) {
|
2015-10-18 21:00:01 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-28 15:01:17 +03:00
|
|
|
|
$admin = request('admin');
|
|
|
|
|
$company = request('company');
|
2020-04-22 22:48:56 +03:00
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
$this->instance->migrate();
|
2015-11-05 23:19:52 +03:00
|
|
|
|
|
2015-10-18 20:18:02 +03:00
|
|
|
|
// Insert admin
|
2020-05-02 13:49:01 +03:00
|
|
|
|
$admin['timezone'] = 'UTC';
|
2015-10-18 20:18:02 +03:00
|
|
|
|
$admin['settings']['username'] = $admin['username'];
|
|
|
|
|
$admin['settings']['password'] = $admin['password'];
|
2023-11-29 12:24:09 +03:00
|
|
|
|
$admin['settings']['notifications'] = true;
|
2016-07-24 11:48:57 +03:00
|
|
|
|
$admin['settings']['calendar_view'] = CALENDAR_VIEW_DEFAULT;
|
2015-10-18 20:18:02 +03:00
|
|
|
|
unset($admin['username'], $admin['password']);
|
2021-10-28 15:01:17 +03:00
|
|
|
|
$admin['id'] = $this->admins_model->save($admin);
|
|
|
|
|
|
|
|
|
|
session([
|
|
|
|
|
'user_id' => $admin['id'],
|
|
|
|
|
'user_email' => $admin['email'],
|
|
|
|
|
'role_slug' => DB_SLUG_ADMIN,
|
|
|
|
|
'timezone' => $admin['timezone'],
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'username' => $admin['settings']['username'],
|
2021-10-28 15:01:17 +03:00
|
|
|
|
]);
|
2015-10-18 20:18:02 +03:00
|
|
|
|
|
|
|
|
|
// Save company settings
|
2021-10-28 15:01:17 +03:00
|
|
|
|
setting([
|
|
|
|
|
'company_name' => $company['company_name'],
|
|
|
|
|
'company_email' => $company['company_email'],
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'company_link' => $company['company_link'],
|
2021-10-28 15:01:17 +03:00
|
|
|
|
]);
|
2015-10-18 20:18:02 +03:00
|
|
|
|
|
2020-12-09 15:45:55 +03:00
|
|
|
|
// Service
|
2021-10-28 15:01:17 +03:00
|
|
|
|
$service_id = $this->services_model->save([
|
2020-12-09 15:45:55 +03:00
|
|
|
|
'name' => 'Service',
|
|
|
|
|
'duration' => '30',
|
|
|
|
|
'price' => '0',
|
|
|
|
|
'currency' => '',
|
2020-04-23 21:36:43 +03:00
|
|
|
|
'availabilities_type' => 'flexible',
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'attendants_number' => '1',
|
2020-12-09 15:45:55 +03:00
|
|
|
|
]);
|
2020-09-07 11:18:08 +03:00
|
|
|
|
|
2020-12-09 15:45:55 +03:00
|
|
|
|
// Provider
|
2021-10-28 15:01:17 +03:00
|
|
|
|
$this->providers_model->save([
|
2020-12-09 15:45:55 +03:00
|
|
|
|
'first_name' => 'Jane',
|
2020-04-23 21:36:43 +03:00
|
|
|
|
'last_name' => 'Doe',
|
2020-12-09 15:45:55 +03:00
|
|
|
|
'email' => 'jane@example.org',
|
|
|
|
|
'phone_number' => '+1 (000) 000-0000',
|
2023-11-29 12:24:09 +03:00
|
|
|
|
'services' => [$service_id],
|
2020-04-23 21:36:43 +03:00
|
|
|
|
'settings' => [
|
2020-12-09 15:45:55 +03:00
|
|
|
|
'username' => 'janedoe',
|
2023-03-01 11:00:24 +03:00
|
|
|
|
'password' => random_string(),
|
2021-10-28 15:01:17 +03:00
|
|
|
|
'working_plan' => setting('company_working_plan'),
|
2023-11-29 12:24:09 +03:00
|
|
|
|
'notifications' => true,
|
|
|
|
|
'google_sync' => false,
|
2020-12-09 15:45:55 +03:00
|
|
|
|
'sync_past_days' => 30,
|
|
|
|
|
'sync_future_days' => 90,
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'calendar_view' => CALENDAR_VIEW_DEFAULT,
|
|
|
|
|
],
|
2020-12-09 15:45:55 +03:00
|
|
|
|
]);
|
2020-04-23 21:36:43 +03:00
|
|
|
|
|
2020-12-09 15:45:55 +03:00
|
|
|
|
// Customer
|
2021-10-28 15:01:17 +03:00
|
|
|
|
$this->customers_model->save([
|
2020-12-09 15:45:55 +03:00
|
|
|
|
'first_name' => 'James',
|
|
|
|
|
'last_name' => 'Doe',
|
|
|
|
|
'email' => 'james@example.org',
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'phone_number' => '+1 (000) 000-0000',
|
2020-12-09 15:45:55 +03:00
|
|
|
|
]);
|
2016-01-01 17:45:01 +02:00
|
|
|
|
|
2021-10-28 15:01:17 +03:00
|
|
|
|
json_response([
|
2023-12-22 13:35:41 +03:00
|
|
|
|
'success' => true,
|
2021-10-28 15:01:17 +03:00
|
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
|
} catch (Throwable $e) {
|
2021-10-28 15:01:17 +03:00
|
|
|
|
json_exception($e);
|
2015-10-18 20:18:02 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|