PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 All 36 releases
vikbooking / admin / helpers / src / checkin / paxfield.php

paxfield.php in VikBooking Hotel Booking Engine & PMS trunk, at admin/helpers/src/checkin/paxfield.php

304 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage core
5 * @author Alessio Gaggii - E4J s.r.l.
6 * @copyright Copyright (C) 2022 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Defines a registry container for the pax field object to parse.
16 *
17 * @since 1.15.0 (J) - 1.5.0 (WP)
18 */
19 class VBOCheckinPaxfield extends JObject
20 {
21 /**
22 * Gets the current field number.
23 *
24 * @return int the field number.
25 */
26 public function getFieldNumber()
27 {
28 return $this->get('field_number', 1);
29 }
30
31 /**
32 * Sets the current field number.
33 *
34 * @param int $num the field number starting from 1.
35 *
36 * @return self
37 */
38 public function setFieldNumber($num = 1)
39 {
40 $this->set('field_number', $num);
41
42 return $this;
43 }
44
45 /**
46 * Gets the current type of guest.
47 *
48 * @return string either "adult" or "child".
49 */
50 public function getGuestType()
51 {
52 return $this->get('guest_type', 'adult');
53 }
54
55 /**
56 * Sets the current type of guest.
57 *
58 * @param string $type either "adult" or "child".
59 *
60 * @return self
61 */
62 public function setGuestType($type = 'adult')
63 {
64 // either "adult" or "child", no surprises
65 $type = $type == 'child' ? 'child' : 'adult';
66
67 $this->set('guest_type', $type);
68
69 return $this;
70 }
71
72 /**
73 * Gets the current guest number.
74 *
75 * @return int the guest number.
76 */
77 public function getGuestNumber()
78 {
79 return $this->get('guest_number', 1);
80 }
81
82 /**
83 * Sets the current guest number.
84 *
85 * @param int $num the guest number starting from 1.
86 *
87 * @return self
88 */
89 public function setGuestNumber($num = 1)
90 {
91 $this->set('guest_number', $num);
92
93 return $this;
94 }
95
96 /**
97 * Gets the current guest data.
98 *
99 * @return mixed the guest data.
100 */
101 public function getGuestData()
102 {
103 return $this->get('guest_data');
104 }
105
106 /**
107 * Sets the current guest data.
108 *
109 * @param mixed $data the guest data.
110 *
111 * @return self
112 */
113 public function setGuestData($data = null)
114 {
115 $this->set('guest_data', $data);
116
117 return $this;
118 }
119
120 /**
121 * Gets the current room index.
122 *
123 * @return int the room index.
124 */
125 public function getRoomIndex()
126 {
127 return $this->get('room_index', 0);
128 }
129
130 /**
131 * Sets the current room index.
132 *
133 * @param int $num the room index starting from 0.
134 *
135 * @return self
136 */
137 public function setRoomIndex($num = 0)
138 {
139 $this->set('room_index', $num);
140
141 return $this;
142 }
143
144 /**
145 * Gets the number of guests for the current room index.
146 *
147 * @param int $adults the number of adults in the current room.
148 * @param int $children the number of children in the current room.
149 *
150 * @return array the respective number of adults and children.
151 */
152 public function getRoomGuests()
153 {
154 $adults = $this->get('room_guests_adults', 0);
155 $children = $this->get('room_guests_children', 0);
156
157 return [$adults, $children];
158 }
159
160 /**
161 * Sets the number of guests for the current room index.
162 *
163 * @param int $adults the number of adults in the current room.
164 * @param int $children the number of children in the current room.
165 *
166 * @return self
167 */
168 public function setRoomGuests($adults = 0, $children = 0)
169 {
170 $this->set('room_guests_adults', (int)$adults);
171 $this->set('room_guests_children', (int)$children);
172
173 return $this;
174 }
175
176 /**
177 * Gets the total number of rooms.
178 *
179 * @return int the total number of rooms.
180 */
181 public function getTotalRooms()
182 {
183 return $this->get('total_rooms', 1);
184 }
185
186 /**
187 * Sets the total number of rooms.
188 *
189 * @param int $num the total number of rooms.
190 *
191 * @return self
192 */
193 public function setTotalRooms($num = 1)
194 {
195 $this->set('total_rooms', $num);
196
197 return $this;
198 }
199
200 /**
201 * Gets the key identifier of the current field.
202 *
203 * @return string the key of the current field.
204 */
205 public function getKey()
206 {
207 return $this->get('key');
208 }
209
210 /**
211 * Sets the key identifier of the current field.
212 *
213 * @param string $key the key identifier.
214 *
215 * @return self
216 */
217 public function setKey($key)
218 {
219 $this->set('key', $key);
220
221 return $this;
222 }
223
224 /**
225 * Gets the current field type attribute value.
226 *
227 * @return string|array the type of field identifier.
228 */
229 public function getType()
230 {
231 return $this->get('type', null);
232 }
233
234 /**
235 * Sets the current field type attribute.
236 *
237 * @param string|array $type the type of field identifier.
238 *
239 * @return self
240 */
241 public function setType($type)
242 {
243 $this->set('type', $type);
244
245 return $this;
246 }
247
248 /**
249 * Gets the current booking record involved.
250 *
251 * @return array The booking record involved.
252 *
253 * @since 1.17.4 (J) - 1.7.4 (WP)
254 */
255 public function getBooking()
256 {
257 return (array) $this->get('booking', []);
258 }
259
260 /**
261 * Sets the current booking record involved.
262 *
263 * @param array $booking The booking record involved.
264 *
265 * @return self
266 *
267 * @since 1.17.4 (J) - 1.7.4 (WP)
268 */
269 public function setBooking(array $booking)
270 {
271 $this->set('booking', $booking);
272
273 return $this;
274 }
275
276 /**
277 * Gets the current booking rooms involved.
278 *
279 * @return array The booking rooms involved.
280 *
281 * @since 1.17.4 (J) - 1.7.4 (WP)
282 */
283 public function getBookingRooms()
284 {
285 return (array) $this->get('booking_rooms', []);
286 }
287
288 /**
289 * Sets the current booking rooms involved.
290 *
291 * @param array $booking_rooms The booking rooms involved.
292 *
293 * @return self
294 *
295 * @since 1.17.4 (J) - 1.7.4 (WP)
296 */
297 public function setBookingRooms(array $booking_rooms)
298 {
299 $this->set('booking_rooms', $booking_rooms);
300
301 return $this;
302 }
303 }
304