/**
 * CONTACT FORM SCRIPT
 *
 * custom contact form script that may be used inside widget or as a function
 * @since 6.0
 */
function bizz_contact_form($wid_email, $wid_trans1, $wid_trans2, $wid_trans3, $wid_trans7, $wid_trans9, $wid_trans10, $wid_trans11, $wid_trans12, $wid_trans13, $wid_trans14, $wid_trans15, $wid_trans16, $wid_trans17, $wid_trans18, $wid_trans19)
{
    $wid_id = bizz_rand_sha1(3);
    if (isset($_POST)) {
        update_option('cformtest', $_POST);
    }
    update_option('cformtest2', $wid_id);
    // FORM SETTINGS: start
    //If the form is submitted
    if (isset($_POST["submitted"])) {
        //Check to see if the honeypot captcha field was filled in
        if (trim($_POST['checking']) !== '') {
            $captchaError = true;
        } else {
            //Check to make sure that the name field is not empty
            if (trim($_POST['contactName']) === '') {
                $nameError = $wid_trans1;
                $hasError = true;
            } else {
                $name = trim($_POST['contactName']);
            }
            //Check to make sure sure that a valid email address is submitted
            if (trim($_POST['email']) === '') {
                $emailError = $wid_trans1;
                $hasError = true;
            } else {
                if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}\$", trim($_POST['email']))) {
                    $emailError = $wid_trans2;
                    $hasError = true;
                } else {
                    $email = trim($_POST['email']);
                }
            }
            //Check to make sure comments were entered
            if (trim($_POST['comments']) === '') {
                $commentError = $wid_trans1;
                $hasError = true;
            } else {
                if (function_exists('stripslashes')) {
                    $comments = stripslashes(wpautop(trim($_POST['comments'])));
                } else {
                    $comments = wpautop(trim($_POST['comments']));
                }
            }
            $headers = "MIME-Version: 1.0" . "\r\n";
            $headers .= "Content-type:text/html; charset=UTF-8" . "\r\n";
            $headers .= 'From: <' . $email . '>' . "\r\n";
            $emailTo = $wid_email;
            $subject = $wid_trans3 . $name;
            $sendCopy = trim($_POST['sendCopy']);
            $body = '<html><body>';
            $body .= '<table rules="all" style="border-color:#dddddd;" cellpadding="10">';
            $body .= "<tr style='background: #eee;'><td><strong>{$wid_trans14}</strong> </td><td>{$name}</td></tr>";
            $body .= "<tr><td><strong>{$wid_trans15}</strong> </td><td>{$email}</td></tr>";
            $body .= "<tr><td><strong>{$wid_trans16}</strong> </td><td>{$comments}</td></tr>";
            $body .= "</table>";
            $body .= "</body></html>";
            // Load array with comment data.
            $commentx = array('author' => $name, 'email' => $email, 'website' => '', 'body' => $comments, 'permalink' => '');
            $hasSpam = 'false';
            // hidden field is not empty?
            if (isset($_POST['checking']) && $_POST['checking'] == '') {
                $hasSpam = 'true';
            }
            // Send mail if there is no error and no spam
            if (!isset($hasError) && $hasSpam == 'false') {
                #If there is no error, send the email
                wp_mail($emailTo, $subject, $body, $headers);
                if ($sendCopy == true) {
                    $subject = $wid_trans7 . $wid_email;
                    wp_mail($email, $subject, $body, $headers);
                }
                $emailSent = true;
            }
        }
    }
    $requested_url = is_ssl() ? 'https://' : 'http://';
    $requested_url .= $_SERVER['HTTP_HOST'];
    $requested_url .= $_SERVER['REQUEST_URI'];
    echo '<input type="hidden" class="cform-id" name="cform-id" value="' . $wid_id . '" />';
    echo '<input type="hidden" class="cform-trans9" name="cform-trans9" value="' . $wid_trans9 . '" />';
    echo '<input type="hidden" class="cform-trans10" name="cform-trans10" value="' . $wid_trans10 . '" />';
    echo '<input type="hidden" class="cform-trans11" name="cform-trans11" value="' . $wid_trans11 . '" />';
    // FORM SETTINGS: end
    ?>

<?php 
    if (isset($hasError)) {
        ?>

	<p class="alert"><?php 
        echo $wid_trans12;
        ?>
</p>
<?php 
    }
    ?>


<?php 
    if ($wid_email == '') {
        ?>

	<p class="alert"><?php 
        echo $wid_trans13;
        ?>
</p>
<?php 
    }
    ?>

<form action="<?php 
    echo esc_url($requested_url);
    ?>
" id="contactForm<?php 
    echo $wid_id;
    ?>
" method="post">
	<ol class="forms">
		<li>
			<label for="contactName"><?php 
    echo $wid_trans14;
    ?>
</label>
			<input type="text" name="contactName" id="contactName" value="<?php 
    if (isset($_POST['contactName'])) {
        echo $_POST['contactName'];
    }
    ?>
