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

321 lines 9.2 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' => 0,
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' => 0,
91 'type' => 'text',
92 'label' => BackendStrings::getNewFormStrings()['first_name'],
93 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
94 'required' => true,
95 'parentId' => 0,
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' => 0,
114 'type' => 'text',
115 'label' => BackendStrings::getNewFormStrings()['last_name'],
116 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
117 'required' => true,
118 'parentId' => 0,
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' => 0,
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' => 0,
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(),
166 ];
167 }
168
169 /**
170 * Get department field options
171 *
172 * @return array<int, array<string, mixed>>
173 */
174 private static function getDepartmentOptions(): array
175 {
176 return [
177 [
178 'id' => 0,
179 'label' => BackendStrings::getTemplateStrings()['hr'],
180 'value' => 'hr',
181 'isDefault' => false,
182 'position' => 1
183 ],
184 [
185 'id' => 0,
186 'label' => BackendStrings::getTemplateStrings()['it'],
187 'value' => 'it',
188 'isDefault' => false,
189 'position' => 2
190 ],
191 [
192 'id' => 0,
193 'label' => BackendStrings::getTemplateStrings()['sales'],
194 'value' => 'sales',
195 'isDefault' => false,
196 'position' => 3
197 ],
198 [
199 'id' => 0,
200 'label' => BackendStrings::getTemplateStrings()['marketing'],
201 'value' => 'marketing',
202 'isDefault' => false,
203 'position' => 4
204 ],
205 [
206 'id' => 0,
207 'label' => BackendStrings::getTemplateStrings()['other'],
208 'value' => 'other',
209 'isDefault' => false,
210 'position' => 5
211 ],
212 ];
213 }
214
215 /**
216 * Get sick leave start date field
217 *
218 * @return array<string, mixed>
219 */
220 private static function getSickLeaveStartDateField(): array
221 {
222 return [
223 'id' => 0,
224 'fieldIndex' => 4,
225 'type' => 'date',
226 'label' => BackendStrings::getTemplateStrings()['sick_leave_start_date'],
227 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date'],
228 'required' => true,
229 'parentId' => null,
230 'defaultValue' => '',
231 'position' => 5,
232 ];
233 }
234
235 /**
236 * Get sick leave end date field
237 *
238 * @return array<string, mixed>
239 */
240 private static function getSickLeaveEndDateField(): array
241 {
242 return [
243 'id' => 0,
244 'fieldIndex' => 5,
245 'type' => 'date',
246 'label' => BackendStrings::getTemplateStrings()['sick_leave_end_date'],
247 'placeholder' => BackendStrings::getTemplateStrings()['select_end_date'],
248 'required' => true,
249 'parentId' => null,
250 'defaultValue' => '',
251 'position' => 6,
252 ];
253 }
254
255 /**
256 * Get doctor's note field
257 *
258 * @return array<string, mixed>
259 */
260 private static function getDoctorsNoteField(): array
261 {
262 return [
263 'id' => 0,
264 'fieldIndex' => 6,
265 'type' => 'textarea',
266 'label' => BackendStrings::getTemplateStrings()['doctors_note'],
267 'placeholder' => BackendStrings::getTemplateStrings()['attach_doctors_note_if_required'],
268 'required' => false,
269 'parentId' => null,
270 'defaultValue' => '',
271 'position' => 7,
272 ];
273 }
274
275 /**
276 * Get notify supervisor field
277 *
278 * @return array<string, mixed>
279 */
280 private static function getNotifySupervisorField(): array
281 {
282 return [
283 'id' => 0,
284 'fieldIndex' => 7,
285 'type' => 'radio',
286 'label' => BackendStrings::getTemplateStrings()['notify_supervisor'],
287 'placeholder' => '',
288 'required' => false,
289 'parentId' => null,
290 'defaultValue' => '',
291 'position' => 8,
292 'fieldOptions' => self::getNotifySupervisorOptions(),
293 ];
294 }
295
296 /**
297 * Get notify supervisor field options
298 *
299 * @return array<int, array<string, mixed>>
300 */
301 private static function getNotifySupervisorOptions(): array
302 {
303 return [
304 [
305 'id' => 0,
306 'label' => BackendStrings::getTemplateStrings()['yes'],
307 'value' => 'yes',
308 'isDefault' => false,
309 'position' => 1
310 ],
311 [
312 'id' => 0,
313 'label' => BackendStrings::getTemplateStrings()['no'],
314 'value' => 'no',
315 'isDefault' => false,
316 'position' => 2
317 ],
318 ];
319 }
320 }
321