| @@ -755,12 +755,21 @@ | ||
| 755 | 755 | $q->where($dbo->qn('o.custmail') . ' = ' . $dbo->q($filters['email'])); |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | if (($filters['phone'] ?? null)) { |
| 759 | - $q->where(sprintf('REPLACE(%s, \' \', \'\') LIKE REPLACE(%s, \' \', \'\')', | |
| 760 | - $dbo->qn('o.phone'), | |
| 761 | - $dbo->q('%' . $filters['phone']) | |
| 762 | - )); | |
| 759 | + $q->where( | |
| 760 | + sprintf( | |
| 761 | + '(%s OR %s)', | |
| 762 | + sprintf('REPLACE(%s, \' \', \'\') LIKE REPLACE(%s, \' \', \'\')', | |
| 763 | + $dbo->qn('o.phone'), | |
| 764 | + $dbo->q('%' . $filters['phone']) | |
| 765 | + ), | |
| 766 | + sprintf('REPLACE(%s, \' \', \'\') LIKE REPLACE(%s, \' \', \'\')', | |
| 767 | + $dbo->qn('o.phone_alias'), | |
| 768 | + $dbo->q('%' . $filters['phone_alias']) | |
| 769 | + ) | |
| 770 | + ) | |
| 771 | + ); | |
| 763 | 772 | } |
| 764 | 773 | |
| 765 | 774 | if (($filters['date_range']['type'] ?? null) && (($filters['date_range']['start'] ?? null) || ($filters['date_range']['end'] ?? null))) { |
| 766 | 775 | // search by date range |
| @@ -1108,8 +1117,46 @@ | ||
| 1108 | 1117 | return (bool) $dbo->getAffectedRows(); |
| 1109 | 1118 | } |
| 1110 | 1119 | |
| 1111 | 1120 | /** |
| 1121 | + * Updates the booking-level phone number or alias phone number (masked phone). | |
| 1122 | + * | |
| 1123 | + * @param ?string $phone The phone number value to set, even null to unset. | |
| 1124 | + * @param bool $isAlias Whether to update the real or alias phone number. | |
| 1125 | + * @param ?int $bookingId Optional booking ID to update. | |
| 1126 | + * | |
| 1127 | + * @return bool | |
| 1128 | + * | |
| 1129 | + * @throws Exception | |
| 1130 | + * | |
| 1131 | + * @since 1.18.16 (J) - 1.8.16 (WP) | |
| 1132 | + */ | |
| 1133 | + public function updatePhoneNumber(?string $phone, bool $isAlias = false, ?int $bookingId = null) | |
| 1134 | + { | |
| 1135 | + $dbo = JFactory::getDbo(); | |
| 1136 | + | |
| 1137 | + if (!$bookingId) { | |
| 1138 | + // get the internal booking record | |
| 1139 | + $booking = $this->getBooking(); | |
| 1140 | + $bookingId = $booking['id'] ?? null; | |
| 1141 | + } | |
| 1142 | + | |
| 1143 | + if (empty($bookingId)) { | |
| 1144 | + throw new Exception('Missing booking ID.', 400); | |
| 1145 | + } | |
| 1146 | + | |
| 1147 | + $dbo->setQuery( | |
| 1148 | + $dbo->getQuery(true) | |
| 1149 | + ->update('#__vikbooking_orders') | |
| 1150 | + ->set($dbo->qn($isAlias ? 'phone_alias' : 'phone') . ' = ' . ($phone ? $dbo->q($phone) : 'NULL')) | |
| 1151 | + ->where($dbo->qn('id') . ' = ' . (int) $bookingId) | |
| 1152 | + ); | |
| 1153 | + $dbo->execute(); | |
| 1154 | + | |
| 1155 | + return (bool) $dbo->getAffectedRows(); | |
| 1156 | + } | |
| 1157 | + | |
| 1158 | + /** | |
| 1112 | 1159 | * Modifies the requested booking ID according to the provided options. |
| 1113 | 1160 | * This method does not support all rate plan options like for the creation of a |
| 1114 | 1161 | * new booking. This is a method for making quick updates concerning a room switch, |
| 1115 | 1162 | * a change of stay dates, new booking total amount, guests, add extra services etc.. |
| @@ -3368,8 +3415,9 @@ | ||
| 3368 | 3415 | $customer_data = ($inj_customer['data'] ?? null) ?: ''; |
| 3369 | 3416 | $customer_email = ($inj_customer['email'] ?? null) ?: ''; |
| 3370 | 3417 | $country_code = ($inj_customer['country'] ?? null) ?: ''; |
| 3371 | 3418 | $phone_number = ($inj_customer['phone'] ?? null) ?: ''; |
| 3419 | + $phone_alias = ($inj_customer['phone_alias'] ?? null) ?: ''; | |
| 3372 | 3420 | $address = ($inj_customer['address'] ?? null) ?: ''; |
| 3373 | 3421 | $city = ($inj_customer['city'] ?? null) ?: ''; |
| 3374 | 3422 | $zip = ($inj_customer['zip'] ?? null) ?: ''; |
| 3375 | 3423 | |
| @@ -3396,8 +3444,10 @@ | ||
| 3396 | 3444 | $customer_data .= "eMail: {$customer_email}\n"; |
| 3397 | 3445 | } |
| 3398 | 3446 | if ($phone_number) { |
| 3399 | 3447 | $customer_data .= "Phone: {$phone_number}\n"; |
| 3448 | + } elseif ($phone_alias) { | |
| 3449 | + $customer_data .= "Phone-alias: {$phone_alias}\n"; | |
| 3400 | 3450 | } |
| 3401 | 3451 | if ($country_code) { |
| 3402 | 3452 | $customer_data .= "Country: {$country_code}\n"; |
| 3403 | 3453 | } |
| @@ -3519,8 +3569,9 @@ | ||
| 3519 | 3569 | $booking->tot_city_taxes = $set_city_tax ?: ($this->get('tot_city_taxes') ? ((float) $this->get('tot_city_taxes')) : null); |
| 3520 | 3570 | $booking->tot_fees = $set_fees ?: ($this->get('tot_fees') ? ((float) $this->get('tot_fees')) : null); |
| 3521 | 3571 | $booking->tot_damage_dep = $this->get('tot_damage_dep') ? ((float) $this->get('tot_damage_dep')) : null; |
| 3522 | 3572 | $booking->phone = $phone_number; |
| 3573 | + $booking->phone_alias = $phone_alias ?: null; | |
| 3523 | 3574 | $booking->cmms = $this->get('cmms') ? ((float) $this->get('cmms')) : null; |
| 3524 | 3575 | $booking->closure = ($status == 'standby' ? 0 : ($set_closed || $units_closed ? 1 : 0)); |
| 3525 | 3576 | $booking->payable = $this->get('payable') ? ((float) $this->get('payable')) : null; |
| 3526 | 3577 | $booking->refund = $this->get('refund') ? ((float) $this->get('refund')) : null; |