コード例 #1
0
/**
* 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&lt;" . MetabaseFetchResult($gDatabase, $result, 0, 15) . "&gt;?subject={$bookingtype}" . "&body=" . rawurlencode($body);
        }
        return $str;
    }
}
コード例 #2
0
 /**
  * account::get()
  * 
  * get
  * 
  * @param  $guestid guest id
  * @param integer $number number of bookings to show (0 for all)
  * @return $data data
  * @access public 
  * @since 2004-03-10
  * @author Christian Ehret <*****@*****.**> 
  */
 function get($guestid, $number)
 {
     global $gDatabase, $tbl_account, $tbl_receipt, $tbl_booking, $tbl_booking_detail, $tbl_room, $tbl_paycat, $errorhandler, $request;
     $query = "SELECT a.description, a.amount, DATE_FORMAT(a.date_payment, '%d.%m.%Y'), \n\t\t\t\t  a.fk_receipt_id, r.receipt_reference_id, b.booking_reference_id, b.pk_booking_id,\n\t\t\t\t  p.paycat, a.fk_paycat_id, a.on_receipt, a.pk_account_id, ro.room\n\t\t\t\t  FROM {$tbl_account} a \n\t\t\t\t  LEFT JOIN {$tbl_receipt} r ON a.fk_receipt_id = r.pk_receipt_id\n\t\t\t\t  LEFT JOIN {$tbl_booking} b ON a.fk_booking_id = b.pk_booking_id\n\t\t\t\t  LEFT JOIN {$tbl_paycat} p ON a.fk_paycat_id = p.pk_paycat_id\n\t\t\t\t  LEFT JOIN {$tbl_booking_detail} bd ON b.pk_booking_id = bd.fk_booking_id\n\t\t\t\t  LEFT JOIN {$tbl_room} ro ON bd.fk_room_id = ro.pk_room_id\n\t\t\t\t  WHERE a.fk_guest_id = {$guestid}\n\t\t\t\t  ORDER BY a.date_payment DESC";
     if ($number != 0) {
         $query .= " LIMIT 0," . $number;
     }
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $errorhandler->display('SQL', 'Account::get()', $query);
     } else {
         $data = array();
         $row = 0;
         for ($row = 0; ($eor = MetabaseEndOfResult($gDatabase, $result)) == 0; ++$row) {
             $color = 1;
             if ($row % 2 != 0) {
                 $color = 0;
             }
             $data[$row] = array('description' => nl2br(MetabaseFetchResult($gDatabase, $result, $row, 0)), 'amount' => MetabaseFetchResult($gDatabase, $result, $row, 1), 'thedate' => MetabaseFetchResult($gDatabase, $result, $row, 2), 'receiptid' => MetabaseFetchResult($gDatabase, $result, $row, 3), 'referenceid' => MetabaseFetchResult($gDatabase, $result, $row, 4), 'breferenceid' => MetabaseFetchResult($gDatabase, $result, $row, 5), 'bookingid' => MetabaseFetchResult($gDatabase, $result, $row, 6), 'paycat' => MetabaseFetchResult($gDatabase, $result, $row, 7), 'paycatid' => MetabaseFetchResult($gDatabase, $result, $row, 8), 'on_receipt' => MetabaseFetchBooleanResult($gDatabase, $result, $row, 9), 'accountid' => MetabaseFetchResult($gDatabase, $result, $row, 10), 'room' => MetabaseFetchResult($gDatabase, $result, $row, 11), 'color' => $color);
         }
         return $data;
     }
 }
