| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage core |
| 5 |
* @author E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2026 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 |
* Obtain vars from arguments received in the layout file. |
| 16 |
* |
| 17 |
* @var int $booking_id The reservation ID. |
| 18 |
* @var VBOBookingSubunitMoveset $moveset The relocation moveset registry. |
| 19 |
* @var array $options The relocation options. |
| 20 |
*/ |
| 21 |
extract($displayData); |
| 22 |
|
| 23 |
// access VBO application |
| 24 |
$vbo_app = VikBooking::getVboApplication(); |
| 25 |
|
| 26 |
// get full booking details (booking registry object) |
| 27 |
$booking = $moveset->getBooking(); |
| 28 |
|
| 29 |
// get the room booking record to relocate |
| 30 |
$relocatingRecord = $moveset->getRelocatingRecord(); |
| 31 |
|
| 32 |
// make sure to set the proper room record index |
| 33 |
$booking->setCurrentRoomIndex($relocatingRecord->getRecordIndex()); |
| 34 |
|
| 35 |
// access room details |
| 36 |
$roomDetails = $booking->getRoomDetails($booking->getCurrentRoomID()); |
| 37 |
|
| 38 |
// access room "features" |
| 39 |
$roomFeatures = VikBooking::getRoomParam('features', $roomDetails['params'] ?? '', []); |
| 40 |
$roomFeaturesMap = []; |
| 41 |
foreach ((array) $roomFeatures as $rind => $rfeatures) { |
| 42 |
foreach ($rfeatures as $fname => $fval) { |
| 43 |
if (strlen((string) $fval)) { |
| 44 |
// map first non-empty feature value for the current room index |
| 45 |
$roomFeaturesMap[$rind] = $fval; |
| 46 |
break; |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
// access relocating booking-customer details |
| 52 |
list($customer_nominative, $booking_avatar_src, $booking_avatar_alt) = $booking->getBookingCustomerData(); |
| 53 |
|
| 54 |
// access room-level stay timestamps for the relocating record |
| 55 |
list($stayFromTs, $stayToTs) = $booking->getStayTimestamps(true); |
| 56 |
$stayFromInfo = getdate($stayFromTs); |
| 57 |
$stayToInfo = getdate($stayToTs); |
| 58 |
|
| 59 |
// build stay dates string |
| 60 |
$stayFromParts = [ |
| 61 |
date('d', $stayFromTs), |
| 62 |
VikBooking::sayMonth($stayFromInfo['mon'], true), |
| 63 |
]; |
| 64 |
$stayToParts = [ |
| 65 |
date('d', $stayToTs), |
| 66 |
VikBooking::sayMonth($stayToInfo['mon'], true), |
| 67 |
]; |
| 68 |
if ($stayFromInfo['year'] != $stayToInfo['year']) { |
| 69 |
// push year on both parts |
| 70 |
$stayFromParts[] = date('y', $stayFromTs); |
| 71 |
$stayToParts[] = date('y', $stayToTs); |
| 72 |
} |
| 73 |
$stayDatesStr = sprintf('%s - %s', implode(' ', $stayFromParts), implode(' ', $stayToParts)); |
| 74 |
?> |
| 75 |
<div class="vbo-room-reassignment-solution-wrap" data-signature="<?php echo JHtml::fetch('esc_attr', $moveset->getSignature()); ?>"> |
| 76 |
<h4><?php echo JText::translate('VBO_REASSIGNMENT_SOLUTION'); ?></h4> |
| 77 |
<div class="vbo-room-reassignment-moves-help"> |
| 78 |
<span><?php echo JText::sprintf('VBO_REASSIGNMENT_MATRIX_DETAILS', number_format($moveset->getIterationNumber(), 0, ',', '.'), number_format($moveset->getTotalMoves(), 0, ',', '.')); ?></span> |
| 79 |
</div> |
| 80 |
<div class="vbo-room-reassignment-head"> |
| 81 |
<div class="vbo-room-reassignment-move-record"> |
| 82 |
<div class="vbo-room-reassignment-booking"> |
| 83 |
<div class="vbo-room-reassignment-booking-guest"> |
| 84 |
<?php |
| 85 |
if (!empty($booking_avatar_src)) { |
| 86 |
?> |
| 87 |
<span class="vbo-booking-guest-avatar"><img src="<?php echo $booking_avatar_src; ?>" class="vbo-tableaux-booking-avatar-img" decoding="async" loading="lazy" <?php echo (!empty($booking_avatar_alt) ? 'alt="' . htmlspecialchars($booking_avatar_alt) . '" ' : ''); ?>/></span> |
| 88 |
<?php |
| 89 |
} |
| 90 |
?> |
| 91 |
<span class="vbo-booking-guest-name"><?php echo $customer_nominative; ?></span> |
| 92 |
<span class="badge badge-info vbo-booking-guest-id"><?php echo $booking->getID(); ?></span> |
| 93 |
</div> |
| 94 |
<div class="vbo-room-reassignment-booking-info"> |
| 95 |
<span class="vbo-booking-info-party"><?php VikBookingIcons::e('users'); ?> <span><?php echo $booking->countTotalAdults() . ($booking->countTotalChildren() ? ' + ' . $booking->countTotalChildren() : ''); ?></span></span> |
| 96 |
<span class="vbo-booking-info-nights"><?php VikBookingIcons::e('moon'); ?> <span><?php echo $booking->getTotalNights(); ?></span></span> |
| 97 |
<span class="vbo-booking-info-dates"><?php VikBookingIcons::e('calendar'); ?> <span><?php echo $stayDatesStr; ?></span></span> |
| 98 |
</div> |
| 99 |
</div> |
| 100 |
<div class="vbo-room-reassignment-move"> |
| 101 |
<div class="vbo-room-reassignment-move-details"> |
| 102 |
<span class="label label-info vbo-room-reassignment-move-room"><?php VikBookingIcons::e('bed'); ?> <?php echo $roomDetails['name'] ?? ''; ?></span> |
| 103 |
<span class="label label-warning vbo-room-reassignment-move-from"><?php echo JText::translate('VBO_MISSING_SUBUNIT'); ?></span> |
| 104 |
<span class="vbo-room-reassignment-move-icn"><?php VikBookingIcons::e('chevron-right'); ?></span> |
| 105 |
<span class="label vbo-room-reassignment-move-to"><?php echo '#' . $relocatingRecord->getRoomUnitIndex() . (($roomFeaturesMap[$relocatingRecord->getRoomUnitIndex()] ?? null) ? ' - ' . $roomFeaturesMap[$relocatingRecord->getRoomUnitIndex()] : ''); ?></span> |
| 106 |
</div> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
</div> |
| 110 |
<div class="vbo-room-reassignment-moves"> |
| 111 |
<h5><?php VikBookingIcons::e('random'); ?> <?php echo JText::translate('VBO_NECESSARY_MOVES'); ?></h5> |
| 112 |
<div class="vbo-room-reassignment-moves-help"> |
| 113 |
<span><?php echo JText::translate('VBO_REASSIGNMENT_NO_STAY_CHANGES'); ?></span> |
| 114 |
</div> |
| 115 |
<div class="vbo-room-reassignment-moves-list"> |
| 116 |
<?php |
| 117 |
foreach ($moveset->getRawMoveset() as $movesetNum => $roomRecord) { |
| 118 |
if ($roomRecord->isRelocating()) { |
| 119 |
// do not display the relocating room booking record again |
| 120 |
continue; |
| 121 |
} |
| 122 |
|
| 123 |
// access current and initial room unit index |
| 124 |
$currentRoomUnitIndex = $roomRecord->getRoomUnitIndex(); |
| 125 |
$initialRoomUnitIndex = $roomRecord->getInitialRoomUnitIndex(); |
| 126 |
|
| 127 |
if (!$currentRoomUnitIndex || $currentRoomUnitIndex == $initialRoomUnitIndex) { |
| 128 |
// do not display a room booking that will not move |
| 129 |
continue; |
| 130 |
} |
| 131 |
|
| 132 |
// wrap the room booking record into a registry |
| 133 |
$roomBookingRegistry = VBOBookingRegistry::getInstance(['id' => $roomRecord->getBookingID()]); |
| 134 |
|
| 135 |
// make sure to set the proper room record index |
| 136 |
$roomBookingRegistry->setCurrentRoomIndex($roomRecord->getRecordIndex()); |
| 137 |
|
| 138 |
// access room booking customer details |
| 139 |
list($customer_nominative, $booking_avatar_src, $booking_avatar_alt) = $roomBookingRegistry->getBookingCustomerData(); |
| 140 |
|
| 141 |
// access room-level stay timestamps for the relocating record |
| 142 |
list($stayFromTs, $stayToTs) = $roomBookingRegistry->getStayTimestamps(true); |
| 143 |
$stayFromInfo = getdate($stayFromTs); |
| 144 |
$stayToInfo = getdate($stayToTs); |
| 145 |
|
| 146 |
// build stay dates string |
| 147 |
$stayFromParts = [ |
| 148 |
date('d', $stayFromTs), |
| 149 |
VikBooking::sayMonth($stayFromInfo['mon'], true), |
| 150 |
]; |
| 151 |
$stayToParts = [ |
| 152 |
date('d', $stayToTs), |
| 153 |
VikBooking::sayMonth($stayToInfo['mon'], true), |
| 154 |
]; |
| 155 |
if ($stayFromInfo['year'] != $stayToInfo['year']) { |
| 156 |
// push year on both parts |
| 157 |
$stayFromParts[] = date('y', $stayFromTs); |
| 158 |
$stayToParts[] = date('y', $stayToTs); |
| 159 |
} |
| 160 |
$stayDatesStr = sprintf('%s - %s', implode(' ', $stayFromParts), implode(' ', $stayToParts)); |
| 161 |
?> |
| 162 |
<div class="vbo-room-reassignment-move-record"> |
| 163 |
<div class="vbo-room-reassignment-booking"> |
| 164 |
<div class="vbo-room-reassignment-booking-guest"> |
| 165 |
<?php |
| 166 |
if (!empty($booking_avatar_src)) { |
| 167 |
?> |
| 168 |
<span class="vbo-booking-guest-avatar"><img src="<?php echo $booking_avatar_src; ?>" class="vbo-tableaux-booking-avatar-img" decoding="async" loading="lazy" <?php echo (!empty($booking_avatar_alt) ? 'alt="' . htmlspecialchars($booking_avatar_alt) . '" ' : ''); ?>/></span> |
| 169 |
<?php |
| 170 |
} |
| 171 |
?> |
| 172 |
<span class="vbo-booking-guest-name"><?php echo $customer_nominative; ?></span> |
| 173 |
<span class="badge badge-info vbo-booking-guest-id"><?php echo $roomBookingRegistry->getID(); ?></span> |
| 174 |
</div> |
| 175 |
<div class="vbo-room-reassignment-booking-info"> |
| 176 |
<span class="vbo-booking-info-party"><?php VikBookingIcons::e('users'); ?> <span><?php echo $roomBookingRegistry->countTotalAdults() . ($roomBookingRegistry->countTotalChildren() ? ' + ' . $roomBookingRegistry->countTotalChildren() : ''); ?></span></span> |
| 177 |
<span class="vbo-booking-info-nights"><?php VikBookingIcons::e('moon'); ?> <span><?php echo $roomBookingRegistry->getTotalNights(); ?></span></span> |
| 178 |
<span class="vbo-booking-info-dates"><?php VikBookingIcons::e('calendar'); ?> <span><?php echo $stayDatesStr; ?></span></span> |
| 179 |
</div> |
| 180 |
</div> |
| 181 |
<div class="vbo-room-reassignment-move"> |
| 182 |
<div class="vbo-room-reassignment-move-details"> |
| 183 |
<span class="label vbo-room-reassignment-move-from"><?php |
| 184 |
if ($initialRoomUnitIndex) { |
| 185 |
echo '#' . $initialRoomUnitIndex . (($roomFeaturesMap[$initialRoomUnitIndex] ?? null) ? ' - ' . $roomFeaturesMap[$initialRoomUnitIndex] : ''); |
| 186 |
} else { |
| 187 |
echo JText::translate('VBO_MISSING_SUBUNIT'); |
| 188 |
} |
| 189 |
?></span> |
| 190 |
<span class="vbo-room-reassignment-move-icn"><?php VikBookingIcons::e('chevron-right'); ?></span> |
| 191 |
<span class="label vbo-room-reassignment-move-to"><?php echo '#' . $currentRoomUnitIndex . (($roomFeaturesMap[$currentRoomUnitIndex] ?? null) ? ' - ' . $roomFeaturesMap[$currentRoomUnitIndex] : ''); ?></span> |
| 192 |
</div> |
| 193 |
<div class="vbo-room-reassignment-move-exclude" data-booking-id="<?php echo $roomBookingRegistry->getID(); ?>"> |
| 194 |
<span class="vbo-room-reassignment-exclude-lbl"><?php echo JText::translate('VBO_NEXT_SOLUTION'); ?></span> |
| 195 |
<span |
| 196 |
class="vbo-toggle-mini vbo-toggle-double-status vbo-tooltip vbo-tooltip-top" |
| 197 |
data-tooltiptext="<?php echo JHtml::fetch('esc_attr', JText::translate('VBO_INCLUDED')); ?>" |
| 198 |
data-text-enabled="<?php echo JHtml::fetch('esc_attr', JText::translate('VBO_INCLUDED')); ?>" |
| 199 |
data-text-disabled="<?php echo JHtml::fetch('esc_attr', JText::translate('VBO_EXCLUDED')); ?>" |
| 200 |
><?php echo $vbo_app->printYesNoButtons('skip_booking_id' . $movesetNum, JText::translate('VBYES'), JText::translate('VBNO'), 0, 1, 0, '', ['red']); ?></span> |
| 201 |
</div> |
| 202 |
</div> |
| 203 |
</div> |
| 204 |
<?php |
| 205 |
} |
| 206 |
?> |
| 207 |
</div> |
| 208 |
</div> |
| 209 |
</div> |
| 210 |
|