예제 #1
0
 function _update_duplicate_data($id, $data)
 {
     if (!TravelHelper::checkTableDuplicate('st_rental')) {
         return;
     }
     if (get_post_type($id) == 'st_rental') {
         $num_rows = TravelHelper::checkIssetPost($id, 'st_rental');
         $location_str = get_post_meta($id, 'multi_location', true);
         $location_id = '';
         // location_id
         $address = get_post_meta($id, 'address', true);
         // address
         $rentals_booking_period = get_post_meta($id, 'rentals_booking_period', true);
         // rentals_booking_period
         $rental_max_adult = get_post_meta($id, 'rental_max_adult', true);
         // rental max adult
         $rental_max_children = get_post_meta($id, 'rental_max_children', true);
         // rental max children
         $sale_price = get_post_meta($id, 'price', true);
         // sale price
         $discount = get_post_meta($id, 'discount_rate', true);
         $is_sale_schedule = get_post_meta($id, 'is_sale_schedule', true);
         if ($is_sale_schedule == 'on') {
             $sale_from = get_post_meta($id, 'sale_price_from', true);
             $sale_to = get_post_meta($id, 'sale_price_to', true);
             if ($sale_from and $sale_from) {
                 $today = date('Y-m-d');
                 $sale_from = date('Y-m-d', strtotime($sale_from));
                 $sale_to = date('Y-m-d', strtotime($sale_to));
                 if ($today >= $sale_from && $today <= $sale_to) {
                 } else {
                     $discount = 0;
                 }
             } else {
                 $discount = 0;
             }
         }
         if ($discount) {
             $sale_price = $sale_price - $sale_price / 100 * $discount;
         }
         $rate_review = STReview::get_avg_rate($id);
         // rate review
         if ($num_rows == 1) {
             $data = array('multi_location' => $location_str, 'location_id' => $location_id, 'address' => $address, 'rental_max_adult' => $rental_max_adult, 'rental_max_children' => $rental_max_children, 'rate_review' => $rate_review, 'sale_price' => $sale_price, 'rentals_booking_period' => $rentals_booking_period);
             $where = array('post_id' => $id);
             TravelHelper::updateDuplicate('st_rental', $data, $where);
         } elseif ($num_rows == 0) {
             $data = array('post_id' => $id, 'multi_location' => $location_str, 'location_id' => $location_id, 'address' => $address, 'rental_max_adult' => $rental_max_adult, 'rental_max_children' => $rental_max_children, 'rate_review' => $rate_review, 'sale_price' => $sale_price, 'rentals_booking_period' => $rentals_booking_period);
             TravelHelper::insertDuplicate('st_rental', $data);
         }
     }
 }
예제 #2
0
 function _update_duplicate_data($id, $data)
 {
     if (!TravelHelper::checkTableDuplicate('st_hotel')) {
         return;
     }
     if (get_post_type($id) == 'hotel_room') {
         $hotel_id = get_post_meta($id, 'room_parent', true);
         $price_avg = get_post_meta($hotel_id, 'price_avg', true);
         if (!$price_avg) {
             return;
         }
         $data = array('multi_location' => get_post_meta($hotel_id, 'multi_location', true), 'id_location' => get_post_meta($hotel_id, 'id_location', true), 'address' => get_post_meta($hotel_id, 'address', true), 'rate_review' => get_post_meta($hotel_id, 'rate_review', true), 'hotel_star' => get_post_meta($hotel_id, 'hotel_star', true), 'price_avg' => $price_avg, 'hotel_booking_period' => get_post_meta($hotel_id, 'hotel_booking_period', true), 'map_lat' => get_post_meta($hotel_id, 'map_lat', true), 'map_lng' => get_post_meta($hotel_id, 'map_lng', true));
         $where = array('post_id' => $hotel_id);
         TravelHelper::updateDuplicate('st_hotel', $data, $where);
     }
 }
