本文整理汇总了PHP中TravelHelper::dateDiff方法的典型用法代码示例。如果您正苦于以下问题:PHP TravelHelper::dateDiff方法的具体用法?PHP TravelHelper::dateDiff怎么用?PHP TravelHelper::dateDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TravelHelper
的用法示例。
在下文中一共展示了TravelHelper::dateDiff方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_add_to_cart
function do_add_to_cart()
{
$pass_validate = true;
$item_id = STInput::request('item_id', '');
if ($item_id <= 0 || get_post_type($item_id) != 'st_holidays') {
STTemplate::set_message(__('This holiday is not available..', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
$number = 1;
$adult_number = intval(STInput::request('adult_number', 1));
$child_number = intval(STInput::request('child_number', 0));
$infant_number = intval(STInput::request('infant_number', 0));
$data['adult_number'] = $adult_number;
$data['child_number'] = $child_number;
$data['infant_number'] = $infant_number;
$max_number = intval(get_post_meta($item_id, 'max_people', true));
$type_holiday = get_post_meta($item_id, 'type_holiday', true);
$data['type_holiday'] = $type_holiday;
$today = date('Y-m-d');
$check_in = STInput::request('check_in', '');
$check_out = STInput::request('check_out', '');
if (!$check_in || !$check_out) {
STTemplate::set_message(__('Select a holiday in the calendar above.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$compare = TravelHelper::dateCompare($today, $check_in);
if ($compare < 0) {
STTemplate::set_message(__('This holiday has expired', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
$booking_period = intval(get_post_meta($item_id, 'holidays_booking_period', true));
$period = TravelHelper::dateDiff($today, $check_in);
if ($period < $booking_period) {
STTemplate::set_message(sprintf(__('This holiday allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
$pass_validate = false;
return false;
}
if ($adult_number + $child_number + $infant_number > $max_number) {
STTemplate::set_message(sprintf(__('Max of people for this holiday is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
$pass_validate = FALSE;
return false;
}
$holiday_available = HolidayHelper::checkAvailableHoliday($item_id, strtotime($check_in), strtotime($check_out));
if (!$holiday_available) {
STTemplate::set_message(__('The check in, check out day is not invalid or this holiday not available.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$free_people = intval(get_post_meta($item_id, 'max_people', true));
$result = HolidayHelper::_get_free_peple($item_id, strtotime($check_in), strtotime($check_out));
if (is_array($result) && count($result)) {
$free_people = intval($result['free_people']);
}
if ($free_people < $adult_number + $child_number + $infant_number) {
STTemplate::set_message(sprintf(__('This holiday only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
$pass_validate = FALSE;
return false;
}
$data_price = STPrice::getPriceByPeopleHoliday($item_id, strtotime($check_in), strtotime($check_out), $adult_number, $child_number, $infant_number);
$total_price = $data_price['total_price'];
$sale_price = STPrice::getSaleHolidaySalePrice($item_id, $total_price, $type_holiday, strtotime($check_in));
$data['check_in'] = date('m/d/Y', strtotime($check_in));
$data['check_out'] = date('m/d/Y', strtotime($check_out));
$people_price = STPrice::getPeoplePrice($item_id, strtotime($check_in), strtotime($check_out));
$data = wp_parse_args($data, $people_price);
$data['ori_price'] = $sale_price;
$data['currency'] = TravelHelper::get_current_currency('symbol');
$data['currency_rate'] = TravelHelper::get_current_currency('rate');
$data['currency_pos'] = TravelHelper::get_current_currency('booking_currency_pos');
$data['commission'] = TravelHelper::get_commission();
$data['data_price'] = $data_price;
$data['discount_rate'] = STPrice::get_discount_rate($item_id, strtotime($check_in));
if ($pass_validate) {
$data['duration'] = $type_holiday == 'daily_holiday' ? floatval(get_post_meta($item_id, 'duration_day', true)) : '';
if ($pass_validate) {
STCart::add_cart($item_id, $number, $sale_price, $data);
}
}
return $pass_validate;
}
示例2: _get_availability_hotel_room
public function _get_availability_hotel_room()
{
$list_date = array();
$room_id = STInput::request('post_id', '');
$check_in = STInput::request('start', '');
$check_out = STInput::request('end', '');
$hotel_id = intval(get_post_meta($room_id, 'room_parent', true));
$allow_full_day = get_post_meta($hotel_id, 'allow_full_day', true);
if (!$allow_full_day || $allow_full_day == '') {
$allow_full_day = 'on';
}
$year = date('Y', $check_in);
if (empty($year)) {
$year = date('Y');
}
$year2 = date('Y', $check_out);
if (empty($year2)) {
$year2 = date('Y');
}
$month = date('m', $check_in);
if (empty($month)) {
$month = date('m');
}
$month2 = date('m', $check_out);
if (empty($month2)) {
$month2 = date('m');
}
$result = HotelHelper::_get_full_ordered($room_id, $month, $month2, $year, $year2);
$number_room = get_post_meta($room_id, 'number_room', true);
$min_max = HotelHelper::_get_min_max_date_ordered($room_id, $year, $year2);
if (is_array($min_max) && count($min_max) && is_array($result) && count($result)) {
$disable = array();
for ($i = intval($min_max['min_date']); $i <= intval($min_max['max_date']); $i = strtotime('+1 day', $i)) {
$num_room = 0;
foreach ($result as $key => $date) {
if ($allow_full_day == 'on') {
if ($i >= intval($date['check_in_timestamp']) && $i <= intval($date['check_out_timestamp'])) {
$num_room += $date['number_room'];
}
} else {
if ($i > intval($date['check_in_timestamp']) && $i < intval($date['check_out_timestamp'])) {
$num_room += $date['number_room'];
}
}
}
$disable[$i] = $num_room;
}
if (count($disable)) {
foreach ($disable as $key => $num_room) {
if (intval($num_room) >= $number_room) {
$list_date[] = date(TravelHelper::getDateFormat(), $key);
}
}
}
}
$list_date_2 = AvailabilityHelper::_getDisableCustomDate($room_id, $month, $month2, $year, $year2);
$date1 = strtotime($year . '-' . $month . '-01');
$date2 = strtotime($year2 . '-' . $month2 . '-01');
$date2 = strtotime(date('Y-m-t', $date2));
$today = strtotime(date('Y-m-d'));
$return = array();
$booking_period = intval(get_post_meta($hotel_id, 'hotel_booking_period', true));
for ($i = $date1; $i <= $date2; $i = strtotime('+1 day', $i)) {
$period = TravelHelper::dateDiff(date('Y-m-d', $today), date('Y-m-d', $i));
$d = date(TravelHelper::getDateFormat(), $i);
if (in_array($d, $list_date)) {
$return[] = array('start' => date('Y-m-d', $i), 'date' => date('Y-m-d', $i), 'day' => date('d', $i), 'status' => 'booked');
} else {
if ($i < $today) {
$return[] = array('start' => date('Y-m-d', $i), 'date' => date('Y-m-d', $i), 'day' => date('d', $i), 'status' => 'past');
} else {
if (in_array($d, $list_date_2)) {
$return[] = array('start' => date('Y-m-d', $i), 'date' => date('Y-m-d', $i), 'day' => date('d', $i), 'status' => 'disabled');
} else {
if ($period < $booking_period) {
$return[] = array('start' => date('Y-m-d', $i), 'date' => date('Y-m-d', $i), 'day' => date('d', $i), 'status' => 'disabled');
} else {
$return[] = array('start' => date('Y-m-d', $i), 'date' => date('Y-m-d', $i), 'day' => date('d', $i), 'status' => 'avalable', 'price' => TravelHelper::format_money(STPrice::getRoomPriceOnlyCustomPrice($room_id, $i, strtotime('+1 day', $i), 1)));
}
}
}
}
}
echo json_encode($return);
die;
}
示例3: do_add_to_cart
function do_add_to_cart()
{
$pass_validate = true;
$item_id = intval(STInput::request('item_id', ''));
if ($item_id <= 0 || get_post_type($item_id) != 'st_activity') {
STTemplate::set_message(__('This activity is not available..', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
$number = 1;
$type_activity = STInput::request('type_activity', 'specific_date');
$adult_number = intval(STInput::request('adult_number', 1));
$child_number = intval(STInput::request('child_number', 0));
$infant_number = intval(STInput::request('infant_number', 0));
$max_number = intval(get_post_meta($item_id, 'max_people', true));
$today = date('Y-m-d');
if ($adult_number + $child_number + $infant_number > $max_number) {
STTemplate::set_message(sprintf(__('Max of people for this activity is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
$pass_validate = FALSE;
return false;
}
if ($type_activity == 'specific_date') {
$check_in = TravelHelper::convertDateFormat(STInput::request('check_in', ''));
$check_out = TravelHelper::convertDateFormat(STInput::request('check_out', ''));
if (empty($check_in)) {
STTemplate::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
if (empty($check_out)) {
STTemplate::set_message(__('The check out field is not empty.', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
$compare = TravelHelper::dateCompare($today, $check_in);
if ($compare < 0) {
STTemplate::set_message(__('This activity has expired', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
$people = $adult_number + $child_number + $child_number;
$result = ActivityHelper::_get_free_peple_special($item_id, $check_in, $check_out);
$free_people = intval(get_post_meta($item_id, 'max_people', true));
if (is_array($result) && count($result)) {
$free_people = intval($result['free_people']);
}
if ($free_people < $people) {
STTemplate::set_message(sprintf(__('This activity only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
$pass_validate = false;
return false;
}
$data['check_in'] = date('m/d/Y', strtotime($check_in));
$data['check_out'] = date('m/d/Y', strtotime($check_out));
} elseif ($type_activity == 'daily_activity') {
$check_in = STInput::request('check_in', '');
if (empty($check_in)) {
STTemplate::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
$check_in = TravelHelper::convertDateFormat($check_in);
$check_in = date('Y-m-d', strtotime($check_in));
$duration = intval(get_post_meta($item_id, 'duration', true));
$check_out = $duration >= 2 ? strtotime('+ ' . $duration . ' days', strtotime($check_in)) : strtotime('+ ' . $duration . ' day', strtotime($check_in));
$check_out = date('Y-m-d', $check_out);
$booking_period = intval(get_post_meta($item_id, 'activity_booking_period', true));
$period = TravelHelper::dateDiff($today, $check_in);
$compare = TravelHelper::dateCompare($today, $check_in);
if ($compare < 0) {
STTemplate::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
if ($booking_period && $booking_period > $period) {
STTemplate::set_message(sprintf(__('This activity allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
$pass_validate = false;
return false;
}
$people = $adult_number + $child_number + $child_number;
$result = ActivityHelper::_get_free_peple_daily($item_id, $check_in);
$free_people = intval(get_post_meta($item_id, 'max_people', true));
if (is_array($result) && count($result)) {
$free_people = intval($result['free_people']);
}
if ($free_people < $people) {
STTemplate::set_message(sprintf(__('This activity only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
$pass_validate = false;
return false;
}
$data['duration'] = $duration;
}
$data['adult_number'] = $adult_number;
$data['child_number'] = $child_number;
$data['infant_number'] = $infant_number;
$data['check_in'] = date('m/d/Y', strtotime($check_in));
$data['check_out'] = date('m/d/Y', strtotime($check_out));
$data['type_activity'] = $type_activity;
$data_price = STPrice::getPriceByPeople($item_id, strtotime($check_in), strtotime($check_out), $adult_number, $child_number, $infant_number);
$total_price = $data_price['total_price'];
$sale_price = STPrice::getSaleTourSalePrice($item_id, $total_price, $type_activity, strtotime($check_in));
//.........这里部分代码省略.........
示例4: __
</td>
<td style="border-left: 1px solid #bcbcbc;border-top: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;padding: 6px;background: #e4e4e4;border-right: 1px solid #bcbcbc;">
<?php
echo __('Information', ST_TEXTDOMAIN);
?>
</td>
</tr>
<?php
$total = 0;
$i = 0;
$i++;
$order_item_id = $order_id;
$object_id = get_post_meta($order_item_id, 'item_id', true);
$check_in = get_post_meta($order_item_id, 'check_in', true);
$check_out = get_post_meta($order_item_id, 'check_out', true);
$numberday = TravelHelper::dateDiff($check_in, $check_out);
$item_price = floatval(get_post_meta($order_item_id, 'item_price', true));
?>
<tr>
<td style="padding: 6px;border-left: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;" valign="top" align="center" width="5%">
<?php
echo esc_html($i);
?>
</td>
<td width="35%" style="vertical-align: top;padding: 6px;border-bottom:1px dashed #ccc;border-left: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;">
<?php
echo get_the_post_thumbnail($object_id, array(360, 270, 'bfi_thumb' => true), array('style' => 'max-width:100%;height:auto'));
?>
</td >
<td style="padding: 6px;vertical-align: top;border-bottom:1px dashed #ccc;border-left: 1px solid #bcbcbc;border-bottom: 1px solid #bcbcbc;border-right: 1px solid #bcbcbc;">
示例5: _get_where_query
function _get_where_query($where)
{
if (!TravelHelper::checkTableDuplicate('st_rental')) {
return $where;
}
global $wpdb;
if ($location_id = STInput::get('location_id') and STInput::get('location_id') or get_post_type(get_the_ID()) == 'location') {
if (!$location_id) {
$location_id = get_the_ID();
}
$list = TravelHelper::getLocationByParent($location_id);
if (is_array($list) && count($list)) {
$where .= " AND (";
$where_tmp = "";
foreach ($list as $item) {
if (empty($where_tmp)) {
$where_tmp .= "tb.multi_location LIKE '%_{$item}_%'";
} else {
$where_tmp .= " OR tb.multi_location LIKE '%_{$item}_%'";
}
}
$list = implode(',', $list);
$where_tmp .= " OR tb.location_id IN ({$list})";
$where .= $where_tmp . ")";
} else {
$where .= " AND (tb.multi_location LIKE '%_{$location_id}_%' OR tb.location_id IN ('{$location_id}')) ";
}
} elseif ($location_name = STInput::request('location_name')) {
$ids_location = TravelerObject::_get_location_by_name($location_name);
if (is_array($ids_location) && count($ids_location)) {
$ids_location_tmp = array();
foreach ($ids_location as $item) {
$list = TravelHelper::getLocationByParent($item);
if (is_array($list) && count($list)) {
foreach ($list as $item) {
$ids_location_tmp[] = $item;
}
}
}
if (count($ids_location_tmp)) {
$ids_location = $ids_location_tmp;
}
}
if (!empty($ids_location)) {
$where .= " AND ((";
$where_tmp = "";
foreach ($ids_location as $id) {
if (empty($where_tmp)) {
$where_tmp .= " tb.multi_location LIKE '%_{$id}_%' ";
} else {
$where_tmp .= " OR tb.multi_location LIKE '%_{$id}_%' ";
}
}
$ids_location = implode(',', $ids_location);
$where_tmp .= " OR (tb.location_id IN ({$ids_location})";
$where .= $where_tmp . ")";
$where .= " OR (tb.address LIKE '%{$location_name}%'";
$where .= " OR {$wpdb->prefix}posts.post_title LIKE '%{$location_name}%')))";
} else {
if (!empty($_REQUEST['search_all'])) {
$where .= " AND (tb.address LIKE '%{$location_name}%'";
$where .= " OR {$wpdb->prefix}posts.post_title LIKE '%{$location_name}%')";
}
}
} elseif ($address = STInput::request('address', '')) {
$value = STInput::request('address');
$value = explode(",", $value);
if (!empty($value[0]) and !empty($value[2])) {
$where .= " AND (tb.address LIKE '%{$value[0]}%' OR tb.address LIKE '%{$value[2]}%')";
} else {
$where .= " AND (tb.address LIKE '%{$address}%')";
}
}
if (isset($_GET['start']) && isset($_GET['end']) and !empty($_GET['start']) and !empty($_GET['end'])) {
$check_in = date('Y-m-d', strtotime(TravelHelper::convertDateFormat($_GET['start'])));
$check_out = date('Y-m-d', strtotime(TravelHelper::convertDateFormat($_GET['end'])));
$today = date('m/d/Y');
$period = TravelHelper::dateDiff($today, $check_in);
$adult_number = STInput::get('adult_number', 0);
if (intval($adult_number) < 0) {
$adult_number = 0;
}
$children_number = STInput::get('children_num', 0);
if (intval($children_number) < 0) {
$children_number = 0;
}
$list_rental = RentalHelper::_rentalValidate($check_in, $check_out, $adult_number, $children_number, 1);
if (!is_array($list_rental) || count($list_rental) <= 0) {
$list_rental = "''";
} else {
$list_rental = implode(',', $list_rental);
}
$where .= " AND {$wpdb->posts}.ID NOT IN ({$list_rental}) AND CAST(tb.rentals_booking_period AS UNSIGNED) <= {$period}";
}
if ($star = STInput::get('star_rate')) {
$stars = STInput::get('star_rate', 1);
$stars = explode(',', $stars);
$all_star = array();
if (!empty($stars) && is_array($stars)) {
foreach ($stars as $val) {
//.........这里部分代码省略.........
示例6: esc_html
?>
: </strong>
<?php
echo esc_html($duration);
?>
</p>
<?php
}
?>
<?php
} else {
if ($type_tour == 'specific_date') {
?>
<?php
if ($check_in and $check_out) {
$period = TravelHelper::dateDiff($check_in, $check_out);
?>
<p>
<strong><?php
st_the_language('tour_date');
?>
: </strong>
<?php
echo date_i18n(TravelHelper::getDateFormat(), strtotime($check_in));
?>
-
<?php
echo date_i18n(TravelHelper::getDateFormat(), strtotime($check_out));
?>
</p>
<?php
示例7: _check_validate
function _check_validate()
{
$data = array();
$order_item_id = STInput::request('order_item_id', '');
$st_first_name = STInput::request('st_first_name', '');
if (empty($st_first_name)) {
STAdmin::set_message(__('The firstname field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_last_name = STInput::request('st_last_name', '');
if (empty($st_last_name)) {
STAdmin::set_message(__('The lastname field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_email = STInput::request('st_email', '');
if (empty($st_email)) {
STAdmin::set_message(__('The email field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_phone = STInput::request('st_phone', '');
if (empty($st_phone)) {
STAdmin::set_message(__('The phone field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
if (STInput::request('section', '') != 'edit_order_item') {
$item_id = intval(STInput::request('item_id', ''));
if ($item_id <= 0 || get_post_type($item_id) != 'st_holidays') {
STAdmin::set_message(__('The holiday field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$type_holiday = get_post_meta($item_id, 'type_holiday', true);
$today = date('Y-m-d');
$check_in = STInput::request('check_in', '');
$check_out = STInput::request('check_out', '');
if (!$check_in || !$check_out) {
STAdmin::set_message(__('Select a holiday in the calendar above.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$compare = TravelHelper::dateCompare($today, $check_in);
if ($compare < 0) {
STAdmin::set_message(__('This holiday has expired', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
$duration = ($type_holiday = 'daily_holiday') ? get_post_meta($item_id, 'duration_day', true) : '';
$booking_period = intval(get_post_meta($item_id, 'holidays_booking_period', true));
$period = TravelHelper::dateDiff($today, $check_in);
if ($period < $booking_period) {
STAdmin::set_message(sprintf(__('This holiday allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
$pass_validate = false;
return false;
}
$adult_number = intval(STInput::request('adult_number', 1));
$child_number = intval(STInput::request('child_number', 0));
$infant_number = intval(STInput::request('infant_number', 0));
$max_number = intval(get_post_meta($item_id, 'max_people', true));
if ($adult_number + $child_number + $infant_number > $max_number) {
STAdmin::set_message(sprintf(__('Max of people for this holiday is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
return false;
}
$holiday_available = HolidayHelper::checkAvailableHoliday($item_id, strtotime($check_in), strtotime($check_out));
if (!$holiday_available) {
STAdmin::set_message(__('The check in, check out day is not invalid or this holiday not available.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$free_people = intval(get_post_meta($item_id, 'max_people', true));
$result = HolidayHelper::_get_free_peple($item_id, strtotime($check_in), strtotime($check_out), $order_item_id);
if (is_array($result) && count($result)) {
$free_people = intval($result['free_people']);
}
if ($free_people > $max_number) {
STAdmin::set_message(sprintf(__('This holiday only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
$pass_validate = FALSE;
return false;
}
$data['order_item_id'] = $order_item_id;
$data['item_id'] = $item_id;
$data['check_in'] = date('m/d/Y', strtotime($check_in));
$data['check_out'] = date('m/d/Y', strtotime($check_out));
$data['adult_number'] = $adult_number;
$data['child_number'] = $child_number;
$data['infant_number'] = $infant_number;
$data['type_holiday'] = $type_holiday;
$data['duration'] = $duration;
$people_price = STPrice::getPeoplePrice($item_id, strtotime($check_in), strtotime($check_out));
$data = wp_parse_args($data, $people_price);
}
return $data;
}
示例8: check_validate
function check_validate()
{
$data = array();
$order_item_id = STInput::request('order_item_id', '');
$st_first_name = STInput::request('st_first_name', '');
if (empty($st_first_name)) {
STAdmin::set_message(__('The firstname field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_last_name = STInput::request('st_last_name', '');
if (empty($st_last_name)) {
STAdmin::set_message(__('The lastname field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_email = STInput::request('st_email', '');
if (empty($st_email)) {
STAdmin::set_message(__('The email field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_phone = STInput::request('st_phone', '');
if (empty($st_phone)) {
STAdmin::set_message(__('The phone field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
if (STInput::request('section', '') != 'edit_order_item') {
$item_id = intval(STInput::request('item_id', ''));
if ($item_id <= 0 || get_post_type($item_id) != 'st_activity') {
STAdmin::set_message(__('The activity field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$type_activity = STInput::request('type_activity', 'daily_activity');
$today = date('Y-m-d');
$check_in = STInput::request('check_in', '');
if (empty($check_in)) {
STAdmin::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_in = date('Y-m-d', strtotime($check_in));
$check_out = STInput::request('check_out', '');
if (empty($check_out)) {
STAdmin::set_message(__('The check out field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_out = date('Y-m-d', strtotime($check_out));
$adult_number = intval(STInput::request('adult_number', 1));
$child_number = intval(STInput::request('child_number', 0));
$infant_number = intval(STInput::request('infant_number', 0));
$max_number = intval(get_post_meta($item_id, 'max_people', true));
if ($adult_number + $child_number + $infant_number > $max_number) {
STAdmin::set_message(sprintf(__('Max of people for this activity is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
return false;
}
if ($type_activity == 'daily_activity') {
$booking_period = intval(get_post_meta($item_id, 'activity_booking_period', true));
$period = TravelHelper::dateDiff($today, $check_in);
$compare = TravelHelper::dateCompare($today, $check_in);
if ($compare < 0) {
STAdmin::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
return false;
}
if ($booking_period && $booking_period > $period) {
STAdmin::set_message(sprintf(__('This activity allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
return false;
}
$people = $adult_number + $child_number + $infant_number;
$result = ActivityHelper::_get_free_peple_daily($item_id, $check_in, $order_item_id);
$free_people = intval(get_post_meta($item_id, 'max_people', true));
if (is_array($result) && count($result)) {
$free_people = intval($result['free_people']);
}
if ($free_people < $people) {
STAdmin::set_message(sprintf(__('This activity only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
return false;
}
$duration = get_post_meta($item_id, 'duration', true);
$data['duration'] = $duration;
} elseif ($type_activity == 'specific_date') {
$compare = TravelHelper::dateCompare($today, $check_in);
if ($compare < 0) {
STAdmin::set_message(__('This activity has expired', ST_TEXTDOMAIN), 'danger');
return false;
}
$people = $adult_number + $child_number + $infant_number;
$result = ActivityHelper::_get_free_peple_special($item_id, $check_in, $check_out, $order_item_id);
$free_people = intval(get_post_meta($item_id, 'max_people', true));
if (is_array($result) && count($result)) {
$free_people = intval($result['free_people']);
}
if ($free_people < $people) {
STAdmin::set_message(sprintf(__('This activity only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
return false;
}
}
$data['item_id'] = $item_id;
$data['order_item_id'] = $order_item_id;
$data['check_in'] = date('m/d/Y', strtotime($check_in));
$data['check_out'] = date('m/d/Y', strtotime($check_out));
$data['adult_number'] = $adult_number;
$data['child_number'] = $child_number;
$data['infant_number'] = $infant_number;
//.........这里部分代码省略.........
示例9: _get_list_availability_holiday_frontend
static function _get_list_availability_holiday_frontend($holiday_id, $check_in, $check_out)
{
$results = array();
$today = strtotime(date('Y-m-d'));
if (get_post_type($holiday_id) == 'st_holidays') {
$adult_price = floatval(get_post_meta($holiday_id, 'adult_price', true));
$child_price = floatval(get_post_meta($holiday_id, 'child_price', true));
$infant_price = floatval(get_post_meta($holiday_id, 'infant_price', true));
$type_holiday = get_post_meta($holiday_id, 'type_holiday', true);
$booking_period = intval(get_post_meta($holiday_id, 'holidays_booking_period', true));
$data_holiday = self::_getdataHolidayEachDate($holiday_id, $check_in, $check_out);
if (is_array($data_holiday) && count($data_holiday)) {
foreach ($data_holiday as $key => $val) {
if ($val->status == 'available') {
$cant_book = self::_get_holiday_cant_order($holiday_id, date('m/d/Y', $val->check_in));
$period = TravelHelper::dateDiff(date('Y-m-d', $today), date('Y-m-d', $val->check_in));
if (intval($val->groupday) == 1) {
if ($val->check_in >= $today && count($cant_book) <= 0 && $period >= $booking_period) {
$results[] = array('start' => date('Y-m-d', $val->check_in), 'end' => date('Y-m-d', $val->check_out), 'adult_price' => TravelHelper::format_money($val->adult_price), 'child_price' => TravelHelper::format_money($val->child_price), 'infant_price' => TravelHelper::format_money($val->infant_price), 'status' => 'available');
}
} else {
if ($val->check_in >= $today && count($cant_book) <= 0 && $period >= $booking_period) {
$results[] = array('start' => date('Y-m-d', $val->check_in), 'end' => date('Y-m-d', $val->check_in), 'adult_price' => TravelHelper::format_money($val->adult_price), 'child_price' => TravelHelper::format_money($val->child_price), 'infant_price' => TravelHelper::format_money($val->infant_price), 'status' => 'available');
}
}
}
}
if ($type_holiday == 'daily_holiday') {
for ($i = $check_in; $i <= $check_out; $i = strtotime('+1 day', $i)) {
$in_item = false;
$status = 'available';
foreach ($data_holiday as $key => $val) {
if ($i >= $val->check_in && $i <= $val->check_out) {
$in_item = true;
$status = $val->status;
break;
}
}
if (!$in_item) {
$cant_book = self::_get_holiday_cant_order($holiday_id, date('m/d/Y', $i));
$period = TravelHelper::dateDiff(date('Y-m-d', $today), date('Y-m-d', $i));
if ($i >= $today && count($cant_book) <= 0 && $period >= $booking_period) {
$results[] = array('start' => date('Y-m-d', $i), 'end' => date('Y-m-d', $i), 'adult_price' => TravelHelper::format_money($adult_price), 'child_price' => TravelHelper::format_money($child_price), 'infant_price' => TravelHelper::format_money($infant_price), 'status' => 'available');
}
}
}
}
} else {
if ($type_holiday == 'daily_holiday') {
for ($i = $check_in; $i <= $check_out; $i = strtotime('+1 day', $i)) {
$cant_book = self::_get_holiday_cant_order($holiday_id, date('m/d/Y', $i));
$period = TravelHelper::dateDiff(date('Y-m-d', $today), date('Y-m-d', $i));
if ($i >= $today && count($cant_book) <= 0 && $period >= $booking_period) {
$results[] = array('title' => get_the_title($holiday_id), 'start' => date('Y-m-d', $i), 'end' => date('Y-m-d', $i), 'adult_price' => TravelHelper::format_money($adult_price), 'child_price' => TravelHelper::format_money($child_price), 'infant_price' => TravelHelper::format_money($infant_price), 'status' => 'available');
}
}
}
}
}
return $results;
}
示例10: check_validate
function check_validate()
{
$data = array();
$order_item_id = STInput::request('order_item_id', '');
$st_first_name = STInput::request('st_first_name', '');
if (empty($st_first_name)) {
STAdmin::set_message(__('The firstname field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_last_name = STInput::request('st_last_name', '');
if (empty($st_last_name)) {
STAdmin::set_message(__('The lastname field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_email = STInput::request('st_email', '');
if (empty($st_email)) {
STAdmin::set_message(__('The email field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$st_phone = STInput::request('st_phone', '');
if (empty($st_phone)) {
STAdmin::set_message(__('The phone field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
if (STInput::request('section', '') != 'edit_order_item') {
$item_id = intval(STInput::request('item_id', ''));
if ($item_id <= 0 || get_post_type($item_id) != 'st_cars') {
STAdmin::set_message(__('The car field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$pick_up = STInput::request('pick_up', '');
$drop_off = STInput::request('drop_off', '');
if (!empty($pick_up) && !empty($drop_off)) {
$pickup_country = get_post_meta($pick_up, 'location_country', true);
if (!$pickup_country) {
STAdmin::set_message(__('The \'country\' field not set for the \'\'', ST_TEXTDOMAIN) . get_the_title($pick_up), 'danger');
$pass_validate = false;
return false;
}
$dropoff_country = get_post_meta($drop_off, 'location_country', true);
if (!$dropoff_country) {
STAdmin::set_message(__('The \'country\' field not set for the \'\'', ST_TEXTDOMAIN) . get_the_title($drop_off), 'danger');
$pass_validate = false;
return false;
}
if ($pickup_country != $dropoff_country) {
STAdmin::set_message(__('The country is not same', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
}
$check_in = STInput::request('check_in', '');
if (empty($check_in)) {
STAdmin::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_in_time = STInput::request('check_in_time', '');
if (empty($check_in_time)) {
STAdmin::set_message(__('The check in time field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_out = STInput::request('check_out', '');
if (empty($check_out)) {
STAdmin::set_message(__('The check out field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_out_time = STInput::request('check_out_time', '');
if (empty($check_out_time)) {
STAdmin::set_message(__('The check out time field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_in_full = $check_in . ' ' . strtoupper($check_in_time);
$check_out_full = $check_out . ' ' . strtoupper($check_out_time);
$check_in_timestamp = strtotime($check_in_full);
$check_out_timestamp = strtotime($check_out_full);
$today = date('m/d/Y');
$period = TravelHelper::dateDiff($today, $check_in);
$compare = TravelHelper::dateCompare($today, $check_out);
$booking_period = intval(get_post_meta($item_id, 'cars_booking_period', true));
if ($booking_period <= 0) {
$booking_period = 0;
}
if ($check_in_timestamp - $check_out_timestamp >= 0) {
STAdmin::set_message(__('The drop off datetime is later than the pick up datetime.', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
if ($compare < 0) {
STAdmin::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
if ($period < $booking_period) {
STAdmin::set_message(sprintf(__('This car allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
$pass_validate = false;
return false;
}
if (!CarHelper::_get_car_cant_order_by_id($item_id, $check_in_timestamp, $check_out_timestamp, $order_item_id)) {
STAdmin::set_message(__('This car is full order', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
//.........这里部分代码省略.........
示例11: _holidayValidate
static function _holidayValidate($check_in)
{
global $wpdb;
$cant_book = self::_get_holiday_cant_order($check_in);
$holidays = self::_getAllHolidayID();
$results = array();
$today = date('Y-m-d');
if (is_array($holidays) && count($holidays)) {
foreach ($holidays as $holiday) {
$type_holiday = get_post_meta($holiday, 'type_holiday', true);
$data_holiday = AvailabilityHelper::_getdataHolidayEachDate($holiday, strtotime($check_in), strtotime($check_in));
$booking_period = intval(get_post_meta($holiday, 'holidays_booking_period', true));
if (is_array($data_holiday) && count($data_holiday)) {
$full = 0;
foreach ($data_holiday as $key => $val) {
$period = TravelHelper::dateDiff($today, date('Y-m-d', $val->check_in));
if ($val->status != 'available' || $period < $booking_period) {
$full += 1;
}
}
if ($full == count($data_holiday)) {
$results[] = $holiday;
}
} else {
if ($type_holiday != 'daily_holiday') {
$results[] = $holiday;
}
}
}
}
if (count($results)) {
$cant_book = array_unique(array_merge($cant_book, $results));
}
return $cant_book;
}
示例12: _tourValidate
static function _tourValidate($check_in)
{
global $wpdb;
$cant_book = self::_get_tour_cant_order($check_in);
$tours = self::_getAllTourID();
$results = array();
$today = date('Y-m-d');
if (is_array($tours) && count($tours)) {
foreach ($tours as $tour) {
$type_tour = get_post_meta($tour, 'type_tour', true);
$data_tour = AvailabilityHelper::_getdataTourEachDate($tour, strtotime($check_in), strtotime($check_in));
$booking_period = intval(get_post_meta($tour, 'tours_booking_period', true));
if (is_array($data_tour) && count($data_tour)) {
$full = 0;
foreach ($data_tour as $key => $val) {
$period = TravelHelper::dateDiff($today, date('Y-m-d', $val->check_in));
if ($val->status != 'available' || $period < $booking_period) {
$full += 1;
}
}
if ($full == count($data_tour)) {
$results[] = $tour;
}
} else {
if ($type_tour != 'daily_tour') {
$results[] = $tour;
}
}
}
}
if (count($results)) {
$cant_book = array_unique(array_merge($cant_book, $results));
}
return $cant_book;
}
示例13: get_template_part
<?php
}
?>
</ul>
<ul class="booking-item-features booking-item-features-small clearfix">
<?php
get_template_part('single-hotel/room-facility', 'list');
?>
</ul>
</div>
<div class="col-md-3">
<?php
$start = TravelHelper::convertDateFormat(STInput::request('start'));
$end = TravelHelper::convertDateFormat(STInput::request('end'));
$numberday = TravelHelper::dateDiff($start, $end);
$is_search_room = STInput::request('is_search_room');
?>
<?php
if ($start and $end and $is_search_room) {
?>
<?php
$room_id = get_the_ID();
$room_num_search = intval(STInput::request('room_num_search', 1));
$sale_price = STPrice::getRoomPrice($room_id, strtotime($start), strtotime($end), $room_num_search);
$total_price = STPrice::getRoomPriceOnlyCustomPrice($room_id, strtotime($start), strtotime($end), $room_num_search);
?>
<?php
if ($sale_price < $total_price) {
?>
<span class="text-lg onsale mr20">
示例14: date
<?php
}
?>
<td class="post-title page-title column-title">
<?php
$check_in = date(TravelHelper::getDateFormat(), strtotime(get_post_meta($post_id, 'check_in', true)));
$check_out = date(TravelHelper::getDateFormat(), strtotime(get_post_meta($post_id, 'check_out', true)));
echo balanceTags($check_in . "<br/>");
$duration = "";
if ($type_tour == 'daily_tour') {
$duration_unit = get_post_meta($item_id, 'duration_unit', true);
$duration = get_post_meta($post_id, 'duration', true);
echo __("Duration", ST_TEXTDOMAIN) . ': ' . $duration . ' ' . TravelHelper::get_duration_text($duration_unit, $duration);
} else {
$diff = TravelHelper::dateDiff(get_post_meta($post_id, 'check_in', true), get_post_meta($post_id, 'check_out', true));
if (!empty($diff) and $diff) {
if ($diff > 1) {
$duration .= esc_attr($diff) . " " . __("days", ST_TEXTDOMAIN);
} else {
$duration .= esc_attr($diff) . " " . __("day", ST_TEXTDOMAIN);
}
}
echo __("Duration", ST_TEXTDOMAIN) . ": " . $duration;
}
?>
</td>
<td class="post-title page-title column-title">
<?php
$price = get_post_meta($post_id, 'total_price', true);
$currency = get_post_meta($post_id, 'currency', true);
示例15: _get_where_query
function _get_where_query($where)
{
if (!TravelHelper::checkTableDuplicate('st_hotel')) {
return $where;
}
global $wpdb;
$where .= "";
if (isset($_REQUEST['location_id']) && !empty($_REQUEST['location_id'])) {
$location_id = STInput::request('location_id', '');
$list = TravelHelper::getLocationByParent($location_id);
if (is_array($list) && count($list)) {
$where .= " AND (";
$where_tmp = "";
foreach ($list as $item) {
if (empty($where_tmp)) {
$where_tmp .= "tb.multi_location LIKE '%_{$item}_%'";
} else {
$where_tmp .= " OR tb.multi_location LIKE '%_{$item}_%'";
}
}
$list = implode(',', $list);
$where_tmp .= " OR tb.id_location IN ({$list})";
$where .= $where_tmp . ")";
} else {
$where .= " AND (tb.multi_location LIKE '%_{$location_id}_%' OR tb.id_location IN ('{$location_id}')) ";
}
} else {
if (!empty($_REQUEST['location_name'])) {
$location_name = STInput::request('location_name', '');
$ids_location = TravelerObject::_get_location_by_name($location_name);
if (is_array($ids_location) && count($ids_location)) {
$ids_location_tmp = array();
foreach ($ids_location as $item) {
$list = TravelHelper::getLocationByParent($item);
if (is_array($list) && count($list)) {
foreach ($list as $item) {
$ids_location_tmp[] = $item;
}
}
}
if (count($ids_location_tmp)) {
$ids_location = $ids_location_tmp;
}
}
if (is_array($ids_location) && count($ids_location)) {
$where .= " AND ((";
$where_tmp = "";
foreach ($ids_location as $id) {
if (empty($where_tmp)) {
$where_tmp .= " tb.multi_location LIKE '%_{$id}_%' ";
} else {
$where_tmp .= " OR tb.multi_location LIKE '%_{$id}_%' ";
}
}
$ids_location = implode(',', $ids_location);
$where_tmp .= " OR (tb.id_location IN ({$ids_location})";
$where .= $where_tmp . ")";
$where .= " OR (tb.address LIKE '%{$location_name}%'";
$where .= " OR {$wpdb->prefix}posts.post_title LIKE '%{$location_name}%')))";
} else {
if (!empty($_REQUEST['search_all'])) {
$where .= " AND (tb.address LIKE '%{$location_name}%'";
$where .= " OR {$wpdb->prefix}posts.post_title LIKE '%{$location_name}%')";
}
}
} elseif (isset($_REQUEST['address']) && !empty($_REQUEST['address'])) {
$address = STInput::request('address', '');
$value = STInput::request('address');
$value = explode(",", $value);
if (!empty($value[0]) and !empty($value[2])) {
$where .= " AND ( tb.address LIKE '%{$value[0]}%' OR tb.address LIKE '%{$value[2]}%')";
} else {
$where .= " AND ( tb.address LIKE '%{$address}%')";
}
}
}
if (isset($_GET['start']) && !empty($_GET['start']) && isset($_GET['end']) && !empty($_GET['end'])) {
$check_in = date('Y-m-d', strtotime(TravelHelper::convertDateFormat($_GET['start'])));
$check_out = date('Y-m-d', strtotime(TravelHelper::convertDateFormat($_GET['end'])));
$today = date('m/d/Y');
$period = TravelHelper::dateDiff($today, $check_in);
$adult_number = STInput::get('adult_number', 0);
if (intval($adult_number) < 0) {
$adult_number = 0;
}
$children_number = STInput::get('children_num', 0);
if (intval($children_number) < 0) {
$children_number = 0;
}
$number_room = STInput::get('room_num_search', 0);
if (intval($number_room) < 0) {
$number_room = 0;
}
$list_hotel = HotelHelper::_hotelValidate($check_in, $check_out, $adult_number, $children_number, $number_room);
if (!is_array($list_hotel) || count($list_hotel) <= 0) {
$list_hotel = "''";
} else {
$list_hotel = implode(',', $list_hotel);
}
$where .= " AND {$wpdb->prefix}posts.ID NOT IN ({$list_hotel}) AND CAST(tb.hotel_booking_period AS UNSIGNED) <= {$period}";
//.........这里部分代码省略.........