PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / trunk
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution vtrunk
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
← All changes | app/Http/Controllers/CalendarIntegrationController.php +53 -0 2.1.2trunk View file →
@@ -7,8 +7,10 @@
7 7 use FluentBooking\App\Models\CalendarSlot;
8 8 use FluentBooking\App\Services\Helper;
9 9 use FluentBooking\App\Services\PermissionManager;
10 10 use FluentBooking\App\Services\Integrations\CalendarIntegrationService;
11 +use FluentBooking\App\Services\Integrations\FluentCRM\CrmContactService;
12 +use FluentCrm\App\Services\PermissionManager as CrmPermissionManager;
11 13
12 14 class CalendarIntegrationController extends Controller
13 15 {
14 16 public function index(CalendarIntegrationService $integrationService, $calendarId, $eventId)
@@ -147,8 +149,59 @@
147 149 $fieldOptions = apply_filters('fluent_booking/get_integration_config_field_options_' . $integrationName, $settings, $calendarEventId);
148 150
149 151 return $this->sendSuccess([
150 152 'field_options' => $fieldOptions,
153 + ]);
154 + } catch (Exception $e) {
155 + return $this->sendError([
156 + 'message' => $e->getMessage(),
157 + ], 422);
158 + }
159 + }
160 +
161 + public function createCrmTaxonomy($calendarId, $slotId, $integrationId)
162 + {
163 + try {
164 + $this->getCalendarEvent($calendarId, $slotId);
165 +
166 + if (!CrmContactService::isActive()) {
167 + return $this->sendError([
168 + 'message' => __('FluentCRM is not active.', 'fluent-booking'),
169 + ], 422);
170 + }
171 +
172 + if (!CrmPermissionManager::currentUserCan('fcrm_manage_contact_cats')) {
173 + return $this->sendError([
174 + 'message' => __('You do not have permission to create FluentCRM tags or lists.', 'fluent-booking'),
175 + ], 403);
176 + }
177 +
178 + $type = $this->request->get('type');
179 + $title = trim((string) $this->request->get('title'));
180 +
181 + if (!in_array($type, ['tags', 'lists'], true)) {
182 + return $this->sendError([
183 + 'message' => __('Invalid taxonomy type.', 'fluent-booking'),
184 + ], 422);
185 + }
186 +
187 + if ($title === '') {
188 + return $this->sendError([
189 + 'message' => __('Please provide a name.', 'fluent-booking'),
190 + ], 422);
191 + }
192 +
193 + $item = CrmContactService::createTaxonomy($type, $title);
194 +
195 + if (!$item) {
196 + return $this->sendError([
197 + 'message' => __('Please use a name that contains letters or numbers.', 'fluent-booking'),
198 + ], 422);
199 + }
200 +
201 + return $this->sendSuccess([
202 + 'item' => $item,
203 + 'message' => __('Successfully created.', 'fluent-booking'),
151 204 ]);
152 205 } catch (Exception $e) {
153 206 return $this->sendError([
154 207 'message' => $e->getMessage(),