예제 #3
0
 function _update_duplicate_data($id, $data)
 {
     if (!TravelHelper::checkTableDuplicate('st_cars')) {
         return;
     }
     if (get_post_type($id) == 'st_cars') {
         $num_rows = TravelHelper::checkIssetPost($id, 'st_cars');
         $location_str = get_post_meta($id, 'multi_location', true);
         $location_id = '';
         // location_id
         $cars_address = get_post_meta($id, 'cars_address', true);
         // address
         $cars_price = get_post_meta($id, 'cars_price', true);
         // price
         $number_car = get_post_meta($id, 'number_car', true);
         // number_car
         $cars_booking_period = get_post_meta($id, 'cars_booking_period', true);
         // cars_booking_period
         $sale_price = get_post_meta($id, 'cars_price', true);
         // sale_price
         $discount = get_post_meta($id, 'discount', true);
         $is_sale_schedule = get_post_meta($id, 'is_sale_schedule', true);
         if ($is_sale_schedule == 'on') {
             $sale_from = get_post_meta($id, 'sale_price_from', true);
             $sale_to = get_post_meta($id, 'sale_price_to', true);
             if ($sale_from and $sale_from) {
                 $today = date('Y-m-d');
                 $sale_from = date('Y-m-d', strtotime($sale_from));
                 $sale_to = date('Y-m-d', strtotime($sale_to));
                 if ($today >= $sale_from && $today <= $sale_to) {
                 } else {
                     $discount = 0;
                 }
             } else {
                 $discount = 0;
             }
         }
         if ($discount) {
             $sale_price = $sale_price - $sale_price / 100 * $discount;
         }
         if ($num_rows == 1) {
             $data = array('multi_location' => $location_str, 'id_location' => $location_id, 'cars_address' => $cars_address, 'cars_price' => $cars_price, 'sale_price' => $sale_price, 'number_car' => $number_car, 'cars_booking_period' => $cars_booking_period);
             $where = array('post_id' => $id);
             TravelHelper::updateDuplicate('st_cars', $data, $where);
         } elseif ($num_rows == 0) {
             $data = array('post_id' => $id, 'multi_location' => $location_str, 'id_location' => $location_id, 'cars_address' => $cars_address, 'cars_price' => $cars_price, 'sale_price' => $sale_price, 'number_car' => $number_car, 'cars_booking_period' => $cars_booking_period);
             TravelHelper::insertDuplicate('st_cars', $data);
         }
     }
 }
