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