/** * createEmailConfirmation() * * Create a mailto link for email confirmation * * @param number $bookid id of booking * @return string mailto link * @access public * @since 2003-10-12 * @author Christian Ehret <*****@*****.**> */ function createEmailConfirmation($bookid) { global $tbl_booking, $tbl_guest, $tbl_address, $tbl_guest_address, $tbl_bookingcat, $tbl_country, $gDatabase, $errorhandler, $request; include_once 'guestclass.inc.php'; $guest = new Guest(); $query = "SELECT {$tbl_booking}.fk_bookingcat_id, {$tbl_booking}.fk_guest_id, \n\t UNIX_TIMESTAMP(start_date), UNIX_TIMESTAMP(end_date), \n\t\t\t TO_DAYS( end_date ) - TO_DAYS( start_date ) AS days, \n\t\t\t {$tbl_booking}.persons, children, {$tbl_guest}.firstname, \n\t\t\t {$tbl_guest}.lastname, {$tbl_bookingcat}.bookingcat, \n\t\t\t DATE_FORMAT({$tbl_guest}.date_of_birth , '%d.%m.%Y'), \n\t\t\t postalcode, city, address, country_de, email, \n\t\t\t booking_type, {$tbl_guest}.formal_greeting, \n\t\t\t {$tbl_guest}.gender, \n\t\t\t COALESCE( CASE WHEN {$tbl_bookingcat}.description = '' THEN NULL ELSE {$tbl_bookingcat}.description END, CASE WHEN {$tbl_bookingcat}.bookingcat = '' THEN NULL ELSE {$tbl_bookingcat}.bookingcat END, '' ),\n\t\t\t children2, children3, children0 \n\t\t\t FROM {$tbl_booking} \n\t\t\t LEFT JOIN {$tbl_guest} ON ({$tbl_booking}.fk_guest_id = {$tbl_guest}.pk_guest_id) \n\t\t\t LEFT JOIN {$tbl_guest_address} ON ({$tbl_guest_address}.default_address = " . MetabaseGetBooleanFieldValue($gDatabase, true) . " \n\t\t\t AND {$tbl_guest}.pk_guest_id = {$tbl_guest_address}.pk_fk_guest_id) \n\t\t\t LEFT JOIN {$tbl_address} ON ({$tbl_address}.pk_address_id = {$tbl_guest_address}.pk_fk_address_id) \n\t\t\t LEFT JOIN {$tbl_bookingcat} ON ({$tbl_booking}.fk_bookingcat_id = {$tbl_bookingcat}.pk_bookingcat_id) \n\t\t\t LEFT JOIN {$tbl_country} ON (fk_country_id = {$tbl_country}.pk_country_id )\n\t\t\t WHERE pk_booking_id = " . $bookid; $result = MetabaseQuery($gDatabase, $query); if (!$result) { $errorhandler->display('SQL', 'Booking::emailConfirmation()', $query); } else { if (MetabaseNumberOfRows($gDatabase, $result) == 1) { $booking = array(); $str = ""; $bookingtype = ""; $bookingstr = ""; $isformal = MetabaseFetchBooleanResult($gDatabase, $result, 0, 16); $dirihnen = "Dir"; if ($isformal) { $dirihnen = "Ihnen"; } switch (MetabaseFetchResult($gDatabase, $result, 0, 16)) { case 'R': $bookingtype = "Reservierungsbestätigung"; $bookingstr = "Reservierung"; break; case 'B': $bookingtype = "Buchungsbestätigung"; $bookingstr = "Buchung"; break; case 'P': $bookingtype = "Buchungsbestätigung"; $bookingstr = "Buchung"; break; } $body = ""; $body .= $guest->GetGreeting(MetabaseFetchResult($gDatabase, $result, 0, 1)) . "\n"; $body .= "hiermit bestätigen wir " . $dirihnen . " folgende " . $bookingstr . ":\n\n"; $body .= "Anreise: " . date("d. m. Y", MetabaseFetchResult($gDatabase, $result, 0, 2)) . "\n"; $body .= "Abreise: " . date("d. m. Y", MetabaseFetchResult($gDatabase, $result, 0, 3)) . "\n"; $body .= "Kategorie: " . MetabaseFetchResult($gDatabase, $result, 0, 19) . "\n"; $body .= "Erwachsene: " . MetabaseFetchResult($gDatabase, $result, 0, 5) . "\n"; $body .= $request->GetVar('children0', 'session') . ": " . MetabaseFetchResult($gDatabase, $result, 0, 22) . "\n"; $body .= $request->GetVar('children1', 'session') . ": " . MetabaseFetchResult($gDatabase, $result, 0, 6) . "\n"; $body .= $request->GetVar('children2', 'session') . ": " . MetabaseFetchResult($gDatabase, $result, 0, 20) . "\n"; $body .= $request->GetVar('children3', 'session') . ": " . MetabaseFetchResult($gDatabase, $result, 0, 21) . "\n\n"; $body .= "für:\n"; $body .= MetabaseFetchResult($gDatabase, $result, 0, 7) . " " . MetabaseFetchResult($gDatabase, $result, 0, 8) . "\n"; $body .= MetabaseFetchResult($gDatabase, $result, 0, 13) . "\n"; $body .= MetabaseFetchResult($gDatabase, $result, 0, 11) . " " . MetabaseFetchResult($gDatabase, $result, 0, 12) . "\n"; $body .= MetabaseFetchResult($gDatabase, $result, 0, 14) . "\n\n"; $str = "mailto:" . MetabaseFetchResult($gDatabase, $result, 0, 7) . "%20" . MetabaseFetchResult($gDatabase, $result, 0, 8) . "%20<" . MetabaseFetchResult($gDatabase, $result, 0, 15) . ">?subject={$bookingtype}" . "&body=" . rawurlencode($body); } return $str; } }