예제 #4
0
 function _update_duplicate_data($id, $data)
 {
     if (!TravelHelper::checkTableDuplicate('st_holidays')) {
         return;
     }
     if (get_post_type($id) == 'st_holidays') {
         $num_rows = TravelHelper::checkIssetPost($id, 'st_holidays');
         $location_str = get_post_meta($id, 'multi_location', true);
         $location_id = '';
         // location_id
         $address = get_post_meta($id, 'address', true);
         // address
         $max_people = get_post_meta($id, 'max_people', true);
         // maxpeople
         $check_in = get_post_meta($id, 'check_in', true);
         // check in
         $check_out = get_post_meta($id, 'check_out', true);
         // check out
         $type_holiday = get_post_meta($id, 'type_holiday', true);
         // check out
         $duration_day = get_post_meta($id, 'duration_day', true);
         // duration_day
         $holidays_booking_period = get_post_meta($id, 'holidays_booking_period', true);
         // holidays_booking_period
         $sale_price = get_post_meta($id, 'price', true);
         // sale_price
         $child_price = get_post_meta($id, 'child_price', true);
         $adult_price = get_post_meta($id, 'adult_price', true);
         $infant_price = get_post_meta($id, 'infant_price', true);
         $discount = get_post_meta($id, 'discount', true);
         $is_sale_schedule = get_post_meta($id, 'is_sale_schedule', true);
         if ($is_sale_schedule == 'on') {
             $sale_from = get_post_meta($id, 'sale_price_from', true);
             $sale_to = get_post_meta($id, 'sale_price_to', true);
             if ($sale_from and $sale_from) {
                 $today = date('Y-m-d');
                 $sale_from = date('Y-m-d', strtotime($sale_from));
                 $sale_to = date('Y-m-d', strtotime($sale_to));
                 if ($today >= $sale_from && $today <= $sale_to) {
                 } else {
                     $discount = 0;
                 }
             } else {
                 $discount = 0;
             }
         }
         if ($discount) {
             $sale_price = $sale_price - $sale_price / 100 * $discount;
             $child_price = $child_price - $child_price / 100 * $discount;
             $adult_price = $adult_price - $adult_price / 100 * $discount;
             $infant_price = $infant_price - $infant_price / 100 * $discount;
         }
         $rate_review = STReview::get_avg_rate($id);
         // rate review
         if ($num_rows == 1) {
             $data = array('multi_location' => $location_str, 'id_location' => $location_id, 'address' => $address, 'type_holiday' => $type_holiday, 'check_in' => $check_in, 'check_out' => $check_out, 'sale_price' => $sale_price, 'child_price' => $child_price, 'adult_price' => $adult_price, 'infant_price' => $infant_price, 'max_people' => $max_people, 'rate_review' => $rate_review, 'duration_day' => $duration_day, 'holidays_booking_period' => $holidays_booking_period);
             $where = array('post_id' => $id);
             TravelHelper::updateDuplicate('st_holidays', $data, $where);
         } elseif ($num_rows == 0) {
             $data = array('post_id' => $id, 'multi_location' => $location_str, 'id_location' => $location_id, 'address' => $address, 'type_holiday' => $type_holiday, 'check_in' => $check_in, 'check_out' => $check_out, 'sale_price' => $sale_price, 'child_price' => $child_price, 'adult_price' => $adult_price, 'infant_price' => $infant_price, 'max_people' => $max_people, 'rate_review' => $rate_review, 'duration_day' => $duration_day, 'holidays_booking_period' => $holidays_booking_period);
             TravelHelper::insertDuplicate('st_holidays', $data);
         }
     }
 }
예제 #5
0
 /**
  *@since 1.1.8
  **/
 function _update_duplicate_data($id, $data)
 {
     if (!TravelHelper::checkTableDuplicate('st_hotel')) {
         return;
     }
     if (get_post_type($id) == 'st_hotel') {
         $num_rows = TravelHelper::checkIssetPost($id, 'st_hotel');
         $location_str = get_post_meta($id, 'multi_location', true);
         $location_id = '';
         // location_id
         $address = get_post_meta($id, 'address', true);
         // address
         $allow_full_day = get_post_meta($id, 'allow_full_day', true);
         // address
         $rate_review = STReview::get_avg_rate($id);
         // rate review
         $hotel_star = get_post_meta($id, 'hotel_star', true);
         // hotel star
         $price_avg = get_post_meta($id, 'price_avg', true);
         // price avg
         $hotel_booking_period = get_post_meta($id, 'hotel_booking_period', true);
         // price avg
         $map_lat = get_post_meta($id, 'map_lat', true);
         // map_lat
         $map_lng = get_post_meta($id, 'map_lng', true);
         // map_lng
         if ($num_rows == 1) {
             $data = array('multi_location' => $location_str, 'id_location' => $location_id, 'address' => $address, 'allow_full_day' => $allow_full_day, 'rate_review' => $rate_review, 'hotel_star' => $hotel_star, 'price_avg' => $price_avg, 'hotel_booking_period' => $hotel_booking_period, 'map_lat' => $map_lat, 'map_lng' => $map_lng);
             $where = array('post_id' => $id);
             TravelHelper::updateDuplicate('st_hotel', $data, $where);
         } elseif ($num_rows == 0) {
             $data = array('post_id' => $id, 'multi_location' => $location_str, 'id_location' => $location_id, 'address' => $address, 'allow_full_day' => $allow_full_day, 'rate_review' => $rate_review, 'hotel_star' => $hotel_star, 'price_avg' => $price_avg, 'hotel_booking_period' => $hotel_booking_period, 'map_lat' => $map_lat, 'map_lng' => $map_lng);
             TravelHelper::insertDuplicate('st_hotel', $data);
         }
     }
 }