| @@ -126,20 +126,47 @@ | ||
| 126 | 126 | break; |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | + // tell if the booking has been automatically cancelled | |
| 131 | + $autoremove = false; | |
| 132 | + | |
| 133 | + // make sure we are not beyond the check-in date and time | |
| 130 | 134 | $today_midnight = mktime(0, 0, 0, date('n'), date('j'), date('Y')); |
| 131 | - $autoremove = false; | |
| 132 | 135 | if ($today_midnight > $order['checkin']) { |
| 133 | 136 | $roomavail = false; |
| 134 | 137 | } |
| 135 | - $minautoremove = VikBooking::getMinutesAutoRemove(); | |
| 136 | - $mins_elapsed = floor((time() - $order['ts']) / 60); | |
| 137 | - if ($minautoremove > 0 && $mins_elapsed > $minautoremove) { | |
| 138 | - $roomavail = false; | |
| 139 | - $autoremove = true; | |
| 138 | + | |
| 139 | + /** | |
| 140 | + * Check if we are dealing with a pending booking solution of a quote. | |
| 141 | + * | |
| 142 | + * @since 1.18.8 (J) - 1.8.8 (WP) | |
| 143 | + */ | |
| 144 | + $quoteValidUntilDt = null; | |
| 145 | + if (!empty($order['idquote'])) { | |
| 146 | + // load quote record | |
| 147 | + $quoteRecord = VBOMvcModel::getInstance('quote')->getItem((int) $order['idquote']); | |
| 148 | + if (!empty($quoteRecord->valid_until)) { | |
| 149 | + $quoteValidUntilDt = JFactory::getDate($quoteRecord->valid_until); | |
| 150 | + } | |
| 140 | 151 | } |
| 141 | 152 | |
| 153 | + if ($quoteValidUntilDt) { | |
| 154 | + // make sure the quote is still valid | |
| 155 | + if (JFactory::getDate('now') > $quoteValidUntilDt) { | |
| 156 | + $roomavail = false; | |
| 157 | + $autoremove = true; | |
| 158 | + } | |
| 159 | + } else { | |
| 160 | + // check global settings for booking auto-cancellation | |
| 161 | + $minautoremove = VikBooking::getMinutesAutoRemove(); | |
| 162 | + $mins_elapsed = floor((time() - $order['ts']) / 60); | |
| 163 | + if ($minautoremove > 0 && $mins_elapsed > $minautoremove) { | |
| 164 | + $roomavail = false; | |
| 165 | + $autoremove = true; | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 142 | 169 | /** |
| 143 | 170 | * Make sure not to cancel an OTA pending reservation. |
| 144 | 171 | * |
| 145 | 172 | * @since 1.15.4 (J) - 1.5.10 (WP) |
| @@ -413,8 +440,9 @@ | ||
| 413 | 440 | $this->nodep = $nodep; |
| 414 | 441 | $this->upselling = $upselling; |
| 415 | 442 | $this->damage_deposit_payment = $damage_deposit_payment; |
| 416 | 443 | $this->prev_dd_payments = $prev_dd_payments; |
| 444 | + $this->quoteValidUntilDt = $quoteValidUntilDt ?? null; | |
| 417 | 445 | $this->vbo_tn = $vbo_tn; |
| 418 | 446 | |
| 419 | 447 | // theme |
| 420 | 448 | $theme = VikBooking::getTheme(); |