| 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 PrivateDiningReservationFormTemplate |
| 13 |
{ |
| 14 |
/** |
| 15 |
* Get the private dining reservation form template |
| 16 |
* |
| 17 |
* @return array<string, mixed> |
| 18 |
*/ |
| 19 |
public static function getTemplate(): array |
| 20 |
{ |
| 21 |
return [ |
| 22 |
'id' => 'private_dining_reservation_form', |
| 23 |
'name' => BackendStrings::getTemplateStrings()['private_dining_reservation_form'], |
| 24 |
'description' => BackendStrings::getTemplateStrings()['private_dining_reservation_form_desc'], |
| 25 |
'category' => 'booking-forms', |
| 26 |
'subcategory' => 'reservation-forms', |
| 27 |
'is_pro' => false, |
| 28 |
'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'private-dining-reservation-form.svg', |
| 29 |
'form_data' => [ |
| 30 |
'name' => BackendStrings::getTemplateStrings()['private_dining_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' => 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 of Name Field |
| 67 |
[ |
| 68 |
'id' => 2, |
| 69 |
'type' => 'text', |
| 70 |
'label' => BackendStrings::getTemplateStrings()['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 |
'optionHide' => false, |
| 78 |
'description' => '', |
| 79 |
'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 80 |
], |
| 81 |
// Last Name - Child of Name Field |
| 82 |
[ |
| 83 |
'id' => 3, |
| 84 |
'type' => 'text', |
| 85 |
'label' => BackendStrings::getTemplateStrings()['last_name'], |
| 86 |
'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 87 |
'required' => true, |
| 88 |
'parentId' => 1, |
| 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' => 4, |
| 99 |
'fieldIndex' => 2, |
| 100 |
'type' => 'email', |
| 101 |
'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 102 |
'placeholder' => BackendStrings::getTemplateStrings()['name_placeholder'], |
| 103 |
'required' => true, |
| 104 |
'parentId' => null, |
| 105 |
'defaultValue' => '', |
| 106 |
'position' => 2, |
| 107 |
], |
| 108 |
// Phone Number |
| 109 |
[ |
| 110 |
'id' => 5, |
| 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, room preference, 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' => 6, |
| 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 |
'minValue' => 1, |
| 144 |
], |
| 145 |
// Room Preference |
| 146 |
[ |
| 147 |
'id' => 10, |
| 148 |
'fieldIndex' => 5, |
| 149 |
'type' => 'select', |
| 150 |
'label' => BackendStrings::getTemplateStrings()['room_preference'], |
| 151 |
'placeholder' => BackendStrings::getTemplateStrings()['select_room_preference'], |
| 152 |
'required' => false, |
| 153 |
'parentId' => null, |
| 154 |
'defaultValue' => '', |
| 155 |
'position' => 5, |
| 156 |
'fieldOptions' => [ |
| 157 |
[ |
| 158 |
'id' => 7, |
| 159 |
'label' => BackendStrings::getTemplateStrings()['private_room_a'], |
| 160 |
'value' => 'private_room_a', |
| 161 |
'isDefault' => false, |
| 162 |
'position' => 1 |
| 163 |
], |
| 164 |
[ |
| 165 |
'id' => 8, |
| 166 |
'label' => BackendStrings::getTemplateStrings()['private_room_b'], |
| 167 |
'value' => 'private_room_b', |
| 168 |
'isDefault' => false, |
| 169 |
'position' => 2 |
| 170 |
], |
| 171 |
[ |
| 172 |
'id' => 9, |
| 173 |
'label' => BackendStrings::getTemplateStrings()['no_preference'], |
| 174 |
'value' => 'no_preference', |
| 175 |
'isDefault' => false, |
| 176 |
'position' => 3 |
| 177 |
], |
| 178 |
] |
| 179 |
], |
| 180 |
// Reservation Date |
| 181 |
[ |
| 182 |
'id' => 11, |
| 183 |
'fieldIndex' => 6, |
| 184 |
'type' => 'date', |
| 185 |
'label' => BackendStrings::getTemplateStrings()['reservation_date'], |
| 186 |
'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_date'], |
| 187 |
'required' => true, |
| 188 |
'parentId' => null, |
| 189 |
'defaultValue' => '', |
| 190 |
'position' => 6, |
| 191 |
'dateFieldType' => 'picker', |
| 192 |
'dateFormat' => 'MM/DD/YYYY', |
| 193 |
], |
| 194 |
// Reservation Time |
| 195 |
[ |
| 196 |
'id' => 12, |
| 197 |
'fieldIndex' => 7, |
| 198 |
'type' => 'time', |
| 199 |
'label' => BackendStrings::getTemplateStrings()['reservation_time'], |
| 200 |
'placeholder' => BackendStrings::getTemplateStrings()['select_reservation_time'], |
| 201 |
'required' => true, |
| 202 |
'parentId' => null, |
| 203 |
'defaultValue' => '', |
| 204 |
'position' => 7, |
| 205 |
'timeFieldType' => 'time-picker', |
| 206 |
'timeFormat' => 'ampm', |
| 207 |
], |
| 208 |
]; |
| 209 |
} |
| 210 |
|
| 211 |
/** |
| 212 |
* Additional information fields (special instructions) |
| 213 |
* |
| 214 |
* @return array<int, array<string, mixed>> |
| 215 |
*/ |
| 216 |
private static function getAdditionalFields(): array |
| 217 |
{ |
| 218 |
return [ |
| 219 |
// Special Instructions |
| 220 |
[ |
| 221 |
'id' => 13, |
| 222 |
'fieldIndex' => 8, |
| 223 |
'type' => 'textarea', |
| 224 |
'label' => BackendStrings::getTemplateStrings()['special_instructions'], |
| 225 |
'placeholder' => BackendStrings::getTemplateStrings()[ |
| 226 |
'private_dining_special_instructions_placeholder' |
| 227 |
], |
| 228 |
'parentId' => null, |
| 229 |
'defaultValue' => '', |
| 230 |
'position' => 8, |
| 231 |
'required' => false, |
| 232 |
'rows' => 4, |
| 233 |
], |
| 234 |
]; |
| 235 |
} |
| 236 |
} |
| 237 |
|