PluginProbe
The Innovative Form Builder – IvyForms / 0.8.1
The Innovative Form Builder – IvyForms v0.8.1
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 / CommercialConstructionChangeFormTemplate.php

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

451 lines 16.5 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 CommercialConstructionChangeFormTemplate
13 {
14 /**
15 * Get the commercial construction change form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'commercial_construction_change_form',
23 'name' => BackendStrings::getTemplateStrings()['commercial_construction_change_form'],
24 'description' => BackendStrings::getTemplateStrings()['commercial_construction_change_form_desc'],
25 'category' => 'order-forms',
26 'subcategory' => 'change-order-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'commercial-construction-change-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['commercial_construction_change_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getContactInformationFields(),
37 self::getProjectDetailsFields(),
38 self::getChangeRequestFields()
39 ),
40 'settings' => []
41 ]
42 ];
43 }
44
45 /**
46 * Get contact information fields
47 *
48 * @return array<int, array<string, mixed>>
49 */
50 private static function getContactInformationFields(): array
51 {
52 return [
53 // Requestor Name
54 [
55 'id' => 0,
56 'fieldIndex' => 1,
57 'type' => 'name',
58 'label' => BackendStrings::getTemplateStrings()['requestor_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_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 'validation' => [
108 'required' => true,
109 'email' => true
110 ],
111 ],
112 // Contact Number
113 [
114 'id' => 0,
115 'fieldIndex' => 3,
116 'type' => 'phone',
117 'label' => BackendStrings::getTemplateStrings()['contact_number'],
118 'placeholder' => '+1 (_) _-_',
119 'required' => false,
120 'parentId' => null,
121 'defaultValue' => '',
122 'position' => 3,
123 'phoneAutoDetect' => true,
124 ],
125 ];
126 }
127
128 /**
129 * Get project details fields
130 *
131 * @return array<int, array<string, mixed>>
132 */
133 private static function getProjectDetailsFields(): array
134 {
135 return array_merge(
136 self::getProjectLocationFields(),
137 self::getProjectInfoFields()
138 );
139 }
140
141 /**
142 * Get project location address fields
143 *
144 * @return array<int, array<string, mixed>>
145 */
146 private static function getProjectLocationFields(): array
147 {
148 return [
149 // Project Location - Parent
150 [
151 'id' => 0,
152 'fieldIndex' => 4,
153 'type' => 'address',
154 'label' => BackendStrings::getTemplateStrings()['project_location'],
155 'placeholder' => '',
156 'required' => true,
157 'parentId' => null,
158 'defaultValue' => '',
159 'readonly' => false,
160 'position' => 4,
161 ],
162 // Address Line 1 - Child of Address Field
163 [
164 'id' => 0,
165 'type' => 'text',
166 'label' => BackendStrings::getTemplateStrings()['address_line_1'],
167 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
168 'required' => true,
169 'parentId' => 0,
170 'fieldIndex' => 4,
171 'defaultValue' => '',
172 'position' => 1,
173 'hideLabel' => false,
174 'description' => '',
175 'addressType' => 'streetAddress',
176 'settings' => json_encode([
177 'type' => 'streetAddress',
178 'hideLabel' => false,
179 'description' => '',
180 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
181 'requiredMessage' => '',
182 'visible' => true,
183 ]),
184 ],
185 // Address Line 2 - Child of Address Field
186 [
187 'id' => 0,
188 'type' => 'text',
189 'label' => BackendStrings::getTemplateStrings()['address_line_2'],
190 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
191 'required' => false,
192 'parentId' => 0,
193 'fieldIndex' => 4,
194 'defaultValue' => '',
195 'position' => 2,
196 'hideLabel' => false,
197 'description' => '',
198 'addressType' => 'addressLine2',
199 'settings' => json_encode([
200 'type' => 'addressLine2',
201 'hideLabel' => false,
202 'description' => '',
203 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
204 'requiredMessage' => '',
205 'visible' => true,
206 ]),
207 ],
208 // City - Child of Address Field
209 [
210 'id' => 0,
211 'type' => 'text',
212 'label' => BackendStrings::getTemplateStrings()['city'],
213 'placeholder' => BackendStrings::getTemplateStrings()['city'],
214 'required' => true,
215 'parentId' => 0,
216 'fieldIndex' => 4,
217 'defaultValue' => '',
218 'position' => 3,
219 'hideLabel' => false,
220 'description' => '',
221 'addressType' => 'city',
222 'settings' => json_encode([
223 'type' => 'city',
224 'hideLabel' => false,
225 'description' => '',
226 'placeholder' => BackendStrings::getTemplateStrings()['city'],
227 'requiredMessage' => '',
228 'visible' => true,
229 ]),
230 ],
231 // State/Province - Child of Address Field
232 [
233 'id' => 0,
234 'type' => 'text',
235 'label' => BackendStrings::getTemplateStrings()['state_province'],
236 'placeholder' => BackendStrings::getTemplateStrings()['state'],
237 'required' => true,
238 'parentId' => 0,
239 'fieldIndex' => 4,
240 'defaultValue' => '',
241 'position' => 4,
242 'hideLabel' => false,
243 'description' => '',
244 'addressType' => 'state',
245 'settings' => json_encode([
246 'type' => 'state',
247 'hideLabel' => false,
248 'description' => '',
249 'placeholder' => BackendStrings::getTemplateStrings()['state'],
250 'requiredMessage' => '',
251 'visible' => true,
252 ]),
253 ],
254 // Zip/Postal Code - Child of Address Field
255 [
256 'id' => 0,
257 'type' => 'text',
258 'label' => BackendStrings::getTemplateStrings()['zip_postal_code'],
259 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
260 'required' => true,
261 'parentId' => 0,
262 'fieldIndex' => 4,
263 'defaultValue' => '',
264 'position' => 5,
265 'hideLabel' => false,
266 'description' => '',
267 'addressType' => 'zip',
268 'settings' => json_encode([
269 'type' => 'zip',
270 'hideLabel' => false,
271 'description' => '',
272 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
273 'requiredMessage' => '',
274 'visible' => true,
275 ]),
276 ],
277 // Country - Child of Address Field
278 [
279 'id' => 0,
280 'type' => 'text',
281 'label' => BackendStrings::getTemplateStrings()['country'],
282 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
283 'required' => true,
284 'parentId' => 0,
285 'fieldIndex' => 4,
286 'defaultValue' => '',
287 'position' => 6,
288 'hideLabel' => false,
289 'description' => '',
290 'addressType' => 'country',
291 'settings' => json_encode([
292 'type' => 'country',
293 'hideLabel' => false,
294 'description' => '',
295 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
296 'requiredMessage' => '',
297 'visible' => true,
298 ]),
299 ],
300 ];
301 }
302
303 /**
304 * Get project info fields
305 *
306 * @return array<int, array<string, mixed>>
307 */
308 private static function getProjectInfoFields(): array
309 {
310 return [
311 // Company Name
312 [
313 'id' => 0,
314 'fieldIndex' => 5,
315 'type' => 'text',
316 'label' => BackendStrings::getTemplateStrings()['company_name'],
317 'placeholder' => BackendStrings::getTemplateStrings()['enter_company_name'],
318 'required' => true,
319 'parentId' => null,
320 'defaultValue' => '',
321 'position' => 5,
322 ],
323 // Commercial Space Type Dropdown
324 [
325 'id' => 0,
326 'fieldIndex' => 6,
327 'type' => 'select',
328 'label' => BackendStrings::getTemplateStrings()['commercial_space_type'],
329 'placeholder' => BackendStrings::getTemplateStrings()['select_commercial_space_type'],
330 'required' => true,
331 'parentId' => null,
332 'defaultValue' => '',
333 'position' => 6,
334 'fieldOptions' => [
335 [
336 'id' => 0,
337 'label' => BackendStrings::getTemplateStrings()['office'],
338 'value' => 'office',
339 'isDefault' => false,
340 'position' => 1,
341 ],
342 [
343 'id' => 0,
344 'label' => BackendStrings::getTemplateStrings()['retail'],
345 'value' => 'retail',
346 'isDefault' => false,
347 'position' => 2,
348 ],
349 [
350 'id' => 0,
351 'label' => BackendStrings::getTemplateStrings()['warehouse'],
352 'value' => 'warehouse',
353 'isDefault' => false,
354 'position' => 3,
355 ],
356 [
357 'id' => 0,
358 'label' => BackendStrings::getTemplateStrings()['industrial'],
359 'value' => 'industrial',
360 'isDefault' => false,
361 'position' => 4,
362 ],
363 [
364 'id' => 0,
365 'label' => BackendStrings::getTemplateStrings()['other'],
366 'value' => 'other',
367 'isDefault' => false,
368 'position' => 5,
369 ],
370 ],
371 ],
372 ];
373 }
374
375 /**
376 * Get change request fields
377 *
378 * @return array<int, array<string, mixed>>
379 */
380 private static function getChangeRequestFields(): array
381 {
382 return [
383 // Change Request Date
384 [
385 'id' => 0,
386 'fieldIndex' => 7,
387 'type' => 'date',
388 'label' => BackendStrings::getTemplateStrings()['change_request_date'],
389 'placeholder' => BackendStrings::getTemplateStrings()['select_change_request_date'],
390 'required' => true,
391 'parentId' => null,
392 'defaultValue' => '',
393 'position' => 7,
394 ],
395 // Description of Change
396 [
397 'id' => 0,
398 'fieldIndex' => 8,
399 'type' => 'textarea',
400 'label' => BackendStrings::getTemplateStrings()['description_of_change'],
401 'placeholder' => BackendStrings::getTemplateStrings()['describe_the_change_requested'],
402 'required' => true,
403 'parentId' => null,
404 'defaultValue' => '',
405 'position' => 8,
406 'rows' => 4,
407 ],
408 // Estimated Financial Impact
409 [
410 'id' => 0,
411 'fieldIndex' => 9,
412 'type' => 'number',
413 'label' => BackendStrings::getTemplateStrings()['estimated_financial_impact'],
414 'placeholder' => BackendStrings::getTemplateStrings()['enter_estimated_financial_impact'],
415 'required' => false,
416 'parentId' => null,
417 'defaultValue' => '',
418 'position' => 9,
419 ],
420 // Requires Management Approval? Radio
421 [
422 'id' => 0,
423 'fieldIndex' => 10,
424 'type' => 'radio',
425 'label' => BackendStrings::getTemplateStrings()['requires_management_approval'],
426 'placeholder' => '',
427 'required' => false,
428 'parentId' => null,
429 'defaultValue' => '',
430 'position' => 10,
431 'fieldOptions' => [
432 [
433 'id' => 0,
434 'label' => BackendStrings::getTemplateStrings()['yes'],
435 'value' => 'yes',
436 'isDefault' => false,
437 'position' => 1,
438 ],
439 [
440 'id' => 0,
441 'label' => BackendStrings::getTemplateStrings()['no'],
442 'value' => 'no',
443 'isDefault' => false,
444 'position' => 2,
445 ],
446 ],
447 ],
448 ];
449 }
450 }
451