Merge branch 'develop' into gli-3104
This commit is contained in:
@@ -79,6 +79,31 @@ class HotelAdvancedPayment extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the advance payment configuration of a room type for its duplicate
|
||||
*
|
||||
* @param int $id_product_old Id of the room type (product) being duplicated
|
||||
* @param int $id_product_new Id of the newly duplicated room type (product)
|
||||
* @return bool
|
||||
*/
|
||||
public static function duplicateAdvancePayment($id_product_old, $id_product_new)
|
||||
{
|
||||
$row = Db::getInstance()->getRow(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_advance_payment` WHERE `id_product` = '.(int)$id_product_old
|
||||
);
|
||||
|
||||
if (!$row) {
|
||||
return true;
|
||||
}
|
||||
|
||||
unset($row['id']);
|
||||
$row['id_product'] = (int)$id_product_new;
|
||||
$row['date_add'] = date('Y-m-d H:i:s');
|
||||
$row['date_upd'] = date('Y-m-d H:i:s');
|
||||
|
||||
return Db::getInstance()->insert('htl_advance_payment', $row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the advance payment amount of the room type in the cart
|
||||
* @param [int] $idCart : cart id
|
||||
|
||||
@@ -604,7 +604,7 @@ class HotelBookingDetail extends ObjectModel
|
||||
$sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment`, hri.`id_status`, hrdd.`date_from` AS `date_from`, hrdd.`date_to` AS `date_to`
|
||||
FROM `'._DB_PREFIX_.'htl_room_information` AS hri
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd. id_room = hri.`id`)
|
||||
WHERE hri.`id_hotel`='.$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND (
|
||||
WHERE hri.`id_hotel`='.(int) $idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND (
|
||||
(hrdd.`date_from` <= \''.pSQL($dateFrom).'\' AND hrdd.`date_to` > \''.pSQL($dateFrom).'\' AND hrdd.`date_to` <= \''.pSQL($dateTo).'\') OR
|
||||
(hrdd.`date_from` >= \''.pSQL($dateFrom).'\' AND hrdd.`date_to` > \''.pSQL($dateFrom).'\' AND hrdd.`date_to` <= \''.pSQL($dateTo).'\') OR
|
||||
(hrdd.`date_from` >= \''.pSQL($dateFrom).'\' AND hrdd.`date_from` < \''.pSQL($dateTo).'\' AND hrdd.`date_to` >= \''.pSQL($dateTo).'\') OR
|
||||
|
||||
@@ -30,6 +30,9 @@ class HotelBookingDocument extends ObjectModel
|
||||
public $file_name;
|
||||
public $date_add;
|
||||
|
||||
/** @var bool True when the file is a PDF but was rejected for unsafe content. */
|
||||
public $isUnsafePdf = false;
|
||||
|
||||
const FILE_TYPE_IMAGE = 1;
|
||||
const FILE_TYPE_PDF = 2;
|
||||
|
||||
@@ -139,16 +142,28 @@ class HotelBookingDocument extends ObjectModel
|
||||
public function setFileType()
|
||||
{
|
||||
$content = @file_get_contents($this->fileInfo['tmp_name']);
|
||||
$activeContentPattern = '/\/(JavaScript|JS|OpenAction|AA|Launch|SubmitForm|ImportData)\b/i';
|
||||
|
||||
// PDF names can hide keywords with hex escapes (/J#53 is /JS), so decode them before matching.
|
||||
$decodedContent = ($content === false) ? '' : preg_replace_callback('/#([0-9a-f]{2})/i', function ($match) {
|
||||
return chr(hexdec($match[1]));
|
||||
}, $content);
|
||||
|
||||
// A complete PDF ends with startxref <offset> %%EOF; anything else is truncated or corrupt.
|
||||
// Encrypted PDFs cannot be scanned, so /Encrypt is blocked too.
|
||||
// /OpenAction followed by '[' is a plain page destination (zoom/fit).
|
||||
// for every generated PDF. Any other /OpenAction value is an action and stays blocked.
|
||||
$activeContentPattern = '/\/(JavaScript|JS|AA|Launch|SubmitForm|ImportData|GoToR|GoToE|EmbeddedFile|RichMedia|XFA|Encrypt)\b|\/OpenAction\b(?!\s*\[)/i';
|
||||
|
||||
$this->isUnsafePdf = false;
|
||||
$this->imageInfo = @getimagesize($this->fileInfo['tmp_name']);
|
||||
|
||||
if ($this->imageInfo && ImageManager::isRealImage($this->fileInfo['tmp_name'])) {
|
||||
$this->file_type = self::FILE_TYPE_IMAGE;
|
||||
} elseif ($content !== false && substr($content, 0, 5) === '%PDF-' && !preg_match($activeContentPattern, $content)) {
|
||||
} elseif ($content !== false && substr($content, 0, 5) === '%PDF-' && preg_match('/startxref\s+\d+\s+%%EOF\s*$/', substr($content, -1024)) && !preg_match($activeContentPattern, $decodedContent)) {
|
||||
$this->file_type = self::FILE_TYPE_PDF;
|
||||
} else {
|
||||
$this->file_type = 0;
|
||||
$this->isUnsafePdf = ($content !== false && substr($content, 0, 5) === '%PDF-');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -385,17 +385,20 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$numNights = max(1, (int) HotelHelper::getNumberOfDays($date_from, $date_to));
|
||||
$unitPriceTe = (float) $totalPrice['total_price_tax_excl'] / $numNights;
|
||||
$taxCalculator = TaxManagerFactory::getManager($objAddress, $idTourismTaxRulesGroup)->getTaxCalculator();
|
||||
$childAges = !empty($occupancy[0]['child_ages']) ? (array) $occupancy[0]['child_ages'] : array();
|
||||
$totalPrice['total_price_tax_incl'] += $taxCalculator->getTaxesTotalAmount(
|
||||
$unitPriceTe,
|
||||
$date_from,
|
||||
$numNights,
|
||||
$occupancy[0]['adults'],
|
||||
$childAges,
|
||||
$collectionType,
|
||||
1,
|
||||
$id_currency
|
||||
);
|
||||
$roomsTourismTax = 0;
|
||||
foreach ($occupancy as $roomOccupancy) {
|
||||
$roomsTourismTax += $taxCalculator->getTaxesTotalAmount(
|
||||
$unitPriceTe,
|
||||
$date_from,
|
||||
$numNights,
|
||||
isset($roomOccupancy['adults']) ? (int) $roomOccupancy['adults'] : 0,
|
||||
!empty($roomOccupancy['child_ages']) ? (array) $roomOccupancy['child_ages'] : array(),
|
||||
$collectionType,
|
||||
1,
|
||||
$id_currency
|
||||
);
|
||||
}
|
||||
$totalPrice['total_price_tax_incl'] += $roomsTourismTax / count($occupancy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ class ServiceProductCartDetail extends ObjectModel
|
||||
$language = new Language($idLang);
|
||||
}
|
||||
|
||||
$sql = 'SELECT spc.*, p.`selling_preference_type`, hcbd.`date_from`, spc.`id_cart` as service_id_cart, hcbd.`date_to`, p.`price_calculation_method`, hcbd.`id_product` as `id_product_room_type`';
|
||||
$sql = 'SELECT spc.*, p.`selling_preference_type`, hcbd.`date_from`, spc.`id_cart` as service_id_cart, hcbd.`date_to`, p.`price_calculation_method`, hcbd.`id_product` as `id_product_room_type`, hcbd.`id_hotel` as `id_room_type_hotel`';
|
||||
if (!$getTotalPrice) {
|
||||
$sql .= ', hbil.`hotel_name`, p.`auto_add_to_cart`, p.`price_addition_type` ';
|
||||
}
|
||||
|
||||
@@ -134,13 +134,16 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
$date_from = date('Y-m-d');
|
||||
}
|
||||
}
|
||||
if (Tools::getValue('date_to')) {
|
||||
$date_to = Tools::getValue('date_to');
|
||||
} else {
|
||||
if (!Validate::isDate($date_from)) {
|
||||
$date_from = date('Y-m-d');
|
||||
}
|
||||
$date_to = Tools::getValue('date_to');
|
||||
if (!$date_to || !Validate::isDate($date_to)) {
|
||||
$date_to = date('Y-m-d');
|
||||
if (strtotime($date_from) >= strtotime($date_to)) {
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_to)));
|
||||
}
|
||||
}
|
||||
// Check-out date must always be after check-in date
|
||||
if (strtotime($date_from) >= strtotime($date_to)) {
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_from)));
|
||||
}
|
||||
|
||||
if (Tools::getValue('id_hotel')) {
|
||||
|
||||
@@ -510,33 +510,23 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$idOrderDetail = $objHtlBooking->id_order_detail;
|
||||
|
||||
// split the admin's single tax-incl entry using the booking's
|
||||
// own tax ratio; (float) cast since DB decimals come back as
|
||||
// strings like "0.000000", which PHP treats as truthy
|
||||
$refundedAmountTaxExcl = (float) $objHtlBooking->total_price_tax_incl
|
||||
? $refundedAmount * ($objHtlBooking->total_price_tax_excl / $objHtlBooking->total_price_tax_incl)
|
||||
: $refundedAmount;
|
||||
|
||||
// $refundedAmount is already tax-incl. (see the "tax incl."
|
||||
$bookingList[$idRetDetail] = array(
|
||||
'id_htl_booking' => $idHtlBooking,
|
||||
'id_order_detail' => $idOrderDetail,
|
||||
'quantity' => $numDays,
|
||||
'num_days' => $numDays,
|
||||
'unit_price' => $refundedAmountTaxExcl / $numDays,
|
||||
'unit_price' => $refundedAmount / $numDays,
|
||||
);
|
||||
} elseif ($idServiceProductOrder = $objOrderReturnDetail->id_service_product_order_detail) {
|
||||
$objServiceProductOrderDetail = new ServiceProductOrderDetail($idServiceProductOrder);
|
||||
|
||||
// same reasoning as the booking branch above
|
||||
$refundedAmountTaxExcl = (float) $objServiceProductOrderDetail->total_price_tax_incl
|
||||
? $refundedAmount * ($objServiceProductOrderDetail->total_price_tax_excl / $objServiceProductOrderDetail->total_price_tax_incl)
|
||||
: $refundedAmount;
|
||||
|
||||
$bookingList[$idRetDetail] = array(
|
||||
'id_service_product_order_detail' => $idServiceProductOrder,
|
||||
'id_order_detail' => $objServiceProductOrderDetail->id_order_detail,
|
||||
'quantity' => $objServiceProductOrderDetail->quantity,
|
||||
'unit_price' => $refundedAmountTaxExcl / $objServiceProductOrderDetail->quantity,
|
||||
'unit_price' => $refundedAmount / $objServiceProductOrderDetail->quantity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +444,6 @@ class HotelReservationSystem extends Module
|
||||
$langTables = array(
|
||||
'htl_room_type_feature_pricing',
|
||||
'htl_branch_info',
|
||||
'htl_features',
|
||||
'htl_amenity',
|
||||
'htl_order_refund_rules',
|
||||
'htl_settings_link'
|
||||
|
||||
@@ -106,7 +106,7 @@ class WkHotelRoom extends Module
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
array(array('adults' => 1, 'children' => 0, 'child_ages' => array()))
|
||||
);
|
||||
$htlRoom['feature_price'] = $featurePrice;
|
||||
|
||||
Reference in New Issue
Block a user