" class="txt requiredField" />
			<?php 
    if (isset($nameError) && $nameError != '') {
        ?>

				<span class="error"><?php 
        echo $nameError;
        ?>
</span> 
			<?php 
    }
    ?>

		</li>
		<li>
			<label for="email"><?php 
    echo $wid_trans15;
    ?>
</label>
			<input type="text" name="email" id="email" value="<?php 
    if (isset($_POST['email'])) {
        echo $_POST['email'];
    }
    ?>
" class="txt requiredField email" />
			<?php 
    if (isset($emailError) && $emailError != '') {
        ?>

				<span class="error"><?php 
        echo $emailError;
        ?>
</span>
			<?php 
    }
    ?>

		</li>
		<li class="textarea">
			<label for="commentsText"><?php 
    echo $wid_trans16;
    ?>
</label>
			<textarea name="comments" id="commentsText" rows="20" cols="30" class="requiredField"><?php 
    if (isset($_POST['comments'])) {
        if (function_exists('stripslashes')) {
            echo stripslashes($_POST['comments']);
        } else {
            echo $_POST['comments'];
        }
    }
    ?>
</textarea>
			<?php 
    if (isset($commentError) && $commentError != '') {
        ?>

				<span class="error"><?php 
        echo $commentError;
        ?>
</span> 
			<?php 
    }
    ?>

		</li>
		<li class="inline">
			<input type="checkbox" name="sendCopy" id="sendCopy" value="true"<?php 
    if (isset($_POST['sendCopy']) && $_POST['sendCopy'] == true) {
        echo ' checked="checked"';
    }
    ?>
 />
			<label for="sendCopy"><?php 
    echo $wid_trans17;
    ?>
</label>
		</li>
		<li class="screenReader">
			<label for="checking" class="screenReader"><?php 
    echo $wid_trans18;
    ?>
</label>
			<input type="text" name="checking" id="checking" class="screenReader" value="<?php 
    if (isset($_POST['checking'])) {
        echo $_POST['checking'];
    }
    ?>
" />
		</li>
		<li class="buttons">
			<input type="hidden" name="submitted" id="submitted" value="true" />
			<input class="submit button" type="submit" value="<?php 
    echo $wid_trans19;
    ?>
" />
			<div class="load" style="display:none;"><?php 
    _e('Sending...', 'bizzthemes');
    ?>
</div>
		</li>
	</ol>
