PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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 1.5, at backend/src/Services/Template/SickLeaveRequestFormTemplate.php

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