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