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

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