| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Services\Template; |
| 4 |
|
| 5 |
use IvyForms\Services\Translations\BackendStrings; |
| 6 |
|
| 7 |
class AnnualLeaveRequestFormTemplate |
| 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' => 'annual_leave_request_form', |
| 18 |
'name' => BackendStrings::getTemplateStrings()['annual_leave_request_form'], |
| 19 |
'description' => BackendStrings::getTemplateStrings()['annual_leave_request_form_desc'], |
| 20 |
'category' => 'leave-request', |
| 21 |
'subcategory' => 'leave-request-forms', |
| 22 |
'is_pro' => false, |
| 23 |
'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'annual-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 |
[ |
| 37 |
'form_data' => [ |
| 38 |
'name' => BackendStrings::getTemplateStrings()['annual_leave_request_form'], |
| 39 |
'published' => 1, |
| 40 |
'showTitle' => 1, |
| 41 |
'storeEntries' => 1, |
| 42 |
'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(), |
| 43 |
'fields' => self::getFormFields(), |
| 44 |
'settings' => [] |
| 45 |
] |
| 46 |
] |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Get all form fields |
| 52 |
* |
| 53 |
* @return array<int, array<string, mixed>> |
| 54 |
*/ |
| 55 |
private static function getFormFields(): array |
| 56 |
{ |
| 57 |
return array_merge( |
| 58 |
[ |
| 59 |
self::getNameField(), |
| 60 |
self::getFirstNameField(), |
| 61 |
self::getLastNameField(), |
| 62 |
], |
| 63 |
self::getEmployeeDetailsFields(), |
| 64 |
self::getLeaveDetailsFields(), |
| 65 |
self::getApprovalFields() |
| 66 |
); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Get name field (parent) |
| 71 |
* |
| 72 |
* @return array<string, mixed> |
| 73 |
*/ |
| 74 |
private static function getNameField(): array |
| 75 |
{ |
| 76 |
return [ |
| 77 |
'id' => 1, |
| 78 |
'fieldIndex' => 1, |
| 79 |
'type' => 'name', |
| 80 |
'label' => BackendStrings::getTemplateStrings()['full_name'], |
| 81 |
'parentId' => null, |
| 82 |
'defaultValue' => '', |
| 83 |
'placeholder' => '', |
| 84 |
'required' => true, |
| 85 |
'readonly' => false, |
| 86 |
'position' => 1, |
| 87 |
]; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Get first name field (child of name field) |
| 92 |
* |
| 93 |
* @return array<string, mixed> |
| 94 |
*/ |
| 95 |
private static function getFirstNameField(): array |
| 96 |
{ |
| 97 |
return [ |
| 98 |
'id' => 2, |
| 99 |
'type' => 'text', |
| 100 |
'label' => BackendStrings::getNewFormStrings()['first_name'], |
| 101 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 102 |
'required' => true, |
| 103 |
'parentId' => 1, |
| 104 |
'fieldIndex' => 1, |
| 105 |
'defaultValue' => '', |
| 106 |
'position' => 1, |
| 107 |
'optionHide' => false, |
| 108 |
'description' => '', |
| 109 |
'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 110 |
]; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Get last name field (child of name field) |
| 115 |
* |
| 116 |
* @return array<string, mixed> |
| 117 |
*/ |
| 118 |
private static function getLastNameField(): array |
| 119 |
{ |
| 120 |
return [ |
| 121 |
'id' => 3, |
| 122 |
'type' => 'text', |
| 123 |
'label' => BackendStrings::getNewFormStrings()['last_name'], |
| 124 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 125 |
'required' => true, |
| 126 |
'parentId' => 1, |
| 127 |
'fieldIndex' => 1, |
| 128 |
'defaultValue' => '', |
| 129 |
'position' => 2, |
| 130 |
'optionHide' => false, |
| 131 |
'description' => '', |
| 132 |
'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 133 |
]; |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Get employee details fields |
| 138 |
* |
| 139 |
* @return array<int, array<string, mixed>> |
| 140 |
*/ |
| 141 |
private static function getEmployeeDetailsFields(): array |
| 142 |
{ |
| 143 |
return [ |
| 144 |
// Email Address |
| 145 |
[ |
| 146 |
'id' => 4, |
| 147 |
'fieldIndex' => 2, |
| 148 |
'type' => 'email', |
| 149 |
'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 150 |
'placeholder' => '[email protected]', |
| 151 |
'required' => true, |
| 152 |
'parentId' => null, |
| 153 |
'defaultValue' => '', |
| 154 |
'position' => 2, |
| 155 |
], |
| 156 |
// Employee ID |
| 157 |
[ |
| 158 |
'id' => 5, |
| 159 |
'fieldIndex' => 3, |
| 160 |
'type' => 'text', |
| 161 |
'label' => BackendStrings::getTemplateStrings()['employee_id'], |
| 162 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_employee_id'], |
| 163 |
'required' => true, |
| 164 |
'parentId' => null, |
| 165 |
'defaultValue' => '', |
| 166 |
'position' => 3, |
| 167 |
], |
| 168 |
// Department |
| 169 |
[ |
| 170 |
'id' => 13, |
| 171 |
'fieldIndex' => 4, |
| 172 |
'type' => 'select', |
| 173 |
'label' => BackendStrings::getTemplateStrings()['department'], |
| 174 |
'placeholder' => BackendStrings::getTemplateStrings()['select_department'], |
| 175 |
'required' => true, |
| 176 |
'parentId' => null, |
| 177 |
'defaultValue' => '', |
| 178 |
'position' => 4, |
| 179 |
'fieldOptions' => [ |
| 180 |
[ |
| 181 |
'id' => 6, |
| 182 |
'label' => BackendStrings::getTemplateStrings()['hr'], |
| 183 |
'value' => 'hr', |
| 184 |
'isDefault' => false, |
| 185 |
'position' => 1 |
| 186 |
], |
| 187 |
[ |
| 188 |
'id' => 7, |
| 189 |
'label' => BackendStrings::getTemplateStrings()['it'], |
| 190 |
'value' => 'it', |
| 191 |
'isDefault' => false, |
| 192 |
'position' => 2 |
| 193 |
], |
| 194 |
[ |
| 195 |
'id' => 8, |
| 196 |
'label' => BackendStrings::getTemplateStrings()['marketing'], |
| 197 |
'value' => 'marketing', |
| 198 |
'isDefault' => false, |
| 199 |
'position' => 3 |
| 200 |
], |
| 201 |
[ |
| 202 |
'id' => 9, |
| 203 |
'label' => BackendStrings::getTemplateStrings()['finance'], |
| 204 |
'value' => 'finance', |
| 205 |
'isDefault' => false, |
| 206 |
'position' => 4 |
| 207 |
], |
| 208 |
[ |
| 209 |
'id' => 10, |
| 210 |
'label' => BackendStrings::getTemplateStrings()['sales'], |
| 211 |
'value' => 'sales', |
| 212 |
'isDefault' => false, |
| 213 |
'position' => 5 |
| 214 |
], |
| 215 |
[ |
| 216 |
'id' => 11, |
| 217 |
'label' => BackendStrings::getTemplateStrings()['operations'], |
| 218 |
'value' => 'operations', |
| 219 |
'isDefault' => false, |
| 220 |
'position' => 6 |
| 221 |
], |
| 222 |
[ |
| 223 |
'id' => 12, |
| 224 |
'label' => BackendStrings::getTemplateStrings()['other'], |
| 225 |
'value' => 'other', |
| 226 |
'isDefault' => false, |
| 227 |
'position' => 7 |
| 228 |
], |
| 229 |
] |
| 230 |
], |
| 231 |
// Job Title/Position |
| 232 |
[ |
| 233 |
'id' => 14, |
| 234 |
'fieldIndex' => 5, |
| 235 |
'type' => 'text', |
| 236 |
'label' => BackendStrings::getTemplateStrings()['job_title_position'], |
| 237 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_job_title'], |
| 238 |
'required' => false, |
| 239 |
'parentId' => null, |
| 240 |
'defaultValue' => '', |
| 241 |
'position' => 5, |
| 242 |
], |
| 243 |
]; |
| 244 |
} |
| 245 |
|
| 246 |
/** |
| 247 |
* Get leave details fields |
| 248 |
* |
| 249 |
* @return array<int, array<string, mixed>> |
| 250 |
*/ |
| 251 |
private static function getLeaveDetailsFields(): array |
| 252 |
{ |
| 253 |
return [ |
| 254 |
// Leave Start Date |
| 255 |
[ |
| 256 |
'id' => 15, |
| 257 |
'fieldIndex' => 6, |
| 258 |
'type' => 'date', |
| 259 |
'label' => BackendStrings::getTemplateStrings()['leave_start_date'], |
| 260 |
'placeholder' => BackendStrings::getTemplateStrings()['select_start_date'], |
| 261 |
'required' => true, |
| 262 |
'parentId' => null, |
| 263 |
'defaultValue' => '', |
| 264 |
'position' => 6, |
| 265 |
'dateFieldType' => 'picker', |
| 266 |
'dateFormat' => 'MM/DD/YYYY', |
| 267 |
], |
| 268 |
// Leave End Date |
| 269 |
[ |
| 270 |
'id' => 16, |
| 271 |
'fieldIndex' => 7, |
| 272 |
'type' => 'date', |
| 273 |
'label' => BackendStrings::getTemplateStrings()['leave_end_date'], |
| 274 |
'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'], |
| 275 |
'required' => true, |
| 276 |
'parentId' => null, |
| 277 |
'defaultValue' => '', |
| 278 |
'position' => 7, |
| 279 |
'dateFieldType' => 'picker', |
| 280 |
'dateFormat' => 'MM/DD/YYYY', |
| 281 |
], |
| 282 |
// Total Number of Days |
| 283 |
[ |
| 284 |
'id' => 17, |
| 285 |
'fieldIndex' => 8, |
| 286 |
'type' => 'number', |
| 287 |
'label' => BackendStrings::getTemplateStrings()['total_number_of_days'], |
| 288 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_total_number_of_days'], |
| 289 |
'required' => true, |
| 290 |
'parentId' => null, |
| 291 |
'defaultValue' => '', |
| 292 |
'position' => 8, |
| 293 |
'minValue' => 1, |
| 294 |
'maxValue' => 365, |
| 295 |
], |
| 296 |
// Annual Leave Balance |
| 297 |
[ |
| 298 |
'id' => 18, |
| 299 |
'fieldIndex' => 9, |
| 300 |
'type' => 'number', |
| 301 |
'label' => BackendStrings::getTemplateStrings()['annual_leave_balance'], |
| 302 |
'placeholder' => BackendStrings::getTemplateStrings()['remaining_leave_days'], |
| 303 |
'required' => false, |
| 304 |
'parentId' => null, |
| 305 |
'defaultValue' => '', |
| 306 |
'position' => 9, |
| 307 |
'minValue' => 0, |
| 308 |
'maxValue' => 365, |
| 309 |
], |
| 310 |
// Reason for Leave |
| 311 |
[ |
| 312 |
'id' => 19, |
| 313 |
'fieldIndex' => 10, |
| 314 |
'type' => 'textarea', |
| 315 |
'label' => BackendStrings::getTemplateStrings()['reason_for_leave'], |
| 316 |
'placeholder' => BackendStrings::getTemplateStrings()['briefly_describe_reason'], |
| 317 |
'required' => false, |
| 318 |
'parentId' => null, |
| 319 |
'defaultValue' => '', |
| 320 |
'position' => 10, |
| 321 |
], |
| 322 |
]; |
| 323 |
} |
| 324 |
|
| 325 |
/** |
| 326 |
* Get approval fields |
| 327 |
* |
| 328 |
* @return array<int, array<string, mixed>> |
| 329 |
*/ |
| 330 |
private static function getApprovalFields(): array |
| 331 |
{ |
| 332 |
return [ |
| 333 |
// Contact During Leave |
| 334 |
[ |
| 335 |
'id' => 22, |
| 336 |
'fieldIndex' => 11, |
| 337 |
'type' => 'radio', |
| 338 |
'label' => BackendStrings::getTemplateStrings()['contact_during_leave'], |
| 339 |
'placeholder' => '', |
| 340 |
'required' => true, |
| 341 |
'parentId' => null, |
| 342 |
'defaultValue' => '', |
| 343 |
'position' => 11, |
| 344 |
'fieldOptions' => [ |
| 345 |
[ |
| 346 |
'id' => 20, |
| 347 |
'label' => BackendStrings::getTemplateStrings()['yes'], |
| 348 |
'value' => 'yes', |
| 349 |
'isDefault' => false, |
| 350 |
'position' => 1 |
| 351 |
], |
| 352 |
[ |
| 353 |
'id' => 21, |
| 354 |
'label' => BackendStrings::getTemplateStrings()['no'], |
| 355 |
'value' => 'no', |
| 356 |
'isDefault' => false, |
| 357 |
'position' => 2 |
| 358 |
], |
| 359 |
] |
| 360 |
], |
| 361 |
// Emergency Contact |
| 362 |
[ |
| 363 |
'id' => 23, |
| 364 |
'fieldIndex' => 12, |
| 365 |
'type' => 'text', |
| 366 |
'label' => BackendStrings::getTemplateStrings()['emergency_contact'], |
| 367 |
'placeholder' => BackendStrings::getTemplateStrings()['emergency_contact_phone'], |
| 368 |
'required' => false, |
| 369 |
'parentId' => null, |
| 370 |
'defaultValue' => '', |
| 371 |
'position' => 12, |
| 372 |
], |
| 373 |
// Supervisor Name |
| 374 |
[ |
| 375 |
'id' => 24, |
| 376 |
'fieldIndex' => 13, |
| 377 |
'type' => 'text', |
| 378 |
'label' => BackendStrings::getTemplateStrings()['supervisor_name'], |
| 379 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_supervisor_name'], |
| 380 |
'required' => true, |
| 381 |
'parentId' => null, |
| 382 |
'defaultValue' => '', |
| 383 |
'position' => 13, |
| 384 |
], |
| 385 |
// Backup / Coverage Plan |
| 386 |
[ |
| 387 |
'id' => 25, |
| 388 |
'fieldIndex' => 14, |
| 389 |
'type' => 'textarea', |
| 390 |
'label' => BackendStrings::getTemplateStrings()['backup_coverage_plan'], |
| 391 |
'placeholder' => BackendStrings::getTemplateStrings()['describe_coverage_arrangements'], |
| 392 |
'required' => false, |
| 393 |
'parentId' => null, |
| 394 |
'defaultValue' => '', |
| 395 |
'position' => 14, |
| 396 |
], |
| 397 |
]; |
| 398 |
} |
| 399 |
} |
| 400 |
|