</form>
<?php 
}
Exemple #2
0
function bizz_booking_validate()
{
    global $wpdb, $booking_settings;
    // get submited form parameters
    $params = $_GET["params"];
    // get booking settings
    $opt_s = $booking_settings->get_settings();
    if (isset($_GET["step"])) {
        $qs_step = $_GET["step"];
        // get submited form parameters
        $params = apply_filters('bizz_filter_booking_step_params', $params, $qs_step, $opt_s);
        // Hook into each step
        do_action('booking_steps', $qs_step, $params, $opt_s);
        // step 2 : user inserts on form date, time & location of pickup and return --> create cookie with date, time & location selection and return available cars
        if ($qs_step == "2") {
            // Locale date and time strings
            $date_format = get_option('date_format', 'Y-m-d');
            $time_format = get_option('time_format', 'H:i');
            // Pickup
            $date_f = date('Y-m-d', strtotime($params['pickup_y'] . '-' . $params['pickup_m'] . '-' . $params['pickup_d']));
            //$date_f = new DateTime( $date_f );
            //$date_ff = date_format( $date_f, $date_format );
            $time_f = new DateTime($params["hour_of_pickup"]);
            $time_ff = date_format($time_f, 'H:i');
            $pickup_stt = strtotime($date_f . ' ' . $time_ff);
            // Return
            $date_t = date('Y-m-d', strtotime($params['return_y'] . '-' . $params['return_m'] . '-' . $params['return_d']));
            //$date_t = new DateTime( $date_t );
            //$date_tf = date_format( $date_t, $date_format );
            $time_t = new DateTime($params["hour_of_return"]);
            $time_tf = date_format($time_t, 'H:i');
            $return_stt = strtotime($date_t . ' ' . $time_tf);
            // Count Slots
            $days = bizz_count_slots($pickup_stt, $return_stt, false, $opt_s);
            $hours = bizz_count_slots($pickup_stt, $return_stt, true, $opt_s);
            $slots = bizz_count_slots($pickup_stt, $return_stt, $opt_s['pay_pricerange'] == 'perhour' ? true : false, $opt_s);
            // Page ID by page name
            $location_of_pickup = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_name = '" . $params["location_of_pickup"] . "' AND post_type = 'bizz_locations'");
            $location_of_pickup = $location_of_pickup ? $location_of_pickup : $params["location_of_pickup"];
            $location_of_pickup_slug = get_post($location_of_pickup);
            $location_of_pickup_slug = $location_of_pickup_slug->post_name;
            # choose pickup location if return is empty
            $params["location_of_return"] = $params["location_of_return"] && (isset($params["return_chk"]) && $params["return_chk"] == "true") ? $params["location_of_return"] : $params["location_of_pickup"];
            $location_of_return = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_name = '" . $params["location_of_return"] . "' AND post_type = 'bizz_locations'");
            $location_of_return = $location_of_return ? $location_of_return : $params["location_of_return"];
            $location_of_return_slug = get_post($location_of_return);
            $location_of_return_slug = $location_of_return_slug->post_name;
            // Coupon code
            $coupon_code = isset($params["coupon_code"]) ? $params["coupon_code"] : '';
            // Locale Pickup
            $date_ffl = $params['date_of_pickup'];
            $time_ffl = date_format($time_f, $time_format);
            // Locale Return
            $date_tfl = $params['date_of_return'];
            $time_tfl = date_format($time_t, $time_format);
            // address
            $address_p = get_post_meta($location_of_pickup, 'bizzthemes_location_address', true);
            $address_r = get_post_meta($location_of_return, 'bizzthemes_location_address', true);
            $carhire_cookie = array("date_of_pickup" => $date_f, "date_of_pickup_d" => $params['pickup_d'], "date_of_pickup_m" => $params['pickup_m'], "date_of_pickup_y" => $params['pickup_y'], "date_of_pickup_dn" => $params['pickup_dn'], "date_of_pickup_locale" => $date_ffl, "hour_of_pickup" => $time_ff, "hour_of_pickup_locale" => $time_ffl, "date_of_return" => $date_t, "date_of_return_d" => $params['return_d'], "date_of_return_m" => $params['return_m'], "date_of_return_y" => $params['return_y'], "date_of_return_dn" => $params['return_dn'], "date_of_return_locale" => $date_tfl, "hour_of_return" => $time_tf, "hour_of_return_locale" => $time_tfl, "location_of_pickup" => $location_of_pickup, "location_of_pickup_slug" => $location_of_pickup_slug, "location_of_pickup_name" => get_the_title($location_of_pickup) . ($address_p ? ', ' . $address_p : ''), "location_of_return" => $location_of_return, "location_of_return_slug" => $location_of_return_slug, "location_of_return_name" => get_the_title($location_of_return) . ($address_r ? ', ' . $address_r : ''), "count_days" => $days, "count_hours" => $hours, "count_slots" => $slots, "currency" => get_bizz_currency($opt_s['pay_currency']), "coupon" => $coupon_code);
            // loop booked days
            $slots_array = bizz_slot_array($carhire_cookie['date_of_pickup'], $carhire_cookie['date_of_return'], $carhire_cookie['hour_of_pickup'], $carhire_cookie['hour_of_return'], $opt_s);
            // pricing posts
            $pricing_posts = bizz_get_pricing_posts($carhire_cookie['count_slots']);
            // booking posts
            $booking_posts = bizz_get_booking_posts();
            // coupon posts
            $coupon_post = apply_filters('bizz_coupon_filter', bizz_get_coupon($coupon_code), $carhire_cookie);
            // Step 2 cookie filter
            $carhire_cookie = apply_filters('step_' . $qs_step . '_cookie', $carhire_cookie, $params, $opt_s);
            // set cookie
            bizz_fill_booking_cookie($carhire_cookie);
            print bizz_return_cars($carhire_cookie, $slots_array, $pricing_posts, $booking_posts, $coupon_post, $opt_s);
        } elseif ($qs_step == "3") {
            $carhire_cookie = array();
            $carhire_cookie = json_decode(stripslashes($_COOKIE['carhire']));
            $carhire_cookie->car_id = $params["car_id"];
            $carhire_cookie->car_name = get_the_title($params["car_id"]);
            $carhire_cookie->dealer_id = get_post_meta($params["car_id"], 'bizzthemes_car_dealer', true);
            $carhire_cookie->car_dealer_email_id = get_post_meta($params["car_id"], 'bizzthemes_car_dealer_email', true);
            $carhire_cookie->car_image = get_post_meta($params["car_id"], 'bizzthemes_car_image', true);
            $carhire_cookie->car_count = $params["car_count"];
            // coupon posts
            $coupon_post = apply_filters('bizz_coupon_filter', bizz_get_coupon($carhire_cookie->coupon), $carhire_cookie);
            // Step 3 cookie filter
            $carhire_cookie = apply_filters('step_' . $qs_step . '_cookie', $carhire_cookie, $params, $opt_s);
            // set cookie
            bizz_fill_booking_cookie($carhire_cookie);
            print bizz_return_car_extras($params["car_id"], $coupon_post, $opt_s);
        } elseif ($qs_step == "4") {
            $carhire_cookie = array();
            $carhire_cookie = json_decode(stripslashes($_COOKIE['carhire']));
            // coupon posts
            $coupon_post = apply_filters('bizz_coupon_filter', bizz_get_coupon($carhire_cookie->coupon), $carhire_cookie);
            // extras
            $array_extras_qs = $params["car_extras"] ? explode("~", $params["car_extras"]) : array();
            $array_extras = array();
            $extras_total = 0;
            $extras_total_disc = 0;
            for ($i = 0; $i < count($array_extras_qs); $i++) {
                $array_extras_inner = array();
                $extra_data = $array_extras_qs[$i];
                $extra_data = explode('|', $extra_data);
                $extra_id = $extra_data[0];
                $custom_extra = get_term($extra_id, 'bizz_cars_extra');
                // slug
                $array_extras_inner[0] = $custom_extra->slug;
                // name
                $array_extras_inner[1] = $custom_extra->name;
                // calculate price for this extra
                $extra_price = bizz_extra_price($extra_id, $carhire_cookie, false, '', $opt_s);
                $extra_price_disc = bizz_extra_price($extra_id, $carhire_cookie, false, $coupon_post, $opt_s);
                $extras_total = $extras_total + $extra_price * $extra_data[1];
                $extras_total_disc = $extras_total_disc + $extra_price_disc * $extra_data[1];
                $array_extras_inner[2] = currencystr_to_float($extra_price, true, $opt_s);
                $array_extras_inner[3] = currencystr_to_float($extra_price_disc, true, $opt_s);
                // id
                $array_extras_inner[4] = $extra_id;
                // count
                $array_extras_inner[5] = $extra_data[1];
                // field
                $array_extras_inner[6] = $extra_data[2];
                // push into an array
                array_push($array_extras, $array_extras_inner);
            }
            $carhire_cookie->car_extras = $array_extras;
            // loop booked days
            $slots_array = bizz_slot_array($carhire_cookie->date_of_pickup, $carhire_cookie->date_of_return, $carhire_cookie->hour_of_pickup, $carhire_cookie->hour_of_return, $opt_s);
            // pricing posts
            $pricing_posts = bizz_get_pricing_posts($carhire_cookie->count_slots);
            // calculate car pricing
            $car_cost = bizz_car_price_byid($carhire_cookie->car_id, $carhire_cookie, $slots_array, $pricing_posts, '', $opt_s);
            $car_cost_disc = bizz_car_price_byid($carhire_cookie->car_id, $carhire_cookie, $slots_array, $pricing_posts, $coupon_post, $opt_s);
            // calculate car pricing with quantity
            if (isset($carhire_cookie->car_count) && $carhire_cookie->car_count > 1) {
                $car_cost = $car_cost * $carhire_cookie->car_count;
                $car_cost_disc = $car_cost_disc * $carhire_cookie->car_count;
            }
            // get car data
            $custom = get_post_custom($carhire_cookie->car_id);
            // DEPRECATED: fixed deposit per type
            if (isset($custom['bizzthemes_car_type']) && count($custom['bizzthemes_car_type']) == 1) {
                $car_type = $custom['bizzthemes_car_type'][0];
                $car_type_term = get_term_by('slug', $car_type, 'bizz_cars_type');
                $car_deposit = get_option('taxonomy_' . $car_type_term->term_id . '_bizz_type_deposit');
                $car_deposit_fixed = $car_deposit ? $car_deposit : $opt_s['pay_deposit'];
            }
            // fixed deposit per vehicle
            $car_deposit = isset($custom['bizzthemes_car_deposit'][0]) ? $custom['bizzthemes_car_deposit'][0] : $opt_s['pay_deposit'];
            $car_deposit_fixed = $car_deposit ? $car_deposit : $opt_s['pay_deposit'];
            // deposit times vehicles booked
            if (isset($carhire_cookie->car_count) && $carhire_cookie->car_count > 1) {
                $car_deposit_fixed = $car_deposit * $carhire_cookie->car_count;
            }
            // tax and deposit
            $tax_percentage = currencystr_to_float($opt_s['pay_tax'], $opt_s) / 100;
            $tax_total = ($extras_total_disc + $car_cost_disc) * $tax_percentage;
            $deposit_percentage = currencystr_to_float($opt_s['pay_deposit'], $opt_s) / 100;
            $deposit_fixed = currencystr_to_float($car_deposit_fixed, $opt_s);
            $deposit_pct = ($extras_total_disc + $car_cost_disc + $tax_total) * $deposit_percentage;
            $deposit_total = isset($opt_s['pay_deposit_select']) && $opt_s['pay_deposit_select'] == 'percentage' ? $deposit_pct : $deposit_fixed;
            if (isset($opt_s['pay_deposit_max']) && $opt_s['pay_deposit_max'] != 0 && $deposit_total > $opt_s['pay_deposit_max']) {
                $deposit_total = currencystr_to_float($opt_s['pay_deposit_max'], $opt_s);
                #deposit max
            }
            $total = $extras_total_disc + $car_cost_disc + $tax_total;
            // DO NOT USE FOR PAYMENT TRANSACTION, READ IT FROM DATABASE!!!
            $carhire_cookie->car_total_payment = array();
            $carhire_cookie->car_total_payment = array("car_total" => float_to_currencystr($car_cost, false, $opt_s), "car_total_disc" => float_to_currencystr($car_cost_disc, false, $opt_s), "extras_total" => float_to_currencystr($extras_total, false, $opt_s), "extras_total_disc" => float_to_currencystr($extras_total_disc, false, $opt_s), "tax_percentage" => float_to_currencystr($tax_percentage, false, $opt_s), "deposit_percentage" => float_to_currencystr($deposit_percentage, false, $opt_s), "deposit_fixed" => float_to_currencystr($deposit_fixed, false, $opt_s), "tax_total" => float_to_currencystr($tax_total, false, $opt_s), "deposit" => float_to_currencystr($deposit_total, false, $opt_s), "deposit_paypal" => number_format($deposit_total, 2, '.', ''), "total" => float_to_currencystr($total, false, $opt_s));
            $carhire_cookie->car_total_payment_output = array("car_total" => float_to_currencystr($car_cost, true, $opt_s), "car_total_disc" => float_to_currencystr($car_cost_disc, true, $opt_s), "extras_total" => float_to_currencystr($extras_total, true, $opt_s), "extras_total_disc" => float_to_currencystr($extras_total_disc, true, $opt_s), "tax_total" => float_to_currencystr($tax_total, true, $opt_s), "deposit" => float_to_currencystr($deposit_total, true, $opt_s), "total" => float_to_currencystr($total, true, $opt_s));
            // Step 4 cookie filter
            $carhire_cookie = apply_filters('step_' . $qs_step . '_cookie', $carhire_cookie, $params, $opt_s);
            // set cookie
            bizz_fill_booking_cookie($carhire_cookie);
            print json_encode($carhire_cookie);
        } else {
            if ($qs_step == "5") {
                global $wpdb;
                // read form
                foreach ($params as $param) {
                    $form_data[$param['name']] = $param['value'];
                }
                // read cookie
                $carhire_cookie = array();
                $carhire_cookie = json_decode(stripslashes($_COOKIE['carhire']));
                // Create post object
                $count_bookings = wp_count_posts('bizz_bookings');
                $title_bookings = __('Booking #', 'bizzthemes') . ($count_bookings->publish + 1);
                $booking_post = array('post_title' => $title_bookings, 'post_status' => 'publish', 'post_type' => 'bizz_bookings');
                // Insert the post into the database
                $this_post_id = wp_insert_post($booking_post);
                // Build variables array
                $bookopts['tracking_id'] = bizz_rand_sha1(9);
                $bookopts['pay_total'] = $carhire_cookie->car_total_payment->total;
                $bookopts['pay_deposit'] = $carhire_cookie->car_total_payment->deposit;
                $bookopts['pay_car'] = $carhire_cookie->car_total_payment->car_total_disc;
                $bookopts['pay_extras'] = $carhire_cookie->car_total_payment->extras_total_disc;
                $bookopts['pay_tax'] = $carhire_cookie->car_total_payment->tax_total;
                $bookopts['car'] = $carhire_cookie->car_id;
                $bookopts['dealer_id'] = $carhire_cookie->dealer_id;
                $bookopts['car_dealer_email_id'] = $carhire_cookie->car_dealer_email_id;
                $bookopts['car_count'] = $carhire_cookie->car_count;
                $bookopts['extras'] = $carhire_cookie->car_extras;
                $bookopts['pickup_location'] = $carhire_cookie->location_of_pickup;
                $bookopts['pickup_location_slug'] = $carhire_cookie->location_of_pickup_slug;
                $bookopts['pickup_location_name'] = $carhire_cookie->location_of_pickup_name;
                $bookopts['return_location'] = $carhire_cookie->location_of_return;
                $bookopts['return_location_slug'] = $carhire_cookie->location_of_return_slug;
                $bookopts['return_location_name'] = $carhire_cookie->location_of_return_name;
                $bookopts['pickup_date'] = $carhire_cookie->date_of_pickup;
                $bookopts['pickup_hour'] = $carhire_cookie->hour_of_pickup;
                $bookopts['return_date'] = $carhire_cookie->date_of_return;
                $bookopts['return_hour'] = $carhire_cookie->hour_of_return;
                $bookopts['duration'] = $carhire_cookie->count_slots;
                $bookopts['flight'] = isset($form_data['flight']) ? $form_data['flight'] : '';
                $bookopts['customer_title'] = isset($form_data['customer_title']) ? $form_data['customer_title'] : '';
                $bookopts['customer_fname'] = isset($form_data['first_name']) ? $form_data['first_name'] : '';
                $bookopts['customer_lname'] = isset($form_data['last_name']) ? $form_data['last_name'] : '';
                $bookopts['customer_fullname'] = isset($form_data['first_name']) && isset($form_data['last_name']) ? $form_data['first_name'] . ' ' . $form_data['last_name'] : '';
                $bookopts['customer_email'] = isset($form_data['email']) ? $form_data['email'] : '';
                $bookopts['customer_phone'] = isset($form_data['phone']) ? $form_data['phone'] : '';
                $bookopts['customer_contact_option'] = isset($form_data['contact_option']) ? $form_data['contact_option'] : '';
                $bookopts['customer_country'] = isset($form_data['countries']) ? $form_data['countries'] : '';
                $bookopts['customer_state'] = isset($form_data['state_or_province']) ? $form_data['state_or_province'] : '';
                $bookopts['customer_city'] = isset($form_data['city']) ? $form_data['city'] : '';
                $bookopts['customer_zip'] = isset($form_data['postcode']) ? $form_data['postcode'] : '';
                $bookopts['customer_address'] = isset($form_data['address']) ? $form_data['address'] : '';
                $bookopts['customer_driver_age'] = isset($form_data['driver_age']) ? $form_data['driver_age'] : '';
                $bookopts['customer_driver_birth'] = isset($form_data['driver_birth']) ? $form_data['driver_birth'] : '';
                $bookopts['customer_driver_license'] = isset($form_data['driver_license']) ? $form_data['driver_license'] : '';
                $bookopts['customer_driver_country'] = isset($form_data['driver_country']) ? $form_data['driver_country'] : '';
                $bookopts['customer_driver_issue'] = isset($form_data['driver_issue']) ? $form_data['driver_issue'] : '';
                $bookopts['customer_driver_expiry'] = isset($form_data['driver_expiry']) ? $form_data['driver_expiry'] : '';
                $bookopts['customer_driver_accidents'] = isset($form_data['driver_accidents']) ? $form_data['driver_accidents'] : '';
                $bookopts['customer_number_passengers'] = isset($form_data['number_passengers']) ? $form_data['number_passengers'] : '';
                $bookopts['customer_comments'] = isset($form_data['comms']) ? $form_data['comms'] : '';
                $bookopts['coupon'] = $carhire_cookie->coupon;
                // Add post meta
                add_post_meta($this_post_id, 'bizzthemes_bookings_track', $bookopts['tracking_id']);
                add_post_meta($this_post_id, 'bizzthemes_car_pay_total', $bookopts['pay_total']);
                add_post_meta($this_post_id, 'bizzthemes_car_pay_deposit', $bookopts['pay_deposit']);
                add_post_meta($this_post_id, 'bizzthemes_car_pay_car', $bookopts['pay_car']);
                add_post_meta($this_post_id, 'bizzthemes_car_pay_extras', $bookopts['pay_extras']);
                add_post_meta($this_post_id, 'bizzthemes_car_pay_tax', $bookopts['pay_tax']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_car', $bookopts['car']);
                #car id car_dealer_email_id
                add_post_meta($this_post_id, 'bizzthemes_bookings_dealer_id', $bookopts['dealer_id']);
                #dealer_id
                add_post_meta($this_post_id, 'bizzthemes_bookings_dealer_email_id', $bookopts['car_dealer_email_id']);
                #dealer_email_id
                add_post_meta($this_post_id, 'bizzthemes_bookings_car_count', $bookopts['car_count']);
                #car id
                // save extras: START
                foreach ((array) $bookopts['extras'] as $key => $value) {
                    if (isset($value[0])) {
                        add_post_meta($this_post_id, 'bizzthemes_bookings_extras', $value[0]);
                    }
                    #extras
                    if (isset($value[5])) {
                        $extras_qty[$value[0]][] = $value[5];
                    }
                    if (isset($value[6])) {
                        $extras_field[$value[0]][] = $value[6];
                    }
                }
                if (isset($extras_qty)) {
                    add_post_meta($this_post_id, 'bizzthemes_bookings_extras_qty', $extras_qty);
                }
                #qty
                if (isset($extras_field)) {
                    add_post_meta($this_post_id, 'bizzthemes_bookings_extras_field', $extras_field);
                }
                #qty
                // save extras: END
                add_post_meta($this_post_id, 'bizzthemes_bookings_pickup', $bookopts['pickup_location_slug']);
                add_post_meta($this_post_id, 'pickup_location_name', $carhire_cookie->location_of_pickup_name);
                add_post_meta($this_post_id, 'return_location_name', $carhire_cookie->location_of_return_name);
                add_post_meta($this_post_id, 'bizzthemes_bookings_return', $bookopts['return_location_slug']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_date1', $bookopts['pickup_date']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_date1_time', $bookopts['pickup_hour']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_date2', $bookopts['return_date']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_date2_time', $bookopts['return_hour']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_flight', $bookopts['flight']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_ctitle', $bookopts['customer_title']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_fname', $bookopts['customer_fname']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_lname', $bookopts['customer_lname']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_email', $bookopts['customer_email']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_phone', $bookopts['customer_phone']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_scontact', $bookopts['customer_contact_option']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_country', $bookopts['customer_country']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_state', $bookopts['customer_state']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_city', $bookopts['customer_city']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_zip', $bookopts['customer_zip']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_address', $bookopts['customer_address']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_driver_age', $bookopts['customer_driver_age']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_driver_birth', $bookopts['customer_driver_birth']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_driver_license', $bookopts['customer_driver_license']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_driver_country', $bookopts['customer_driver_country']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_driver_issue', $bookopts['customer_driver_issue']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_driver_expiry', $bookopts['customer_driver_expiry']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_driver_accidents', $bookopts['customer_driver_accidents']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_number_passengers', $bookopts['customer_number_passengers']);
                add_post_meta($this_post_id, 'bizzthemes_bookings_comm_que', $bookopts['customer_comments']);
                if ($opt_s['pay_credit']) {
                    add_post_meta($this_post_id, 'bizzthemes_bookings_cc_type', $form_data['cc_type']);
                    add_post_meta($this_post_id, 'bizzthemes_bookings_cc_number', $form_data['cc_number']);
                    add_post_meta($this_post_id, 'bizzthemes_bookings_cc_expiration_m', $form_data['cc_expiration_m']);
                    add_post_meta($this_post_id, 'bizzthemes_bookings_cc_expiration_y', $form_data['cc_expiration_y']);
                    add_post_meta($this_post_id, 'bizzthemes_bookings_cc_security', $form_data['cc_security']);
                }
                if (isset($form_data['payment_method']) && $form_data['payment_method'] != '') {
                    add_post_meta($this_post_id, 'bizzthemes_car_pay_method', $form_data['payment_method']);
                }
                if (isset($carhire_cookie->coupon) && $carhire_cookie->coupon != '') {
                    add_post_meta($this_post_id, 'bizzthemes_bookings_coupon', $carhire_cookie->coupon);
                }
                // Date Time Format
                $pickup_date_format = date(get_option('date_format'), strtotime($bookopts['pickup_date']));
                $pickup_time_format = date(get_option('time_format'), strtotime($bookopts['pickup_hour']));
                $return_date_format = date(get_option('date_format'), strtotime($bookopts['return_date']));
                $return_time_format = date(get_option('time_format'), strtotime($bookopts['return_hour']));
                // Extras
                $extras = '';
                if (is_array($bookopts['extras'])) {
                    foreach ($bookopts['extras'] as $key => $value) {
                        if (isset($value[1])) {
                            $extras .= '

						<tr><td>' . __('Extra', 'bizzthemes') . ' </td><td>' . $value[1] . ' x ' . $value[5] . '</td></tr>

						';
                        }
                    }
                } else {
                    $extras .= '

				<tr><td colspan="2">' . __('No extras selected.', 'bizzthemes') . '</td></tr>

				';
                }
                // Remove WPML home_url filter
                global $sitepress;
                remove_filter('home_url', array($sitepress, 'home_url'), 1, 4);
                // Send via email
                $your_email = $bookopts['car_dealer_email_id'];
                $customer_email = $bookopts['customer_email'];
                $headers = "MIME-Version: 1.0" . "\r\n";
                $headers .= "Content-type:text/html; charset=UTF-8" . "\r\n";
                $headers .= 'From: ' . $bookopts['customer_fullname'] . ' <' . $customer_email . '>' . "\r\n";
                $emailTo = $your_email;
                $subject = html_entity_decode($title_bookings, ENT_QUOTES, 'UTF-8');
                $body = '<html><body>';
                $body .= '<table rules="all" style="border-color:#dddddd;" cellpadding="10">';
                $body .= "<tr><td colspan='2'><strong>" . __('Customer?', 'bizzthemes') . "</strong> </td></tr>";
                $body .= "<tr><td>" . __('Tracking ID', 'bizzthemes') . " </td><td>" . $bookopts['tracking_id'] . "</td></tr>";
                $body .= "<tr><td>" . __('First Name', 'bizzthemes') . " </td><td>" . $bookopts['customer_fname'] . "</td></tr>";
                $body .= "<tr><td>" . __('Last Name', 'bizzthemes') . " </td><td>" . $bookopts['customer_lname'] . "</td></tr>";
                $body .= "<tr><td>" . __('Email', 'bizzthemes') . " </td><td>" . $bookopts['customer_email'] . "</td></tr>";
                $body .= "<tr><td>" . __('Phone', 'bizzthemes') . " </td><td>" . $bookopts['customer_phone'] . "</td></tr>";
                $body .= "<tr><td>" . __('Contact Option', 'bizzthemes') . " </td><td>" . $bookopts['customer_contact_option'] . "</td></tr>";
                $body .= "<tr><td>" . __('Comments/Questions', 'bizzthemes') . " </td><td>" . $bookopts['customer_comments'] . "</td></tr>";
                $body .= "<tr><td colspan='2'><strong>" . __('Vehicle?', 'bizzthemes') . "</strong> </td></tr>";
                $body .= "<tr><td>" . __('Vehicle Name', 'bizzthemes') . " </td><td>" . get_the_title($bookopts['car']) . "</td></tr>";
                $body .= "<tr><td>" . __('Quantity', 'bizzthemes') . " </td><td>" . $bookopts['car_count'] . "</td></tr>";
                $body .= "<tr><td colspan='2'><strong>" . __('Extras?', 'bizzthemes') . "</strong></td></tr>";
                $body .= $extras;
                $body .= "<tr><td colspan='2'><strong>" . __('When and Where?', 'bizzthemes') . "</strong> </td></tr>";
                $body .= "<tr><td>" . __('Pickup Location', 'bizzthemes') . " </td><td>" . $bookopts['pickup_location_name'] . "</td></tr>";
                $body .= "<tr><td>" . __('Return Location', 'bizzthemes') . " </td><td>" . $bookopts['return_location_name'] . "</td></tr>";
                $body .= "<tr><td>" . __('Start Date and Time', 'bizzthemes') . " </td><td>" . $pickup_date_format . ' @ ' . $pickup_time_format . "</td></tr>";
                $body .= "<tr><td>" . __('Return Date and Time', 'bizzthemes') . " </td><td>" . $return_date_format . ' @ ' . $return_time_format . "</td></tr>";
                $body .= "<tr><td colspan='2'><strong>" . __('Payment?', 'bizzthemes') . "</strong> </td></tr>";
                $body .= "<tr><td>" . __('Total', 'bizzthemes') . " </td><td>" . get_bizz_currency($opt_s['pay_currency']) . $bookopts['pay_total'] . "</td></tr>";
                $body .= "<tr><td>" . __('Deposit', 'bizzthemes') . " </td><td>" . get_bizz_currency($opt_s['pay_currency']) . $bookopts['pay_deposit'] . "</td></tr>";
                $body .= "<tr><td>" . __('Vehicle', 'bizzthemes') . " </td><td>" . get_bizz_currency($opt_s['pay_currency']) . $bookopts['pay_car'] . "</td></tr>";
                $body .= "<tr><td>" . __('Extras', 'bizzthemes') . " </td><td>" . get_bizz_currency($opt_s['pay_currency']) . $bookopts['pay_extras'] . "</td></tr>";
                $body .= "<tr><td>" . __('Tax', 'bizzthemes') . " </td><td>" . get_bizz_currency($opt_s['pay_currency']) . $bookopts['pay_tax'] . "</td></tr>";
                $body .= "<tr><td colspan='2'><strong>" . __('Next?', 'bizzthemes') . "</strong> </td></tr>";
                $body .= "<tr><td>" . __('Action') . " </td><td><a href='" . home_url('/') . "wp-admin/post.php?post=" . $this_post_id . "&action=edit'>" . __('Accept or Cancel this booking', 'bizzthemes') . "</a></td></tr>";
                $body .= "</table>";
                $body .= "</body></html>";
                $body = apply_filters('admin_email_notification_body', $body, $this_post_id, $bookopts, $opt_s);
                $body = html_entity_decode($body, ENT_QUOTES, 'UTF-8');
                //if ( $opt_s['admin_notifications'] != 1 )
                //Changed KL  . wp mail not configured . using server mail
                mail($your_email, $subject, $body, $headers);
                //wp_mail($your_email, $subject, $body, $headers); //you
                // notification function inside post-type-bookings.php
                //added KL. Creditcard Notifications are sent from callback
                if ($form_data['payment_method'] != 'creditcard') {
                    $bookopts["post_ID"] = $this_post_id;
                    booking_send_notification('customer', $bookopts, true);
                }
                // Add back WPML home_url filter
                if (class_exists('SitePress')) {
                    add_filter('home_url', array($sitepress, 'home_url'), 1, 4);
                }
                // Success
                $carhire_cookie->process = 'success';
                $carhire_cookie->payment_method = isset($form_data['payment_method']) && $form_data['payment_method'] != '' ? $form_data['payment_method'] : 'manual';
                $carhire_cookie->book_id = $this_post_id;
                $carhire_cookie->track_id = $bookopts['tracking_id'];
                // Redirect (optional)
                $carhire_cookie->redirect = apply_filters('bizz_payment_redirect', false, $bookopts, $form_data, $this_post_id, $opt_s);
                if ($form_data['payment_method'] == 'creditcard') {
                    //mail('*****@*****.**','COOKIE' ,$carhire_cookie->redirect);
                    //header('location: '.$qppaylink);
                }
                // Hook into final payments step
                do_action('bizz_payment_complete', $bookopts, $form_data, $this_post_id, $opt_s);
                // Step 5 cookie filter
                $carhire_cookie = apply_filters('step_' . $qs_step . '_cookie', $carhire_cookie, $params, $opt_s);
                print json_encode($carhire_cookie);
            } else {
                if ($qs_step == "dc") {
                    bizz_clear_booking_cookie();
                    print "cookie cleared";
                } else {
                    if ($qs_step == "so") {
                        // selected special offer
                        // nothing here yet
                    }
                }
            }
        }
        /*
        else {
        	header("HTTP/1.0 400 Bad request");
        	print "Bad request! (unknown step)";
        }
        */
    }
    /*
    else {
    header("HTTP/1.0 400 Bad request");
    print "Bad request! (step not defined)";
    }
    */
    exit;
}