PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
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
ivyforms / backend / src / Services / Template / SickLeaveRequestFormTemplate.php

SickLeaveRequestFormTemplate.php in The Innovative Form Builder – IvyForms 0.9, at backend/src/Services/Template/SickLeaveRequestFormTemplate.php

329 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 SickLeaveRequestFormTemplate
13 {
14 /**
15 * Get the sick leave request form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'sick_leave_request_form',
23 'name' => BackendStrings::getTemplateStrings()['sick_leave_request_form'],
24 'description' => BackendStrings::getTemplateStrings()['sick_leave_request_form_desc'],
25 'category' => 'leave-request',
26 'subcategory' => 'leave-request-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'sick-leave-request-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['sick_leave_request_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => self::getFormFields(),
36 'settings' => []
37 ]
38 ];
39 }
40
41 /**
42 * Get all form fields
43 *
44 * @return array<int, array<string, mixed>>
45 */
46 private static function getFormFields(): array
47 {
48 return [
49 self::getNameField(),
50 self::getFirstNameField(),
51 self::getLastNameField(),
52 self::getEmailField(),
53 self::getDepartmentField(),
54 self::getSickLeaveStartDateField(),
55 self::getSickLeaveEndDateField(),
56 self::getDoctorsNoteField(),
57 self::getNotifySupervisorField(),
58 ];
59 }
60
61 /**
62 * Get name field (parent)
63 *
64 * @return array<string, mixed>
65 */
66 private static function getNameField(): array
67 {
68 return [
69 'id' => 1,
70 'fieldIndex' => 1,
71 'type' => 'name',
72 'label' => BackendStrings::getTemplateStrings()['full_name'],
73 'parentId' => null,
74 'defaultValue' => '',
75 'placeholder' => '',
76 'required' => true,
77 'readonly' => false,
78 'position' => 1,
79 ];
80 }
81
82 /**
83 * Get first name field (child of name field)
84 *
85 * @return array<string, mixed>
86 */
87 private static function getFirstNameField(): array
88 {
89 return [
90 'id' => 2,
91 'type' => 'text',
92 'label' => BackendStrings::getNewFormStrings()['first_name'],
93 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
94 'required' => true,
95 'parentId' => 1,
96 'fieldIndex' => 1,
97 'defaultValue' => '',
98 'position' => 1,
99 'optionHide' => false,
100 'description' => '',
101 'settings' => json_encode(['nameFieldType' => 'nameField1']),
102 ];
103 }
104
105 /**
106 * Get last name field (child of name field)
107 *
108 * @return array<string, mixed>
109 */
110 private static function getLastNameField(): array
111 {
112 return [
113 'id' => 3,
114 'type' => 'text',
115 'label' => BackendStrings::getNewFormStrings()['last_name'],
116 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
117 'required' => true,
118 'parentId' => 1,
119 'fieldIndex' => 1,
120 'defaultValue' => '',
121 'position' => 2,
122 'optionHide' => false,
123 'description' => '',
124 'settings' => json_encode(['nameFieldType' => 'nameField2']),
125 ];
126 }
127
128 /**
129 * Get email field
130 *
131 * @return array<string, mixed>
132 */
133 private static function getEmailField(): array
134 {
135 return [
136 'id' => 4,
137 'fieldIndex' => 2,
138 'type' => 'email',
139 'label' => BackendStrings::getTemplateStrings()['email_address'],
140 'placeholder' => '[email protected]',
141 'required' => true,
142 'parentId' => null,
143 'defaultValue' => '',
144 'position' => 2,
145 ];
146 }
147
148 /**
149 * Get department field
150 *
151 * @return array<string, mixed>
152 */
153 private static function getDepartmentField(): array
154 {
155 return [
156 'id' => 5,
157 'fieldIndex' => 3,
158 'type' => 'select',
159 'label' => BackendStrings::getTemplateStrings()['department'],
160 'placeholder' => BackendStrings::getTemplateStrings()['select_department'],
161 'required' => true,
162 'parentId' => null,
163 'defaultValue' => '',
164 'position' => 3,
165 'fieldOptions' => self::getDepartmentOptions(1),
166 ];
167 }
168
169 /**
170 * Get department field options
171 *
172 * @param int $startId Starting ID for the options
173 *
174 * @return array<int, array<string, mixed>>
175 */
176 private static function getDepartmentOptions(int $startId): array
177 {
178 return [
179 [
180 'id' => $startId,
181 'label' => BackendStrings::getTemplateStrings()['hr'],
182 'value' => 'hr',
183 'isDefault' => false,
184 'position' => 1
185 ],
186 [
187 'id' => $startId + 1,
188 'label' => BackendStrings::getTemplateStrings()['it'],
189 'value' => 'it',
190 'isDefault' => false,
191 'position' => 2
192 ],
193 [
194 'id' => $startId + 2,
195 'label' => BackendStrings::getTemplateStrings()['sales'],
196 'value' => 'sales',
197 'isDefault' => false,
198 'position' => 3
199 ],
200 [
201 'id' => $startId + 3,
202 'label' => BackendStrings::getTemplateStrings()['marketing'],
203 'value' => 'marketing',
204 'isDefault' => false,
205 'position' => 4
206 ],
207 [
208 'id' => $startId + 4,
209 'label' => BackendStrings::getTemplateStrings()['other'],
210 'value' => 'other',
211 'isDefault' => false,
212 'position' => 5
213 ],
214 ];
215 }
216
217 /**
218 * Get sick leave start date field
219 *
220 * @return array<string, mixed>
221 */
222 private static function getSickLeaveStartDateField(): array
223 {
224 return [
225 'id' => 11,
226 'fieldIndex' => 4,
227 'type' => 'date',
228 'label' => BackendStrings::getTemplateStrings()['sick_leave_start_date'],
229 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date'],
230 'required' => true,
231 'parentId' => null,
232 'defaultValue' => '',
233 'position' => 5,
234 'dateFieldType' => 'picker',
235 'dateFormat' => 'MM/DD/YYYY',
236 ];
237 }
238
239 /**
240 * Get sick leave end date field
241 *
242 * @return array<string, mixed>
243 */
244 private static function getSickLeaveEndDateField(): array
245 {
246 return [
247 'id' => 12,
248 'fieldIndex' => 5,
249 'type' => 'date',
250 'label' => BackendStrings::getTemplateStrings()['sick_leave_end_date'],
251 'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'],
252 'required' => true,
253 'parentId' => null,
254 'defaultValue' => '',
255 'position' => 6,
256 'dateFieldType' => 'picker',
257 'dateFormat' => 'MM/DD/YYYY',
258 ];
259 }
260
261 /**
262 * Get doctor's note field
263 *
264 * @return array<string, mixed>
265 */
266 private static function getDoctorsNoteField(): array
267 {
268 return [
269 'id' => 13,
270 'fieldIndex' => 6,
271 'type' => 'textarea',
272 'label' => BackendStrings::getTemplateStrings()['doctors_note'],
273 'placeholder' => BackendStrings::getTemplateStrings()['attach_doctors_note_if_required'],
274 'required' => false,
275 'parentId' => null,
276 'defaultValue' => '',
277 'position' => 7,
278 ];
279 }
280
281 /**
282 * Get notify supervisor field
283 *
284 * @return array<string, mixed>
285 */
286 private static function getNotifySupervisorField(): array
287 {
288 return [
289 'id' => 14,
290 'fieldIndex' => 7,
291 'type' => 'radio',
292 'label' => BackendStrings::getTemplateStrings()['notify_supervisor'],
293 'placeholder' => '',
294 'required' => false,
295 'parentId' => null,
296 'defaultValue' => '',
297 'position' => 8,
298 'fieldOptions' => self::getNotifySupervisorOptions(1),
299 ];
300 }
301
302 /**
303 * Get notify supervisor field options
304 *
305 * @param int $startId Starting ID for the options
306 *
307 * @return array<int, array<string, mixed>>
308 */
309 private static function getNotifySupervisorOptions(int $startId): array
310 {
311 return [
312 [
313 'id' => $startId,
314 'label' => BackendStrings::getTemplateStrings()['yes'],
315 'value' => 'yes',
316 'isDefault' => false,
317 'position' => 1
318 ],
319 [
320 'id' => $startId + 1,
321 'label' => BackendStrings::getTemplateStrings()['no'],
322 'value' => 'no',
323 'isDefault' => false,
324 'position' => 2
325 ],
326 ];
327 }
328 }
329