本文整理汇总了PHP中TravelHelper::dateCompare方法的典型用法代码示例。如果您正苦于以下问题:PHP TravelHelper::dateCompare方法的具体用法?PHP TravelHelper::dateCompare怎么用?PHP TravelHelper::dateCompare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TravelHelper
的用法示例。
在下文中一共展示了TravelHelper::dateCompare方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _check_validate
public 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_rental') {
STAdmin::set_message(__('The rental field is not empty.', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_in = STInput::request('check_in', '');
if (empty($check_in)) {
STAdmin::set_message(__('Date is invalid', ST_TEXTDOMAIN), 'danger');
return false;
}
$check_out = STInput::request('check_out', '');
if (empty($check_out)) {
STAdmin::set_message(__('Date is invalid', ST_TEXTDOMAIN), 'danger');
return false;
}
if (STInput::request('adult_number', '') == "") {
STAdmin::set_message(__('The No. adults field is not empty', ST_TEXTDOMAIN), 'danger');
return false;
}
$adult_number = intval(STInput::request('adult_number', ''));
if ($adult_number <= 0) {
$adult_number = 1;
}
if (STInput::request('child_number', '') == "") {
STAdmin::set_message(__('The No. children field is not empty', ST_TEXTDOMAIN), 'danger');
return false;
}
$child_number = intval(STInput::request('child_number', ''));
if ($child_number <= 0) {
$child_number = 0;
}
if (strtotime($check_out) - strtotime($check_in) <= 0) {
STAdmin::set_message(__('The check-out is later than the check-in.', ST_TEXTDOMAIN), 'danger');
return false;
}
$adult = intval(get_post_meta($item_id, 'rental_max_adult', true));
$children = intval(get_post_meta($item_id, 'rental_max_children', true));
if ($adult_number > $adult) {
STAdmin::set_message(__('Number of adults in the room are incorrect.', ST_TEXTDOMAIN), 'danger');
return false;
}
if ($child_number > $children) {
STAdmin::set_message(__('Number of children in the room are incorrect.', ST_TEXTDOMAIN), 'danger');
return false;
}
$today = date('m/d/Y');
$period = TravelHelper::dateDiff($today, $check_in);
$compare = TravelHelper::dateCompare($today, $check_in);
$booking_period = get_post_meta($item_id, 'rentals_booking_period', true);
if (empty($booking_period) || $booking_period <= 0) {
$booking_period = 0;
}
if ($compare < 0) {
STAdmin::set_message(__('You can not set check-in date in the past', ST_TEXTDOMAIN), 'danger');
return false;
}
if ($period < $booking_period) {
STAdmin::set_message(sprintf(__('This rental allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
return false;
}
$checkin_ymd = date('Y-m-d', strtotime($check_in));
$checkout_ymd = date('Y-m-d', strtotime($check_out));
if (!RentalHelper::check_day_cant_order($item_id, $checkin_ymd, $checkout_ymd, 1)) {
STAdmin::set_message(sprintf(__('This rental is not available from %s to %s.', ST_TEXTDOMAIN), $checkin_ymd, $checkout_ymd), 'danger');
$pass_validate = FALSE;
return false;
}
if (!RentalHelper::_check_room_available($item_id, $checkin_ymd, $checkout_ymd, 1)) {
STAdmin::set_message(__('This rental is not available.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$data = array('order_item_id' => $order_item_id, 'item_id' => $item_id, 'type' => 'normal_booking', 'check_in' => $check_in, 'check_out' => $check_out, 'st_booking_post_type' => 'st_rental', 'st_booking_id' => $item_id, 'adult_number' => $adult_number, 'child_number' => $child_number, 'room_num_search' => 1, 'check_in_timestamp' => strtotime($check_in), 'check_out_timestamp' => strtotime($check_out), 'status' => $_POST['status']);
}
return $data;
//.........这里部分代码省略.........
示例3: do_add_to_cart
function do_add_to_cart()
{
$form_validate = TRUE;
$item_id = intval(STInput::request('item_id', ''));
if ($item_id <= 0 || get_post_type($item_id) != 'st_rental') {
STTemplate::set_message(__('This rental is not available.', ST_TEXTDOMAIN), 'danger');
$form_validate = FALSE;
return false;
}
$check_in = STInput::request('start', '');
if (empty($check_in)) {
STTemplate::set_message(__('The check in field is not empty.', ST_TEXTDOMAIN), 'danger');
$form_validate = FALSE;
return false;
}
$check_in = TravelHelper::convertDateFormat($check_in);
$check_out = STInput::request('end', '');
if (empty($check_out)) {
STTemplate::set_message(__('The check out field is not empty.', ST_TEXTDOMAIN), 'danger');
$form_validate = FALSE;
return false;
}
$check_out = TravelHelper::convertDateFormat($check_out);
$today = date('m/d/Y');
$booking_period = get_post_meta($item_id, 'rentals_booking_period', true);
if (empty($booking_period) || $booking_period <= 0) {
$booking_period = 0;
}
$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');
$form_validate = FALSE;
return false;
}
if ($period < $booking_period) {
STTemplate::set_message(sprintf(__('This rental allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
$form_validate = FALSE;
return false;
}
$adult_number = intval(STInput::request('adult_number', ''));
$child_number = intval(STInput::request('child_number', ''));
$max_adult = intval(get_post_meta($item_id, 'rental_max_adult', true));
$max_children = intval(get_post_meta($item_id, 'rental_max_children', true));
if ($adult_number > $max_adult) {
STTemplate::set_message(sprintf(__('A maximum number of adult(s): %d', ST_TEXTDOMAIN), $max_adult), 'danger');
$form_validate = FALSE;
return false;
}
if ($child_number > $max_children) {
STTemplate::set_message(sprintf(__('A maximum number of children: %d', ST_TEXTDOMAIN), $max_children), 'danger');
$form_validate = FALSE;
return false;
}
$number_room = intval(get_post_meta($item_id, 'rental_number', true));
$check_in_tmp = date('Y-m-d', strtotime($check_in));
$check_out_tmp = date('Y-m-d', strtotime($check_out));
if (!RentalHelper::check_day_cant_order($item_id, $check_in_tmp, $check_out_tmp, 1)) {
STTemplate::set_message(sprintf(__('This rental is not available from %s to %s.', ST_TEXTDOMAIN), $check_in_tmp, $check_out_tmp), 'danger');
$pass_validate = FALSE;
return false;
}
if (!RentalHelper::_check_room_available($item_id, $check_in_tmp, $check_out_tmp, 1)) {
STTemplate::set_message(__('This rental is not available.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$item_price = STPrice::getRentalPriceOnlyCustomPrice($item_id, strtotime($check_in), strtotime($check_out));
$extras = STInput::request('extra_price', array());
$numberday = TravelHelper::dateDiff($check_in, $check_out);
$extra_price = STPrice::getExtraPrice($extras, 1, $numberday);
$price_sale = STPrice::getSalePrice($item_id, $item_price, strtotime($check_in), strtotime($check_out));
$discount_rate = STPrice::get_discount_rate($item_id, strtotime($check_in));
$data = array('item_price' => $item_price, 'ori_price' => $price_sale + $extra_price, 'check_in' => $check_in, 'check_out' => $check_out, 'adult_number' => $adult_number, 'child_number' => $child_number, 'extras' => $extras, 'extra_price' => $extra_price, 'commission' => TravelHelper::get_commission(), 'discount_rate' => $discount_rate);
if ($form_validate) {
$form_validate = apply_filters('st_rental_add_cart_validate', $form_validate);
}
if ($form_validate) {
STCart::add_cart($item_id, 1, $item_price, $data);
}
return $form_validate;
}
示例4: 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));
//.........这里部分代码省略.........
示例5: 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_hotel') {
STTemplate::set_message(__('This hotel is not available.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$room_id = intval(STInput::request('room_id', ''));
if ($room_id <= 0 || get_post_type($room_id) != 'hotel_room') {
STTemplate::set_message(__('This room is not available.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$check_in = STInput::request('check_in', '');
if (empty($check_in)) {
STTemplate::set_message(__('Date is invalid', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$check_in = TravelHelper::convertDateFormat($check_in);
$check_out = STInput::request('check_out', '');
if (empty($check_out)) {
STTemplate::set_message(__('Date is invalid', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$check_out = TravelHelper::convertDateFormat($check_out);
$room_num_search = intval(STInput::request('room_num_search', ''));
if ($room_num_search <= 0) {
$room_num_search = 1;
}
$adult_number = intval(STInput::request('adult_number', ''));
if ($adult_number <= 0) {
$adult_number = 1;
}
$child_number = intval(STInput::request('child_number', ''));
if ($child_number <= 0) {
$child_number = 0;
}
$checkin_ymd = date('Y-m-d', strtotime($check_in));
$checkout_ymd = date('Y-m-d', strtotime($check_out));
if (!HotelHelper::check_day_cant_order($room_id, $checkin_ymd, $checkout_ymd, $room_num_search)) {
STTemplate::set_message(sprintf(__('This room is not available from %s to %s.', ST_TEXTDOMAIN), $checkin_ymd, $checkout_ymd), 'danger');
$pass_validate = FALSE;
return false;
}
if (!HotelHelper::_check_room_available($room_id, $checkin_ymd, $checkout_ymd, $room_num_search)) {
STTemplate::set_message(__('This room is not available.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
if (strtotime($check_out) - strtotime($check_in) <= 0) {
STTemplate::set_message(__('The check-out is later than the check-in.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$num_room = intval(get_post_meta($room_id, 'number_room', true));
$adult = intval(get_post_meta($room_id, 'adult_number', true));
$children = intval(get_post_meta($room_id, 'children_number', true));
if ($room_num_search > $num_room) {
STTemplate::set_message(__('Max of rooms are incorrect.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
if ($adult_number > $adult) {
STTemplate::set_message(sprintf(__('Max of adults is %d people.', ST_TEXTDOMAIN), $adult), 'danger');
$pass_validate = FALSE;
return false;
}
if ($child_number > $children) {
STTemplate::set_message(__('Number of children in the room are incorrect.', ST_TEXTDOMAIN), 'danger');
$pass_validate = FALSE;
return false;
}
$today = date('m/d/Y');
$period = TravelHelper::dateDiff($today, $check_in);
$booking_min_day = intval(get_post_meta($item_id, 'min_book_room', true));
$compare = TravelHelper::dateCompare($today, $check_in);
$booking_period = get_post_meta($item_id, 'hotel_booking_period', true);
if (empty($booking_period) || $booking_period <= 0) {
$booking_period = 0;
}
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 ($period < $booking_period) {
STTemplate::set_message(sprintf(__('This hotel allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
$pass_validate = FALSE;
return false;
}
if ($booking_min_day and $booking_min_day > TravelHelper::dateDiff($check_in, $check_out)) {
STTemplate::set_message(sprintf(__('Please booking at least %d day(s)', ST_TEXTDOMAIN), $booking_min_day), 'danger');
$pass_validate = false;
return false;
}
$item_price = floatval(get_post_meta($room_id, 'price', true));
//.........这里部分代码省略.........
示例6: _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;
}
示例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_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;
//.........这里部分代码省略.........
示例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: do_add_to_cart
//.........这里部分代码省略.........
$check_in = date('Y-m-d H:i:s', strtotime($check_in));
$check_out = '';
$check_out_n = '';
$check_out_time = '';
if (isset($_REQUEST['drop-off-date']) && !empty($_REQUEST['drop-off-date'])) {
$check_out = TravelHelper::convertDateFormat($_REQUEST['drop-off-date']);
$check_out_n = $check_out;
}
if (isset($_REQUEST['drop-off-time']) && !empty($_REQUEST['drop-off-time'])) {
$check_out .= ' ' . $_REQUEST['drop-off-time'];
$check_out_time = $_REQUEST['drop-off-time'];
}
$check_out = date('Y-m-d H:i:s', strtotime($check_out));
$location_id_pick_up = STInput::request('location_id_pick_up', '');
$location_id_drop_off = STInput::request('location_id_drop_off', '');
if (isset($_REQUEST['location_id_pick_up']) && !empty($_REQUEST['location_id_pick_up']) && isset($_REQUEST['location_id_drop_off']) && !empty($_REQUEST['location_id_drop_off'])) {
$location_id_pick_up = intval(STInput::request('location_id_pick_up', '0'));
$location_id_drop_off = intval(STInput::request('location_id_drop_off', '0'));
$pickup_country = get_post_meta($location_id_pick_up, 'location_country', true);
$dropoff_country = get_post_meta($location_id_drop_off, 'location_country', true);
if (!$pickup_country) {
STTemplate::set_message(__('The \'country\' field not set for the \'' . get_the_title($location_id_pick_up) . '\'', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
if (!$dropoff_country) {
STTemplate::set_message(__('The \'country\' field not set for \'' . get_the_title($location_id_drop_off) . '\'', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
if ($pickup_country != $dropoff_country) {
STTemplate::set_message(__('The country is not same', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
}
$today = date('m/d/Y');
$booking_period = intval(get_post_meta($item_id, 'cars_booking_period', true));
$booking_min_day = intval(get_post_meta($item_id, 'cars_booking_min_day', true));
$booking_min_hour = intval(get_post_meta($item_id, 'cars_booking_min_hour', true));
if (empty($booking_period) || $booking_period <= 0) {
$booking_period = 0;
}
$check_in_timestamp = '';
$check_out_timestamp = '';
if (!empty($check_in_n) && !empty($check_out_n)) {
$period = TravelHelper::dateDiff($today, $check_in_n);
$compare = TravelHelper::dateCompare($today, $check_in_n);
$check_in_timestamp = strtotime($check_in);
$check_out_timestamp = strtotime($check_out);
if ($check_in_timestamp - $check_out_timestamp >= 0) {
STTemplate::set_message(__('The drop off datetime is later than the pick up datetime.', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
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 ($period < $booking_period) {
STTemplate::set_message(sprintf(__('This car allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
$pass_validate = false;
return false;
}
$unit = st()->get_option('cars_price_unit', 'day');
if ($unit == 'day' and $booking_min_day and $booking_min_day > self::get_date_diff($check_in_timestamp, $check_out_timestamp)) {
STTemplate::set_message(sprintf(__('Please booking at least %d day(s)', ST_TEXTDOMAIN), $booking_min_day), 'danger');
$pass_validate = false;
return false;
}
if ($unit == 'hour' and $booking_min_hour and $booking_min_hour > self::get_date_diff($check_in_timestamp, $check_out_timestamp)) {
STTemplate::set_message(sprintf(__('Please booking at least %d hour(s)', ST_TEXTDOMAIN), $booking_min_hour), 'danger');
$pass_validate = false;
return false;
}
}
if ($check_in_timestamp > 0 && $check_out_timestamp > 0) {
if (!CarHelper::_get_car_cant_order_by_id($item_id, $check_in_timestamp, $check_out_timestamp)) {
STTemplate::set_message(__('This car is full order', ST_TEXTDOMAIN), 'danger');
$pass_validate = false;
return false;
}
}
$selected_equipments = json_decode(str_ireplace("\\", '', STInput::request('selected_equipments', '')));
$info_price = STCars::get_info_price($item_id, strtotime($check_in), strtotime($check_out));
$price_unit = $info_price['price'];
$item_price = floatval(get_post_meta($item_id, 'cars_price', true));
$price_equipment = STPrice::getPriceEuipmentCar($selected_equipments, $check_in_timestamp, $check_out_timestamp);
$sale_price = STPrice::getSaleCarPrice($item_id, $item_price, strtotime($check_in), strtotime($check_out));
$car_sale_price = STPrice::get_car_price_by_number_of_day_or_hour($item_id, $item_price, strtotime($check_in), strtotime($check_out));
$discount_rate = STPrice::get_discount_rate($item_id, strtotime($check_in));
$numberday = $numberday = STCars::get_date_diff(strtotime($check_in), strtotime($check_out), st()->get_option('cars_price_unit', 'day'));
$data = array('check_in' => $check_in_n, 'check_out' => $check_out_n, 'check_in_time' => $check_in_time, 'check_out_time' => $check_out_time, 'check_in_timestamp' => strtotime($check_in), 'check_out_timestamp' => strtotime($check_out), 'location_id_pick_up' => $location_id_pick_up, 'location_id_drop_off' => $location_id_drop_off, 'pick_up' => get_the_title($location_id_pick_up), 'drop_off' => get_the_title($location_id_drop_off), 'ori_price' => $sale_price + $price_equipment, 'item_price' => $item_price, 'sale_price' => $car_sale_price, 'numberday' => $numberday, 'price_equipment' => $price_equipment, 'data_equipment' => $selected_equipments, 'commission' => TravelHelper::get_commission(), 'discount_rate' => $discount_rate);
$pass_validate = apply_filters('st_car_add_cart_validate', $pass_validate, $item_id, $number, $price_unit, $data);
if ($pass_validate) {
STCart::add_cart($item_id, $number, $price_equipment + $sale_price, $data);
}
return $pass_validate;
}