diff --git a/application/controllers/api/v1/Unavailabilities_api_v1.php b/application/controllers/api/v1/Unavailabilities_api_v1.php index 016c196435..783a0a2cb7 100644 --- a/application/controllers/api/v1/Unavailabilities_api_v1.php +++ b/application/controllers/api/v1/Unavailabilities_api_v1.php @@ -50,8 +50,42 @@ public function index(): void $with = $this->api->request_with(); + $where = null; + + // Date query param. + + $date = request('date'); + + if (!empty($date)) { + $where['DATE(start_datetime)'] = (new DateTime($date))->format('Y-m-d'); + } + + // From query param. + + $from = request('from'); + + if (!empty($from)) { + $where['DATE(start_datetime) >='] = (new DateTime($from))->format('Y-m-d'); + } + + // Till query param. + + $till = request('till'); + + if (!empty($till)) { + $where['DATE(end_datetime) <='] = (new DateTime($till))->format('Y-m-d'); + } + + // Provider ID query param. + + $provider_id = request('providerId'); + + if (!empty($provider_id)) { + $where['id_users_provider'] = $provider_id; + } + $unavailabilities = empty($keyword) - ? $this->unavailabilities_model->get(null, $limit, $offset, $order_by) + ? $this->unavailabilities_model->get($where, $limit, $offset, $order_by) : $this->unavailabilities_model->search($keyword, $limit, $offset, $order_by); foreach ($unavailabilities as &$unavailability) { diff --git a/application/models/Appointments_model.php b/application/models/Appointments_model.php index 6c4644c14e..ef04e7f22d 100644 --- a/application/models/Appointments_model.php +++ b/application/models/Appointments_model.php @@ -616,6 +616,10 @@ public function api_decode(array &$appointment, array $base = null): void $decoded_request['id_services'] = $appointment['serviceId']; } + if (array_key_exists('color', $appointment)) { + $decoded_request['color'] = $appointment['color']; + } + if (array_key_exists('googleCalendarId', $appointment)) { $decoded_request['id_google_calendar'] = $appointment['googleCalendarId']; } diff --git a/application/models/Services_model.php b/application/models/Services_model.php index e8191cf136..3662484387 100644 --- a/application/models/Services_model.php +++ b/application/models/Services_model.php @@ -413,6 +413,7 @@ public function api_encode(array &$service): void 'duration' => (int) $service['duration'], 'price' => (float) $service['price'], 'currency' => $service['currency'], + 'color' => $service['color'], 'description' => $service['description'], 'location' => $service['location'], 'availabilitiesType' => $service['availabilities_type'], @@ -455,6 +456,10 @@ public function api_decode(array &$service, array $base = null): void $decoded_resource['currency'] = $service['currency']; } + if (array_key_exists('color', $service)) { + $decoded_resource['color'] = $service['color']; + } + if (array_key_exists('description', $service)) { $decoded_resource['description'] = $service['description']; } diff --git a/application/models/Unavailabilities_model.php b/application/models/Unavailabilities_model.php index 86ad425320..8c79b4396f 100644 --- a/application/models/Unavailabilities_model.php +++ b/application/models/Unavailabilities_model.php @@ -7,7 +7,7 @@ * @author A.Tselegidis * @copyright Copyright (c) Alex Tselegidis * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyunavailabilities.org + * @link https://easyappointments.org * @since v1.0.0 * ---------------------------------------------------------------------------- */ diff --git a/openapi.yml b/openapi.yml index d5916fba49..a39d81edce 100644 --- a/openapi.yml +++ b/openapi.yml @@ -2022,6 +2022,8 @@ components: format: float currency: type: string + color: + type: string location: type: string description: @@ -2040,6 +2042,7 @@ components: duration: 30 price: 10 currency: USD + color: '#123456' location: Test Street 1A, 12345 Some State, Some Place description: This is a test service. availabilitiesType: flexible @@ -2057,6 +2060,8 @@ components: type: number currency: type: string + color: + type: string location: type: string description: @@ -2074,6 +2079,7 @@ components: duration: 30 price: 10 currency: USD + color: '#123456' location: Test Street 1A, 12345 Some State, Some Place description: This is a test service. availabilitiesType: flexible