PluginProbe
The Innovative Form Builder – IvyForms / 0.8.1
The Innovative Form Builder – IvyForms v0.8.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 / DinnerReservationFormTemplate.php

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

275 lines 9.9 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 DinnerReservationFormTemplate
13 {
14 /**
15 * Get the dinner reservation form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'dinner_reservation_form',
23 'name' => BackendStrings::getTemplateStrings()['dinner_reservation_form'],
24 'description' => BackendStrings::getTemplateStrings()['dinner_reservation_form_desc'],
25 'category' => 'booking-forms',
26 'subcategory' => 'reservation-forms',
27 'is_pro' => false,
28 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'dinner-reservation-form.svg',
29 'form_data' => [
30 'name' => BackendStrings::getTemplateStrings()['dinner_reservation_form'],
31 'published' => 1,
32 'showTitle' => 1,
33 'storeEntries' => 1,
34 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
35 'fields' => array_merge(
36 self::getGuestInformationFields(),
37 self::getReservationDetailsFields(),
38 self::getAdditionalFields()
39 ),
40 'settings' => []
41 ]
42 ];
43 }
44
45 /**
46 * Guest information fields (name, email, phone)
47 *
48 * @return array<int, array<string, mixed>>
49 */
50 private static function getGuestInformationFields(): array
51 {
52 return [
53 // Name Field - Parent
54 [
55 'id' => 0,
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 of Name Field
67 [
68 'id' => 0,
69 'type' => 'text',
70 'label' => BackendStrings::getTemplateStrings()['first_name'],
71 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
72 'required' => true,
73 'parentId' => 0,
74 'fieldIndex' => 1,
75 'defaultValue' => '',
76 'position' => 1,
77 'optionHide' => false,
78 'description' => '',
79 'settings' => json_encode(['nameFieldType' => 'nameField1']),
80 ],
81 // Last Name - Child of Name Field
82 [
83 'id' => 0,
84 'type' => 'text',
85 'label' => BackendStrings::getTemplateStrings()['last_name'],
86 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
87 'required' => true,
88 'parentId' => 0,
89 'fieldIndex' => 1,
90 'defaultValue' => '',
91 'position' => 2,
92 'optionHide' => false,
93 'description' => '',
94 'settings' => json_encode(['nameFieldType' => 'nameField2']),
95 ],
96 // Email Address
97 [
98 'id' => 0,
99 'fieldIndex' => 2,
100 'type' => 'email',
101 'label' => BackendStrings::getTemplateStrings()['email_address'],
102 'placeholder' => BackendStrings::getTemplateStrings()['email_placeholder'],
103 'required' => true,
104 'parentId' => null,
105 'defaultValue' => '',
106 'position' => 2,
107 ],
108 // Phone Number
109 [
110 'id' => 0,
111 'fieldIndex' => 3,
112 'type' => 'phone',
113 'label' => BackendStrings::getTemplateStrings()['phone_number'],
114 'placeholder' => BackendStrings::getTemplateStrings()['phone_placeholder'],
115 'required' => true,
116 'parentId' => null,
117 'defaultValue' => '',
118 'position' => 3,
119 'phoneAutoDetect' => true,
120 ],
121 ];
122 }
123
124 /**
125 * Reservation detail fields (guests, seating, date, time)
126 *
127 * @return array<int, array<string, mixed>>
128 */
129 private static function getReservationDetailsFields(): array
130 {
131 return [
132 // Number of Guests
133 [
134 'id' => 0,
135 'fieldIndex' => 4,
136 'type' => 'number',
137 'label' => BackendStrings::getTemplateStrings()['number_of_guests'],
138 'placeholder' => BackendStrings::getTemplateStrings()['enter_total_guests'],
139 'required' => true,
140 'parentId' => null,
141 'defaultValue' => '',
142 'position' => 4,
143 ],
144 // Seating Preference
145 [
146 'id' => 0,
147 'fieldIndex' => 5,
148 'type' => 'select',
149 'label' => BackendStrings::getTemplateStrings()['seating_preference'],
150 'placeholder' => BackendStrings::getTemplateStrings()['select_seating_preference'],
151 'required' => false,
152 'parentId' => null,
153 'defaultValue' => '',
154 'position' => 5,
155 'fieldOptions' => [
156 [
157 'id' => 0,
158 'label' => BackendStrings::getTemplateStrings()['indoor'],
159 'value' => 'indoor',
160 'isDefault' => false,
161 'position' => 1
162 ],
163 [
164 'id' => 0,
165 'label' => BackendStrings::getTemplateStrings()['outdoor'],
166 'value' => 'outdoor',
167 'isDefault' => false,
168 'position' => 2
169 ],
170 [
171 'id' => 0,
172 'label' => BackendStrings::getTemplateStrings()['private_room'],
173 'value' => 'private_room',
174 'isDefault' => false,
175 'position' => 3
176 ],
177 [
178 'id' => 0,
179 'label' => BackendStrings::getTemplateStrings()['window_seat'],
180 'value' => 'window_seat',
181 'isDefault' => false,
182 'position' => 4],
183 ]
184 ],
185 // Reservation Date
186 [
187 'id' => 0,
188 'fieldIndex' => 6,
189 'type' => 'date',
190 'label' => BackendStrings::getTemplateStrings()['reservation_date'],
191 'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_date'],
192 'required' => true,
193 'parentId' => null,
194 'defaultValue' => '',
195 'position' => 6,
196 'dateFieldType' => 'picker',
197 'dateFormat' => 'MM/DD/YYYY',
198 ],
199 // Reservation Time
200 [
201 'id' => 0,
202 'fieldIndex' => 7,
203 'type' => 'time',
204 'label' => BackendStrings::getTemplateStrings()['reservation_time'],
205 'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_time'],
206 'required' => true,
207 'parentId' => null,
208 'defaultValue' => '',
209 'position' => 7,
210 'timeFieldType' => 'time-picker',
211 'timeFormat' => 'ampm',
212 ],
213 ];
214 }
215
216 /**
217 * Additional information fields (special requests, occasion)
218 *
219 * @return array<int, array<string, mixed>>
220 */
221 private static function getAdditionalFields(): array
222 {
223 return [
224 // Special Requests
225 [
226 'id' => 0,
227 'fieldIndex' => 8,
228 'type' => 'textarea',
229 'label' => BackendStrings::getTemplateStrings()['special_requests'],
230 'placeholder' => BackendStrings::getTemplateStrings()['special_requests_placeholder'],
231 'parentId' => null,
232 'defaultValue' => '',
233 'position' => 8,
234 'required' => false,
235 'rows' => 4,
236 ],
237 // Occasion
238 [
239 'id' => 0,
240 'fieldIndex' => 9,
241 'type' => 'checkbox',
242 'label' => BackendStrings::getTemplateStrings()['occasion_question'],
243 'parentId' => null,
244 'position' => 9,
245 'required' => false,
246 'defaultValue' => '',
247 'placeholder' => '',
248 'fieldOptions' => [
249 [
250 'id' => 0,
251 'label' => BackendStrings::getTemplateStrings()['birthday'],
252 'value' => 'birthday',
253 'isDefault' => false,
254 'position' => 1
255 ],
256 [
257 'id' => 0,
258 'label' => BackendStrings::getTemplateStrings()['anniversary'],
259 'value' => 'anniversary',
260 'isDefault' => false,
261 'position' => 2
262 ],
263 [
264 'id' => 0,
265 'label' => BackendStrings::getTemplateStrings()['other'],
266 'value' => 'other',
267 'isDefault' => false,
268 'position' => 3
269 ],
270 ]
271 ],
272 ];
273 }
274 }
275