コード例 #3
0
 function DumpDatabase($arguments)
 {
     if (!isset($arguments["Output"])) {
         return "it was not specified a valid output function";
     }
     $output = $arguments["Output"];
     $eol = isset($arguments["EndOfLine"]) ? $arguments["EndOfLine"] : "\n";
     $dump_definition = isset($arguments["Definition"]);
     $sequences = array();
     if (isset($this->database_definition["SEQUENCES"])) {
         for ($error = "", Reset($this->database_definition["SEQUENCES"]), $sequence = 0; $sequence < count($this->database_definition["SEQUENCES"]); Next($this->database_definition["SEQUENCES"]), $sequence++) {
             $sequence_name = Key($this->database_definition["SEQUENCES"]);
             if (isset($this->database_definition["SEQUENCES"][$sequence_name]["on"])) {
                 $table = $this->database_definition["SEQUENCES"][$sequence_name]["on"]["table"];
             } else {
                 $table = "";
             }
             $sequences[$table][] = $sequence_name;
         }
     }
     $previous_database_name = strcmp($this->database_definition["name"], "") ? MetabaseSetDatabase($this->database, $this->database_definition["name"]) : "";
     $output("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>{$eol}");
     $output("<database>{$eol}{$eol} <name>" . $this->database_definition["name"] . "</name>{$eol} <create>" . $this->database_definition["create"] . "</create>{$eol}");
     for ($error = "", Reset($this->database_definition["TABLES"]), $table = 0; $table < count($this->database_definition["TABLES"]); Next($this->database_definition["TABLES"]), $table++) {
         $table_name = Key($this->database_definition["TABLES"]);
         $output("{$eol} <table>{$eol}{$eol}  <name>{$table_name}</name>{$eol}");
         $output("{$eol}  <declaration>{$eol}");
         $fields = $this->database_definition["TABLES"][$table_name]["FIELDS"];
         for (Reset($fields), $field_number = 0; $field_number < count($fields); $field_number++, Next($fields)) {
             $field_name = Key($fields);
             $field = $fields[$field_name];
             if (!isset($field["type"])) {
                 return "it was not specified the type of the field \"{$field_name}\" of the table \"{$table_name}\"";
             }
             $output("{$eol}   <field>{$eol}    <name>{$field_name}</name>{$eol}    <type>" . $field["type"] . "</type>{$eol}");
             switch ($field["type"]) {
                 case "integer":
                     if (isset($field["unsigned"])) {
                         $output("    <unsigned>1</unsigned>{$eol}");
                     }
                     break;
                 case "text":
                 case "clob":
                 case "blob":
                     if (isset($field["length"])) {
                         $output("    <length>" . $field["length"] . "</length>{$eol}");
                     }
                     break;
                 case "boolean":
                 case "date":
                 case "timestamp":
                 case "time":
                 case "float":
                 case "decimal":
                     break;
                 default:
                     return "type \"" . $field["type"] . "\" is not yet supported";
             }
             if (isset($field["notnull"])) {
                 $output("    <notnull>1</notnull>{$eol}");
             }
             if (isset($field["default"])) {
                 $output("    <default>" . $this->EscapeSpecialCharacters($field["default"]) . "</default>{$eol}");
             }
             $output("   </field>{$eol}");
         }
         if (isset($this->database_definition["TABLES"][$table_name]["INDEXES"])) {
             $indexes = $this->database_definition["TABLES"][$table_name]["INDEXES"];
             for (Reset($indexes), $index_number = 0; $index_number < count($indexes); $index_number++, Next($indexes)) {
                 $index_name = Key($indexes);
                 $index = $indexes[$index_name];
                 $output("{$eol}   <index>{$eol}    <name>{$index_name}</name>{$eol}");
                 if (isset($indexes[$index_name]["unique"])) {
                     $output("    <unique>1</unique>{$eol}");
                 }
                 for (Reset($index["FIELDS"]), $field_number = 0; $field_number < count($index["FIELDS"]); $field_number++, Next($index["FIELDS"])) {
                     $field_name = Key($index["FIELDS"]);
                     $field = $index["FIELDS"][$field_name];
                     $output("    <field>{$eol}     <name>{$field_name}</name>{$eol}");
                     if (isset($field["sorting"])) {
                         $output("     <sorting>" . $field["sorting"] . "</sorting>{$eol}");
                     }
                     $output("    </field>{$eol}");
                 }
                 $output("   </index>{$eol}");
             }
         }
         $output("{$eol}  </declaration>{$eol}");
         if ($dump_definition) {
             if (isset($this->database_definition["TABLES"][$table_name]["initialization"])) {
                 $output("{$eol}  <initialization>{$eol}");
                 $instructions = $this->database_definition["TABLES"][$table_name]["initialization"];
                 for (Reset($instructions), $instruction = 0; $instruction < count($instructions); $instruction++, Next($instructions)) {
                     switch ($instructions[$instruction]["type"]) {
                         case "insert":
                             $output("{$eol}   <insert>{$eol}");
                             $fields = $instructions[$instruction]["FIELDS"];
                             for (Reset($fields), $field_number = 0; $field_number < count($fields); $field_number++, Next($fields)) {
                                 $field_name = Key($fields);
                                 $output("{$eol}    <field>{$eol}     <name>{$field_name}</name>{$eol}     <value>" . $this->EscapeSpecialCharacters($fields[$field_name]) . "</value>{$eol}    </field>{$eol}");
                             }
                             $output("{$eol}   </insert>{$eol}");
                             break;
                     }
                 }
                 $output("{$eol}  </initialization>{$eol}");
             }
         } else {
             if (count($this->database_definition["TABLES"][$table_name]["FIELDS"]) == 0) {
                 return "the definition of the table \"{$table_name}\" does not contain any fields";
             }
             if (strcmp($error = $this->GetFields($table_name, $query_fields), "")) {
                 return $error;
             }
             if ($support_summary_functions = MetabaseSupport($this->database, "SummaryFunctions")) {
                 if (($result = MetabaseQuery($this->database, "SELECT COUNT(*) FROM {$table_name}")) == 0) {
                     return MetabaseError($this->database);
                 }
                 $rows = MetabaseFetchResult($this->database, $result, 0, 0);
                 MetabaseFreeResult($this->database, $result);
             }
             if (($result = MetabaseQuery($this->database, "SELECT {$query_fields} FROM {$table_name}")) == 0) {
                 return MetabaseError($this->database);
             }
             if (!$support_summary_functions) {
                 $rows = MetabaseNumberOfRows($this->database, $result);
             }
             if ($rows > 0) {
                 $output("{$eol}  <initialization>{$eol}");
                 for ($row = 0; $row < $rows; $row++) {
                     $output("{$eol}   <insert>{$eol}");
                     for (Reset($fields), $field_number = 0; $field_number < count($fields); $field_number++, Next($fields)) {
                         $field_name = Key($fields);
                         if (!MetabaseResultIsNull($this->database, $result, $row, $field_name)) {
                             $field = $fields[$field_name];
                             $output("{$eol}    <field>{$eol}     <name>{$field_name}</name>{$eol}     <value>");
                             switch ($field["type"]) {
                                 case "integer":
                                 case "text":
                                     $output($this->EscapeSpecialCharacters(MetabaseFetchResult($this->database, $result, $row, $field_name)));
                                     break;
                                 case "clob":
                                     if (!($lob = MetabaseFetchCLOBResult($this->database, $result, $row, $field_name))) {
                                         return MetabaseError($this->database);
                                     }
                                     while (!MetabaseEndOfLOB($lob)) {
                                         if (MetabaseReadLOB($lob, $data, 8000) < 0) {
                                             return MetabaseLOBError($lob);
                                         }
                                         $output($this->EscapeSpecialCharacters($data));
                                     }
                                     MetabaseDestroyLOB($lob);
                                     break;
                                 case "blob":
                                     if (!($lob = MetabaseFetchBLOBResult($this->database, $result, $row, $field_name))) {
                                         return MetabaseError($this->database);
                                     }
                                     while (!MetabaseEndOfLOB($lob)) {
                                         if (MetabaseReadLOB($lob, $data, 8000) < 0) {
                                             return MetabaseLOBError($lob);
                                         }
                                         $output(bin2hex($data));
                                     }
                                     MetabaseDestroyLOB($lob);
                                     break;
                                 case "float":
                                     $output($this->EscapeSpecialCharacters(MetabaseFetchFloatResult($this->database, $result, $row, $field_name)));
                                     break;
                                 case "decimal":
                                     $output($this->EscapeSpecialCharacters(MetabaseFetchDecimalResult($this->database, $result, $row, $field_name)));
                                     break;
                                 case "boolean":
                                     $output($this->EscapeSpecialCharacters(MetabaseFetchBooleanResult($this->database, $result, $row, $field_name)));
                                     break;
                                 case "date":
                                     $output($this->EscapeSpecialCharacters(MetabaseFetchDateResult($this->database, $result, $row, $field_name)));
                                     break;
                                 case "timestamp":
                                     $output($this->EscapeSpecialCharacters(MetabaseFetchTimestampResult($this->database, $result, $row, $field_name)));
                                     break;
                                 case "time":
                                     $output($this->EscapeSpecialCharacters(MetabaseFetchTimeResult($this->database, $result, $row, $field_name)));
                                     break;
                                 default:
                                     return "type \"" . $field["type"] . "\" is not yet supported";
                             }
                             $output("</value>{$eol}    </field>{$eol}");
                         }
                     }
                     $output("{$eol}   </insert>{$eol}");
                 }
                 $output("{$eol}  </initialization>{$eol}");
             }
             MetabaseFreeResult($this->database, $result);
         }
         $output("{$eol} </table>{$eol}");
         if (isset($sequences[$table_name])) {
             for ($sequence = 0; $sequence < count($sequences[$table_name]); $sequence++) {
                 if (!$this->DumpSequence($sequences[$table_name][$sequence], $output, $eol, $dump_definition)) {
                     return MetabaseError($this->database);
                 }
             }
         }
     }
     if (isset($sequences[""])) {
         for ($sequence = 0; $sequence < count($sequences[""]); $sequence++) {
             if (!$this->DumpSequence($sequences[""][$sequence], $output, $eol, $dump_definition)) {
                 return MetabaseError($this->database);
             }
         }
     }
     $output("{$eol}</database>{$eol}");
     if (strcmp($previous_database_name, "")) {
         MetabaseSetDatabase($this->database, $previous_database_name);
     }
     return $error;
 }
コード例 #4
0
 /**
  * Article::getselPeriod()
  * 
  * This function returns a period.
  * 
  * @param integer $periodid period id
  * @return array period
  * @access public 
  * @since 2004-12-13
  * @author Christian Ehret <*****@*****.**> 
  */
 function getselPeriod($periodid)
 {
     global $gDatabase, $tbl_period, $request, $errorhandler;
     $period = array();
     $query = "SELECT period, active\n\t\t                 FROM {$tbl_period}\n\t\t\t\t\t\t WHERE pk_period_id = {$periodid} ";
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $errorhandler->display('SQL', 'Article::getselPeriod()', $query);
     } else {
         if (MetabaseNumberOfRows($gDatabase, $result) > 0) {
             $period = array("periodid" => $period, "period" => MetabaseFetchResult($gDatabase, $result, 0, 0), "active" => MetabaseFetchBooleanResult($gDatabase, $result, 0, 1));
         }
     }
     return $period;
 }
コード例 #5
0
 /**
  * Guest::getGreeting()
  * 
  * get the greeting for a guest
  * 
  * @param integer $guestid guestid
  * @return string greeting
  * @access public 
  * @since 2003-09-30
  * @author Christian Ehret <*****@*****.**> 
  */
 function getGreeting($guestid)
 {
     global $tbl_guest, $tbl_salutation, $gDatabase, $errorhandler;
     $str = "";
     $query = sprintf("SELECT s.salutation_de, g.academic_title, \n\t\t                  g.firstname, g.lastname, g.formal_greeting, g.gender \n\t\t\t\t\t\t  FROM {$tbl_guest} g\n\t\t\t\t\t\t  LEFT JOIN {$tbl_salutation} s ON (g.fk_salutation_id = s.pk_salutation_id) \n\t\t\t\t\t\t  WHERE g.pk_guest_id = %s", $guestid);
     $result = MetabaseQuery($gDatabase, $query);
     if ($result) {
         if (MetabaseFetchBooleanResult($gDatabase, $result, 0, 4)) {
             switch (MetabaseFetchResult($gDatabase, $result, 0, 0)) {
                 case 'Herr':
                     $str = "Sehr geehrter Herr ";
                     if (MetabaseFetchResult($gDatabase, $result, 0, 1) != "" && MetabaseFetchResult($gDatabase, $result, 0, 1) != null) {
                         $str .= MetabaseFetchResult($gDatabase, $result, 0, 1) . " ";
                     }
                     break;
                 case 'Frau':
                     $str = "Sehr geehrte Frau ";
                     if (MetabaseFetchResult($gDatabase, $result, 0, 1) != "" && MetabaseFetchResult($gDatabase, $result, 0, 1) != null) {
                         $str .= MetabaseFetchResult($gDatabase, $result, 0, 1) . " ";
                     }
                     break;
                 case 'Familie':
                     $str = "Sehr geehrte Familie ";
                     break;
             }
             $str .= MetabaseFetchResult($gDatabase, $result, 0, 3) . ", ";
         } else {
             if (MetabaseFetchResult($gDatabase, $result, 0, 5) == "M") {
                 $str = "Lieber ";
             } else {
                 $str = "Liebe ";
             }
             $str .= MetabaseFetchResult($gDatabase, $result, 0, 2) . ", ";
         }
     } else {
         $str = "Sehr geehrte Damen und Herren, ";
     }
     return $str;
 }
