public function __construct() { parent::__construct(); add_action('after_switch_theme', array($this, 'redirect_after_set_up_theme')); add_action('admin_menu', array($this, 'st_create_submenu'), 11); add_action('admin_enqueue_scripts', array($this, 'add_script')); }
/** * * * @since 1.0 * */ function _save_separated_field($post_id) { if (!empty($_POST['st_custom_price_nonce'])) { if (!wp_verify_nonce($_POST['st_custom_price_nonce'], plugin_basename(__FILE__))) { return $post_id; } if (!current_user_can('edit_post', $post_id)) { return $post_id; } $price_new = STInput::request('st_price'); $price_type = STInput::request('st_price_type'); $start_date = STInput::request('st_start_date'); $end_date = STInput::request('st_end_date'); $status = STInput::request('st_status'); $priority = STInput::request('st_priority'); STAdmin::st_delete_price($post_id); if ($price_new and $start_date and $end_date) { foreach ($price_new as $k => $v) { if (!empty($v)) { STAdmin::st_add_price($post_id, $price_type[$k], $v, $start_date[$k], $end_date[$k], $status[$k], $priority[$k]); } } } } }
function __construct() { parent::__construct(); add_action('add_meta_boxes', array($this, 'add_item_metabox')); add_action('admin_enqueue_scripts', array($this, 'admin_queue_scripts')); add_action('wp_ajax_st_order_select', array($this, 'st_order_select')); add_action('wp_ajax_save_order_item', array($this, 'save_order_item')); add_action('wp_ajax_st_delete_order_item', array($this, 'st_delete_order_item')); }
/** * * * @since 1.1.1 * */ function init_metabox() { //Room $this->metabox[] = array('id' => 'room_metabox', 'title' => __('Room Setting', ST_TEXTDOMAIN), 'desc' => '', 'pages' => array('hotel_room'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('label' => __('General', ST_TEXTDOMAIN), 'id' => 'room_reneral_tab', 'type' => 'tab'), array('label' => __('Hotel', ST_TEXTDOMAIN), 'id' => 'room_parent', 'type' => 'post_select_ajax', 'desc' => __('Choose the hotel that the room belongs to', ST_TEXTDOMAIN), 'post_type' => 'st_hotel', 'placeholder' => __('Search for a Hotel', ST_TEXTDOMAIN)), array('label' => __('Number of Rooms', ST_TEXTDOMAIN), 'id' => 'number_room', 'type' => 'text', 'desc' => __('Number of rooms available for booking', ST_TEXTDOMAIN), 'std' => 1), array('label' => __('Gallery', ST_TEXTDOMAIN), 'id' => 'gallery', 'type' => 'gallery'), array('label' => __('Hotel Room Layout', ST_TEXTDOMAIN), 'id' => 'st_custom_layout', 'post_type' => 'st_layouts', 'desc' => __('Hotel Room Layout', ST_TEXTDOMAIN), 'type' => 'select', 'choices' => st_get_layout('hotel_room')), array('label' => __('Room Price', ST_TEXTDOMAIN), 'id' => 'room_price_tab', 'type' => 'tab'), array('label' => sprintf(__('Price (%s)', ST_TEXTDOMAIN), TravelHelper::get_default_currency('symbol')), 'id' => 'price', 'type' => 'text', 'desc' => __('Per night', ST_TEXTDOMAIN)), array('label' => __('Extra Price', ST_TEXTDOMAIN), 'id' => 'extra_price', 'type' => 'list-item', 'settings' => array(array('id' => 'extra_name', 'type' => 'text', 'std' => 'extra_', 'label' => __('Name of Item', ST_TEXTDOMAIN)), array('id' => 'extra_max_number', 'type' => 'text', 'std' => '', 'label' => __('Max of Number', ST_TEXTDOMAIN)), array('id' => 'extra_price', 'type' => 'text', 'std' => '', 'label' => __('Price', ST_TEXTDOMAIN), 'desc' => __('per 1 Item', ST_TEXTDOMAIN)))), array('label' => __('Discount Rate', ST_TEXTDOMAIN), 'id' => 'discount_rate', 'type' => 'text', 'desc' => __('Discount by %', ST_TEXTDOMAIN)), array('label' => __('Sale Schedule', ST_TEXTDOMAIN), 'id' => 'is_sale_schedule', 'type' => 'on-off', 'std' => 'off'), array('label' => __('Sale Price Date From', ST_TEXTDOMAIN), 'desc' => __('Sale Price Date From', ST_TEXTDOMAIN), 'id' => 'sale_price_from', 'type' => 'date-picker', 'condition' => 'is_sale_schedule:is(on)'), array('label' => __('Sale Price Date To', ST_TEXTDOMAIN), 'desc' => __('Sale Price Date To', ST_TEXTDOMAIN), 'id' => 'sale_price_to', 'type' => 'date-picker', 'condition' => 'is_sale_schedule:is(on)'), array('id' => 'deposit_payment_status', 'label' => __("Deposit payment options", ST_TEXTDOMAIN), 'desc' => __('You can select <code>Disallow Deposit</code>, <code>Deposit by percent</code>, <code>Deposit by amount</code>'), 'type' => 'select', 'choices' => array(array('value' => '', 'label' => __('Disallow Deposit', ST_TEXTDOMAIN)), array('value' => 'percent', 'label' => __('Deposit by percent', ST_TEXTDOMAIN)), array('value' => 'amount', 'label' => __('Deposit by amount', ST_TEXTDOMAIN)))), array('label' => __('Deposit payment amount', ST_TEXTDOMAIN), 'desc' => __('Leave empty for disallow deposit payment', ST_TEXTDOMAIN), 'id' => 'deposit_payment_amount', 'type' => 'text', 'condition' => 'deposit_payment_status:not()'), array('label' => __('Room Facility', ST_TEXTDOMAIN), 'id' => 'room_detail_tab', 'type' => 'tab'), array('label' => __('No. adults', ST_TEXTDOMAIN), 'id' => 'adult_number', 'type' => 'text', 'desc' => __('Number of Adults in room', ST_TEXTDOMAIN), 'std' => 1), array('label' => __('No. children', ST_TEXTDOMAIN), 'id' => 'children_number', 'type' => 'text', 'desc' => __('Number of Children in room', ST_TEXTDOMAIN), 'std' => 0), array('label' => __('No. beds', ST_TEXTDOMAIN), 'id' => 'bed_number', 'type' => 'text', 'desc' => __('Number of Beds in room', ST_TEXTDOMAIN), 'std' => 0), array('label' => __('Room footage (square feet)', ST_TEXTDOMAIN), 'desc' => __('Room footage (square feet)', ST_TEXTDOMAIN), 'id' => 'room_footage', 'type' => 'text'), array('label' => __('Room external booking', ST_TEXTDOMAIN), 'id' => 'st_room_external_booking', 'type' => 'on-off', 'std' => "off"), array('label' => __('Room external booking', ST_TEXTDOMAIN), 'id' => 'st_room_external_booking_link', 'type' => 'text', 'std' => "", 'condition' => 'st_room_external_booking:is(on)', 'desc' => "<em>" . __('Notice: Must be http://...', ST_TEXTDOMAIN) . "</em>"), array('label' => __('Other facility', ST_TEXTDOMAIN), 'id' => 'other_facility', 'type' => 'tab'), array('label' => __('Add a facility', ST_TEXTDOMAIN), 'id' => 'add_new_facility', 'type' => 'list-item', 'settings' => array(array('id' => 'facility_value', 'type' => 'text', 'std' => '', 'label' => __('Value', ST_TEXTDOMAIN)), array('id' => 'facility_icon', 'type' => 'text', 'std' => '', 'label' => __('Icon', ST_TEXTDOMAIN), 'desc' => __('Support: fonticon <code>(eg: fa-facebook)</code>', ST_TEXTDOMAIN)))), array('label' => __('Description', ST_TEXTDOMAIN), 'id' => 'room_description', 'type' => 'textarea', 'std' => ''), array('label' => __('Availability', ST_TEXTDOMAIN), 'id' => 'availability_tab', 'type' => 'tab'), array('label' => __("Default State", ST_TEXTDOMAIN), 'id' => 'default_state', 'type' => 'select', 'choices' => array(array('value' => "available", 'label' => __("Available", ST_TEXTDOMAIN)), array('value' => "not_available", 'label' => __("Not Available", ST_TEXTDOMAIN)))), array('label' => __('Hotel Calendar', ST_TEXTDOMAIN), 'id' => 'st_hotel_calendar', 'type' => 'st_hotel_calendar'))); $data_paypment = STPaymentGateways::get_payment_gateways(); if (!empty($data_paypment) and is_array($data_paypment)) { $this->metabox[0]['fields'][] = array('label' => __('Payment', ST_TEXTDOMAIN), 'id' => 'payment_detail_tab', 'type' => 'tab'); foreach ($data_paypment as $k => $v) { $this->metabox[0]['fields'][] = array('label' => $v->get_name(), 'id' => 'is_meta_payment_gateway_' . $k, 'type' => 'on-off', 'desc' => $v->get_name(), 'std' => 'on'); } } parent::register_metabox($this->metabox); }
/* verify a description */ $has_desc = $field_desc ? TRUE : FALSE; echo '<div class="format-setting type-post_select_ajax ' . ($has_desc ? 'has-desc' : 'no-desc') . '">'; /* description */ echo $has_desc ? '<div class="description">' . htmlspecialchars_decode($field_desc) . '</div>' : ''; /* format setting inner wrapper */ echo '<div class="format-setting-inner">'; /* allow fields to be filtered */ echo '<div class="option-tree-ui-' . $type . '-input-wrap">'; ?> <input type="hidden" name="st_custom_price_nonce" value="<?php echo esc_attr($st_custom_price_nonce); ?> "/> <?php $data = STAdmin::st_get_all_price($post_id); ?> <div class="data_price"> <?php if (!empty($data) and is_array($data)) { ?> <?php foreach ($data as $k => $v) { $id_rand = rand(); ?> <div class="item"> <div class="data"> <div class="form"> <label ><?php _e("Price:", ST_TEXTDOMAIN); ?>
* * Created by ShineTheme * */ ?> <div class="st-create"> <h2><?php _e("Cars Bookings"); ?> </h2> </div> <?php $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $limit = 10; $offset = ($paged - 1) * $limit; $data_post = STAdmin::get_history_bookings('st_cars', $offset, $limit, $data->ID); $posts = $data_post['rows']; $total = ceil($data_post['total'] / $limit); ?> <table class="table table-bordered table-striped table-booking-history"> <thead> <tr> <th><?php _e("STT", ST_TEXTDOMAIN); ?> </th> <th><?php _e("Customer", ST_TEXTDOMAIN); ?> </th>
function st_insert_post_type_room() { if (!empty($_REQUEST['btn_insert_post_type_room'])) { if (wp_verify_nonce($_REQUEST['st_insert_room'], 'user_setting')) { if (st()->get_option('partner_post_by_admin', 'on') == 'on') { $post_status = 'draft'; } else { $post_status = 'publish'; } $current_user = wp_get_current_user(); $title = $_REQUEST['title']; $st_content = $_REQUEST['st_content']; $my_post = array('post_title' => $title, 'post_content' => $st_content, 'post_status' => $post_status, 'post_author' => $current_user->ID, 'post_type' => 'hotel_room', 'post_excerpt' => $_REQUEST['desc']); $id_post = wp_insert_post($my_post); wp_set_post_terms($id_post, $_REQUEST['id_category'], 'room_type'); if (!empty($id_post)) { $featured_image = $_FILES['featured-image']; // set featured_image $id_featured_image = self::upload_image_return($featured_image, 'featured-image', $featured_image['type']); set_post_thumbnail($id_post, $id_featured_image); update_post_meta($id_post, 'room_parent', $_REQUEST['room_parent']); update_post_meta($id_post, 'number_room', $_REQUEST['number_room']); update_post_meta($id_post, 'price', $_REQUEST['price']); update_post_meta($id_post, 'discount_rate', $_REQUEST['discount_rate']); update_post_meta($id_post, 'adult_number', $_REQUEST['adult_number']); update_post_meta($id_post, 'children_number', $_REQUEST['children_number']); update_post_meta($id_post, 'bed_number', $_REQUEST['bed_number']); update_post_meta($id_post, 'room_footage', $_REQUEST['room_footage']); if (!empty($_REQUEST['taxonomy'])) { $taxonomy = $_REQUEST['taxonomy']; if (!empty($taxonomy)) { foreach ($taxonomy as $k => $v) { $tmp = explode(",", $v); $term = get_term($tmp[0], $tmp[1]); $ids = array(); $term_up = get_the_terms($id_post, $tmp[1]); if (!empty($term_up)) { foreach ($term_up as $key => $value) { array_push($ids, $value->term_id); } } array_push($ids, $term->term_taxonomy_id); wp_set_post_terms($id_post, $ids, $tmp[1]); } } } if (!empty($_REQUEST['st_price'])) { $price_new = $_REQUEST['st_price']; $price_type = $_REQUEST['st_price_type']; $start_date = $_REQUEST['st_start_date']; $end_date = $_REQUEST['st_end_date']; $status = $_REQUEST['st_status']; $priority = $_REQUEST['st_priority']; STAdmin::st_delete_price($id_post); if ($price_new and $start_date and $end_date) { foreach ($price_new as $k => $v) { if (!empty($v)) { STAdmin::st_add_price($id_post, $price_type[$k], $v, $start_date[$k], $end_date[$k], $status[$k], $priority[$k]); } } } } self::_update_content_meta_box($_REQUEST['room_parent']); self::$msg = array('status' => 'success', 'msg' => 'Create room successfully !'); } else { self::$msg = array('status' => 'danger', 'msg' => 'Error : Create room not successfully !'); } } } }
static function set_message($message, $type = '') { self::$message = $message; self::$message_type = $type; }
function __construct() { parent::__construct(); }
/** *@since 1.1.3 **/ public function init_metabox() { $this->metabox[] = array('id' => 'rental_room_metabox', 'title' => __('Room Setting', ST_TEXTDOMAIN), 'desc' => '', 'pages' => array('rental_room'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('label' => __('General', ST_TEXTDOMAIN), 'id' => 'room_reneral_tab', 'type' => 'tab'), array('label' => __('Rental', ST_TEXTDOMAIN), 'id' => 'room_parent', 'type' => 'post_select_ajax', 'desc' => __('Choose the rental that the room belongs to', ST_TEXTDOMAIN), 'post_type' => 'st_rental', 'placeholder' => __('Search for a Rental', ST_TEXTDOMAIN)), array('label' => __('Gallery', ST_TEXTDOMAIN), 'id' => 'gallery', 'type' => 'gallery'), array('label' => __('Rental Room Layout', ST_TEXTDOMAIN), 'id' => 'st_custom_layout', 'post_type' => 'st_layouts', 'desc' => __('Rental Room Layout', ST_TEXTDOMAIN), 'type' => 'select', 'choices' => st_get_layout('rental_room')), array('label' => __('Room Facility', ST_TEXTDOMAIN), 'id' => 'rental_facility', 'type' => 'tab'), array('label' => __('No. Adults', ST_TEXTDOMAIN), 'id' => 'adult_number', 'type' => 'text', 'desc' => __('Number of Adults in room', ST_TEXTDOMAIN), 'std' => '1'), array('label' => __('No. Children', ST_TEXTDOMAIN), 'id' => 'children_number', 'type' => 'text', 'desc' => __('Number of Children in room', ST_TEXTDOMAIN), 'std' => '0'), array('label' => __('No. Beds', ST_TEXTDOMAIN), 'id' => 'bed_number', 'type' => 'text', 'desc' => __('Number of Beds in room', ST_TEXTDOMAIN), 'std' => '0'), array('label' => __('Room footage (square feet)', ST_TEXTDOMAIN), 'desc' => __('Room footage (square feet)', ST_TEXTDOMAIN), 'id' => 'room_footage', 'type' => 'text'), array('label' => __('Add a custom facility', ST_TEXTDOMAIN), 'id' => 'add_new_facility', 'type' => 'list-item', 'settings' => array(array('id' => 'value', 'type' => 'text', 'std' => '', 'label' => __('Value', ST_TEXTDOMAIN)), array('id' => 'facility_icon', 'type' => 'text', 'std' => '', 'label' => __('Icon', ST_TEXTDOMAIN), 'desc' => __('Support: fonticon <code>(eg: fa-facebook)</code>', ST_TEXTDOMAIN)))), array('label' => __('Description', ST_TEXTDOMAIN), 'id' => 'room_description', 'type' => 'textarea', 'std' => ''))); parent::register_metabox($this->metabox); }
function _save_booking($order_id) { if (!check_admin_referer('shb_action', 'shb_field')) { die; } //Update Order $orderitem = array('item_number' => '', 'item_id' => '', 'item_price' => '', 'check_in' => '', 'check_in_time' => '', 'check_out' => '', 'check_out_time' => '', 'item_equipment' => '', 'pick_up' => '', 'drop_off' => '', 'driver_age' => '', 'driver_name' => ''); $data = wp_parse_args($_POST, $orderitem); foreach ($orderitem as $val) { if ($val == 'check_in' or $val == 'check_out') { update_post_meta($order_id, $val, date('Y-m-d', strtotime($data[$val]))); } else { if ($val == 'item_equipment') { $items = $data[$val]; $list_items = array(); if (!empty($items)) { foreach ($items as $k => $v) { $tmp = explode("|", $v); $list_items[$tmp[1]] = $tmp[0]; } } update_post_meta($order_id, $val, json_encode($list_items)); } else { if (isset($data[$val])) { update_post_meta($order_id, $val, $data[$val]); } } } } //Update User $order_parent = $order_id; $id_user = isset($_POST['id_user']) ? $_POST['id_user'] : FALSE; if ($order_parent and $id_user) { update_post_meta($order_parent, 'id_user', $id_user); } $check_out_field = STCart::get_checkout_fields(); if (!empty($check_out_field)) { foreach ($check_out_field as $field_name => $field_desc) { update_post_meta($order_id, $field_name, STInput::post($field_name)); } } $user_fields = array('status' => '', 'st_tax' => ''); $data = wp_parse_args($_POST, $user_fields); if ($order_parent) { foreach ($user_fields as $val => $value) { update_post_meta($order_parent, $val, $data[$val]); } } STAdmin::set_message('Update Success', 'updated'); }
/** *@since 1.1.3 **/ public function init_metabox() { $this->metabox[] = array('id' => 'rental_room_metabox', 'title' => __('Room Setting', ST_TEXTDOMAIN), 'desc' => '', 'pages' => array('rental_room'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('label' => __('General', ST_TEXTDOMAIN), 'id' => 'room_reneral_tab', 'type' => 'tab'), array('label' => __('Rental', ST_TEXTDOMAIN), 'id' => 'room_parent', 'type' => 'post_select_ajax', 'desc' => __('Choose the rental that the room belong', ST_TEXTDOMAIN), 'post_type' => 'st_rental', 'placeholder' => __('Search for a Rental', ST_TEXTDOMAIN)), array('label' => __('Gallery', ST_TEXTDOMAIN), 'id' => 'gallery', 'type' => 'gallery'), array('label' => __('Rental Room Layout', ST_TEXTDOMAIN), 'id' => 'st_custom_layout', 'post_type' => 'st_layouts', 'desc' => __('Rental Room Layout', ST_TEXTDOMAIN), 'type' => 'select', 'choices' => st_get_layout('rental_room')))); parent::register_metabox($this->metabox); }
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; }
function _save_booking($order_id) { if (!check_admin_referer('shb_action', 'shb_field')) { die('shb_action'); } //Update Order $orderitem = array('item_number', 'item_id', 'item_price', 'check_in', 'check_out'); $data = wp_parse_args($_POST, $orderitem); foreach ($orderitem as $val) { if ($val == 'check_in' or $val == 'check_out') { update_post_meta($order_id, $val, date('Y-m-d', strtotime($data[$val]))); } else { update_post_meta($order_id, $val, $data[$val]); } } //Update User $order_parent = $order_id; $id_user = isset($_POST['id_user']) ? $_POST['id_user'] : false; if ($order_parent and $id_user) { update_post_meta($order_parent, 'id_user', $id_user); } $check_out_field = STCart::get_checkout_fields(); if (!empty($check_out_field)) { foreach ($check_out_field as $field_name => $field_desc) { update_post_meta($order_id, $field_name, STInput::post($field_name)); } } $user_fields = array('status' => '', 'st_tax' => ''); $data = wp_parse_args($_POST, $user_fields); if ($order_parent) { foreach ($user_fields as $val => $value) { update_post_meta($order_parent, $val, $data[$val]); } } STAdmin::set_message('Update Success', 'updated'); }
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; return false; } $data = array('order_item_id' => $order_item_id, 'item_id' => $item_id, 'location_id_pick_up' => $pick_up, 'location_id_drop_off' => $drop_off, 'check_in' => date('Y-m-d', strtotime($check_in)), 'check_out' => date('Y-m-d', strtotime($check_out)), 'check_in_timestamp' => $check_in_timestamp, 'check_out_timestamp' => $check_out_timestamp, 'st_booking_post_type' => 'st_cars', 'st_booking_id' => $item_id, 'check_in_time' => $check_in_time, 'check_out_time' => $check_out_time); } return $data; }
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; }
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; }
//query_posts($arg); $page = isset($_GET['paged']) ? $_GET['paged'] : 1; $limit = 20; $offset = ($page - 1) * $limit; $data = STAdmin::get_history_bookings('st_rental', $offset, $limit); $posts = $data['rows']; $total = ceil($data['total'] / $limit); global $wp_query; $paging = array(); $paging['base'] = admin_url('edit.php?post_type=st_rental&page=st_rental_booking%_%'); $paging['format'] = '&paged=%#%'; $paging['total'] = $total; $paging['current'] = $page; echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>'; echo '<h2>' . __('Rental Booking', ST_TEXTDOMAIN) . '<a href="' . admin_url('edit.php?post_type=st_rental&page=st_rental_booking§ion=add_booking') . '" class="add-new-h2">' . __('Add New', ST_TEXTDOMAIN) . '</a></h2>'; STAdmin::message(); ?> <form id="posts-filter" action="<?php echo admin_url('edit.php?post_type=st_rental&page=st_rental_booking'); ?> " method="get"> <input type="hidden" name="post_type" value="st_rental"> <input type="hidden" name="page" value="st_rental_booking"> <div class="wp-filter st-wp-filter"> <div class="filter-items"> <div class="alignleft actions"> <input type="text" class="st_datepicker" format="mm/dd/yyyy" name="st_date_start" placeholder="<?php _e('Filter by Date from', ST_TEXTDOMAIN); ?>
echo esc_html(TravelHelper::format_money($v['price'])); ?> </td> </tr> <?php } ?> </table> </div> <?php } } if ($is_custom_price == 'price_by_date') { ?> <?php $data_price = STAdmin::st_get_all_price(get_the_ID()); $format = TravelHelper::getDateFormat(); if (!empty($data_price)) { ?> <div class="table-responsive"> <table class="table table-bordered"> <tr> <th><?php _e("#", ST_TEXTDOMAIN); ?> </th> <th><?php _e("Date Start", ST_TEXTDOMAIN); ?> </th> <th><?php