| @@ -58,8 +58,67 @@ | ||
| 58 | 58 | return $paxf_obj->listFields(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | + * Retrieves the list of pre-checkin pax fields for an extended collection type. | |
| 63 | + * | |
| 64 | + * @param string $type the pax data type representing the class. | |
| 65 | + * @param array $def_fields list of default pre-checkin labels and attributes. | |
| 66 | + * | |
| 67 | + * @return array the list of pax fields to collect in the front-end during pre-checkin. | |
| 68 | + * | |
| 69 | + * @since 1.17.2 (J) - 1.7.2 (WP) | |
| 70 | + */ | |
| 71 | + public static function getPrecheckinFields(string $type = '', array $def_fields = []) | |
| 72 | + { | |
| 73 | + // default empty containers | |
| 74 | + $labels = []; | |
| 75 | + $attributes = []; | |
| 76 | + | |
| 77 | + if (empty($type)) { | |
| 78 | + return [$labels, $attributes]; | |
| 79 | + } | |
| 80 | + | |
| 81 | + // invoke custom pax fields object | |
| 82 | + $paxf_obj = self::getInstance($type); | |
| 83 | + if (!$paxf_obj) { | |
| 84 | + return [$labels, $attributes]; | |
| 85 | + } | |
| 86 | + | |
| 87 | + return $paxf_obj->listPrecheckinFields($def_fields); | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * Invokes a callback on the pax data type driver after the pre-checkin information have been stored or updated. | |
| 92 | + * | |
| 93 | + * @param string $type the pax data type representing the driver. | |
| 94 | + * @param array $data the guest registration data stored. | |
| 95 | + * @param array $booking the booking record involved with the guests registration. | |
| 96 | + * @param array $customer optional customer record associated with the booking. | |
| 97 | + * | |
| 98 | + * @return void | |
| 99 | + * | |
| 100 | + * @since 1.17.5 (J) - 1.7.5 (WP) | |
| 101 | + */ | |
| 102 | + public static function callbackPrecheckinDataStored(string $type, array $data, array $booking, array $customer = []) | |
| 103 | + { | |
| 104 | + if (!$type) { | |
| 105 | + // no driver to invoke | |
| 106 | + return; | |
| 107 | + } | |
| 108 | + | |
| 109 | + // invoke custom pax fields object | |
| 110 | + $paxf_obj = self::getInstance($type); | |
| 111 | + if (!$paxf_obj) { | |
| 112 | + // requested driver not found | |
| 113 | + return; | |
| 114 | + } | |
| 115 | + | |
| 116 | + // let the driver finalize the operation | |
| 117 | + return $paxf_obj->onPrecheckinDataStored($data, $booking, $customer); | |
| 118 | + } | |
| 119 | + | |
| 120 | + /** | |
| 62 | 121 | * Returns the instance of the custom pax data collection type object. |
| 63 | 122 | * |
| 64 | 123 | * @param string $type the pax data type representing the class. |
| 65 | 124 | * |
| @@ -230,23 +289,21 @@ | ||
| 230 | 289 | $dbo = JFactory::getDbo(); |
| 231 | 290 | |
| 232 | 291 | $q = "SELECT `idcustomer` FROM `#__vikbooking_customers_orders` WHERE `idorder`=" . (int)$bid; |
| 233 | 292 | $dbo->setQuery($q, 0, 1); |
| 234 | - $dbo->execute(); | |
| 235 | - if (!$dbo->getNumRows()) { | |
| 293 | + $id_customer = $dbo->loadResult(); | |
| 294 | + if (!$id_customer) { | |
| 236 | 295 | return []; |
| 237 | 296 | } |
| 238 | - $id_customer = $dbo->loadResult(); | |
| 239 | 297 | |
| 240 | 298 | $q = "SELECT `co`.`idorder`, `co`.`pax_data`, `o`.`ts`, `o`.`checkin`, `o`.`checkout` FROM `#__vikbooking_customers_orders` AS `co` |
| 241 | 299 | LEFT JOIN `#__vikbooking_orders` AS `o` ON `co`.`idorder`=`o`.`id` |
| 242 | 300 | WHERE `co`.`idcustomer`=" . (int)$id_customer . " AND `co`.`idorder` != " . (int)$bid . " AND `co`.`pax_data` IS NOT NULL ORDER BY `co`.`idorder` DESC"; |
| 243 | 301 | $dbo->setQuery($q, 0, $lim); |
| 244 | - $dbo->execute(); | |
| 245 | - if (!$dbo->getNumRows()) { | |
| 302 | + $prev_records = $dbo->loadAssocList(); | |
| 303 | + if (!$prev_records) { | |
| 246 | 304 | return []; |
| 247 | 305 | } |
| 248 | - $prev_records = $dbo->loadAssocList(); | |
| 249 | 306 | |
| 250 | 307 | foreach ($prev_records as $k => $v) { |
| 251 | 308 | // attempt to decode checkin data |
| 252 | 309 | $pax_data = json_decode($v['pax_data'], true); |