示例#1
0
                        $people = 0;
                        foreach ($result as $key => $date) {
                            if ($i == intval($date['check_in'])) {
                                $people += intval($date['adult_number']) + intval($date['child_number']) + intval($date['infant_number']);
                            }
                        }
                        if ($people >= $max_people) {
                            $disable[] = date(TravelHelper::getDateFormat(), $i);
                        }
                    }
                }
            }
            if (count($disable)) {
                echo json_encode($disable);
                die;
            }
            echo json_encode($disable);
            die;
        }
        static function _get_minmax($activity_id, $year)
        {
            global $wpdb;
            $activity_id = apply_filters('st_get_post_id_origin', $activity_id);
            $sql = "SELECT\r\n\t\t\tMIN(check_in_timestamp) as check_in,\r\n\t\t\tMAX(check_out_timestamp) as check_out\r\n\t\t\tFROM\r\n\t\t\t\t{$wpdb->prefix}st_order_item_meta\r\n\t\t\tWHERE\r\n\t\t\t\tst_booking_post_type = 'st_activity'\r\n\t\t\tAND status NOT IN ('trash', 'canceled')\r\n\t\t\tAND origin_id = '{$activity_id}'\r\n\t\t\tAND YEAR (\r\n\t\t\t\tFROM_UNIXTIME(check_in_timestamp)\r\n\t\t\t) = {$year}\r\n\t\t\tAND YEAR (\r\n\t\t\t\tFROM_UNIXTIME(check_out_timestamp)\r\n\t\t\t) = {$year}";
            $min_max = $wpdb->get_row($sql, ARRAY_A);
            return $min_max;
        }
    }
    $activityhelper = new ActivityHelper();
    $activityhelper->init();
}
 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;
         $data['type_activity'] = $type_activity;
         $data['adult_price'] = floatval(get_post_meta($item_id, 'adult_price', true));
         $data['child_price'] = floatval(get_post_meta($item_id, 'child_price', true));
         $data['infant_price'] = floatval(get_post_meta($item_id, 'infant_price', true));
     }
     return $data;
 }
示例#3
0
 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));
     $discount_rate = STPrice::get_discount_rate($item_id, strtotime($check_in));
     $data['adult_price'] = floatval(get_post_meta($item_id, 'adult_price', true));
     $data['child_price'] = floatval(get_post_meta($item_id, 'child_price', true));
     $data['infant_price'] = floatval(get_post_meta($item_id, 'infant_price', true));
     $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'] = $discount_rate;
     if ($pass_validate) {
         $pass_validate = apply_filters('st_activity_add_cart_validate', $pass_validate);
     }
     if ($pass_validate) {
         STCart::add_cart($item_id, $number, $sale_price, $data);
     }
     return $pass_validate;
 }
示例#4
0
<?php

$diff = $activity->getTimestamp()->getFuzzyDifference();
?>
<a href="<?php 
echo SITE_BASE;
?>
/profile/<?php 
echo $activity->getProfileId();
?>
">
  <?php 
echo $activity->getRealname();
?>
</a> <?php 
echo $diff;
echo ActivityHelper::action($activity->getType());