PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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
← All changes | backend/src/Services/Template/MaintenanceWorkOrderFormTemplate.php +102 -57 0.9 → 1.5 View file →
@@ -1,23 +1,18 @@
1 1 <?php
2 2
3 3 namespace IvyForms\Services\Template;
4 4
5 -// phpcs:disable PSR1.Files.SideEffects
6 -if (!defined('ABSPATH')) {
7 - exit; // Exit if accessed directly
8 -}
9 -
10 5 use IvyForms\Services\Translations\BackendStrings;
11 6
12 7 class MaintenanceWorkOrderFormTemplate
13 8 {
14 9 /**
15 - * Get the maintenance work order form template
10 + * Get template metadata (without form_data)
16 11 *
17 12 * @return array<string, mixed>
18 13 */
19 - public static function getTemplate(): array
14 + public static function getTemplateMeta(): array
20 15 {
21 16 return [
22 17 'id' => 'maintenance_work_order_form',
23 18 'name' => BackendStrings::getTemplateStrings()['maintenance_work_order_form'],
@@ -24,9 +19,22 @@
24 19 'description' => BackendStrings::getTemplateStrings()['maintenance_work_order_form_desc'],
25 20 'category' => 'order-forms',
26 21 'subcategory' => 'work-order-forms',
27 22 'is_pro' => false,
28 - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'maintenance-work-order-form.svg',
23 + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'maintenance-work-order-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 + [
29 37 'form_data' => [
30 38 'name' => BackendStrings::getTemplateStrings()['maintenance_work_order_form'],
31 39 'published' => 1,
32 40 'showTitle' => 1,
@@ -39,9 +47,10 @@
39 47 self::getSubmissionApprovalFields()
40 48 ),
41 49 'settings' => []
42 50 ]
43 - ];
51 + ]
52 + );
44 53 }
45 54
46 55 /**
47 56 * Get requester information fields
@@ -128,8 +137,21 @@
128 137 * @return array<int, array<string, mixed>>
129 138 */
130 139 private static function getLocationFacilityFields(): array
131 140 {
141 + return array_merge(
142 + self::getLocationFields(),
143 + self::getFacilityAddressFields()
144 + );
145 + }
146 +
147 + /**
148 + * Building / department / room fields
149 + *
150 + * @return array<int, array<string, mixed>>
151 + */
152 + private static function getLocationFields(): array
153 + {
132 154 return [
133 155 // Building / Department / Room
134 156 [
135 157 'id' => 6,
@@ -141,8 +163,19 @@
141 163 'parentId' => null,
142 164 'defaultValue' => '',
143 165 'position' => 4,
144 166 ],
167 + ];
168 + }
169 +
170 + /**
171 + * Facility address fields
172 + *
173 + * @return array<int, array<string, mixed>>
174 + */
175 + private static function getFacilityAddressFields(): array
176 + {
177 + return [
145 178 // Address Field - Parent
146 179 [
147 180 'id' => 7,
148 181 'fieldIndex' => 5,
@@ -168,16 +201,18 @@
168 201 'position' => 1,
169 202 'hideLabel' => false,
170 203 'description' => '',
171 204 'addressType' => 'streetAddress',
172 - 'settings' => json_encode([
173 - 'type' => 'streetAddress',
174 - 'hideLabel' => false,
175 - 'description' => '',
176 - 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
177 - 'requiredMessage' => '',
178 - 'visible' => true
179 - ]),
205 + 'settings' => json_encode(
206 + [
207 + 'type' => 'streetAddress',
208 + 'hideLabel' => false,
209 + 'description' => '',
210 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_1'],
211 + 'requiredMessage' => '',
212 + 'visible' => true
213 + ]
214 + ),
180 215 ],
181 216 // Address Line 2 - Child of Address Field
182 217 [
183 218 'id' => 11,
@@ -191,16 +226,18 @@
191 226 'position' => 2,
192 227 'hideLabel' => false,
193 228 'description' => '',
194 229 'addressType' => 'addressLine2',
195 - 'settings' => json_encode([
196 - 'type' => 'addressLine2',
197 - 'hideLabel' => false,
198 - 'description' => '',
199 - 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
200 - 'requiredMessage' => '',
201 - 'visible' => true
202 - ]),
230 + 'settings' => json_encode(
231 + [
232 + 'type' => 'addressLine2',
233 + 'hideLabel' => false,
234 + 'description' => '',
235 + 'placeholder' => BackendStrings::getTemplateStrings()['enter_address_line_2'],
236 + 'requiredMessage' => '',
237 + 'visible' => true
238 + ]
239 + ),
203 240 ],
204 241 // City - Child of Address Field
205 242 [
206 243 'id' => 13,
@@ -214,16 +251,18 @@
214 251 'position' => 3,
215 252 'hideLabel' => false,
216 253 'description' => '',
217 254 'addressType' => 'city',
218 - 'settings' => json_encode([
219 - 'type' => 'city',
220 - 'hideLabel' => false,
221 - 'description' => '',
222 - 'placeholder' => BackendStrings::getTemplateStrings()['city'],
223 - 'requiredMessage' => '',
224 - 'visible' => true
225 - ]),
255 + 'settings' => json_encode(
256 + [
257 + 'type' => 'city',
258 + 'hideLabel' => false,
259 + 'description' => '',
260 + 'placeholder' => BackendStrings::getTemplateStrings()['city'],
261 + 'requiredMessage' => '',
262 + 'visible' => true
263 + ]
264 + ),
226 265 ],
227 266 // State / Province - Child of Address Field
228 267 [
229 268 'id' => 15,
@@ -237,16 +276,18 @@
237 276 'position' => 4,
238 277 'hideLabel' => false,
239 278 'description' => '',
240 279 'addressType' => 'state',
241 - 'settings' => json_encode([
242 - 'type' => 'state',
243 - 'hideLabel' => false,
244 - 'description' => '',
245 - 'placeholder' => BackendStrings::getTemplateStrings()['state'],
246 - 'requiredMessage' => '',
247 - 'visible' => true
248 - ]),
280 + 'settings' => json_encode(
281 + [
282 + 'type' => 'state',
283 + 'hideLabel' => false,
284 + 'description' => '',
285 + 'placeholder' => BackendStrings::getTemplateStrings()['state'],
286 + 'requiredMessage' => '',
287 + 'visible' => true
288 + ]
289 + ),
249 290 ],
250 291 // Zip / Postal Code - Child of Address Field
251 292 [
252 293 'id' => 17,
@@ -260,16 +301,18 @@
260 301 'position' => 5,
261 302 'hideLabel' => false,
262 303 'description' => '',
263 304 'addressType' => 'zip',
264 - 'settings' => json_encode([
265 - 'type' => 'zip',
266 - 'hideLabel' => false,
267 - 'description' => '',
268 - 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
269 - 'requiredMessage' => '',
270 - 'visible' => true
271 - ]),
305 + 'settings' => json_encode(
306 + [
307 + 'type' => 'zip',
308 + 'hideLabel' => false,
309 + 'description' => '',
310 + 'placeholder' => BackendStrings::getTemplateStrings()['zip'],
311 + 'requiredMessage' => '',
312 + 'visible' => true
313 + ]
314 + ),
272 315 ],
273 316 // Country - Child of Address Field
274 317 [
275 318 'id' => 19,
@@ -283,16 +326,18 @@
283 326 'position' => 6,
284 327 'hideLabel' => false,
285 328 'description' => '',
286 329 'addressType' => 'country',
287 - 'settings' => json_encode([
288 - 'type' => 'country',
289 - 'hideLabel' => false,
290 - 'description' => '',
291 - 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
292 - 'requiredMessage' => '',
293 - 'visible' => true
294 - ]),
330 + 'settings' => json_encode(
331 + [
332 + 'type' => 'country',
333 + 'hideLabel' => false,
334 + 'description' => '',
335 + 'placeholder' => BackendStrings::getTemplateStrings()['select_country'],
336 + 'requiredMessage' => '',
337 + 'visible' => true
338 + ]
339 + ),
295 340 ],
296 341 ];
297 342 }
298 343