コード例 #6
0
ファイル: driver_test.php プロジェクト: BackupTheBerlios/zvs
function VerifyFetchedValues($database, $result, $row, &$data, &$value, &$field)
{
    return strcmp($value = MetabaseFetchResult($database, $result, $row, "user_name"), $data[$field = "user_name"]) || strcmp($value = MetabaseFetchResult($database, $result, $row, "user_password"), $data[$field = "user_password"]) || strcmp($value = MetabaseFetchBooleanResult($database, $result, $row, "subscribed"), $data[$field = "subscribed"]) || strcmp($value = MetabaseFetchResult($database, $result, $row, "user_id"), $data[$field = "user_id"]) || ($value = MetabaseFetchDecimalResult($database, $result, $row, "quota")) != $data[$field = "quota"] || strcmp($value = MetabaseFetchFloatResult($database, $result, $row, "weight"), $data[$field = "weight"]) || strcmp($value = MetabaseFetchDateResult($database, $result, $row, "access_date"), $data[$field = "access_date"]) || strcmp($value = MetabaseFetchTimeResult($database, $result, $row, "access_time"), $data[$field = "access_time"]) || strcmp($value = MetabaseFetchTimestampResult($database, $result, $row, "approved"), $data[$field = "approved"]);
}
コード例 #7
0
 /**
  * RoomCategory::getall()
  * 
  * This function returns all categories.
  * 
  * @return array categories
  * @access public 
  * @since 2003-07-24
  * @author Christian Ehret <*****@*****.**> 
  */
 function getall()
 {
     global $gDatabase, $tbl_roomcat, $tbl_roomcat_article, $tbl_article, $errorhandler, $request;
     $cat = array();
     $query = "SELECT pk_roomcat_id, roomcat, price_type \n\t\t\t\t  FROM {$tbl_roomcat} \n\t\t\t\t  WHERE ISNULL(fk_deleted_user_id) \n\t\t\t\t  ORDER BY roomcat";
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $errorhandler->display('SQL', 'RoomCategory::getall()', $query);
     } else {
         $row = 0;
         for ($row = 0; ($eor = MetabaseEndOfResult($gDatabase, $result)) == 0; ++$row) {
             $color = 0;
             $articles = "";
             if ($row % 2 != 0) {
                 $color = 1;
             }
             $query = "SELECT a.article, ra.price_type, ra.person, ra.children, ra.children2, ra.children3, ra.included \n\t\t\t\t          FROM {$tbl_article} a, {$tbl_roomcat_article} ra\n\t\t\t\t\t\t  WHERE a.pk_article_id = ra.pk_fk_article_id\n\t\t\t\t\t\t  AND ra.pk_fk_roomcat_id = " . MetabaseFetchResult($gDatabase, $result, $row, 0);
             $result2 = MetabaseQuery($gDatabase, $query);
             if (!$result2) {
                 $errorhandler->display('SQL', 'RoomCategory::getall()', $query);
             } else {
                 for ($row2 = 0; ($eor = MetabaseEndOfResult($gDatabase, $result2)) == 0; ++$row2) {
                     if ($articles !== "") {
                         $articles .= ",<br>";
                     }
                     $text = "<b>" . MetabaseFetchResult($gDatabase, $result2, $row2, 0) . "</b><br>";
                     if (MetabaseFetchResult($gDatabase, $result2, $row2, 1) == 'PR') {
                         $text .= "pauschal";
                     } else {
                         $text .= "Pro Person f&uuml;r: <br>";
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row2, 2)) {
                             $text .= "Erwachsene<br>";
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row2, 3)) {
                             $text .= $request->GetVar('children1', 'session') . "<br>";
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row2, 4)) {
                             $text .= $request->GetVar('children2', 'session') . "<br>";
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row2, 5)) {
                             $text .= $request->GetVar('children3', 'session') . "<br>";
                         }
                     }
                     if (MetabaseFetchBooleanResult($gDatabase, $result2, $row2, 6)) {
                         $text .= "Im Zimmerpreis enthalten<br>";
                     }
                     $articles .= "<A ONMOUSEOVER=\" popup('{$text}','{$wwwroot}');\" ONMOUSEOUT=\"kill();\">" . MetabaseFetchResult($gDatabase, $result2, $row2, 0) . "</A>";
                 }
             }
             $cat[$row] = array('catid' => MetabaseFetchResult($gDatabase, $result, $row, 0), 'name' => MetabaseFetchResult($gDatabase, $result, $row, 1), 'price_type' => MetabaseFetchResult($gDatabase, $result, $row, 2), 'color' => $color, 'articles' => $articles);
         }
     }
     return $cat;
 }
コード例 #8
0
 /**
  * Kassa::getTimeline()
  * 
  * This function returns all bought articles for one guest.
  * 
  * @param number $guestid guest id
  * @param date $start start date
  * @param date $end end date
  * @param string $order order desc or asc
  * @param array $cats categories
  * @return array articles
  * @access public 
  * @since 2004-01-06
  * @author Christian Ehret <*****@*****.**> 
  */
 function getTimeline($guestid, $start, $end, $order, $cats = array())
 {
     global $gDatabase2, $tbl_bararticle, $tbl_user, $tbl_bought, $tbl_barguest, $request, $errorhandler, $articlerows;
     $article = array();
     if (count($cats) > 0) {
         $catstr = "AND ba.fk_bararticlecat_id IN (";
         for ($i = 0; $i < count($cats); $i++) {
             if ($i > 0) {
                 $catstr .= ", ";
             }
             $catstr .= $cats[$i];
         }
         $catstr .= ")";
     } else {
         return array();
     }
     list($day, $month, $year) = split('.', $start);
     $query = "SELECT ba.pk_bararticle_id, ba.description, ba.price, DATE_FORMAT( b.timestamp, '%d.%m.%Y, %H:%i' ), num, pk_bought_id, paid,\n\t\t\t\t  DATE_FORMAT( b.updated_date, '%d.%m.%Y, %H:%i Uhr' ), u2.firstname, u2.lastname,\n\t\t\t\t  DATE_FORMAT( b.inserted_date, '%d.%m.%Y, %H:%i Uhr' ), u1.firstname, u1.lastname \n                 FROM {$tbl_bought} b\n\t\t\t\t  \t\t  LEFT JOIN {$tbl_barguest} bg ON bg.pk_barguest_id = b.fk_barguest_id\n\t\t\t\t  \t      LEFT JOIN {$tbl_bararticle} ba ON b.fk_bararticle_id = ba.pk_bararticle_id\n\t\t\t\t\t\t  LEFT JOIN {$tbl_user} u1 ON b.fk_inserted_user_id = u1.pk_user_id\n\t\t\t\t\t\t  LEFT JOIN {$tbl_user} u2 ON b.fk_updated_user_id = u2.pk_user_id\n\t\t\t\t\t\t  WHERE bg.pk_barguest_id = {$guestid} \n\t\t\t\t\t\t  {$catstr} ";
     if ($start !== "") {
         list($day, $month, $year) = split('[.]', $start);
         $query .= "AND UNIX_TIMESTAMP(b.timestamp) >= " . mktime(0, 0, 0, $month, $day, $year) . " ";
     }
     if ($end !== "") {
         list($day, $month, $year) = split('[.]', $end);
         $query .= "AND UNIX_TIMESTAMP(b.timestamp) <= " . mktime(0, 0, 0, $month, $day + 1, $year) . " ";
     }
     $query .= "ORDER BY b.timestamp " . $order;
     $result = MetabaseQuery($gDatabase2, $query);
     if (!$result) {
         $errorhandler->display('SQL', 'Kassa::getTimeline()', $query);
     } else {
         $row = 0;
         for ($row = 0; ($eor = MetabaseEndOfResult($gDatabase2, $result)) == 0; ++$row) {
             $color = 0;
             if ($row % 2 != 0) {
                 $color = 1;
             }
             $total = MetabaseFetchResult($gDatabase2, $result, $row, 2) * MetabaseFetchResult($gDatabase2, $result, $row, 4);
             // print "paid: ".MetabaseFetchBooleanResult($gDatabase2, $result, $row, 6);
             if (MetabaseFetchBooleanResult($gDatabase2, $result, $row, 6)) {
                 $sum2 += $total;
                 $sum += $total;
                 $paid = $total;
             } else {
                 $sum += $total;
                 $paid = "0.00";
             }
             $article[$row] = array('articleid' => MetabaseFetchResult($gDatabase2, $result, $row, 0), 'description' => MetabaseFetchResult($gDatabase2, $result, $row, 1), 'price' => MetabaseFetchResult($gDatabase2, $result, $row, 2), 'timestamp' => MetabaseFetchResult($gDatabase2, $result, $row, 3), 'num' => MetabaseFetchResult($gDatabase2, $result, $row, 4), 'boughtid' => MetabaseFetchResult($gDatabase2, $result, $row, 5), 'paid' => MetabaseFetchBooleanResult($gDatabase2, $result, $row, 6), 'updated' => MetabaseFetchResult($gDatabase2, $result, $row, 7), 'updateduser' => MetabaseFetchResult($gDatabase2, $result, $row, 8) . " " . MetabaseFetchResult($gDatabase2, $result, $row, 9), 'inserted' => MetabaseFetchResult($gDatabase2, $result, $row, 10), 'inserteduser' => MetabaseFetchResult($gDatabase2, $result, $row, 11) . " " . MetabaseFetchResult($gDatabase2, $result, $row, 12), 'total1' => number_format($total, 2, '.', ''), 'total2' => number_format($paid, 2, '.', ''), 'color' => $color);
         }
         $color = 0;
         if ($row % 2 != 0) {
             $color = 1;
         }
         $article[$row] = array('articleid' => 0, 'description' => "Summe:", 'price' => "", 'timestamp' => "", 'num' => "", 'boughtid' => "", 'paid' => "", 'updated' => "", 'total1' => number_format($sum, 2, '.', ''), 'total2' => number_format($sum2, 2, '.', ''), 'color' => $color);
         $sum -= $sum2;
         $article[$row + 1] = array('articleid' => 0, 'description' => "zu zahlen:", 'price' => "", 'timestamp' => "", 'num' => "", 'boughtid' => "", 'paid' => "", 'updated' => "", 'total1' => number_format($sum, 2, '.', ''), 'total2' => "", 'color' => $color);
     }
     return $article;
 }
