update date diff function
This commit is contained in:
@@ -1379,7 +1379,7 @@ class HotelCartBookingData extends ObjectModel
|
||||
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
|
||||
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
|
||||
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`active`=1
|
||||
AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fp.`date_from` = DATE_FORMAT(\''.pSQL($date).'\', "%Y-%m-%d")'
|
||||
AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fp.`date_from` = \''.pSQL($date).'\''
|
||||
)) {
|
||||
return $featurePrice;
|
||||
}
|
||||
@@ -1389,8 +1389,8 @@ class HotelCartBookingData extends ObjectModel
|
||||
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
|
||||
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
|
||||
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.'
|
||||
AND fp.`is_special_days_exists`=1 AND fp.`active`=1 AND fp.`date_from` <= DATE_FORMAT(\''.pSQL($date).'\', "%Y-%m-%d")
|
||||
AND fp.`date_to` >= DATE_FORMAT(\''.pSQL($date).'\', "%Y-%m-%d")'
|
||||
AND fp.`is_special_days_exists`=1 AND fp.`active`=1 AND fp.`date_from` <= \''.pSQL($date).'\'
|
||||
AND fp.`date_to` >= \''.pSQL($date).'\''
|
||||
)) {
|
||||
foreach ($featurePrice as $fRow) {
|
||||
$specialDays = json_decode($fRow['special_days']);
|
||||
@@ -1406,7 +1406,7 @@ class HotelCartBookingData extends ObjectModel
|
||||
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
|
||||
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE.'
|
||||
AND `is_special_days_exists`=0 AND `active`=1
|
||||
AND fp.`date_from` <= DATE_FORMAT(\''.pSQL($date).'\', "%Y-%m-%d") AND fp.`date_to` >= DATE_FORMAT(\''.pSQL($date).'\', "%Y-%m-%d")'
|
||||
AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\''
|
||||
)) {
|
||||
return $featurePrice;
|
||||
}
|
||||
|
||||
@@ -2492,21 +2492,13 @@ class HotelHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the number of days between two dates. If same date is passed, it returns the hourly difference
|
||||
*/
|
||||
public static function getNumberOfDays($dateFrom, $dateTo)
|
||||
{
|
||||
$start = new DateTime($dateFrom);
|
||||
$end = new DateTime($dateTo);
|
||||
$difference = $start->diff($end);
|
||||
if ($start->format('Y-m-d') == $end->format('Y-m-d')) {
|
||||
$diff = $difference->h;
|
||||
} else {
|
||||
$diff = $difference->days;
|
||||
}
|
||||
$startDate = new DateTime($dateFrom);
|
||||
$endDate = new DateTime($dateTo);
|
||||
$daysDifference = $startDate->diff($endDate)->days;
|
||||
|
||||
return $diff;
|
||||
return $daysDifference;
|
||||
}
|
||||
|
||||
public static function validateDateRangeForHotel($dateFrom, $dateTo, $idHotel)
|
||||
|
||||
Reference in New Issue
Block a user