<?php
include './conn.php';
if (!empty($_POST["zip"]) && $_POST["zip"] != 'none') {
    $city = $_POST['city'];
    $zip = $_POST['zip'];
    $street = $_POST['street'];
    $housenumber = $_POST['housenumber'];
    $passengers = $_POST['passengers'];
    $suitcases = $_POST['suitcases'];
    $handlugage = $_POST['handluggage'];
    $pickupdate = $_POST['pickupdate'];
    $hour = $_POST['hour'];
    $minute = $_POST['minute'];
    $rueckfahrt = $_POST['retturn'];
    $boosterseat = $_POST['boosterseat'];
    $childseat = $_POST['childseat'];
    $carrycot = $_POST['carrycot'];
    $addaddress = $_POST['zusatzadresse'];
    $payment = $_POST['payment'];
    $salutation = $_POST['salutation'];
    $name = $_POST['name'];
    $surname = $_POST['surname'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $note = $_POST['note'];
    $aa1zip = $_POST['aa1zip'];
    $aa1street = $_POST['aa1street'];
    $aa1housenumber = $_POST['aa1housenumber'];
    $aa2zip = $_POST['aa2zip'];
    $aa2street = $_POST['aa2street'];
    $aa2housenumber = $_POST['aa2housenumber'];
    $aa3zip = $_POST['aa3zip'];
    $aa3street = $_POST['aa3street'];
    $aa3housenumber = $_POST['aa3housenumber'];
    $pickupdatereturn = $_POST['pickupdatereturn'];
    $hourreturn = $_POST['hourreturn'];
    $minutereturn = $_POST['minutereturn'];
    $departure = $_POST['departure'];
    $flightnumber = $_POST['flightnumber'];
    $km = $_POST['km'];
    $min = $_POST['min'];
    if ($addaddress == 'none') {
	$addaddress = '0';
    }
    $result = mysql_query("SELECT smtp_server,smtp_user,smtp_pass,smtp_email,sitename,session_time,sms_user,sms_password,sms_sys_zum,sms_sys_vom,sms_sys_zum_f,sms_sys_vom_f,sms_web_zum,sms_web_vom,child_seat_price,booster_seat_price,carrycot_price,additional_address_price,map_in_forms,invoice_year,sys_path,sys_port,night_price_wien,night_price_other,price_balance,creditcard_price,icons_in_form,email_trip_info,company_phone,company_url,company_atu,company_bankname,company_iban,company_konto,company_bic,company_blz,rechnung_h1,rechnung_header,company_admin,sms_send_name,sms_number_bottom,invoice_days,backup_fahrten_email,order_number_prefix_web,from_airport_plus,from_to_minus FROM options WHERE id = '1'");
    if ($result === FALSE) {
	die(mysql_error());
    }
    $row = mysql_fetch_array($result);
    $opt_order_number_prefix_web = $row['order_number_prefix_web'];
    $opt_smtp_server = $row['smtp_server'];
    $opt_smtp_user = $row['smtp_user'];
    $opt_smtp_pass = $row['smtp_pass'];
    $opt_smtp_email = $row['smtp_email'];
    $opt_sitename = $row['sitename'];
    $opt_session_time = $row['session_time'];
    $opt_sms_user = $row['sms_user'];
    $opt_sms_password = $row['sms_password'];
    $opt_sms_sys_zum = $row['sms_sys_zum'];
    $opt_sms_sys_vom = $row['sms_sys_vom'];
    $opt_sms_sys_zum_f = $row['sms_sys_zum_f'];
    $opt_sms_sys_vom_f = $row['sms_sys_vom_f'];
    $opt_sms_web_zum = $row['sms_web_zum'];
    $opt_sms_web_vom = $row['sms_web_vom'];
    $opt_child_seat_price = $row['child_seat_price'];
    $opt_booster_seat_price = $row['booster_seat_price'];
    $opt_carrycot_price = $row['carrycot_price'];
    $opt_additional_address_price = $row['additional_address_price'];
    $opt_map_in_forms = $row['map_in_forms'];
    $opt_invoice_year = $row['invoice_year'];
    $opt_sys_path = $row['sys_path'];
    $opt_sys_port = $row['sys_port'];
    $opt_night_price_wien = $row['night_price_wien'];
    $opt_night_price_other = $row['night_price_other'];
    $opt_price_balance = $row['price_balance'];
    $opt_creditcard_price = $row['creditcard_price'];
    $opt_icons_in_form = $row['icons_in_form'];
    $opt_email_trip_info = $row['email_trip_info'];
    $opt_company_phone = $row['company_phone'];
    $opt_company_url = $row['company_url'];
    $opt_company_atu = $row['company_atu'];
    $opt_company_bankname = $row['company_bankname'];
    $opt_company_iban = $row['company_iban'];
    $opt_company_konto = $row['company_konto'];
    $opt_company_bic = $row['company_bic'];
    $opt_company_blz = $row['company_blz'];
    $opt_rechnung_h1 = $row['rechnung_h1'];
    $opt_rechnung_header = $row['rechnung_header'];
    $opt_company_admin = $row['company_admin'];
    $opt_sms_send_name = $row['sms_send_name'];
    $opt_sms_number_bottom = $row['sms_number_bottom'];
    $opt_invoice_days = $row['invoice_days'];
    $opt_backup_fahrten_email = $row['backup_fahrten_email'];
    $from_airport_plus = $row['from_airport_plus'];
    $from_to_minus = $row['from_to_minus'];



    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT name FROM city WHERE id = '{$city}' ");
    $row = mysql_fetch_array($result);
    $city_name = $row['name'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT code FROM zip WHERE id = '{$zip}' ");
    $row = mysql_fetch_array($result);
    $zip_code = $row['code'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT name FROM street WHERE id = '{$street}' ");
    $row = mysql_fetch_array($result);
    $street_name = $row['name'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT code FROM zip WHERE id = '{$aa1zip}' ");
    $row = mysql_fetch_array($result);
    $aa1zip_code = $row['code'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT name FROM street WHERE id = '{$aa1street}' ");
    $row = mysql_fetch_array($result);
    $aa1street_name = $row['name'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT code FROM zip WHERE id = '{$aa2zip}' ");
    $row = mysql_fetch_array($result);
    $aa2zip_code = $row['code'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT name FROM street WHERE id = '{$aa2street}' ");
    $row = mysql_fetch_array($result);
    $aa2street_name = $row['name'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT code FROM zip WHERE id = '{$aa3zip}' ");
    $row = mysql_fetch_array($result);
    $aa3zip_code = $row['code'];
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("SELECT name FROM street WHERE id = '{$aa3street}' ");
    $row = mysql_fetch_array($result);
    $aa3street_name = $row['name'];
    if ($passengers == '') {
	$car = 'limo';
    }
    if ($suitcases == '') {
	$car = 'limo';
    }
    if ($suitcases <= '2') {
	$car = 'limo';
    }
    if ($passengers <= '3') {
	$car = 'limo';
    }
    if ($suitcases == 3 || $suitcases == 4) {
	$car = 'kombi';
    }
    if ($passengers == 4) {
	$car = 'kombi';
    }
    if ($suitcases <= 8 && $suitcases >= 5) {
	$car = 'van';
    }
    if ($passengers <= 8 && $passengers >= 5) {
	$car = 'van';
    }
    if ($aa1zip != 'none' && $aa1zip != '') {
	$result = mysql_query("SELECT price FROM additional_address_price WHERE zip1='$zip' AND zip2 = '$aa1zip'") or die("MySQL-Error: " . mysql_error());
	if (mysql_num_rows($result)) {
	    while ($row = mysql_fetch_array($result)) {
		$aa1zip_price = $row['price'];
	    }
	} else {
	    $aa1zip_price = $opt_additional_address_price;
	}
    } else {
	$aa1zip_price = 0;
    }
    if ($aa2zip != 'none' && $aa2zip != '') {
	$result = mysql_query("SELECT price FROM additional_address_price WHERE zip1='$aa1zip' AND zip2 = '$aa2zip'") or die("MySQL-Error: " . mysql_error());
	if (mysql_num_rows($result)) {
	    while ($row = mysql_fetch_array($result)) {
		$aa2zip_price = $row['price'];
	    }
	} else {
	    $aa2zip_price = $opt_additional_address_price;
	}
    } else {
	$aa2zip_price = 0;
    }
    if ($aa2zip != 'none' && $aa2zip != '') {
	$result = mysql_query("SELECT price FROM additional_address_price WHERE zip1='$aa2zip' AND zip2 = '$aa3zip'") or die("MySQL-Error: " . mysql_error());
	if (mysql_num_rows($result)) {
	    while ($row = mysql_fetch_array($result)) {
		$aa3zip_price = $row['price'];
	    }
	} else {
	    $aa3zip_price = $opt_additional_address_price;
	}
    } else {
	$aa3zip_price = 0;
    }
    $sql = mysql_query("SELECT $car FROM zip WHERE id='$zip'");
    if ($sql === FALSE) {
	die(mysql_error());
    }
    while ($row = mysql_fetch_array($sql)) {
	$price = $row[$car];
    }
    $price = ($price * $opt_price_balance);
    if ($boosterseat == '1') {
	$price = $price + $opt_booster_seat_price;
    }
    if ($boosterseat == '2') {
	$price = $price + $opt_booster_seat_price + $opt_booster_seat_price;
    }
    if ($boosterseat == '3') {
	$price = $price + $opt_booster_seat_price + $opt_booster_seat_price + $opt_booster_seat_price;
    }
    if ($childseat == '1') {
	$price = $price + $opt_child_seat_price;
    }
    if ($childseat == '2') {
	$price = $price + $opt_child_seat_price + $opt_child_seat_price;
    }
    if ($childseat == '3') {
	$price = $price + $opt_child_seat_price + $opt_child_seat_price + $opt_child_seat_price;
    }
    if ($carrycot == '1') {
	$price = $price + $opt_carrycot_price;
    }
    if ($carrycot == '2') {
	$price = $price + $opt_carrycot_price + $opt_carrycot_price;
    }
    if ($carrycot == '3') {
	$price = $price + $opt_carrycot_price + $opt_carrycot_price + $opt_carrycot_price;
    }
    if ($payment == "Kreditkarte") {
	$price = $price + $opt_creditcard_price;
    }
    $result = mysql_query("SELECT count(id) as total FROM night_price WHERE `hour`='{$hour}'");
    $row = mysql_fetch_array($result);
    if ($row ['total'] > 0) {
	if ($city == '1') {
	    $price = $price + $opt_night_price_wien;
	} else {
	    $price = $price + $opt_night_price_other;
	}
	$price = ($price + $aa1zip_price + $aa2zip_price + $aa3zip_price);
    } else {
	$price = ($price + $aa1zip_price + $aa2zip_price + $aa3zip_price);
    }
    $pricezaruek = $price;
    if ($rueckfahrt == "2") {
	$result = mysql_query("SELECT count(id) as total FROM night_price WHERE `hour`='{$hour}'");
	$row = mysql_fetch_array($result);
	if ($row ['total'] > 0) {
	    if ($city == '1') {
		$pricereturn = $pricezaruek - $opt_night_price_wien;
	    } else {
		$pricereturn = $pricezaruek - $opt_night_price_other;
	    }
	} else {
	    $pricereturn = $pricezaruek;
	}
	$pricereturn = $pricereturn + $from_airport_plus;
	$pricereturn = $pricereturn - $from_to_minus;



	$result = mysql_query("SELECT count(id) as total FROM night_price WHERE `hour`='{$hourreturn}'");
	$row = mysql_fetch_array($result);
	if ($row ['total'] > 0) {
	    if ($city == '1') {
		$pricereturn = $pricereturn + $opt_night_price_wien;
	    } else {
		$pricereturn = $pricereturn + $opt_night_price_other;
	    }
	}
    } else {
	$pricereturn = 0.00;
    }
    $price = number_format((float) $price, 2, '.', '');
    $pricereturn = number_format((float) $pricereturn, 2, '.', '');
    $pick_up_date = date("Y-m-d", strtotime($pickupdate));
    $pick_up_time = $hour . ':' . $minute . ':00';
    $pickup = 'ZUM';
    $house_number = $housenumber;
    if ($zip != '0') {
	if ($passengers <= 3 || $suitcases <= 2) {
	    $car_type = 'L';
	}
	if ($passengers == 4 || $suitcases == 4 || $suitcases == 3) {
	    $car_type = 'K';
	}
	if ($passengers >= 5 && $passengers <= 8 || $suitcases >= 5 && $suitcases <= 8) {
	    $car_type = 'V';
	}
    }
    $child_seat = $childseat;
    $booster_seat = $boosterseat;
    $suitcase = $suitcases;
    $hand_luggage = $handlugage;
    $additional_address = $addaddress;
    $aa1_zip = $aa1zip;
    $aa1_street = $aa1street;
    $aa1_house_number = $aa1housenumber;
    $aa2_zip = $aa2zip;
    $aa2_street = $aa2street;
    $aa2_house_number = $aa2housenumber;
    $aa3_zip = $aa3zip;
    $aa3_street = $aa3street;
    $aa3_house_number = $aa3housenumber;
    $flight_departure = $departure;
    $flight_number = $flightnumber;
    if ($aa1_zip == 'none') {
	$aa1_zip = '';
    }
    if ($aa1_street == 'none') {
	$aa1_street = '';
    }
    if ($aa2_zip == 'none') {
	$aa2_zip = '';
    }
    if ($aa2_street == 'none') {
	$aa2_street = '';
    }
    if ($aa3_zip == 'none') {
	$aa3_zip = '';
    }
    if ($aa3_street == 'none') {
	$aa3_street = '';
    }
    setlocale(LC_TIME, 'de_DE', 'deu_deu');
    $datum = $pickupdate;
    $time = strtotime($datum);
    $month = date("Y-m", $time);

    function random_string($length) {
	$key = '';
	$keys = array_merge(range(0, 9));
	for ($i = 0; $i < $length; $i++) {
	    $key .= $keys[array_rand($keys)];
	}
	return $key;
    }

    function random_code($length) {
	$key = '';
	$keys = array_merge(range(0, 9), range('a', 'z'));
	for ($i = 0; $i < $length; $i++) {
	    $key .= $keys[array_rand($keys)];
	}
	return $key;
    }

    $rand = random_string(8);
    $order_no = $opt_order_number_prefix_web . $rand;
    $confirm_code = md5($order_no);
    $order_date = date('Y-m-d H:i:s');
    if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
	$customer_ip = $_SERVER["HTTP_CLIENT_IP"];
    } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
	$customer_ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
    } else {
	$customer_ip = $_SERVER["REMOTE_ADDR"];
    }
    $sqlchk = mysql_query("SELECT customer_no FROM customers WHERE email = '{$email}'");
    if (mysql_fetch_row($sqlchk)) {
	$result = mysql_query("SELECT customer_no FROM customers WHERE email = '{$email}'");
	$row = mysql_fetch_array($result);
	$customer_no = $row['customer_no'];
	mysql_query("SET NAMES 'utf8'");
	$sqlchk1 = mysql_query("SELECT * FROM customers_routes WHERE customer_no = '{$customer_no}' AND city = '{$city}' AND zip = '{$zip}' AND street = '{$street}'");
	if (mysql_fetch_row($sqlchk1)) {

	} else {
	    mysql_query("SET NAMES 'utf8'");
	    mysql_query("INSERT INTO `customers_routes` (customer_no, city, zip, street, house_number)
      VALUES ('$customer_no', '$city', '$zip', '$street', '$housenumber')")or die(mysql_error());
	}
    } else {
	$customer_no = random_string(6);
	$pin = random_string(4);
	mysql_query("SET NAMES 'utf8'");
	mysql_query("INSERT INTO `customers` (customer_no, pin, salutation, name, surname, email, phone)
      VALUES ('$customer_no', '$pin', '$salutation', '$name', '$surname', '$email', '$phone')")or die(mysql_error());
	mysql_query("SET NAMES 'utf8'");
	mysql_query("INSERT INTO `customers_routes` (customer_no, city, zip, street, house_number)
      VALUES ('$customer_no', '$city', '$zip', '$street', '$housenumber')")or die(mysql_error());
    }
    mysql_query("SET NAMES 'utf8'");
    $result = mysql_query("INSERT INTO `orders` (order_no, confirm_code, order_date, customer_ip, customer_no, pick_up_date, pick_up_time, pickup, salutation, name, surname, city, zip, street, house_number, phone, email, car_type, passengers, booster_seat, child_seat, suitcase, hand_luggage, additional_address, aa1_zip, aa1_street, aa1_house_number, aa2_zip, aa2_street, aa2_house_number, aa3_zip, aa3_street, aa3_house_number, payment, note, price, cancellation, month, confirmed, paid,km,min)
      VALUES ('$order_no', '$confirm_code', '$order_date', '$customer_ip', '$customer_no', '$pick_up_date', '$pick_up_time', '$pickup', '$salutation', '$name', '$surname', '$city', '$zip', '$street', '$house_number', '$phone', '$email', '$car_type', '$passengers', '$booster_seat', '$childseat', '$suitcase', '$handlugage', '$additional_address', '$aa1_zip', '$aa1_street', '$aa1_house_number', '$aa2_zip', '$aa2_street', '$aa2_house_number', '$aa3_zip', '$aa3_street', '$aa3_house_number', '$payment', '$note', '$price', '0','$month', '0', '0', '$km', '$min') ")or die(mysql_error());
    if ($result) {
	$insertzum = "OK";
    } else {
	$insertzum = "ERROR";
    }
    if ($rueckfahrt == '2') {
	$order_noR = $order_no . '-R';
	$confirm_codeR = $confirm_code . '-R';
	$pick_up_date = date("Y-m-d", strtotime($pickupdatereturn));
	$pick_up_time = $hourreturn . ':' . $minutereturn . ':00';
	$pickup = 'VOM';
	$priceQ = $pricereturn;
	$check_sql = "SELECT * FROM flight_city WHERE name = '" . $departure . "'";
	$result = mysql_query($check_sql) or die("MySQL-Error: " . mysql_error());
	if (!mysql_num_rows($result)) {
	    mysql_query("SET NAMES 'utf8'");
	    mysql_query("INSERT INTO `flight_city` (name) VALUES ('$departure') ")or die(mysql_error());
	}
	$check_sql = "SELECT * FROM flight_numbers WHERE number = '" . $flightnumber . "'";
	$result = mysql_query($check_sql) or die("MySQL-Error: " . mysql_error());
	if (!mysql_num_rows($result)) {
	    mysql_query("SET NAMES 'utf8'");
	    mysql_query("INSERT INTO `flight_numbers` (number) VALUES ('$flightnumber') ")or die(mysql_error());
	}
	$flight_number = $flightnumber;
	mysql_query("SET NAMES 'utf8'");
	$result = mysql_query("INSERT INTO `orders` (order_no, confirm_code, order_date, customer_ip, customer_no, pick_up_date, pick_up_time, pickup,  salutation, name, surname, city, zip, street, house_number, phone, email, car_type, passengers, booster_seat, child_seat, suitcase, hand_luggage, additional_address, aa1_zip, aa1_street, aa1_house_number, aa2_zip, aa2_street, aa2_house_number, aa3_zip, aa3_street, aa3_house_number, payment, note, price, cancellation, month, confirmed, paid,flight_departure,flight_number,km,min)
      VALUES ('$order_noR', '$confirm_codeR', '$order_date', '$customer_ip', '$customer_no', '$pick_up_date', '$pick_up_time', '$pickup', '$salutation', '$name', '$surname', '$city', '$zip', '$street', '$house_number', '$phone', '$email', '$car_type', '$passengers', '$booster_seat',  '$childseat', '$suitcase',  '$handlugage', '$additional_address', '$aa1_zip', '$aa1_street', '$aa1_house_number', '$aa2_zip', '$aa2_street', '$aa2_house_number', '$aa3_zip', '$aa3_street', '$aa3_house_number', '$payment', '$note', '$priceQ', '0','$month', '0', '0', '$departure', '$flight_number', '$km', '$min') ")or die(mysql_error());
	if ($result) {
	    $insertvom = "OK";
	} else {
	    $insertvom = "ERROR";
	}
    }
    if ($rueckfahrt == '2') {
	if ($insertzum == 'OK' && $insertvom == 'OK') {
	    $success = "OK";
	}
    } elseif ($rueckfahrt == '1') {
	if ($insertzum == 'OK') {
	    $success = "OK";
	}
    } else {
	$success = 'ERROR';
    }
    $priceM = str_replace('.', ',', $price);
    $pricereturnM = str_replace('.', ',', $pricereturn);
    if ($additional_address == '1') {
	$aa1 = '<tr>
                                                                <td bgcolor="#FCEFC2" align="left" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Zusatzadresse</strong></td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="#FCEFC2" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zusatz Ziel 1</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $aa1street_name . ' ' . $aa1housenumber . ', ' . $aa1zip_code . '
                                                                </td>
                                                            </tr>  ';
	$aa2 = '';
	$aa3 = '';
    } else if ($additional_address == '2') {
	$aa1 = '<tr>
                                                                <td bgcolor="#FCEFC2" align="left" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Zusatzadresse</strong></td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="#FCEFC2" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zusatz Ziel 1</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $aa1street_name . ' ' . $aa1housenumber . ', ' . $aa1zip_code . '
                                                                </td>
                                                            </tr>  ';
	$aa2 = '<tr>
                                                                <td bgcolor="#FCEFC2" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zusatz Ziel 2</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $aa2street_name . ' ' . $aa2housenumber . ', ' . $aa2zip_code . '
                                                                </td>
                                                            </tr>  ';
	$aa3 = '';
    } else if ($additional_address == '3') {
	$aa1 = '<tr>
                                                                <td bgcolor="#FCEFC2" align="left" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Zusatzadresse</strong></td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="#FCEFC2" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zusatz Ziel 1</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $aa1street_name . ' ' . $aa1housenumber . ', ' . $aa1zip_code . '
                                                                </td>
                                                            </tr>  ';
	$aa2 = '<tr>
                                                                <td bgcolor="#FCEFC2" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zusatz Ziel 2</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $aa2street_name . ' ' . $aa2housenumber . ', ' . $aa2zip_code . '
                                                                </td>
                                                            </tr>  ';
	$aa3 = '<tr>
                                                                <td bgcolor="#FCEFC2" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zusatz Ziel 3</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $aa3street_name . ' ' . $aa3housenumber . ', ' . $aa3zip_code . '
                                                                </td>
                                                            </tr>';
    } else if ($additional_address == '0' || $additional_address == '') {
	$aa1 = '';
	$aa2 = '';
	$aa3 = '';
    }
    $to = $email;
    $subject = 'Auftragsbestätigung zu Ihrer Bestellung';
    $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>AIRPORT TAXI VIENNA - Flughafentaxi Wien - Bestätigung</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    </head>
    <body style="margin: 0; padding: 0;">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td style="padding: 10px 0 30px 0;">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;">
                        <tr>
                            <td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px;">
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td style="color: #153643; font-family: Arial, sans-serif; font-size: 17px;"><strong>Sehr geehrter ' . $salutation . ' ' . $name . ' ' . $surname . ',<br /><br />
                                                vielen Dank für Ihre Bestellung, die wir Ihnen wie folgt bestätigen:</strong><br /><br /><br />
                                            Ihre Kundennummer: ' . $customer_no . '<br /><br /><strong>Richtung zum Flughafen</strong></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                    <td width="260" valign="top">
                                                        <table border="1" cellpadding="0" cellspacing="0" width="100%" style="padding:0px;">
                                                            <tr>
                                                                <td valign="bottom" style="padding: 7px 0 0px 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Bestelldetails</strong>
                                                                </td>
                                                                <td align="right" style="padding: 7px 10px 0px 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Bestellnummer:</strong> ' . $order_no . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td   align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Abholdatum und Uhrzeit
                                                                </td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $pickupdate . ' - ' . $hour . ':' . $minute . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Abfahrt von															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $street_name . ' ' . $housenumber . ', ' . $zip_code . ' ' . $city_name . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Reiseziel nach															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;"> Flughafen Wien-Schwechat
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Personen</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $passengers . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Koffer															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $suitcases . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Handgepäck															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $handlugage . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="left" style="padding: 5px 10px 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Kontaktinformationen</strong>															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Name															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $name . ' ' . $surname . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    E-Mail</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $email . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Telefonnummer</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $phone . '
                                                                </td>
                                                            </tr>
                                                             <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Anmerkung</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $note . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="left" style="padding: 5px 10px 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Zahlungsinfo</strong></td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>  <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zahlungsweise</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $payment . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="left" style="padding: 5px 10px 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Optionen</strong></td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Kindersitz</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $childseat . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Kindersitzerhöhung</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $boosterseat . '
                                                                </td>
                                                            </tr>
' . $aa1 . ' ' . $aa2 . ' ' . $aa3 . '
                                                            <tr>
                                                                <td bgcolor="" style="padding:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    Die Route ist ' . $km . ' Km lang und dauert ca. ' . $min . ' Minuten
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding:10px;font-family: Arial, sans-serif;font-weight:bold;font-size:18px;" colspan="2">
                                                                    Preis: ' . $priceM . ' EUR
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    Mit freundlichen Gr&uuml;&szlig;en <br /> Ihr ' . $opt_sitename . ' Team
                                                                </td>
                                                            </tr>
							     <td style="padding:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    Lieber Kunde,  <br />Bitte machen sie keine Bestellung beim Fahrer da es vielleicht zu falschen Angaben führen kann und wir nicht für unsere Zuverlässigkeit garantieren können.
																	</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    AIRPORT TRANSFER</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                    LIMOUSINENSERVICE ZUM FIXPREIS</td>
                                                            </tr>
                                                             <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                     TEL.: ' . $opt_company_phone . '</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                    WEB: <a title="http://' . $opt_company_url . '/" href="http://' . $opt_company_url . '/">' . $opt_company_url . '</a></td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                    E-Mail: <a title="mailto:' . $opt_smtp_email . '" href="mailto:' . $opt_smtp_email . '">' . $opt_smtp_email . '</a></td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
</html>
';
    require './imapMail/PHPMailerAutoload.php';
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    $mail->addReplyTo($opt_smtp_email, $opt_sitename);
    $mail->SMTPSecure = "tls";
    $mail->Host = $opt_smtp_server;
    $mail->Port = 587;
    $mail->Username = $opt_smtp_user;
    $mail->Password = $opt_smtp_pass;
    $mail->CharSet = 'UTF-8';
    $mail->SetFrom($opt_smtp_email, $opt_sitename);
    $mail->Subject = $subject;
    $mail->ContentType = 'text/html';
    $mail->IsHTML(true);
    $mail->Body = $message;
    if ($success == 'OK') {
	$mail->AddAddress($to, $name . ' ' . $surname);
	if (!$mail->Send()) {
	    $emailzum = 'ERROR';
	} else {
	    $emailzum = 'OK';
	}
	$mail = new PHPMailer();
	$mail->IsSMTP();
	$mail->SMTPDebug = 0;
	$mail->SMTPAuth = true;
	$mail->addReplyTo($opt_smtp_email, $opt_sitename);
	$mail->SMTPSecure = "tls";
	$mail->Host = $opt_smtp_server;
	$mail->Port = 587;
	$mail->Username = $opt_smtp_user;
	$mail->Password = $opt_smtp_pass;
	$mail->CharSet = 'UTF-8';
	$mail->SetFrom($opt_smtp_email, $opt_sitename);
	$mail->Subject = $opt_sitename . ' #KOPIE# - ' . $pickupdate . ' - ' . $hour . ':' . $minute;
	$mail->ContentType = 'text/html';
	$mail->IsHTML(true);
	$mail->Body = $message;
	$mail->AddAddress($opt_backup_fahrten_email, $opt_backup_fahrten_email);
	if (!$mail->Send()) {

	} else {

	}
    }
    if ($rueckfahrt == '2') {
	$to = $email;
	$subject = 'Auftragsbestätigung zu Ihrer Bestellung';
	$message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>AIRPORT TAXI VIENNA - Flughafentaxi Wien - Bestätigung</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
    <body style="margin: 0; padding: 0;">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td style="padding: 10px 0 30px 0;">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;">
                        <tr>
                            <td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px;">
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td style="color: #153643; font-family: Arial, sans-serif; font-size: 17px;"><strong>Sehr geehrter ' . $salutation . ' ' . $name . ' ' . $surname . ',<br /><br />
                                                vielen Dank für Ihre Bestellung, die wir Ihnen wie folgt bestätigen:</strong><br /><br /><br />
                                            Ihre Kundennummer: ' . $customer_no . '<br /><br /><strong>Richtung vom Flughafen</strong></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                    <td width="260" valign="top">
                                                        <table border="1" cellpadding="0" cellspacing="0" width="100%">
                                                            <tr>
                                                                <td valign="bottom" style="padding: 7px 0 0px 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;" bgcolor="">
                                                                    <strong>Bestelldetails</strong>
                                                                </td>
                                                                <td bgcolor="" align="right" style="padding: 7px 10px 0px 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Bestellnummer:</strong> ' . $order_noR . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td  bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Flug-Info
                                                                </td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;"> ' . $departure . ' / ' . $flightnumber . ' </td>
                                                            </tr>
                                                            <tr>
                                                                <td  bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Abholdatum und Uhrzeit
                                                                </td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;"> ' . $pickupdatereturn . ' - ' . $hourreturn . ':' . $minutereturn . ' </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Abfahrt von															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                       Flughafen Wien-Schwechat
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Reiseziel nach															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">   ' . $street_name . ' ' . $housenumber . ', ' . $zip_code . ' ' . $city_name . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Personen</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $passengers . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Koffer															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $suitcases . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Handgepäck															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $handlugage . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="left" style="padding: 5px 10px 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Kontaktinformationen</strong>															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Name															</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $name . ' ' . $surname . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    E-Mail</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $email . '
                                                                </td>
                                                            </tr>
                                                             <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Telefonnummer</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $phone . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Anmerkung</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $note . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="left" style="padding: 5px 10px 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Zahlungsinfo</strong></td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>  <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Zahlungsweise</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $payment . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="left" style="padding: 5px 10px 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    <strong>Optionen</strong></td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Kindersitz</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $childseat . '
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td bgcolor="" align="right" style="padding: 5px 10px 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    Kindersitzerhöhung</td>
                                                                <td style="padding: 5px 0 0 10px; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                                                    ' . $boosterseat . '
                                                                </td>
                                                            </tr>
' . $aa1 . ' ' . $aa2 . ' ' . $aa3 . '
                                                            <tr>
                                                                <td bgcolor="" style="padding:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    Die Route ist ' . $km . ' Km lang und dauert ca. ' . $min . ' Minuten
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding:10px;font-family: Arial, sans-serif;font-weight:bold;font-size:18px;" colspan="2">
                                                                    Preis: ' . $pricereturnM . ' EUR
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    Mit freundlichen Gr&uuml;&szlig;en <br /> Ihr ' . $opt_sitename . ' Team
                                                                </td>
                                                            </tr>
							     <td style="padding:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    Lieber Kunde,  <br />Bitte machen sie keine Bestellung beim Fahrer da es vielleicht zu falschen Angaben führen kann und wir nicht für unsere Zuverlässigkeit garantieren können.
																	</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:10px;font-family: Arial, sans-serif;" colspan="2">
                                                                    AIRPORT TRANSFER</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                    LIMOUSINENSERVICE ZUM FIXPREIS</td>
                                                            </tr>
                                                                <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                     TEL.: ' . $opt_company_phone . '</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                    WEB: <a title="http://' . $opt_company_url . '/" href="http://' . $opt_company_url . '/">' . $opt_company_url . '</a></td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding-top:0px;font-family: Arial, sans-serif;" colspan="2">
                                                                    E-Mail: <a title="mailto:' . $opt_smtp_email . '" href="mailto:' . $opt_smtp_email . '">' . $opt_smtp_email . '</a></td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
</html>
';
	$mail = new PHPMailer();
	$mail->IsSMTP();
	$mail->SMTPDebug = 0;
	$mail->SMTPAuth = true;
	$mail->addReplyTo($opt_smtp_email, $opt_sitename);
	$mail->SMTPSecure = "tls";
	$mail->Host = $opt_smtp_server;
	$mail->Port = 587;
	$mail->Username = $opt_smtp_user;
	$mail->Password = $opt_smtp_pass;
	$mail->CharSet = 'UTF-8';
	$mail->SetFrom($opt_smtp_email, $opt_sitename);
	$mail->Subject = $subject;
	$mail->ContentType = 'text/html';
	$mail->IsHTML(true);
	$mail->Body = $message;
	if ($success == 'OK') {
	    $mail->AddAddress($to, $name . ' ' . $surname);
	    if (!$mail->Send()) {
		$emailvom = 'ERROR';
	    } else {
		$emailvom = 'OK';
	    }
	    $mail = new PHPMailer();
	    $mail->IsSMTP();
	    $mail->SMTPDebug = 0;
	    $mail->SMTPAuth = true;
	    $mail->addReplyTo($opt_smtp_email, $opt_sitename);
	    $mail->SMTPSecure = "tls";
	    $mail->Host = $opt_smtp_server;
	    $mail->Port = 587;
	    $mail->Username = $opt_smtp_user;
	    $mail->Password = $opt_smtp_pass;
	    $mail->CharSet = 'UTF-8';
	    $mail->SetFrom($opt_smtp_email, $opt_sitename);
	    $mail->Subject = $opt_sitename . ' #KOPIE# - ' . $pickupdatereturn . ' - ' . $hourreturn . ':' . $minutereturn;
	    $mail->ContentType = 'text/html';
	    $mail->IsHTML(true);
	    $mail->Body = $message;
	    $mail->AddAddress($opt_backup_fahrten_email, $opt_backup_fahrten_email);
	    if (!$mail->Send()) {

	    } else {

	    }
	}
    }
    if ($rueckfahrt == '2') {
	if ($emailvom == 'OK' && $emailvom == 'OK') {
	    $done = "OK";
	}
    } elseif ($rueckfahrt == '1') {
	if ($emailzum == 'OK') {
	    $done = "OK";
	}
    } else {
	$done = 'ERROR';
    }
    if ($done == 'OK') {
	$array = array('OK');
	echo json_encode($array);
    } else {
	$array = array('ERROR');
	echo json_encode($array);
    }
} else {
    $array = array('ERROR');
    echo json_encode($array);
}
?>