コード例 #9
0
 /**
  * price::get()
  * 
  * get receipt
  * 
  * @access public 
  * @param number $bookingid booking id
  * @param number $length_short_stay length of short stay
  * @param number $guestid guest id
  * @return array receipt return false if something went wrong e.g. season is not defined
  * @since 2004-02-04
  * @author Christian Ehret <*****@*****.**> 
  */
 function get($bookingid, $length_short_stay, $guestid)
 {
     global $gDatabase, $tbl_price, $tbl_price2, $tbl_booking, $tbl_booking_detail, $tbl_room, $tbl_season, $tbl_guest, $tbl_guest_address, $tbl_address, $tbl_salutation, $tbl_country, $tbl_roomcat, $tbl_bookingcat, $errorhandler, $request, $tbl_article, $tbl_roomcat_article, $tbl_account;
     $mwst_room = $request->GetVar('mwst_room', 'Session');
     $receipt = array();
     $query = "SELECT rc.price_type FROM {$tbl_booking} b\n\t\t\t\t\tLEFT JOIN {$tbl_booking_detail} bd ON bd.fk_booking_id = b.pk_booking_id\n\t\t\t\t\tLEFT JOIN {$tbl_room} r ON bd.fk_room_id = r.pk_room_id\n\t\t\t\t\tLEFT JOIN {$tbl_roomcat} rc ON r.fk_roomcat_id = rc.pk_roomcat_id\n\t\t\t\t\tWHERE b.pk_booking_id = {$bookingid}";
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $errorhandler->display('SQL', 'Receipt::get()', $query);
     } else {
         $price_type = MetabaseFetchResult($gDatabase, $result, 0, 0);
     }
     // normal price type (per Person)
     if ($price_type == 'N') {
         $personlocation = -1;
         $childrenlocation = -1;
         $children2location = -1;
         $children3location = -1;
         $pauschlocation = -1;
         $query = "SELECT \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_person_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\tp.price_person_short\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\tp.price_person\n\t\t\t\t\t\tEND AS price_person, \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_children_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\tp.price_children_short\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\tp.price_children\n\t\t\t\t\t\tEND\tAS price_children, \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_absolute_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\tp.price_absolute_short\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\tp.price_absolute\n\t\t\t\t\t\tEND\tAS price_absolute, \t\t\t\t\t\t\n\t\t\t\t\t     p.price_type,\n\t\t\t\t\t\t DATE_FORMAT(b.start_date, '%d.%m.%Y'), DATE_FORMAT(b.end_date, '%d.%m.%Y'), \n\t\t\t\t\t\t b.persons, b.children, r.room, s.name, \n\t\t\t\t\t\t TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) AS days, \n\t\t\t\t\t\t g.firstname, g.lastname, g.academic_title, b.booking_reference_id,\n\t\t\t\t\t\t a.postalcode, a.city, a.address, sal.salutation_de, coun.country_de, \n\t\t\t\t\t\t bc.bookingcat,\n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_person_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\tEND AS price_person_short, \t\n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_children_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\tEND\tAS price_children_short, \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_absolute_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\tEND\tAS price_absolute_short,\t\t\n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_children2_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\tp.price_children2_short\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\tp.price_children2\n\t\t\t\t\t\tEND\tAS price_children2, \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_children3_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\tp.price_children3_short\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\tp.price_children3\n\t\t\t\t\t\tEND\tAS price_children3, \t\n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_children2_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\tEND\tAS price_children2_short, \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_children3_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\tEND\tAS price_children3_short,\n\t\t\t\t\tb.children2, b.children3, r.fk_roomcat_id, g.pk_guest_id, bc.days \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n\t\t\t\t\tFROM {$tbl_price} p, {$tbl_booking} b\n\t\t\t\t\tLEFT JOIN {$tbl_booking_detail} bd ON bd.fk_booking_id = b.pk_booking_id\n\t\t\t\t\tLEFT JOIN {$tbl_room} r ON bd.fk_room_id = r.pk_room_id\n\t\t\t\t\tLEFT JOIN {$tbl_guest} g ON (b.fk_guest_id = g.pk_guest_id) \n\t\t\t\t \tLEFT JOIN {$tbl_guest_address} ga ON (ga.default_address  = " . MetabaseGetBooleanFieldValue($gDatabase, true) . " \n\t\t\t\t\t \tAND g.pk_guest_id = ga.pk_fk_guest_id) \n\t\t\t\t \tLEFT JOIN {$tbl_address} a ON (a.pk_address_id = ga.pk_fk_address_id) \n\t\t\t\t\tLEFT JOIN {$tbl_salutation} sal ON (g.fk_salutation_id = sal.pk_salutation_id) \n\t\t\t\t\tLEFT JOIN {$tbl_country} coun ON (a.fk_country_id = coun.pk_country_id )\t\n\t\t\t\t\tLEFT JOIN {$tbl_bookingcat} bc ON (b.fk_bookingcat_id = bc.pk_bookingcat_id) \n\t\t\t\t\tLEFT JOIN {$tbl_season} s ON b.start_date BETWEEN s.start_date AND s.end_date AND ISNULL(s.deleted_date)\n\t\t\t\t\tWHERE b.pk_booking_id = {$bookingid} \n\t\t\t\t\t\t\tAND p.fk_roomcat_id = r.fk_roomcat_id \n\t\t\t\t\t\t\tAND p.fk_bookingcat_id = b.fk_bookingcat_id \n\t\t\t\t\t\t\tAND p.fk_season_id = s.pk_season_id \n\t\t\t\t\t\t\tAND ISNULL(p.deleted_date)\n\t\t\t\t";
         $result = MetabaseQuery($gDatabase, $query);
         if (!$result) {
             $errorhandler->display('SQL', 'Receipt::get()', $query);
         } elseif (MetabaseNumberOfRows($gDatabase, $result) != 0) {
             $bcdays = MetabaseFetchResult($gDatabase, $result, 0, 32);
             $roomcatid = MetabaseFetchResult($gDatabase, $result, 0, 30);
             $realdays = MetabaseFetchResult($gDatabase, $result, 0, 10);
             $days = ceil($realdays / $bcdays);
             if ($realdays % $bcdays != 0) {
                 $pauscherror = "Die Buchungskategorie enth&auml;lt {$bcdays} Tage - es wurden aber {$realdays} Tage gebucht!";
             } else {
                 $pauscherror = '';
             }
             $price_type = MetabaseFetchResult($gDatabase, $result, 0, 3);
             $persons = MetabaseFetchResult($gDatabase, $result, 0, 6);
             $num_person = $days * $persons;
             $price_person = MetabaseFetchResult($gDatabase, $result, 0, 0);
             $price_person_netto = round($price_person * 100 / (100 + $mwst_room), 2);
             $price_person_total = $num_person * $price_person;
             $price_person_netto_total = $num_person * $price_person_netto;
             $children = MetabaseFetchResult($gDatabase, $result, 0, 7);
             $num_children = $days * $children;
             $price_children = MetabaseFetchResult($gDatabase, $result, 0, 1);
             $price_children_netto = round($price_children * 100 / (100 + $mwst_room), 2);
             $price_children_total = $num_children * $price_children;
             $price_children_netto_total = $num_children * $price_children_netto;
             $children2 = MetabaseFetchResult($gDatabase, $result, 0, 28);
             $num_children2 = $days * $children2;
             $price_children2 = MetabaseFetchResult($gDatabase, $result, 0, 24);
             $price_children2_netto = round($price_children2 * 100 / (100 + $mwst_room), 2);
             $price_children2_total = $num_children2 * $price_children2;
             $price_children2_netto_total = $num_children2 * $price_children2_netto;
             $children3 = MetabaseFetchResult($gDatabase, $result, 0, 29);
             $num_children3 = $days * $children3;
             $price_children3 = MetabaseFetchResult($gDatabase, $result, 0, 25);
             $price_children3_netto = round($price_children3 * 100 / (100 + $mwst_room), 2);
             $price_children3_total = $num_children3 * $price_children3;
             $price_children3_netto_total = $num_children3 * $price_children3_netto;
             $num_absolute = $days;
             $price_absolute = MetabaseFetchResult($gDatabase, $result, 0, 2);
             $price_absolute_netto = round($price_absolute * 100 / (100 + $mwst_room), 2);
             $price_absolute_total = $num_absolute * $price_absolute;
             $price_absolute_netto_total = $num_absolute * $price_absolute_netto;
             if ($guestid == -1 || $guestid == '') {
                 $guestid = MetabaseFetchResult($gDatabase, $result, 0, 31);
             }
             if ($price_type == 'PP') {
                 $price_netto_total = $price_person_netto_total + $price_children_netto_total + $price_children2_netto_total + $price_children3_netto_total;
                 $price_total = $price_person_total + $price_children_total + $price_children2_total + $price_children3_total;
             } else {
                 $price_netto_total = $price_absolute_netto_total;
                 $price_total = $price_absolute_total;
             }
             $address = "";
             if (MetabaseFetchResult($gDatabase, $result, 0, 18) !== 'n/a') {
                 $address .= MetabaseFetchResult($gDatabase, $result, 0, 18) . "\n";
             }
             if (trim(MetabaseFetchResult($gDatabase, $result, 0, 13)) !== "") {
                 $address .= MetabaseFetchResult($gDatabase, $result, 0, 13) . " ";
             }
             $address .= MetabaseFetchResult($gDatabase, $result, 0, 11) . " " . MetabaseFetchResult($gDatabase, $result, 0, 12) . "\n";
             $address .= MetabaseFetchResult($gDatabase, $result, 0, 17) . "\n";
             $address .= MetabaseFetchResult($gDatabase, $result, 0, 15) . " " . MetabaseFetchResult($gDatabase, $result, 0, 16) . "\n\n";
             if (MetabaseFetchResult($gDatabase, $result, 0, 19) !== 'n/a') {
                 $address .= MetabaseFetchResult($gDatabase, $result, 0, 19);
             }
             $receipt[data] = array('bookid' => $bookingid, 'guestid' => $guestid, 'referenceid' => '', 'address' => $address, 'receipt_date' => date("d.m.Y"), 'start_date' => array(MetabaseFetchResult($gDatabase, $result, 0, 4)), 'end_date' => array(MetabaseFetchResult($gDatabase, $result, 0, 5)), 'receiptid' => '-1', 'draftreceiptid' => '-1', 'price_netto_total' => $price_netto_total, 'price_total' => $price_total, 'pauscherror' => $pauscherror);
             $i = 0;
             $nextcolor = 0;
             if ($price_type == "PP") {
                 if ($persons > 0) {
                     $article = MetabaseFetchResult($gDatabase, $result, 0, 20) . "\n";
                     $article .= $persons;
                     if ($persons > 1) {
                         $article .= " Erwachsene\n";
                     } else {
                         $article .= " Erwachsener\n";
                     }
                     $article .= $realdays;
                     if ($realdays > 1) {
                         $article .= " &Uuml;bernachtungen";
                     } else {
                         $article .= " &Uuml;bernachtung";
                     }
                     if (MetabaseFetchResult($gDatabase, $result, 0, 21) == 'true') {
                         $article .= " (Kurzbuchertarif)";
                     }
                     $receipt[items][$i][color] = $nextcolor;
                     $receipt[items][$i][id] = $i;
                     $receipt[items][$i][itemid] = -1;
                     $receipt[items][$i][article] = $article;
                     $receipt[items][$i][number] = $num_person;
                     $receipt[items][$i][netto_single] = number_format($price_person_netto, 2, '.', '');
                     $receipt[items][$i][mwst] = $request->GetVar('mwst_room', 'Session');
                     $receipt[items][$i][brutto_single] = number_format($price_person, 2, '.', '');
                     $receipt[items][$i][netto] = number_format($price_person_netto_total, 2, '.', '');
                     $receipt[items][$i][brutto] = number_format($price_person_total, 2, '.', '');
                     $personlocation = $i;
                     $i++;
                     if ($nextcolor == 0) {
                         $nextcolor = 1;
                     } else {
                         $nextcolor = 0;
                     }
                 }
                 if ($children > 0) {
                     $article = MetabaseFetchResult($gDatabase, $result, 0, 20) . "\n";
                     $article .= $children;
                     /*
                                         if ($children > 1) {
                                             $article .= " Kinder\n";
                                         } else {
                                             $article .= " Kind\n";
                                         } 
                     */
                     $article .= " " . $request->GetVar('children1', 'session') . "\n";
                     $article .= $days;
                     if ($days > 1) {
                         $article .= " &Uuml;bernachtungen";
                     } else {
                         $article .= " &Uuml;bernachtung";
                     }
                     if (MetabaseFetchResult($gDatabase, $result, 0, 21) == 'true') {
                         $article .= " (Kurzbuchertarif)";
                     }
                     $receipt[items][$i][color] = $nextcolor;
                     $receipt[items][$i][id] = $i;
                     $receipt[items][$i][itemid] = -1;
                     $receipt[items][$i][article] = $article;
                     $receipt[items][$i][number] = $num_children;
                     $receipt[items][$i][netto_single] = number_format($price_children_netto, 2, '.', '');
                     $receipt[items][$i][mwst] = $request->GetVar('mwst_room', 'Session');
                     $receipt[items][$i][brutto_single] = number_format($price_children, 2, '.', '');
                     $receipt[items][$i][netto] = number_format($price_children_netto_total, 2, '.', '');
                     $receipt[items][$i][brutto] = number_format($price_children_total, 2, '.', '');
                     $childrenlocation = $i;
                     $i++;
                     if ($nextcolor == 0) {
                         $nextcolor = 1;
                     } else {
                         $nextcolor = 0;
                     }
                 }
                 if ($children2 > 0) {
                     $article = MetabaseFetchResult($gDatabase, $result, 0, 20) . "\n";
                     $article .= $children2;
                     /*
                                         if ($children2 > 1) {
                                             $article .= " Kinder\n";
                                         } else {
                                             $article .= " Kind\n";
                                         } 
                     */
                     $article .= " " . $request->GetVar('children2', 'session') . "\n";
                     $article .= $days;
                     if ($days > 1) {
                         $article .= " &Uuml;bernachtungen";
                     } else {
                         $article .= " &Uuml;bernachtung";
                     }
                     if (MetabaseFetchResult($gDatabase, $result, 0, 26) == 'true') {
                         $article .= " (Kurzbuchertarif)";
                     }
                     $receipt[items][$i][color] = $nextcolor;
                     $receipt[items][$i][id] = $i;
                     $receipt[items][$i][itemid] = -1;
                     $receipt[items][$i][article] = $article;
                     $receipt[items][$i][number] = $num_children2;
                     $receipt[items][$i][netto_single] = number_format($price_children2_netto, 2, '.', '');
                     $receipt[items][$i][mwst] = $request->GetVar('mwst_room', 'Session');
                     $receipt[items][$i][brutto_single] = number_format($price_children2, 2, '.', '');
                     $receipt[items][$i][netto] = number_format($price_children2_netto_total, 2, '.', '');
                     $receipt[items][$i][brutto] = number_format($price_children2_total, 2, '.', '');
                     $children2location = $i;
                     $i++;
                     if ($nextcolor == 0) {
                         $nextcolor = 1;
                     } else {
                         $nextcolor = 0;
                     }
                 }
                 if ($children3 > 0) {
                     $article = MetabaseFetchResult($gDatabase, $result, 0, 20) . "\n";
                     $article .= $children3;
                     /*
                                         if ($children3 > 1) {
                                             $article .= " Kinder\n";
                                         } else {
                                             $article .= " Kind\n";
                                         } 
                     */
                     $article .= " " . $request->GetVar('children3', 'session') . "\n";
                     $article .= $days;
                     if ($days > 1) {
                         $article .= " &Uuml;bernachtungen";
                     } else {
                         $article .= " &Uuml;bernachtung";
                     }
                     if (MetabaseFetchResult($gDatabase, $result, 0, 27) == 'true') {
                         $article .= " (Kurzbuchertarif)";
                     }
                     $receipt[items][$i][color] = $nextcolor;
                     $receipt[items][$i][id] = $i;
                     $receipt[items][$i][itemid] = -1;
                     $receipt[items][$i][article] = $article;
                     $receipt[items][$i][number] = $num_children3;
                     $receipt[items][$i][netto_single] = number_format($price_children3_netto, 2, '.', '');
                     $receipt[items][$i][mwst] = $request->GetVar('mwst_room', 'Session');
                     $receipt[items][$i][brutto_single] = number_format($price_children3, 2, '.', '');
                     $receipt[items][$i][netto] = number_format($price_children3_netto_total, 2, '.', '');
                     $receipt[items][$i][brutto] = number_format($price_children3_total, 2, '.', '');
                     $children3location = $i;
                     $i++;
                     if ($nextcolor == 0) {
                         $nextcolor = 1;
                     } else {
                         $nextcolor = 0;
                     }
                 }
             } else {
                 $article = MetabaseFetchResult($gDatabase, $result, 0, 20) . "\n";
                 $article .= $days;
                 if ($days > 1) {
                     $article .= " &Uuml;bernachtungen";
                 } else {
                     $article .= " &Uuml;bernachtung";
                 }
                 if (MetabaseFetchResult($gDatabase, $result, 0, 21) == 'true') {
                     $article .= " (Kurzbuchertarif)";
                 }
                 $receipt[items][$i][color] = $nextcolor;
                 $receipt[items][$i][id] = $i;
                 $receipt[items][$i][itemid] = -1;
                 $receipt[items][$i][article] = $article;
                 $receipt[items][$i][number] = $num_absolute;
                 $receipt[items][$i][netto_single] = number_format($price_absolute_netto, 2, '.', '');
                 $receipt[items][$i][mwst] = $request->GetVar('mwst_room', 'Session');
                 $receipt[items][$i][brutto_single] = number_format($price_absolute, 2, '.', '');
                 $receipt[items][$i][netto] = number_format($price_absolute_netto_total, 2, '.', '');
                 $receipt[items][$i][brutto] = number_format($price_absolute_total, 2, '.', '');
                 $pauschlocation = $i;
                 $i++;
                 if ($nextcolor == 0) {
                     $nextcolor = 1;
                 } else {
                     $nextcolor = 0;
                 }
             }
             $query = "SELECT article, price_netto, price_brutto, mwst, price_type, \n\t\t\t\t\t  person, children, children2, children3, included\n\t\t\t\t\t  FROM {$tbl_article}, {$tbl_roomcat_article}\n\t\t\t\t\t  WHERE pk_article_id = pk_fk_article_id \n\t\t\t\t\t  AND pk_fk_roomcat_id = " . $roomcatid;
             $result2 = MetabaseQuery($gDatabase, $query);
             if (!$result2) {
                 $errorhandler->display('SQL', 'Receipt::get()', $query);
             } else {
                 for ($row = 0; ($eor = MetabaseEndOfResult($gDatabase, $result2)) == 0; ++$row) {
                     $price_substract = MetabaseFetchResult($gDatabase, $result2, $row, 2);
                     $price_netto_substract = round($price_substract * 100 / (100 + $mwst_room), 2);
                     if (MetabaseFetchResult($gDatabase, $result2, $row, 4) == 'PP') {
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 5) == true && $num_person > 0) {
                             $receipt[items][$i][color] = $nextcolor;
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_person;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_person * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_person * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             // substract included articles
                             if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 9) == true) {
                                 $price_person -= $price_substract;
                                 $price_person_netto = round($price_person * 100 / (100 + $mwst_room), 2);
                                 $price_person_total = $num_person * $price_person;
                                 $price_person_netto_total = $num_person * $price_person_netto;
                                 $receipt[items][$personlocation][brutto_single] = number_format($price_person, 2, '.', '');
                                 $receipt[items][$personlocation][netto_single] = number_format($price_person_netto, 2, '.', '');
                                 $receipt[items][$personlocation][netto] = number_format($price_person_netto_total, 2, '.', '');
                                 $receipt[items][$personlocation][brutto] = number_format($price_person_total, 2, '.', '');
                                 $receipt[data][price_netto_total] -= $price_netto_substract * $num_person;
                                 $receipt[data][price_total] -= $price_substract * $num_person;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_person * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_person * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 6) == true && $num_children > 0) {
                             $receipt[items][$i][color] = $nextcolor;
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_children;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_children * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_children * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             // substract included articles
                             if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 9) == true) {
                                 $price_children -= $price_substract;
                                 $price_children_netto = round($price_children * 100 / (100 + $mwst_room), 2);
                                 $price_children_total = $num_children * $price_children;
                                 $price_children_netto_total = $num_children * $price_children_netto;
                                 $receipt[items][$childrenlocation][brutto_single] = number_format($price_children, 2, '.', '');
                                 $receipt[items][$childrenlocation][netto_single] = number_format($price_children_netto, 2, '.', '');
                                 $receipt[items][$childrenlocation][netto] = number_format($price_children_netto_total, 2, '.', '');
                                 $receipt[items][$childrenlocation][brutto] = number_format($price_children_total, 2, '.', '');
                                 $receipt[data][price_netto_total] -= $price_netto_substract * $num_children;
                                 $receipt[data][price_total] -= $price_substract * $num_children;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_children * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_children * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 7) == true && $num_children2 > 0) {
                             $receipt[items][$i][color] = $nextcolor;
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_children2;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             // substract included articles
                             if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 9) == true) {
                                 $price_children2 -= $price_substract;
                                 $price_children2_netto = round($price_children2 * 100 / (100 + $mwst_room), 2);
                                 $price_children2_total = $num_children2 * $price_children2;
                                 $price_children2_netto_total = $num_children2 * $price_children2_netto;
                                 $receipt[items][$children2location][brutto_single] = number_format($price_children2, 2, '.', '');
                                 $receipt[items][$children2location][netto_single] = number_format($price_children2_netto, 2, '.', '');
                                 $receipt[items][$children2location][netto] = number_format($price_children2_netto_total, 2, '.', '');
                                 $receipt[items][$children2location][brutto] = number_format($price_children2_total, 2, '.', '');
                                 $receipt[data][price_netto_total] -= $price_netto_substract * $num_children2;
                                 $receipt[data][price_total] -= $price_substract * $num_children2;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 6) == true && $num_children3 > 0) {
                             $receipt[items][$i][color] = $nextcolor;
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_children3;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             // substract included articles
                             if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 9) == true) {
                                 $price_children3 -= $price_substract;
                                 $price_children3_netto = round($price_children3 * 100 / (100 + $mwst_room), 2);
                                 $price_children3_total = $num_children3 * $price_children3;
                                 $price_children3_netto_total = $num_children3 * $price_children3_netto;
                                 $receipt[items][$children3location][brutto_single] = number_format($price_children3, 2, '.', '');
                                 $receipt[items][$children3location][netto_single] = number_format($price_children3_netto, 2, '.', '');
                                 $receipt[items][$children3location][netto] = number_format($price_children3_netto_total, 2, '.', '');
                                 $receipt[items][$children3location][brutto] = number_format($price_children3_total, 2, '.', '');
                                 $receipt[data][price_netto_total] -= $price_netto_substract * $num_children3;
                                 $receipt[data][price_total] -= $price_substract * $num_children3;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                     } else {
                         $receipt[items][$i][color] = $nextcolor;
                         $receipt[items][$i][id] = $i;
                         $receipt[items][$i][itemid] = -1;
                         $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                         $receipt[items][$i][number] = 1;
                         $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                         $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                         $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                         $receipt[items][$i][netto] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                         $receipt[items][$i][brutto] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                         $i++;
                         if ($nextcolor == 0) {
                             $nextcolor = 1;
                         } else {
                             $nextcolor = 0;
                         }
                         $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + MetabaseFetchResult($gDatabase, $result2, $row, 1);
                         $receipt[data][price_total] = $receipt[data][price_total] + MetabaseFetchResult($gDatabase, $result2, $row, 2);
                     }
                 }
             }
             $receipt[data][price_netto_total] = number_format($receipt[data][price_netto_total], 2, '.', '');
             $receipt[data][price_total] = number_format($receipt[data][price_total], 2, '.', '');
         } else {
             return false;
             exit;
         }
         // advanced price type
     } else {
         $query = "SELECT \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\tp.price_short\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\tp.price\n\t\t\t\t\t\tEND AS price, \n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_short_additional <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\tp.price_short_additional\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\tp.price_additional\n\t\t\t\t\t\tEND\tAS price_additional, \n\t\t\t\t\t\t DATE_FORMAT(b.start_date, '%d.%m.%Y'), DATE_FORMAT(b.end_date, '%d.%m.%Y'), \n\t\t\t\t\t\t r.room, s.name, \n\t\t\t\t\t\t TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) AS days, \n\t\t\t\t\t\t g.firstname, g.lastname, g.academic_title, b.booking_reference_id,\n\t\t\t\t\t\t a.postalcode, a.city, a.address, sal.salutation_de, coun.country_de, \n\t\t\t\t\t\t bc.bookingcat,\n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_short <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\tEND AS price_short, \t\n\t\t\t\t\tCASE  \n\t\t\t\t\t\tWHEN TO_DAYS( b.end_date ) - TO_DAYS( b.start_date ) <= {$length_short_stay} AND p.price_short_additional <> 0.00\n\t\t\t\t\t\t\tTHEN \n\t\t\t\t\t\t\t\t'true'\n\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\tEND\tAS price_short_additional, \n\t\t\t\t\tb.persons + b.children + b.children2 + b.children3 as persons, \n\t\t\t\t\tr.fk_roomcat_id, g.pk_guest_id, p.persons_included, b.persons, b.children, b.children2,\n\t\t\t\t\tb.children3, bc.days \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n\t\t\t\t\tFROM {$tbl_price2} p, {$tbl_booking} b\n\t\t\t\t\tLEFT JOIN {$tbl_booking_detail} bd ON bd.fk_booking_id = b.pk_booking_id\n\t\t\t\t\tLEFT JOIN {$tbl_room} r ON bd.fk_room_id = r.pk_room_id\n\t\t\t\t\tLEFT JOIN {$tbl_guest} g ON (b.fk_guest_id = g.pk_guest_id) \n\t\t\t\t \tLEFT JOIN {$tbl_guest_address} ga ON (ga.default_address  = " . MetabaseGetBooleanFieldValue($gDatabase, true) . " \n\t\t\t\t\t \tAND g.pk_guest_id = ga.pk_fk_guest_id) \n\t\t\t\t \tLEFT JOIN {$tbl_address} a ON (a.pk_address_id = ga.pk_fk_address_id) \n\t\t\t\t\tLEFT JOIN {$tbl_salutation} sal ON (g.fk_salutation_id = sal.pk_salutation_id) \n\t\t\t\t\tLEFT JOIN {$tbl_country} coun ON (a.fk_country_id = coun.pk_country_id )\t\n\t\t\t\t\tLEFT JOIN {$tbl_bookingcat} bc ON (b.fk_bookingcat_id = bc.pk_bookingcat_id) \n\t\t\t\t\tLEFT JOIN {$tbl_season} s ON b.start_date BETWEEN s.start_date AND s.end_date AND ISNULL(s.deleted_date)\n\t\t\t\t\tWHERE b.pk_booking_id = {$bookingid} \n\t\t\t\t\t\t\tAND p.fk_roomcat_id = r.fk_roomcat_id \n\t\t\t\t\t\t\tAND p.fk_bookingcat_id = b.fk_bookingcat_id \n\t\t\t\t\t\t\tAND p.fk_season_id = s.pk_season_id \n\t\t\t\t\t\t\tAND ISNULL(p.deleted_date)\n\t\t\t\t";
         $result = MetabaseQuery($gDatabase, $query);
         if (!$result) {
             $errorhandler->display('SQL', 'Receipt::get()', $query);
         } else {
             $bcdays = MetabaseFetchResult($gDatabase, $result, 0, 27);
             $roomcatid = MetabaseFetchResult($gDatabase, $result, 0, 20);
             $realdays = MetabaseFetchResult($gDatabase, $result, 0, 6);
             $days = ceil($realdays / $bcdays);
             if ($realdays % $bcdays != 0) {
                 $pauscherror = "Die Buchungskategorie enth&auml;lt {$bcdays} Tage - es wurden aber {$realdays} Tage gebucht!";
             } else {
                 $pauscherror = '';
             }
             $persons = MetabaseFetchResult($gDatabase, $result, 0, 19);
             $num_person = $days * $persons;
             $base_price = MetabaseFetchResult($gDatabase, $result, 0, 0);
             $base_price_netto = round($base_price * 100 / (100 + $mwst_room), 2);
             $base_price_total = $days * $base_price;
             $base_price_netto_total = $days * $base_price_netto;
             $included = MetabaseFetchResult($gDatabase, $result, 0, 22);
             $add_num = $persons - $included;
             $add_price = MetabaseFetchResult($gDatabase, $result, 0, 1);
             $add_price_netto = round($add_price * 100 / (100 + $mwst_room), 2);
             if ($add_num > 0) {
                 $add_price_total = $days * $add_num * $add_price;
                 $add_price_netto_total = $days * $add_num * $add_price_netto;
             } else {
                 $add_price_total = 0.0;
                 $add_price_netto_total = 0.0;
             }
             $num_persons = $days * MetabaseFetchResult($gDatabase, $result, 0, 23);
             $num_children = $days * MetabaseFetchResult($gDatabase, $result, 0, 24);
             $num_children2 = $days * MetabaseFetchResult($gDatabase, $result, 0, 25);
             $num_children3 = $days * MetabaseFetchResult($gDatabase, $result, 0, 25);
             $guestid = MetabaseFetchResult($gDatabase, $result, 0, 21);
             $price_netto_total = $base_price_netto_total + $add_price_netto_total;
             $price_total = $base_price_total + $add_price_total;
             $address = "";
             if (MetabaseFetchResult($gDatabase, $result, 0, 14) !== 'n/a') {
                 $address .= MetabaseFetchResult($gDatabase, $result, 0, 14) . "\n";
             }
             if (trim(MetabaseFetchResult($gDatabase, $result, 0, 9)) !== "") {
                 $address .= MetabaseFetchResult($gDatabase, $result, 0, 9) . " ";
             }
             $address .= MetabaseFetchResult($gDatabase, $result, 0, 7) . " " . MetabaseFetchResult($gDatabase, $result, 0, 8) . "\n";
             $address .= MetabaseFetchResult($gDatabase, $result, 0, 13) . "\n";
             $address .= MetabaseFetchResult($gDatabase, $result, 0, 11) . " " . MetabaseFetchResult($gDatabase, $result, 0, 12) . "\n\n";
             if (MetabaseFetchResult($gDatabase, $result, 0, 15) !== 'n/a') {
                 $address .= MetabaseFetchResult($gDatabase, $result, 0, 15);
             }
             $receipt[data] = array('bookid' => $bookingid, 'guestid' => $guestid, 'referenceid' => MetabaseFetchResult($gDatabase, $result, 0, 10) . '-R', 'address' => $address, 'receipt_date' => date("d.m.Y"), 'start_date' => array(MetabaseFetchResult($gDatabase, $result, 0, 2)), 'end_date' => array(MetabaseFetchResult($gDatabase, $result, 0, 3)), 'receiptid' => '-1', 'price_netto_total' => $price_netto_total, 'price_total' => $price_total, 'pauscherror' => $pauscherror);
             $i = 0;
             $nextcolor = 0;
             if ($persons > 0) {
                 $article = MetabaseFetchResult($gDatabase, $result, 0, 16) . "\n";
                 $article .= "Grundpreis (";
                 if ($persons > $included) {
                     $article .= $included;
                 } else {
                     $article .= $persons;
                 }
                 if ($persons > 1) {
                     $article .= " Personen)\n";
                 } else {
                     $article .= " Person)\n";
                 }
                 $article .= $realdays;
                 if ($realdays > 1) {
                     $article .= " &Uuml;bernachtungen";
                 } else {
                     $article .= " &Uuml;bernachtung";
                 }
                 if (MetabaseFetchResult($gDatabase, $result, 0, 17) == 'true') {
                     $article .= " (Kurzbuchertarif)";
                 }
                 $receipt[items][$i][color] = $nextcolor;
                 $receipt[items][$i][id] = $i;
                 $receipt[items][$i][itemid] = -1;
                 $receipt[items][$i][article] = $article;
                 $receipt[items][$i][number] = $days;
                 $receipt[items][$i][netto_single] = number_format($base_price_netto, 2, '.', '');
                 $receipt[items][$i][mwst] = $request->GetVar('mwst_room', 'Session');
                 $receipt[items][$i][brutto_single] = number_format($base_price, 2, '.', '');
                 $receipt[items][$i][netto] = number_format($base_price_netto_total, 2, '.', '');
                 $receipt[items][$i][brutto] = number_format($base_price_total, 2, '.', '');
                 $i++;
                 if ($nextcolor == 0) {
                     $nextcolor = 1;
                 } else {
                     $nextcolor = 0;
                 }
             }
             if ($add_num > 0) {
                 $article = MetabaseFetchResult($gDatabase, $result, 0, 16) . "\n";
                 if ($add_num > 1) {
                     $article .= $add_num . " zus&auml;tzliche Personen\n";
                 } else {
                     $article .= $add_num . " zus&auml;tzliche Person\n";
                 }
                 $article .= $days;
                 if ($days > 1) {
                     $article .= " &Uuml;bernachtungen";
                 } else {
                     $article .= " &Uuml;bernachtung";
                 }
                 if (MetabaseFetchResult($gDatabase, $result, 0, 18) == 'true') {
                     $article .= " (Kurzbuchertarif)";
                 }
                 $receipt[items][$i][color] = $nextcolor;
                 $receipt[items][$i][id] = $i;
                 $receipt[items][$i][itemid] = -1;
                 $receipt[items][$i][article] = $article;
                 $receipt[items][$i][number] = $add_num * $days;
                 $receipt[items][$i][netto_single] = number_format($add_price_netto, 2, '.', '');
                 $receipt[items][$i][mwst] = $request->GetVar('mwst_room', 'Session');
                 $receipt[items][$i][brutto_single] = number_format($add_price, 2, '.', '');
                 $receipt[items][$i][netto] = number_format($add_price_netto_total, 2, '.', '');
                 $receipt[items][$i][brutto] = number_format($add_price_total, 2, '.', '');
                 $i++;
                 if ($nextcolor == 0) {
                     $nextcolor = 1;
                 } else {
                     $nextcolor = 0;
                 }
             }
             $query = "SELECT article, price_netto, price_brutto, mwst, price_type, \n\t\t\t\t\t  person, children, children2, children3, included\n\t\t\t\t\t  FROM {$tbl_article}, {$tbl_roomcat_article}\n\t\t\t\t\t  WHERE pk_article_id = pk_fk_article_id \n\t\t\t\t\t  AND pk_fk_roomcat_id = " . $roomcatid;
             $result2 = MetabaseQuery($gDatabase, $query);
             if (!$result2) {
                 $errorhandler->display('SQL', 'Receipt::get()', $query);
             } else {
                 for ($row = 0; ($eor = MetabaseEndOfResult($gDatabase, $result2)) == 0; ++$row) {
                     $price_substract = MetabaseFetchResult($gDatabase, $result2, $row, 1);
                     $price_netto_substract = round($price_substract * 100 / (100 + $mwst_room), 2);
                     if (MetabaseFetchResult($gDatabase, $result2, $row, 4) == 'PP') {
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 5) == true && $num_person > 0) {
                             $receipt[items][$i][color] = $nextcolor;
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_persons;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_persons * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_persons * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_persons * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_persons * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 6) == true && $num_children > 0) {
                             $receipt[items][$i][color] = $nextcolor;
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_children;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_children * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_children * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_children * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_children * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 7) == true && $num_children2 > 0) {
                             $receipt[items][$i][color] = $nextcolor;
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_children2;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_children2 * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                         if (MetabaseFetchBooleanResult($gDatabase, $result2, $row, 6) == true && $num_children3 > 0) {
                             $receipt[items][$i][color] = $nextcolor . "children3";
                             $receipt[items][$i][id] = $i;
                             $receipt[items][$i][itemid] = -1;
                             $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                             $receipt[items][$i][number] = $num_children3;
                             $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                             $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $receipt[items][$i][netto] = number_format($num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                             $receipt[items][$i][brutto] = number_format($num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                             $i++;
                             if ($nextcolor == 0) {
                                 $nextcolor = 1;
                             } else {
                                 $nextcolor = 0;
                             }
                             $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + $num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 1);
                             $receipt[data][price_total] = $receipt[data][price_total] + $num_children3 * MetabaseFetchResult($gDatabase, $result2, $row, 2);
                         }
                     } else {
                         $receipt[items][$i][color] = $nextcolor;
                         $receipt[items][$i][id] = $i;
                         $receipt[items][$i][itemid] = -1;
                         $receipt[items][$i][article] = MetabaseFetchResult($gDatabase, $result2, $row, 0);
                         $receipt[items][$i][number] = 1;
                         $receipt[items][$i][netto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                         $receipt[items][$i][mwst] = MetabaseFetchResult($gDatabase, $result2, $row, 3);
                         $receipt[items][$i][brutto_single] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                         $receipt[items][$i][netto] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 1), 2, '.', '');
                         $receipt[items][$i][brutto] = number_format(MetabaseFetchResult($gDatabase, $result2, $row, 2), 2, '.', '');
                         $i++;
                         if ($nextcolor == 0) {
                             $nextcolor = 1;
                         } else {
                             $nextcolor = 0;
                         }
                         $receipt[data][price_netto_total] = $receipt[data][price_netto_total] + MetabaseFetchResult($gDatabase, $result2, $row, 1);
                         $receipt[data][price_total] = $receipt[data][price_total] + MetabaseFetchResult($gDatabase, $result2, $row, 2);
                     }
                 }
             }
             $receipt[data][price_netto_total] = number_format($receipt[data][price_netto_total], 2, '.', '');
             $receipt[data][price_total] = number_format($receipt[data][price_total], 2, '.', '');
         }
     }
     return $receipt;
 }