function page() { global $booking_settings; // get booking settings $opt_s = $booking_settings->get_settings(); ?> <div class="headline_area"> <h1 class="title"><?php the_title(); ?> </h1> </div> <div class="wrapper"> <div class="row"> <div class="filter fil-1 col-md-6"> <label for="car_type"><?php _e('Type:', 'bizzthemes'); ?> </label> <select id="car_type" class="form-control car_type"> <option value="-1"><?php _e('Any', 'bizzthemes'); ?> </option> <?php $type_terms = get_terms('bizz_cars_type', array('hide_empty' => 0)); $type_options = array(); foreach ($type_terms as $type_term) { echo '<option value="' . $type_term->slug . '">' . $type_term->name . '</option>'; } ?> </select> </div> <div class="filter fil-3 col-md-6"> <label for="car_sort"><?php _e('Sort:', 'bizzthemes'); ?> </label> <select id="car_sort" class="form-control car_sort"> <option value="-1"><?php _e('Latest first', 'bizzthemes'); ?> </option> <option value="price-low" <?php selected($opt_s['vehicle_sort'], 'price-asc'); ?> ><?php _e('Price: low to high', 'bizzthemes'); ?> </option> <option value="price-high" <?php selected($opt_s['vehicle_sort'], 'price-desc'); ?> ><?php _e('Price: high to low', 'bizzthemes'); ?> </option> <option value="name-asc" <?php selected($opt_s['vehicle_sort'], 'name-asc'); ?> ><?php _e('Name: ascending', 'bizzthemes'); ?> </option> <option value="name-desc" <?php selected($opt_s['vehicle_sort'], 'name-desc'); ?> ><?php _e('Name: descending', 'bizzthemes'); ?> </option> </select> </div> </div> <ul id="car_list" class="templatelist clist"> <?php // car posts $args = apply_filters('bizz_car_return', array('post_type' => 'bizz_cars', 'numberposts' => -1, 'suppress_filters' => false)); $car_posts = get_posts($args); // pricing posts $args = array('post_type' => 'bizz_pricing', 'numberposts' => -1, 'fields' => 'ids', 'suppress_filters' => false); $pricing_posts = get_posts($args); $car_options["cars"] = array(); foreach ($car_posts as $car_post) { $custom = get_post_custom($car_post->ID); $car_img = isset($custom["bizzthemes_car_image"][0]) ? $custom["bizzthemes_car_image"][0] : get_template_directory_uri() . '/lib_theme/images/no-img.jpg'; // from $price_from = '<span class="from">' . __('from', 'bizzthemes') . '</span>'; // range $price_range = isset($opt_s['pay_pricerange']) && $opt_s['pay_pricerange'] == 'perhour' ? __('per hour', 'bizzthemes') : __('per day', 'bizzthemes'); $price_range = '<span class="range">' . $price_range . '</span>'; // pricing $pricing = array(); $car_pricing = get_post_meta($car_post->ID, 'bizzthemes_car_pricing', true); foreach ($pricing_posts as $post_id) { $post_custom = get_post_custom($post_id); $queried_post = get_post($post_id); // skip other car types if ($car_pricing && !in_array($queried_post->post_name, $car_pricing)) { continue; } else { if (!$car_pricing && isset($post_custom['bizzthemes_price_type'][0]) && $custom["bizzthemes_car_type"][0] != $post_custom['bizzthemes_price_type'][0]) { continue; } } $post_price = currencystr_to_float($post_custom['bizzthemes_price_daily'][0], $opt_s); $pricing[] = $post_price; } if (!empty($pricing)) { // tax percentage $tax_percentage = isset($opt_s['pay_tax']) ? currencystr_to_float($opt_s['pay_tax'], $opt_s) / 100 : 1; $pricing = min($pricing); #take lowest $pricing = $pricing + $pricing * $tax_percentage; $price = $price_from . '<br/>' . float_to_currencystr($pricing, true, $opt_s) . '<br/>' . $price_range; } else { $pricing = ''; $price = ''; } // build car options array $car_options["cars"][] = array('id' => $car_post->ID, 'post_name' => $car_post->post_name, 'name' => $car_post->post_title, 'description' => do_shortcode($custom["bizzthemes_car_description"][0]), 'edit' => get_edit_post_link($car_post->ID), 'picture_src' => $car_img, 'type' => $custom["bizzthemes_car_type"], 'currency' => get_bizz_currency($opt_s['pay_currency']), 'cost' => $price == "" ? 'not-set' : $price, 'cost_val' => $pricing == "" ? 'not-set' : $pricing, 'availability' => true, 'equipment' => array('seats' => $custom["bizzthemes_car_seats"][0], 'doors' => $custom["bizzthemes_car_doors"][0], 'transmission' => $custom["bizzthemes_car_transmission"][0])); } // sort the same as on booking widget $car_options["cars"] = apply_filters('bizz_car_sort', bizz_list_sort($car_options["cars"], 'availability'), $car_options["cars"]); foreach ($car_options["cars"] as $car_post) { ?> <li class="clearfix" id="li_car_<?php echo $car_post['id']; ?> "> <div class="data_wrapper"> <div class="picture left"> <img class="car_image img-polaroid" src="<?php echo $car_post['picture_src']; ?> " width="100" alt="" /> </div> <div class="details clearfix"> <h2 class="car_name"><?php echo $car_post['name']; ?> iii</h2> <input type="hidden" class="car_id" value="<?php echo $car_post['id']; ?> " /> <input type="hidden" class="car_type" value="<?php echo implode(",", $car_post["type"]); ?> " /> <input type="hidden" class="car_transmission" value="<?php echo $car_post["equipment"]["transmission"]; ?> " /> <input type="hidden" class="car_val" value="<?php echo $car_post['cost_val']; ?> " /> <ul class="car_properties"> <li class="seats"><span class="eq_value"><?php echo $car_post["equipment"]["seats"]; ?> </span></li> <li class="doors"><span class="eq_value"><?php echo $car_post["equipment"]["doors"]; ?> </span></li> <li class="transmission"><span class="eq_value"><?php echo $car_post["equipment"]["transmission"]; ?> </span></li> </ul> <a href="#" class="toggled car_details"><?php _e('Details', 'bizzthemes'); ?> </a> <?php if (current_user_can('manage_options')) { ?> <a href="<?php echo get_edit_post_link($car_post['id']); ?> " class="car_edit"><?php _e('(Edit)', 'bizzthemes'); ?> </a> <?php } ?> <div class="car_details_tooltip"><?php echo wpautop($car_post["description"]); ?> </div> </div> </div> <div class="price_wrapper"> <!-- Button to trigger modal --> <button data-target="#bookingmodal" role="button" class="btn btn-danger btn-bookingmodal" data-toggle="modal"><?php _e('Book Now', 'bizzthemes'); ?> </button> <span class="car_price"><?php echo $car_post['cost']; ?> </span> </div> </li> <?php } ?> </ul> </div> <?php }
function add_bizz_cars_extra_column($value, $column, $term_id) { switch ($column) { case 'price': global $booking_settings; // get booking settings $opt_s = $booking_settings->get_settings(); $term_price = get_option('taxonomy_' . $term_id . '_bizz_extra_price'); if ($term_price == '-') { _e('Free', 'bizzthemes'); } else { echo get_bizz_currency($opt_s['pay_currency']) . $term_price; } break; case 'range': global $booking_settings; // get booking settings $opt_s = $booking_settings->get_settings(); $term_range = get_option('taxonomy_' . $term_id . '_bizz_extra_price_s'); $day_hour = isset($opt_s['pay_pricerange']) && $opt_s['pay_pricerange'] == 'perhour' ? __('per hour', 'bizzthemes') : __('per day', 'bizzthemes'); $term_range = $term_range == 'rental' ? __('per rental', 'bizzthemes') : $day_hour; echo $term_range; break; case 'image': $term_img = get_option('taxonomy_' . $term_id . '_bizz_extra_image'); echo '<a href="' . $term_img . '"><img height="75" alt="" src="' . $term_img . '"></a>'; break; } }
function bizz_pricing_metaboxes($meta_boxes) { global $booking_settings; $prefix = 'bizzthemes_'; $opt_s = $booking_settings->get_settings(); $price_range = isset($opt_s['pay_pricerange']) && $opt_s['pay_pricerange'] == 'perhour' ? __('per hour', 'bizzthemes') : __('per day', 'bizzthemes'); // type $type_terms = get_terms('bizz_cars_type', array('hide_empty' => 0)); $type_options = array(); foreach ($type_terms as $type_term) { $type_options[] = array('name' => $type_term->name, 'value' => $type_term->slug); } $meta_boxes[] = array('id' => 'bizzthemes_pricing_meta', 'title' => __('Price Details', 'bizzthemes'), 'pages' => array('bizz_pricing'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => __('Range', 'bizzthemes'), 'id' => $prefix . 'price_range', 'from_default' => '1', 'to_default' => '1095', 'desc_from' => __('From', 'bizzthemes'), 'desc_to' => __('To (including)', 'bizzthemes'), 'type' => 'days_range'), array('name' => __('Season (optional)', 'bizzthemes'), 'id' => $prefix . 'price_season', 'desc_from' => __('From', 'bizzthemes'), 'desc_to' => __('To (including)', 'bizzthemes'), 'type' => 'calendar_range'), array('name' => __('Price', 'bizzthemes'), 'desc' => $price_range, 'id' => $prefix . 'price_daily', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'text_money'), array('name' => __('Car dealer', 'bizzthemes'), 'id' => $prefix . 'price_dealer', 'type' => 'text_small', 'std' => get_current_user_id()))); return $meta_boxes; }
function bizz_bookings_metaboxes($meta_boxes) { global $post, $booking_settings; $prefix = 'bizzthemes_'; $opt_s = $booking_settings->get_settings(); // cars $car_args = array('post_type' => 'bizz_cars', 'numberposts' => -1); $car_posts = get_posts($car_args); $car_options = array(); $car_options[0] = array('name' => __('-- Select --', 'bizzthemes'), 'value' => ''); if ($car_posts) { foreach ($car_posts as $car_post) { $car_options[] = array('name' => $car_post->post_title, 'value' => $car_post->ID); } } // count for ($i = 1; $i <= 20; $i++) { $car_count[] = array('name' => $i, 'value' => $i); } // locations $location_posts = get_posts(array('post_type' => 'bizz_locations', 'numberposts' => -1)); $location_options = array(); $location_options[0] = array('name' => __('-- Select --', 'bizzthemes'), 'value' => ''); foreach ($location_posts as $location_post) { $location_options[] = array('name' => $location_post->post_title, 'value' => $location_post->ID); } // months $months = array(); $months[0] = array('name' => __('-- Select --', 'bizzthemes'), 'value' => ''); for ($i = 1; $i <= 12; $i++) { $months[] = array('name' => date("F", mktime(0, 0, 0, $i, 10)), 'value' => $i); } // years $years = array(); $current_year = date("Y"); $start_year = $current_year - 5; $final_year = $start_year + 16; $years[0] = array('name' => __('-- Select --', 'bizzthemes'), 'value' => ''); for ($i = $start_year; $i <= $final_year; $i++) { $years[] = array('name' => $i, 'value' => $i); } $meta_boxes[] = array('id' => 'bizzthemes_bookings_status', 'title' => __('Booking Status', 'bizzthemes'), 'pages' => array('bizz_bookings'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => __('Status', 'bizzthemes'), 'desc' => __('Updating booking status will automatically send email notification to the customer.', 'bizzthemes'), 'id' => $prefix . 'bookings_status', 'type' => 'select', 'options' => array(array('name' => __('Pending', 'bizzthemes'), 'value' => 'pending'), array('name' => __('Approved', 'bizzthemes'), 'value' => 'approved'), array('name' => __('Cancelled', 'bizzthemes'), 'value' => 'cancelled'), array('name' => __('Refunded', 'bizzthemes'), 'value' => 'refunded'))), array('name' => __('Tracking ID', 'bizzthemes'), 'desc' => __('Tracking number for this booking. Same as post ID.', 'bizzthemes'), 'id' => $prefix . 'bookings_track', 'type' => 'text_small'))); $meta_boxes[] = array('id' => 'bizzthemes_bookings_car', 'title' => __('Vehicle and Extras', 'bizzthemes'), 'pages' => array('bizz_bookings'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => __('Vehicle', 'bizzthemes'), 'id' => $prefix . 'bookings_car', 'type' => 'select', 'options' => $car_options), array('name' => __('Quantity', 'bizzthemes'), 'id' => $prefix . 'bookings_car_count', 'type' => 'select', 'options' => $car_count), array('name' => '<a href="edit-tags.php?taxonomy=bizz_cars_extra&post_type=bizz_bookings">' . __('Vehicle Extras', 'bizzthemes') . '</a>', 'desc' => '<a href="edit-tags.php?taxonomy=bizz_cars_extra&post_type=bizz_bookings">' . __('Add more', 'bizzthemes') . '</a>', 'id' => $prefix . 'bookings_extras', 'multiple' => true, 'std' => '1', 'type' => 'extras'), array('name' => __('Coupon Code', 'bizzthemes'), 'desc' => __('Coupon code, used with this purchase.', 'bizzthemes'), 'id' => $prefix . 'bookings_coupon', 'type' => 'text_small'))); $meta_boxes[] = array('id' => 'bizzthemes_bookings_date', 'title' => __('Date and Location', 'bizzthemes'), 'pages' => array('bizz_bookings'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => __('Pickup Location', 'bizzthemes'), 'id' => $prefix . 'bookings_pickup', 'type' => 'location_select', 'options' => $location_options), array('name' => __('Return Location', 'bizzthemes'), 'id' => $prefix . 'bookings_return', 'type' => 'location_select', 'options' => $location_options), array('name' => __('Start Date', 'bizzthemes'), 'id' => $prefix . 'bookings_date1', 'type' => 'date_time'), array('name' => __('Return Date', 'bizzthemes'), 'id' => $prefix . 'bookings_date2', 'type' => 'date_time'), array('name' => __('Flight Number', 'bizzthemes'), 'desc' => __('If available, include both the carrier code and the flight number, like BA2244. This is vital to ensure your vehicle is available if your flight is delayed.', 'bizzthemes'), 'id' => $prefix . 'bookings_flight', 'type' => 'text_small'))); $meta_boxes[] = array('id' => 'bizzthemes_bookings_customer', 'title' => __('Customer Details', 'bizzthemes'), 'pages' => array('bizz_bookings'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => __('Customer Title', 'bizzthemes'), 'id' => $prefix . 'bookings_ctitle', 'type' => 'select', 'options' => array(array('name' => __('Mr', 'bizzthemes'), 'value' => 'mr'), array('name' => __('Mrs', 'bizzthemes'), 'value' => 'mrs'), array('name' => __('Miss', 'bizzthemes'), 'value' => 'miss'), array('name' => __('Dr', 'bizzthemes'), 'value' => 'dr'), array('name' => __('Prof', 'bizzthemes'), 'value' => 'prof'), array('name' => __('Rev', 'bizzthemes'), 'value' => 'rev'))), array('name' => __('First Name', 'bizzthemes'), 'id' => $prefix . 'bookings_fname', 'type' => 'text_medium'), array('name' => __('Last Name', 'bizzthemes'), 'id' => $prefix . 'bookings_lname', 'type' => 'text_medium'), array('name' => __('Email', 'bizzthemes'), 'id' => $prefix . 'bookings_email', 'type' => 'text_medium'), array('name' => __('Phone', 'bizzthemes'), 'id' => $prefix . 'bookings_phone', 'type' => 'text_medium'), array('name' => __('Contact Option', 'bizzthemes'), 'id' => $prefix . 'bookings_scontact', 'type' => 'select', 'options' => array(array('name' => __('Email', 'bizzthemes'), 'value' => 'email'), array('name' => __('Phone (SMS)', 'bizzthemes'), 'value' => 'sms'), array('name' => __('Phone (Call)', 'bizzthemes'), 'value' => 'call'))), array('name' => __('Address', 'bizzthemes'), 'id' => $prefix . 'bookings_address', 'type' => 'text_medium'), array('name' => __('Postcode/ZIP', 'bizzthemes'), 'id' => $prefix . 'bookings_zip', 'type' => 'text_medium'), array('name' => __('City', 'bizzthemes'), 'id' => $prefix . 'bookings_city', 'type' => 'text_medium'), array('name' => __('State/Province', 'bizzthemes'), 'id' => $prefix . 'bookings_state', 'type' => 'text_medium'), array('name' => __('Country', 'bizzthemes'), 'id' => $prefix . 'bookings_country', 'type' => 'select', 'options' => bizz_country_list()), array('name' => __('Age of Driver', 'bizzthemes'), 'id' => $prefix . 'bookings_driver_age', 'type' => 'text_medium'), array('name' => __('Date of Birth', 'bizzthemes'), 'id' => $prefix . 'bookings_driver_birth', 'type' => 'text_medium'), array('name' => __('Driving Licence Number', 'bizzthemes'), 'id' => $prefix . 'bookings_driver_license', 'type' => 'text_medium'), array('name' => __('Country / State of issue', 'bizzthemes'), 'id' => $prefix . 'bookings_driver_country', 'type' => 'text_medium'), array('name' => __('Issue Date', 'bizzthemes'), 'id' => $prefix . 'bookings_driver_issue', 'type' => 'text_medium'), array('name' => __('Expiry Date', 'bizzthemes'), 'id' => $prefix . 'bookings_driver_expiry', 'type' => 'text_medium'), array('name' => __('Accidents, claims or motoring convictions over the past 3 years?', 'bizzthemes'), 'id' => $prefix . 'bookings_driver_accidents', 'type' => 'select', 'options' => array(array('name' => __('No', 'bizzthemes'), 'value' => 'noe'), array('name' => __('Yes (please provide details in Comments box below)', 'bizzthemes'), 'value' => 'yes'))), array('name' => __('Number of Passengers', 'bizzthemes'), 'id' => $prefix . 'bookings_number_passengers', 'type' => 'text_medium'), array('name' => __('Comments/Questions', 'bizzthemes'), 'id' => $prefix . 'bookings_comm_que', 'type' => 'textarea', 'options' => array('textarea_rows' => 5)))); $meta_boxes[] = array('id' => 'bizzthemes_bookings_invoice', 'title' => __('Invoice', 'bizzthemes'), 'pages' => array('bizz_bookings'), 'context' => 'side', 'priority' => 'low', 'show_names' => true, 'fields' => array(array('name' => __('Vehicle', 'bizzthemes'), 'desc' => __('enter the car amount', 'bizzthemes'), 'id' => $prefix . 'car_pay_car', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'text_money'), array('name' => __('Extras', 'bizzthemes'), 'desc' => __('enter the extras amount', 'bizzthemes'), 'id' => $prefix . 'car_pay_extras', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'text_money'), array('name' => __('Tax', 'bizzthemes'), 'desc' => __('enter the tax amount', 'bizzthemes'), 'id' => $prefix . 'car_pay_tax', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'text_money'), array('name' => __('Total', 'bizzthemes'), 'desc' => __('enter the total amount', 'bizzthemes'), 'id' => $prefix . 'car_pay_total', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'text_money'), array('name' => __('Deposit', 'bizzthemes'), 'desc' => __('Amount paid before rental', 'bizzthemes'), 'id' => $prefix . 'car_pay_deposit', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'text_money'))); $meta_boxes[] = array('id' => 'bizzthemes_bookings_payment', 'title' => __('Payment', 'bizzthemes'), 'pages' => array('bizz_bookings'), 'context' => 'side', 'priority' => 'low', 'show_names' => true, 'fields' => array(array('name' => __('Paid', 'bizzthemes'), 'id' => $prefix . 'car_pay_paid', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'text_money'), array('name' => __('Remaining', 'bizzthemes'), 'id' => $prefix . 'car_pay_remaining', 'currency' => get_bizz_currency($opt_s['pay_currency']), 'type' => 'remaining'), array('name' => __('Payment method', 'bizzthemes'), 'id' => $prefix . 'car_pay_method', 'type' => 'select', 'options' => array(array('name' => __('-- Select --', 'bizzthemes'), 'value' => '0'), array('name' => __('PayPal', 'bizzthemes'), 'value' => 'paypal'), array('name' => __('Credit Card', 'bizzthemes'), 'value' => 'creditcard'), array('name' => __('Cash on Delivery', 'bizzthemes'), 'value' => 'cod'), array('name' => __('Bank Transfer', 'bizzthemes'), 'value' => 'banktransfer'), array('name' => __('Mollie Payment', 'bizzthemes'), 'value' => 'mollie'))), array('id' => $prefix . 'booking_paypal_details', 'type' => 'hidden', 'desc' => ''))); if (isset($opt_s['pay_credit']) && $opt_s['pay_credit']) { $meta_boxes[] = array('id' => 'bizzthemes_bookings_cc', 'title' => __('Credit Card', 'bizzthemes'), 'pages' => array('bizz_bookings'), 'context' => 'side', 'priority' => 'low', 'show_names' => true, 'fields' => array(array('name' => __('Type', 'bizzthemes'), 'id' => $prefix . 'bookings_cc_type', 'type' => 'select', 'options' => array(array('name' => __('-- Select --', 'bizzthemes'), 'value' => '0'), array('name' => __('Visa', 'bizzthemes'), 'value' => 'visa'), array('name' => __('MasterCard', 'bizzthemes'), 'value' => 'mastercard'), array('name' => __('Maestro', 'bizzthemes'), 'value' => 'maestro'), array('name' => __('AmericanExpress', 'bizzthemes'), 'value' => 'amex'))), array('name' => __('Number', 'bizzthemes'), 'id' => $prefix . 'bookings_cc_number', 'type' => 'text_small'), array('name' => __('Expiration Month', 'bizzthemes'), 'id' => $prefix . 'bookings_cc_expiration_m', 'type' => 'select', 'options' => $months), array('name' => __('Expiration Year', 'bizzthemes'), 'id' => $prefix . 'bookings_cc_expiration_y', 'type' => 'select', 'options' => $years), array('name' => __('Security Code', 'bizzthemes'), 'id' => $prefix . 'bookings_cc_security', 'type' => 'text_small'))); } return $meta_boxes; }
function float_to_currencystr($n, $add_currency_symbol = true, $opt_s) { // set defaults $opt_s['decimal_places'] == '' ? $decimal_places = 2 : ($decimal_places = $opt_s['decimal_places']); $opt_s['decimal_point'] == '' ? $decimal_point = '.' : ($decimal_point = $opt_s['decimal_point']); $opt_s['thousands_separator'] == '' ? $thousands_separator = ',' : ($thousands_separator = $opt_s['thousands_separator']); $opt_s['currencysymbol_position'] == '' ? $currencysymbol_position = 'before-nospace' : ($currencysymbol_position = $opt_s['currencysymbol_position']); // get symbol of currency $currency_symbol = get_bizz_currency($opt_s['pay_currency']); // format number $res = number_format($n, $decimal_places, html_entity_decode($decimal_point), html_entity_decode($thousands_separator)); if ($add_currency_symbol) { switch ($currencysymbol_position) { case 'before': $res = $currency_symbol . ' ' . $res; break; case 'before-nospace': $res = $currency_symbol . $res; break; case 'after': $res = $res . ' ' . $currency_symbol; break; case 'after-nospace': $res = $res . $currency_symbol; break; } } return $res; }
/** * Get currency options. */ private function get_currency_options() { $currencies = get_bizz_currency(); $options = array(); foreach ($currencies as $k => $v) { $options[$k] = $v['name']; } return $options; }