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

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

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