PluginProbe
The Innovative Form Builder – IvyForms / 1.0
The Innovative Form Builder – IvyForms v1.0
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 1.0, at backend/src/Services/Template/CommercialConstructionChangeFormTemplate.php

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