', $text );
//Replace special chars
$text = str_replace('ä', 'ä', $text );
$text = str_replace('Ä', 'Ä', $text );
$text = str_replace('ö', 'ö', $text );
$text = str_replace('Ö', 'Ö', $text );
$text = str_replace('ß', 'ß', $text );
$text = str_replace('ü', 'ü', $text );
$text = str_replace('Ü', 'Ü', $text );
$text = str_replace('\n', '
', $text );
return $text;
}
/**
* Prepares text for mail sending.
*
* @param text text to send via mail.
* @param prepared mail.
*/
function prepareMail( $text )
{
//Replace special chars
$text = str_replace('ä', 'ae', $text );
$text = str_replace('Ä', 'Ae', $text );
$text = str_replace('ö', 'oe', $text );
$text = str_replace('Ö', 'Oe', $text );
$text = str_replace('ü', 'ue', $text );
$text = str_replace('Ü', 'Ue', $text );
$text = str_replace('\n', '
', $text );
return $text;
}
// Calculate a new ticket number
$ticket = $data['abbreviation'].ticketNumber(5);
$template = @file_get_contents(DOKU_PLUGIN.'onlineordering/template_'.$conf['lang'].'.txt');
// Replace parameters
$template = str_replace('{title}', $form['title'], $template);
$template = str_replace('{firstname}', $form['firstname'], $template);
$template = str_replace('{lastname}', $form['lastname'], $template);
$template = str_replace('{postcode}', $form['postcode'], $template);
$template = str_replace('{street}', $form['street'], $template);
$template = str_replace('{place}', $form['place'], $template);
$template = str_replace('{country}', $form['country'], $template);
$template = str_replace('{remarks}', $form['remarks'], $template);
$template = str_replace('{ticket}', $ticket, $template);
$template = str_replace('{nr_tickets}', $form['tickets'], $template);
$template = str_replace('{item_name}', $data['item_name'], $template);
$template = str_replace('{currency}', $data['currency'], $template);
$template = str_replace('{price}', number_format($data['price'],2,',','.'), $template);
$bank_account = $data['bank_account'];
if ( !isset($bank_account) ) {
$bank_account = $this->getConf('bank_account');
}
$template = str_replace('{bank_account}', $bank_account, $template);
$porto = $this->_get_porto( $data, $form['country'] );
$total_price = ($data['price'] * $form['tickets']) + $porto;
$template = str_replace('{porto}', number_format($porto,2,',','.'), $template);
$template = str_replace('{total_price}', number_format($total_price,2,',','.'), $template);
$date = date("d-m-Y");
$time = date("H:m");
$datetime = $date.' '.$time;
$template = str_replace('{date}', $date, $template);
$template = str_replace('{time}', $time, $template);
$template = str_replace('{datetime}', $datetime, $template);
$template = str_replace('{signature}', $this->getConf('signature'), $template);
$mail = prepareMail( $template );
// Prepare email
$subject = "Online ordering of ".$data['item_name'];
// Get the sender_email from the parameters
$sender_email = $data['sender_email'];
if ( !isset( $sender_email))
{
// Get the sender_email from the configuration
$sender_email = $this->getConf('sender_email');
}
// Make the from
$from = 'From: ';
// Get the sender name
$sender_name = $data['sender_name'];
if ( !isset( $sender_name ) ) {
$sender_name = $this->getConf('sender_name');
}
if ( isset( $sender_name ) )
{
$from .= '"'.$sender_name.'" ';
}
// Add the email
$from .= '<'.$sender_email.'>\r\n';
// Make a header
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Make the recipient address
$recipient = '"'.$form['firstname'].' '.$form['lastname'].'" <'.$form['email'].'>';
// Get the cc email from the parameters
$email_cc = $data['email_cc'];
if ( !isset( $email_cc ) ) {
// Get the cc email from the configuration
$email_cc = $this->getConf("email_cc");
}
if ( isset( $email_cc ) ) {
$email_cc = str_replace(', ', ',', $email_cc );
// Add blind copies
$header .= "BCC: ".$email_cc."\r\n";
}
$result = @mail($recipient, $subject, $mail, $header.$from);
if ($result) {
$output .= '
';
$output .= ''.$this->getLang('thank_you_for_ordering').'
';
$sent_notice = str_replace('{email}', $form['email'], $this->getLang('sent_notice'));
$sent_notice = str_replace('{name}', $form['firstname'].' '.$form['lastname'], $sent_notice );
$output .= $sent_notice.':
';
$output .= '';
$output .= prepareHTML( $template );
$output .= '
';
$output .= '