PluginProbe
The Innovative Form Builder – IvyForms / 0.8.2
The Innovative Form Builder – IvyForms v0.8.2
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / ConsultationAppointmentFormTemplate.php

ConsultationAppointmentFormTemplate.php in The Innovative Form Builder – IvyForms 0.8.2, at backend/src/Services/Template/ConsultationAppointmentFormTemplate.php

365 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Template;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Services\Translations\BackendStrings;
11
12 class ConsultationAppointmentFormTemplate
13 {
14 /**
15 * Get the consultation appointment form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'consultation_appointment_form',
23 'name' => BackendStrings::getTemplateStrings()['consultation_appointment_form'],
24 'description' => BackendStrings::getTemplateStrings()['consultation_appointment_form_desc'],
25 'category' => 'booking-forms',
26 'subcategory' => 'appointment-booking-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'consultation-appointment-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['consultation_appointment_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getClientInformationFields(),
37 self::getConsultationDetailsFields(),
38 self::getAdditionalPreferencesFields()
39 ),
40 'settings' => []
41 ]
42 ];
43 }
44
45 /**
46 * Get client information fields
47 *
48 * @return array<int, array<string, mixed>>
49 */
50 private static function getClientInformationFields(): array
51 {
52 return [
53 // Name Field - Parent
54 [
55 'id' => 0,
56 'fieldIndex' => 1,
57 'type' => 'name',
58 'label' => BackendStrings::getTemplateStrings()['full_name'],
59 'parentId' => null,
60 'defaultValue' => '',
61 'placeholder' => '',
62 'required' => true,
63 'readonly' => false,
64 'position' => 1,
65 ],
66 // First Name - Child of Name Field
67 [
68 'id' => 0,
69 'type' => 'text',
70 'label' => BackendStrings::getNewFormStrings()['first_name'],
71 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
72 'required' => true,
73 'parentId' => 0,
74 'fieldIndex' => 1,
75 'defaultValue' => '',
76 'position' => 1,
77 'optionHide' => false,
78 'description' => '',
79 'settings' => json_encode(['nameFieldType' => 'nameField1']),
80 ],
81 // Last Name - Child of Name Field
82 [
83 'id' => 0,
84 'type' => 'text',
85 'label' => BackendStrings::getNewFormStrings()['last_name'],
86 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
87 'required' => true,
88 'parentId' => 0,
89 'fieldIndex' => 1,
90 'defaultValue' => '',
91 'position' => 2,
92 'optionHide' => false,
93 'description' => '',
94 'settings' => json_encode(['nameFieldType' => 'nameField2']),
95 ],
96 // Email Address
97 [
98 'id' => 0,
99 'fieldIndex' => 2,
100 'type' => 'email',
101 'label' => BackendStrings::getTemplateStrings()['email_address'],
102 'placeholder' => '[email protected]',
103 'required' => true,
104 'parentId' => null,
105 'defaultValue' => '',
106 'position' => 2,
107 ],
108 // Phone Number
109 [
110 'id' => 0,
111 'fieldIndex' => 3,
112 'type' => 'phone',
113 'label' => BackendStrings::getTemplateStrings()['phone_number'],
114 'placeholder' => '+1 (_) _-_',
115 'required' => true,
116 'parentId' => null,
117 'defaultValue' => '',
118 'position' => 3,
119 'phoneAutoDetect' => true,
120 ],
121 ];
122 }
123
124 /**
125 * Get consultation details fields
126 *
127 * @return array<int, array<string, mixed>>
128 */
129 private static function getConsultationDetailsFields(): array
130 {
131 return array_merge(
132 self::getConsultationTypeField(),
133 self::getAdvisorPreferenceField(),
134 self::getPreferredDateField(),
135 self::getPreferredTimeField()
136 );
137 }
138
139 /**
140 * Get consultation type field
141 *
142 * @return array<int, array<string, mixed>>
143 */
144 private static function getConsultationTypeField(): array
145 {
146 return [
147 [
148 'id' => 0,
149 'fieldIndex' => 4,
150 'type' => 'select',
151 'label' => BackendStrings::getTemplateStrings()['consultation_type'],
152 'placeholder' => BackendStrings::getTemplateStrings()['select_consultation_type'],
153 'required' => true,
154 'parentId' => null,
155 'defaultValue' => '',
156 'position' => 4,
157 'fieldOptions' => [
158 [
159 'id' => 0,
160 'label' => BackendStrings::getTemplateStrings()['business'],
161 'value' => 'business',
162 'isDefault' => false,
163 'position' => 1
164 ],
165 [
166 'id' => 0,
167 'label' => BackendStrings::getTemplateStrings()['legal'],
168 'value' => 'legal',
169 'isDefault' => false,
170 'position' => 2
171 ],
172 [
173 'id' => 0,
174 'label' => BackendStrings::getTemplateStrings()['financial'],
175 'value' => 'financial',
176 'isDefault' => false,
177 'position' => 3
178 ],
179 [
180 'id' => 0,
181 'label' => BackendStrings::getTemplateStrings()['personal'],
182 'value' => 'personal',
183 'isDefault' => false,
184 'position' => 4
185 ],
186 [
187 'id' => 0,
188 'label' => BackendStrings::getTemplateStrings()['other'],
189 'value' => 'other',
190 'isDefault' => false,
191 'position' => 5
192 ],
193 ]
194 ],
195 ];
196 }
197
198 /**
199 * Get advisor preference field
200 *
201 * @return array<int, array<string, mixed>>
202 */
203 private static function getAdvisorPreferenceField(): array
204 {
205 return [
206 [
207 'id' => 0,
208 'fieldIndex' => 5,
209 'type' => 'select',
210 'label' => BackendStrings::getTemplateStrings()['preferred_advisor'],
211 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_advisor'],
212 'required' => false,
213 'parentId' => null,
214 'defaultValue' => '',
215 'position' => 5,
216 'fieldOptions' => [
217 [
218 'id' => 0,
219 'label' => BackendStrings::getTemplateStrings()['advisor_a'],
220 'value' => 'advisor_a',
221 'isDefault' => false,
222 'position' => 1
223 ],
224 [
225 'id' => 0,
226 'label' => BackendStrings::getTemplateStrings()['advisor_b'],
227 'value' => 'advisor_b',
228 'isDefault' => false,
229 'position' => 2
230 ],
231 [
232 'id' => 0,
233 'label' => BackendStrings::getTemplateStrings()['no_preference'],
234 'value' => 'no_preference',
235 'isDefault' => true,
236 'position' => 3
237 ],
238 ]
239 ],
240 ];
241 }
242
243 /**
244 * Get preferred date field
245 *
246 * @return array<int, array<string, mixed>>
247 */
248 private static function getPreferredDateField(): array
249 {
250 return [
251 [
252 'id' => 0,
253 'fieldIndex' => 6,
254 'type' => 'date',
255 'label' => BackendStrings::getTemplateStrings()['preferred_appointment_date'],
256 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_date'],
257 'required' => true,
258 'parentId' => null,
259 'defaultValue' => '',
260 'position' => 6,
261 'dateFieldType' => 'picker',
262 'dateFormat' => 'MM/DD/YYYY',
263 ],
264 ];
265 }
266
267 /**
268 * Get preferred time field
269 *
270 * @return array<int, array<string, mixed>>
271 */
272 private static function getPreferredTimeField(): array
273 {
274 return [
275 [
276 'id' => 0,
277 'fieldIndex' => 7,
278 'type' => 'time',
279 'label' => BackendStrings::getTemplateStrings()['preferred_time_slot'],
280 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_time'],
281 'required' => true,
282 'parentId' => null,
283 'defaultValue' => '',
284 'position' => 7,
285 'timeFieldType' => 'time-picker',
286 'timeFormat' => 'ampm',
287 ],
288 ];
289 }
290
291 /**
292 * Get additional preferences fields
293 *
294 * @return array<int, array<string, mixed>>
295 */
296 private static function getAdditionalPreferencesFields(): array
297 {
298 return array_merge(
299 self::getTopicsQuestionsField(),
300 self::getVirtualMeetingField()
301 );
302 }
303
304 /**
305 * Get topics/questions field
306 *
307 * @return array<int, array<string, mixed>>
308 */
309 private static function getTopicsQuestionsField(): array
310 {
311 return [
312 [
313 'id' => 0,
314 'fieldIndex' => 8,
315 'type' => 'textarea',
316 'label' => BackendStrings::getTemplateStrings()['topics_questions_to_discuss'],
317 'placeholder' => BackendStrings::getTemplateStrings()['list_topics_questions_consultation'],
318 'parentId' => null,
319 'defaultValue' => '',
320 'position' => 8,
321 'required' => false,
322 'rows' => 4,
323 ],
324 ];
325 }
326
327 /**
328 * Get virtual meeting field
329 *
330 * @return array<int, array<string, mixed>>
331 */
332 private static function getVirtualMeetingField(): array
333 {
334 return [
335 [
336 'id' => 0,
337 'fieldIndex' => 9,
338 'type' => 'radio',
339 'label' => BackendStrings::getTemplateStrings()['virtual_meeting'],
340 'parentId' => null,
341 'position' => 9,
342 'required' => false,
343 'defaultValue' => '',
344 'placeholder' => '',
345 'fieldOptions' => [
346 [
347 'id' => 0,
348 'label' => BackendStrings::getTemplateStrings()['yes'],
349 'value' => 'yes',
350 'isDefault' => false,
351 'position' => 1
352 ],
353 [
354 'id' => 0,
355 'label' => BackendStrings::getTemplateStrings()['no'],
356 'value' => 'no',
357 'isDefault' => false,
358 'position' => 2
359 ],
360 ]
361 ],
362 ];
363 }
364 }
365