PluginProbe
The Innovative Form Builder – IvyForms / 0.7
The Innovative Form Builder – IvyForms v0.7
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.7, at backend/src/Services/Template/ConsultationAppointmentFormTemplate.php

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