require("inc.config.php"); require("class.phpmailer.php"); setlocale(LC_TIME, 'de_DE.utf8'); header("Content-Type: text/html; charset=utf-8"); if ( $_POST["page"] == "" ) $_POST["page"] = 1; if ( $_POST["page"] == 5 ) { $result = mysql_query("SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name='tickets'"); $row = mysql_fetch_row($result); $next_id = $row[0]; $result = mysql_query("SELECT t.*, m.title FROM termine t, musical m WHERE m.id=t.m_id AND t.id=$_POST[t_id]") or die(mysql_error()); $row = mysql_fetch_assoc($result); $code = date("d", strtotime($row["date"])); $next_id = str_pad($next_id, 4, "0", STR_PAD_LEFT); $ticket_n = str_pad($_POST["ticket_n"], 2, "0", STR_PAD_LEFT); $ticket_r = str_pad($_POST["ticket_r"], 2, "0", STR_PAD_LEFT); $ticket_ch = str_pad($_POST["ticket_ch"], 2, "0", STR_PAD_LEFT); $total_sum = ($_POST["ticket_n"] * $row["price_n"] + $_POST["ticket_r"] * $row["price_r"] + $_POST["ticket_ch"] * $row["price_ch"]) + 2; // Rabattaktionen if ( $_POST["rabatt"] == "FMITGLIED-MFY-JOURNEY-2018" ) { $discount_rate = ($_POST["ticket_n"] * $row["price_n"] + $_POST["ticket_r"] * $row["price_r"] + $_POST["ticket_ch"] * $row["price_ch"]) - ($_POST["ticket_n"] * $row["price_n"] + $_POST["ticket_r"] * $row["price_r"] + $_POST["ticket_ch"] * $row["price_ch"]) * 0.85; } else { $discount_rate = ($_POST["ticket_n"] * $row["price_n"] + $_POST["ticket_r"] * $row["price_r"] + $_POST["ticket_ch"] * $row["price_ch"]) - ($_POST["ticket_n"] * $row["price_n"] + $_POST["ticket_r"] * $row["price_r"] + $_POST["ticket_ch"] * $row["price_ch"]) * $row["discount"]; } // 4 zu 3 Aktion /* if ( $_POST["ticket_n"] + $_POST["ticket_r"] == 4 ) { if ( $_POST["ticket_r"] > 0 ) $discount = $row["price_r"]; else $discount = $row["price_n"]; } */ $code = "$code-$next_id-$ticket_n-$ticket_r"; $sql = "INSERT INTO tickets VALUES ( '', '$_POST[t_id]', '0', '$_POST[address_first_name]', '$_POST[address_last_name]', '', '', '$_POST[address_street]', '$_POST[address_postal]', '$_POST[address_city]', '$_POST[address_email]', '$_POST[address_phone]', '$_POST[ticket_n]', '$_POST[ticket_r]', '$_POST[ticket_ch]', '0', '$discount_rate', '".($total_sum - $discount_rate)."', '$code', '0', '0', '".time()."', '0', '$_POST[ad_type]', '$_SERVER[REMOTE_ADDR]' )"; mysql_query($sql) or die(mysql_error()); $f = fopen("resources/templates/mail.html", "r"); $body = fread($f, filesize("resources/templates/mail.html")); fclose($f); $body = str_replace("{firstname}", ($_POST["address_first_name"]=="") ? "" : "$_POST[address_first_name] ", $body); $body = str_replace("{lastname}", $_POST["address_last_name"], $body); $body = str_replace("{code}", $code, $body); $body = str_replace("{event}", "$row[title], ".date("d.m.Y H:i", strtotime($row["date"]))." Uhr", $body); $body = str_replace("{total_sum}", str_replace(".", ",", number_format($total_sum - $discount_rate, 2)), $body); $tickets = "
Standard | "; $tickets .= "$_POST[ticket_n] x | "; $tickets .= "".str_replace(".", ",", number_format($row["price_n"], 2))." € | "; $tickets .= "".str_replace(".", ",", number_format($_POST["ticket_n"] * $row["price_n"], 2))." € | "; $tickets .= "
Ermäßigt | "; $tickets .= "$_POST[ticket_r] x | "; $tickets .= "".str_replace(".", ",", number_format($row["price_r"], 2))." € | "; $tickets .= "".str_replace(".", ",", number_format($_POST["ticket_r"] * $row["price_r"], 2))." € | "; if ( $_POST["ticket_ch"] != 0) { $tickets .= "
Kinder b. 14 Jahre | "; $tickets .= "$_POST[ticket_ch] x | "; $tickets .= "".str_replace(".", ",", number_format($row["price_ch"], 2))." € | "; $tickets .= "".str_replace(".", ",", number_format($_POST["ticket_ch"] * $row["price_ch"], 2))." € | "; $tickets .= "
4 zu 3 - Aktion | "; $tickets .= ""; $tickets .= " | "; $tickets .= " | ".str_replace(".", ",", number_format($discount, 2))." | "; $tickets .= "
Servicegebühr | "; $tickets .= ""; $tickets .= " | "; $tickets .= " | 2,00 € | "; $tickets .= "
Rabatt | "; $tickets .= ""; $tickets .= " | "; $tickets .= " | -".str_replace(".", ",", number_format($discount_rate, 2))." € | "; $tickets .= "
Gesamtsumme | "; $tickets .= ""; $tickets .= " | "; $tickets .= " | ".str_replace(".", ",", number_format($total_sum-$discount_rate, 2))." € | "; $tickets .= "