← All changes
|
backend/src/Services/Template/MaternityLeaveRequestFormTemplate.php
+42
-30
0.7
→
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 MaternityLeaveRequestFormTemplate |
| 13 | 8 | { |
| 14 | 9 | /** |
| 15 | - * Get the maternity leave request 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' => 'maternity_leave_request_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['maternity_leave_request_form'], |
| @@ -22,10 +17,24 @@ | ||
| 22 | 17 | 'id' => 'maternity_leave_request_form', |
| 23 | 18 | 'name' => BackendStrings::getTemplateStrings()['maternity_leave_request_form'], |
| 24 | 19 | 'description' => BackendStrings::getTemplateStrings()['maternity_leave_request_form_desc'], |
| 25 | 20 | 'category' => 'leave-request', |
| 21 | + 'subcategory' => 'leave-request-forms', | |
| 26 | 22 | 'is_pro' => false, |
| 27 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'maternity-leave-request-form.svg', | |
| 23 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'maternity-leave-request-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 | + [ | |
| 28 | 37 | 'form_data' => [ |
| 29 | 38 | 'name' => BackendStrings::getTemplateStrings()['maternity_leave_request_form'], |
| 30 | 39 | 'published' => 1, |
| 31 | 40 | 'showTitle' => 1, |
| @@ -37,9 +46,10 @@ | ||
| 37 | 46 | self::getNotificationFields() |
| 38 | 47 | ), |
| 39 | 48 | 'settings' => [] |
| 40 | 49 | ] |
| 41 | - ]; | |
| 50 | + ] | |
| 51 | + ); | |
| 42 | 52 | } |
| 43 | 53 | |
| 44 | 54 | /** |
| 45 | 55 | * Employee information fields |
| @@ -50,9 +60,9 @@ | ||
| 50 | 60 | { |
| 51 | 61 | return [ |
| 52 | 62 | // Name Field - Parent |
| 53 | 63 | [ |
| 54 | - 'id' => 0, | |
| 64 | + 'id' => 1, | |
| 55 | 65 | 'fieldIndex' => 1, |
| 56 | 66 | 'type' => 'name', |
| 57 | 67 | 'label' => BackendStrings::getTemplateStrings()['full_name'], |
| 58 | 68 | 'parentId' => null, |
| @@ -63,14 +73,14 @@ | ||
| 63 | 73 | 'position' => 1, |
| 64 | 74 | ], |
| 65 | 75 | // First Name - Child |
| 66 | 76 | [ |
| 67 | - 'id' => 0, | |
| 77 | + 'id' => 2, | |
| 68 | 78 | 'type' => 'text', |
| 69 | 79 | 'label' => BackendStrings::getNewFormStrings()['first_name'], |
| 70 | 80 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 71 | 81 | 'required' => true, |
| 72 | - 'parentId' => 0, | |
| 82 | + 'parentId' => 1, | |
| 73 | 83 | 'fieldIndex' => 1, |
| 74 | 84 | 'defaultValue' => '', |
| 75 | 85 | 'position' => 1, |
| 76 | 86 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| @@ -76,14 +86,14 @@ | ||
| 76 | 86 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 77 | 87 | ], |
| 78 | 88 | // Last Name - Child |
| 79 | 89 | [ |
| 80 | - 'id' => 0, | |
| 90 | + 'id' => 3, | |
| 81 | 91 | 'type' => 'text', |
| 82 | 92 | 'label' => BackendStrings::getNewFormStrings()['last_name'], |
| 83 | 93 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 84 | 94 | 'required' => true, |
| 85 | - 'parentId' => 0, | |
| 95 | + 'parentId' => 1, | |
| 86 | 96 | 'fieldIndex' => 1, |
| 87 | 97 | 'defaultValue' => '', |
| 88 | 98 | 'position' => 2, |
| 89 | 99 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| @@ -89,9 +99,9 @@ | ||
| 89 | 99 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 90 | 100 | ], |
| 91 | 101 | |
| 92 | 102 | [ |
| 93 | - 'id' => 0, | |
| 103 | + 'id' => 4, | |
| 94 | 104 | 'fieldIndex' => 2, |
| 95 | 105 | 'type' => 'email', |
| 96 | 106 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 97 | 107 | 'placeholder' => BackendStrings::getTemplateStrings()['email_placeholder'], |
| @@ -101,9 +111,9 @@ | ||
| 101 | 111 | 'position' => 2, |
| 102 | 112 | ], |
| 103 | 113 | // Department select |
| 104 | 114 | [ |
| 105 | - 'id' => 0, | |
| 115 | + 'id' => 10, | |
| 106 | 116 | 'fieldIndex' => 3, |
| 107 | 117 | 'type' => 'select', |
| 108 | 118 | 'label' => BackendStrings::getTemplateStrings()['department'], |
| 109 | 119 | 'placeholder' => BackendStrings::getTemplateStrings()['select_department'], |
| @@ -112,9 +122,9 @@ | ||
| 112 | 122 | 'defaultValue' => '', |
| 113 | 123 | 'position' => 3, |
| 114 | 124 | 'fieldOptions' => [ |
| 115 | 125 | [ |
| 116 | - 'id' => 0, | |
| 126 | + 'id' => 5, | |
| 117 | 127 | 'label' => BackendStrings::getTemplateStrings()['hr'], |
| 118 | 128 | 'value' => 'hr', |
| 119 | 129 | 'isDefault' => false, |
| 120 | 130 | 'position' => 1 |
| @@ -119,21 +129,21 @@ | ||
| 119 | 129 | 'isDefault' => false, |
| 120 | 130 | 'position' => 1 |
| 121 | 131 | ], |
| 122 | 132 | [ |
| 123 | - 'id' => 0, | |
| 133 | + 'id' => 6, | |
| 124 | 134 | 'label' => BackendStrings::getTemplateStrings()['it'], |
| 125 | 135 | 'value' => 'it', |
| 126 | 136 | 'isDefault' => false, |
| 127 | 137 | 'position' => 2], |
| 128 | 138 | [ |
| 129 | - 'id' => 0, | |
| 139 | + 'id' => 7, | |
| 130 | 140 | 'label' => BackendStrings::getTemplateStrings()['sales'], |
| 131 | 141 | 'value' => 'sales', |
| 132 | 142 | 'isDefault' => false, |
| 133 | 143 | 'position' => 3], |
| 134 | 144 | [ |
| 135 | - 'id' => 0, | |
| 145 | + 'id' => 8, | |
| 136 | 146 | 'label' => BackendStrings::getTemplateStrings()['marketing'], |
| 137 | 147 | 'value' => 'marketing', |
| 138 | 148 | 'isDefault' => false, |
| 139 | 149 | 'position' => 4 |
| @@ -138,9 +148,9 @@ | ||
| 138 | 148 | 'isDefault' => false, |
| 139 | 149 | 'position' => 4 |
| 140 | 150 | ], |
| 141 | 151 | [ |
| 142 | - 'id' => 0, | |
| 152 | + 'id' => 9, | |
| 143 | 153 | 'label' => BackendStrings::getTemplateStrings()['other'], |
| 144 | 154 | 'value' => 'other', |
| 145 | 155 | 'isDefault' => false, |
| 146 | 156 | 'position' => 5], |
| @@ -158,9 +168,9 @@ | ||
| 158 | 168 | { |
| 159 | 169 | return [ |
| 160 | 170 | // Leave Type (Maternity only) |
| 161 | 171 | [ |
| 162 | - 'id' => 0, | |
| 172 | + 'id' => 12, | |
| 163 | 173 | 'fieldIndex' => 4, |
| 164 | 174 | 'type' => 'select', |
| 165 | 175 | 'label' => BackendStrings::getTemplateStrings()['type_of_leave'], |
| 166 | 176 | 'placeholder' => BackendStrings::getTemplateStrings()['select_type_of_leave'], |
| @@ -169,9 +179,9 @@ | ||
| 169 | 179 | 'defaultValue' => '', |
| 170 | 180 | 'position' => 4, |
| 171 | 181 | 'fieldOptions' => [ |
| 172 | 182 | [ |
| 173 | - 'id' => 0, | |
| 183 | + 'id' => 11, | |
| 174 | 184 | 'label' => BackendStrings::getTemplateStrings()['maternity_leave'], |
| 175 | 185 | 'value' => 'maternity_leave', |
| 176 | 186 | 'isDefault' => false, |
| 177 | 187 | 'position' => 1 |
| @@ -179,9 +189,9 @@ | ||
| 179 | 189 | ] |
| 180 | 190 | ], |
| 181 | 191 | // Start Date of Leave |
| 182 | 192 | [ |
| 183 | - 'id' => 0, | |
| 193 | + 'id' => 13, | |
| 184 | 194 | 'fieldIndex' => 5, |
| 185 | 195 | 'type' => 'date', |
| 186 | 196 | 'label' => BackendStrings::getTemplateStrings()['start_date_of_leave'], |
| 187 | 197 | 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date_of_leave'], |
| @@ -193,9 +203,9 @@ | ||
| 193 | 203 | 'dateFormat' => 'MM/DD/YYYY', |
| 194 | 204 | ], |
| 195 | 205 | // Expected Return Date |
| 196 | 206 | [ |
| 197 | - 'id' => 0, | |
| 207 | + 'id' => 14, | |
| 198 | 208 | 'fieldIndex' => 6, |
| 199 | 209 | 'type' => 'date', |
| 200 | 210 | 'label' => BackendStrings::getTemplateStrings()['expected_return_date'], |
| 201 | 211 | 'placeholder' => BackendStrings::getTemplateStrings()['select_expected_return_date'], |
| @@ -207,9 +217,9 @@ | ||
| 207 | 217 | 'dateFormat' => 'MM/DD/YYYY', |
| 208 | 218 | ], |
| 209 | 219 | // Additional Notes |
| 210 | 220 | [ |
| 211 | - 'id' => 0, | |
| 221 | + 'id' => 15, | |
| 212 | 222 | 'fieldIndex' => 7, |
| 213 | 223 | 'type' => 'textarea', |
| 214 | 224 | 'label' => BackendStrings::getTemplateStrings()['additional_notes'], |
| 215 | 225 | 'placeholder' => BackendStrings::getTemplateStrings()['additional_notes_placeholder'], |
| @@ -231,9 +241,9 @@ | ||
| 231 | 241 | { |
| 232 | 242 | return [ |
| 233 | 243 | // Notify my supervisor? checkbox |
| 234 | 244 | [ |
| 235 | - 'id' => 0, | |
| 245 | + 'id' => 18, | |
| 236 | 246 | 'fieldIndex' => 8, |
| 237 | 247 | 'type' => 'checkbox', |
| 238 | 248 | 'label' => BackendStrings::getTemplateStrings()['notify_my_supervisor'], |
| 239 | 249 | 'parentId' => null, |
| @@ -241,18 +251,20 @@ | ||
| 241 | 251 | 'required' => false, |
| 242 | 252 | 'defaultValue' => '', |
| 243 | 253 | 'fieldOptions' => [ |
| 244 | 254 | [ |
| 245 | - 'id' => 0, | |
| 255 | + 'id' => 16, | |
| 246 | 256 | 'label' => BackendStrings::getTemplateStrings()['notify_my_supervisor_yes'], |
| 247 | 257 | 'value' => 'yes', |
| 248 | 258 | 'isDefault' => false, |
| 249 | 259 | 'position' => 1], |
| 250 | - ['id' => 0, | |
| 260 | + [ | |
| 261 | + 'id' => 17, | |
| 251 | 262 | 'label' => BackendStrings::getTemplateStrings()['notify_my_supervisor_no'], |
| 252 | 263 | 'value' => 'no', |
| 253 | 264 | 'isDefault' => false, |
| 254 | - 'position' => 2], | |
| 265 | + 'position' => 2 | |
| 266 | + ], | |
| 255 | 267 | ] |
| 256 | 268 | ], |
| 257 | 269 | ]; |
| 258 | 270 | } |