← All changes
|
backend/src/Services/Template/RepairWorkOrderFormTemplate.php
+41
-32
0.8.2
→
1.5.1
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 RepairWorkOrderFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the repair 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' => 'repair_work_order_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['repair_work_order_form'], |
| @@ -24,9 +19,22 @@ | ||
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['repair_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 . 'repair-work-order-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'repair-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()['repair_work_order_form'], |
| 31 | 39 | 'published' => 1, |
| 32 | 40 | 'showTitle' => 1, |
| @@ -38,9 +46,10 @@ | ||
| 38 | 46 | self::getAdditionalInformationFields() |
| 39 | 47 | ), |
| 40 | 48 | 'settings' => [] |
| 41 | 49 | ] |
| 42 | - ]; | |
| 50 | + ] | |
| 51 | + ); | |
| 43 | 52 | } |
| 44 | 53 | |
| 45 | 54 | /** |
| 46 | 55 | * Get contact information fields |
| @@ -51,9 +60,9 @@ | ||
| 51 | 60 | { |
| 52 | 61 | return [ |
| 53 | 62 | // Employee Name |
| 54 | 63 | [ |
| 55 | - 'id' => 0, | |
| 64 | + 'id' => 1, | |
| 56 | 65 | 'fieldIndex' => 1, |
| 57 | 66 | 'type' => 'name', |
| 58 | 67 | 'label' => BackendStrings::getTemplateStrings()['employee_name'], |
| 59 | 68 | 'parentId' => null, |
| @@ -64,14 +73,14 @@ | ||
| 64 | 73 | 'position' => 1, |
| 65 | 74 | ], |
| 66 | 75 | // First Name - Child of Name Field |
| 67 | 76 | [ |
| 68 | - 'id' => 0, | |
| 77 | + 'id' => 2, | |
| 69 | 78 | 'type' => 'text', |
| 70 | 79 | 'label' => BackendStrings::getNewFormStrings()['first_name'], |
| 71 | 80 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_name'], |
| 72 | 81 | 'required' => true, |
| 73 | - 'parentId' => 0, | |
| 82 | + 'parentId' => 1, | |
| 74 | 83 | 'fieldIndex' => 1, |
| 75 | 84 | 'defaultValue' => '', |
| 76 | 85 | 'position' => 1, |
| 77 | 86 | 'optionHide' => false, |
| @@ -79,14 +88,14 @@ | ||
| 79 | 88 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 80 | 89 | ], |
| 81 | 90 | // Last Name - Child of Name Field |
| 82 | 91 | [ |
| 83 | - 'id' => 0, | |
| 92 | + 'id' => 3, | |
| 84 | 93 | 'type' => 'text', |
| 85 | 94 | 'label' => BackendStrings::getNewFormStrings()['last_name'], |
| 86 | 95 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 87 | 96 | 'required' => true, |
| 88 | - 'parentId' => 0, | |
| 97 | + 'parentId' => 1, | |
| 89 | 98 | 'fieldIndex' => 1, |
| 90 | 99 | 'defaultValue' => '', |
| 91 | 100 | 'position' => 2, |
| 92 | 101 | 'optionHide' => false, |
| @@ -94,9 +103,9 @@ | ||
| 94 | 103 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 95 | 104 | ], |
| 96 | 105 | // Email Address |
| 97 | 106 | [ |
| 98 | - 'id' => 0, | |
| 107 | + 'id' => 4, | |
| 99 | 108 | 'fieldIndex' => 2, |
| 100 | 109 | 'type' => 'email', |
| 101 | 110 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 102 | 111 | 'placeholder' => '[email protected]', |
| @@ -110,9 +119,9 @@ | ||
| 110 | 119 | ], |
| 111 | 120 | ], |
| 112 | 121 | // Phone Number |
| 113 | 122 | [ |
| 114 | - 'id' => 0, | |
| 123 | + 'id' => 5, | |
| 115 | 124 | 'fieldIndex' => 3, |
| 116 | 125 | 'type' => 'phone', |
| 117 | 126 | 'label' => BackendStrings::getTemplateStrings()['contact_number'], |
| 118 | 127 | 'placeholder' => '+1 (_) _-_', |
| @@ -134,9 +143,9 @@ | ||
| 134 | 143 | { |
| 135 | 144 | return [ |
| 136 | 145 | // Location |
| 137 | 146 | [ |
| 138 | - 'id' => 0, | |
| 147 | + 'id' => 6, | |
| 139 | 148 | 'fieldIndex' => 4, |
| 140 | 149 | 'type' => 'text', |
| 141 | 150 | 'label' => BackendStrings::getTemplateStrings()['location'], |
| 142 | 151 | 'placeholder' => BackendStrings::getTemplateStrings()['exact_location_of_issue'], |
| @@ -146,9 +155,9 @@ | ||
| 146 | 155 | 'position' => 4, |
| 147 | 156 | ], |
| 148 | 157 | // Equipment/Item to Repair |
| 149 | 158 | [ |
| 150 | - 'id' => 0, | |
| 159 | + 'id' => 7, | |
| 151 | 160 | 'fieldIndex' => 5, |
| 152 | 161 | 'type' => 'text', |
| 153 | 162 | 'label' => BackendStrings::getTemplateStrings()['equipment_item_to_repair'], |
| 154 | 163 | 'placeholder' => BackendStrings::getTemplateStrings()['device_or_item_name'], |
| @@ -158,9 +167,9 @@ | ||
| 158 | 167 | 'position' => 5, |
| 159 | 168 | ], |
| 160 | 169 | // Repair Type Dropdown |
| 161 | 170 | [ |
| 162 | - 'id' => 0, | |
| 171 | + 'id' => 12, | |
| 163 | 172 | 'fieldIndex' => 6, |
| 164 | 173 | 'type' => 'select', |
| 165 | 174 | 'label' => BackendStrings::getTemplateStrings()['repair_type'], |
| 166 | 175 | 'placeholder' => BackendStrings::getTemplateStrings()['select_repair_type'], |
| @@ -169,9 +178,9 @@ | ||
| 169 | 178 | 'defaultValue' => '', |
| 170 | 179 | 'position' => 6, |
| 171 | 180 | 'fieldOptions' => [ |
| 172 | 181 | [ |
| 173 | - 'id' => 0, | |
| 182 | + 'id' => 8, | |
| 174 | 183 | 'label' => BackendStrings::getTemplateStrings()['mechanical'], |
| 175 | 184 | 'value' => 'mechanical', |
| 176 | 185 | 'isDefault' => false, |
| 177 | 186 | 'position' => 1, |
| @@ -176,9 +185,9 @@ | ||
| 176 | 185 | 'isDefault' => false, |
| 177 | 186 | 'position' => 1, |
| 178 | 187 | ], |
| 179 | 188 | [ |
| 180 | - 'id' => 0, | |
| 189 | + 'id' => 9, | |
| 181 | 190 | 'label' => BackendStrings::getTemplateStrings()['electrical'], |
| 182 | 191 | 'value' => 'electrical', |
| 183 | 192 | 'isDefault' => false, |
| 184 | 193 | 'position' => 2, |
| @@ -183,9 +192,9 @@ | ||
| 183 | 192 | 'isDefault' => false, |
| 184 | 193 | 'position' => 2, |
| 185 | 194 | ], |
| 186 | 195 | [ |
| 187 | - 'id' => 0, | |
| 196 | + 'id' => 10, | |
| 188 | 197 | 'label' => BackendStrings::getTemplateStrings()['software'], |
| 189 | 198 | 'value' => 'software', |
| 190 | 199 | 'isDefault' => false, |
| 191 | 200 | 'position' => 3, |
| @@ -190,9 +199,9 @@ | ||
| 190 | 199 | 'isDefault' => false, |
| 191 | 200 | 'position' => 3, |
| 192 | 201 | ], |
| 193 | 202 | [ |
| 194 | - 'id' => 0, | |
| 203 | + 'id' => 11, | |
| 195 | 204 | 'label' => BackendStrings::getTemplateStrings()['other'], |
| 196 | 205 | 'value' => 'other', |
| 197 | 206 | 'isDefault' => false, |
| 198 | 207 | 'position' => 4, |
| @@ -200,9 +209,9 @@ | ||
| 200 | 209 | ], |
| 201 | 210 | ], |
| 202 | 211 | // Severity Dropdown |
| 203 | 212 | [ |
| 204 | - 'id' => 0, | |
| 213 | + 'id' => 16, | |
| 205 | 214 | 'fieldIndex' => 7, |
| 206 | 215 | 'type' => 'select', |
| 207 | 216 | 'label' => BackendStrings::getTemplateStrings()['severity'], |
| 208 | 217 | 'placeholder' => BackendStrings::getTemplateStrings()['select_severity'], |
| @@ -211,9 +220,9 @@ | ||
| 211 | 220 | 'defaultValue' => '', |
| 212 | 221 | 'position' => 7, |
| 213 | 222 | 'fieldOptions' => [ |
| 214 | 223 | [ |
| 215 | - 'id' => 0, | |
| 224 | + 'id' => 13, | |
| 216 | 225 | 'label' => BackendStrings::getTemplateStrings()['minor'], |
| 217 | 226 | 'value' => 'minor', |
| 218 | 227 | 'isDefault' => false, |
| 219 | 228 | 'position' => 1, |
| @@ -218,9 +227,9 @@ | ||
| 218 | 227 | 'isDefault' => false, |
| 219 | 228 | 'position' => 1, |
| 220 | 229 | ], |
| 221 | 230 | [ |
| 222 | - 'id' => 0, | |
| 231 | + 'id' => 14, | |
| 223 | 232 | 'label' => BackendStrings::getTemplateStrings()['major'], |
| 224 | 233 | 'value' => 'major', |
| 225 | 234 | 'isDefault' => false, |
| 226 | 235 | 'position' => 2, |
| @@ -225,9 +234,9 @@ | ||
| 225 | 234 | 'isDefault' => false, |
| 226 | 235 | 'position' => 2, |
| 227 | 236 | ], |
| 228 | 237 | [ |
| 229 | - 'id' => 0, | |
| 238 | + 'id' => 15, | |
| 230 | 239 | 'label' => BackendStrings::getTemplateStrings()['critical'], |
| 231 | 240 | 'value' => 'critical', |
| 232 | 241 | 'isDefault' => false, |
| 233 | 242 | 'position' => 3, |
| @@ -235,9 +244,9 @@ | ||
| 235 | 244 | ], |
| 236 | 245 | ], |
| 237 | 246 | // Preferred Repair Date |
| 238 | 247 | [ |
| 239 | - 'id' => 0, | |
| 248 | + 'id' => 17, | |
| 240 | 249 | 'fieldIndex' => 8, |
| 241 | 250 | 'type' => 'date', |
| 242 | 251 | 'label' => BackendStrings::getTemplateStrings()['preferred_repair_date'], |
| 243 | 252 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_preferred_repair_date'], |
| @@ -258,9 +267,9 @@ | ||
| 258 | 267 | { |
| 259 | 268 | return [ |
| 260 | 269 | // Steps Already Taken |
| 261 | 270 | [ |
| 262 | - 'id' => 0, | |
| 271 | + 'id' => 18, | |
| 263 | 272 | 'fieldIndex' => 9, |
| 264 | 273 | 'type' => 'textarea', |
| 265 | 274 | 'label' => BackendStrings::getTemplateStrings()['steps_already_taken'], |
| 266 | 275 | 'placeholder' => BackendStrings::getTemplateStrings()['describe_troubleshooting_done'], |
| @@ -271,9 +280,9 @@ | ||
| 271 | 280 | 'rows' => 4, |
| 272 | 281 | ], |
| 273 | 282 | // Notify Department Head |
| 274 | 283 | [ |
| 275 | - 'id' => 0, | |
| 284 | + 'id' => 21, | |
| 276 | 285 | 'fieldIndex' => 10, |
| 277 | 286 | 'type' => 'checkbox', |
| 278 | 287 | 'label' => BackendStrings::getTemplateStrings()['notify_department_head'], |
| 279 | 288 | 'placeholder' => '', |
| @@ -282,9 +291,9 @@ | ||
| 282 | 291 | 'defaultValue' => '', |
| 283 | 292 | 'position' => 10, |
| 284 | 293 | 'fieldOptions' => [ |
| 285 | 294 | [ |
| 286 | - 'id' => 0, | |
| 295 | + 'id' => 19, | |
| 287 | 296 | 'label' => BackendStrings::getTemplateStrings()['yes'], |
| 288 | 297 | 'value' => 'yes', |
| 289 | 298 | 'isDefault' => false, |
| 290 | 299 | 'position' => 1, |
| @@ -289,9 +298,9 @@ | ||
| 289 | 298 | 'isDefault' => false, |
| 290 | 299 | 'position' => 1, |
| 291 | 300 | ], |
| 292 | 301 | [ |
| 293 | - 'id' => 0, | |
| 302 | + 'id' => 20, | |
| 294 | 303 | 'label' => BackendStrings::getTemplateStrings()['no'], |
| 295 | 304 | 'value' => 'no', |
| 296 | 305 | 'isDefault' => false, |
| 297 | 306 | 'position' => 2, |