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 / MaternityLeaveRequestFormTemplate.php

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

263 lines 9.4 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 MaternityLeaveRequestFormTemplate
13 {
14 /**
15 * Get the maternity leave request form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'maternity_leave_request_form',
23 'name' => BackendStrings::getTemplateStrings()['maternity_leave_request_form'],
24 'description' => BackendStrings::getTemplateStrings()['maternity_leave_request_form_desc'],
25 'category' => 'leave-request',
26 'subcategory' => 'leave-request-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'maternity-leave-request-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['maternity_leave_request_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getEmployeeFields(),
37 self::getLeaveFields(),
38 self::getNotificationFields()
39 ),
40 'settings' => []
41 ]
42 ];
43 }
44
45 /**
46 * Employee information fields
47 *
48 * @return array<int, array<string, mixed>>
49 */
50 private static function getEmployeeFields(): array
51 {
52 return [
53 // Name Field - Parent
54 [
55 'id' => 1,
56 'fieldIndex' => 1,
57 'type' => 'name',
58 'label' => BackendStrings::getTemplateStrings()['full_name'],
59 'parentId' => null,
60 'defaultValue' => '',
61 'placeholder' => '',
62 'required' => true,
63 'readonly' => false,
64 'position' => 1,
65 ],
66 // First Name - Child
67 [
68 'id' => 2,
69 'type' => 'text',
70 'label' => BackendStrings::getNewFormStrings()['first_name'],
71 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
72 'required' => true,
73 'parentId' => 1,
74 'fieldIndex' => 1,
75 'defaultValue' => '',
76 'position' => 1,
77 'settings' => json_encode(['nameFieldType' => 'nameField1']),
78 ],
79 // Last Name - Child
80 [
81 'id' => 3,
82 'type' => 'text',
83 'label' => BackendStrings::getNewFormStrings()['last_name'],
84 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
85 'required' => true,
86 'parentId' => 1,
87 'fieldIndex' => 1,
88 'defaultValue' => '',
89 'position' => 2,
90 'settings' => json_encode(['nameFieldType' => 'nameField2']),
91 ],
92 // Email
93 [
94 'id' => 4,
95 'fieldIndex' => 2,
96 'type' => 'email',
97 'label' => BackendStrings::getTemplateStrings()['email_address'],
98 'placeholder' => BackendStrings::getTemplateStrings()['email_placeholder'],
99 'required' => true,
100 'parentId' => null,
101 'defaultValue' => '',
102 'position' => 2,
103 ],
104 // Department select
105 [
106 'id' => 10,
107 'fieldIndex' => 3,
108 'type' => 'select',
109 'label' => BackendStrings::getTemplateStrings()['department'],
110 'placeholder' => BackendStrings::getTemplateStrings()['select_department'],
111 'required' => true,
112 'parentId' => null,
113 'defaultValue' => '',
114 'position' => 3,
115 'fieldOptions' => [
116 [
117 'id' => 5,
118 'label' => BackendStrings::getTemplateStrings()['hr'],
119 'value' => 'hr',
120 'isDefault' => false,
121 'position' => 1
122 ],
123 [
124 'id' => 6,
125 'label' => BackendStrings::getTemplateStrings()['it'],
126 'value' => 'it',
127 'isDefault' => false,
128 'position' => 2],
129 [
130 'id' => 7,
131 'label' => BackendStrings::getTemplateStrings()['sales'],
132 'value' => 'sales',
133 'isDefault' => false,
134 'position' => 3],
135 [
136 'id' => 8,
137 'label' => BackendStrings::getTemplateStrings()['marketing'],
138 'value' => 'marketing',
139 'isDefault' => false,
140 'position' => 4
141 ],
142 [
143 'id' => 9,
144 'label' => BackendStrings::getTemplateStrings()['other'],
145 'value' => 'other',
146 'isDefault' => false,
147 'position' => 5],
148 ]
149 ],
150 ];
151 }
152
153 /**
154 * Leave-specific fields
155 *
156 * @return array<int, array<string, mixed>>
157 */
158 private static function getLeaveFields(): array
159 {
160 return [
161 // Leave Type (Maternity only)
162 [
163 'id' => 12,
164 'fieldIndex' => 4,
165 'type' => 'select',
166 'label' => BackendStrings::getTemplateStrings()['type_of_leave'],
167 'placeholder' => BackendStrings::getTemplateStrings()['select_type_of_leave'],
168 'required' => true,
169 'parentId' => null,
170 'defaultValue' => '',
171 'position' => 4,
172 'fieldOptions' => [
173 [
174 'id' => 11,
175 'label' => BackendStrings::getTemplateStrings()['maternity_leave'],
176 'value' => 'maternity_leave',
177 'isDefault' => false,
178 'position' => 1
179 ],
180 ]
181 ],
182 // Start Date of Leave
183 [
184 'id' => 13,
185 'fieldIndex' => 5,
186 'type' => 'date',
187 'label' => BackendStrings::getTemplateStrings()['start_date_of_leave'],
188 'placeholder' => BackendStrings::getTemplateStrings()['select_start_date_of_leave'],
189 'required' => true,
190 'parentId' => null,
191 'defaultValue' => '',
192 'position' => 5,
193 'dateFieldType' => 'picker',
194 'dateFormat' => 'MM/DD/YYYY',
195 ],
196 // Expected Return Date
197 [
198 'id' => 14,
199 'fieldIndex' => 6,
200 'type' => 'date',
201 'label' => BackendStrings::getTemplateStrings()['expected_return_date'],
202 'placeholder' => BackendStrings::getTemplateStrings()['select_expected_return_date'],
203 'required' => true,
204 'parentId' => null,
205 'defaultValue' => '',
206 'position' => 6,
207 'dateFieldType' => 'picker',
208 'dateFormat' => 'MM/DD/YYYY',
209 ],
210 // Additional Notes
211 [
212 'id' => 15,
213 'fieldIndex' => 7,
214 'type' => 'textarea',
215 'label' => BackendStrings::getTemplateStrings()['additional_notes'],
216 'placeholder' => BackendStrings::getTemplateStrings()['additional_notes_placeholder'],
217 'required' => false,
218 'parentId' => null,
219 'defaultValue' => '',
220 'position' => 7,
221 'rows' => 4,
222 ],
223 ];
224 }
225
226 /**
227 * Notification / approval fields
228 *
229 * @return array<int, array<string, mixed>>
230 */
231 private static function getNotificationFields(): array
232 {
233 return [
234 // Notify my supervisor? checkbox
235 [
236 'id' => 18,
237 'fieldIndex' => 8,
238 'type' => 'checkbox',
239 'label' => BackendStrings::getTemplateStrings()['notify_my_supervisor'],
240 'parentId' => null,
241 'position' => 8,
242 'required' => false,
243 'defaultValue' => '',
244 'fieldOptions' => [
245 [
246 'id' => 16,
247 'label' => BackendStrings::getTemplateStrings()['notify_my_supervisor_yes'],
248 'value' => 'yes',
249 'isDefault' => false,
250 'position' => 1],
251 [
252 'id' => 17,
253 'label' => BackendStrings::getTemplateStrings()['notify_my_supervisor_no'],
254 'value' => 'no',
255 'isDefault' => false,
256 'position' => 2
257 ],
258 ]
259 ],
260 ];
261 }
262 }
263