$query = "SELECT orders_id, customers_id, customers_telephone, customers_email_address,\n                       delivery_name, delivery_company, delivery_street_address, delivery_city,\n                       delivery_postcode, delivery_country\n                FROM {$orderstable}\n                WHERE orders_id= '" . intval($_POST['KeyAdresse']) . "'";
        $result =& $dbconn->Execute($query);
        $order = $result->fields;
        if (!$order['delivery_firstname'] && !$order['delivery_lastname']) {
            list($order['delivery_firstname'], $order['delivery_lastname']) = split(" ", $Order->delivery_name);
        }
        //falls kein kunde existiert, key muss irgendwo her!
        if (!$order['customers_id']) {
            $order['customers_id'] = 10000000 - $order['orders_id'];
        }
        echo CSVkonform($order['orders_id']) . ';';
        echo CSVkonform($order['customers_id']) . ';';
        echo CSVkonform($order['delivery_firstname']) . ';';
        echo CSVkonform($order['delivery_lastname']) . ';';
        echo CSVkonform($order['delivery_company']) . ';';
        echo CSVkonform($order['delivery_street_address']) . ';';
        echo CSVkonform($order['delivery_postcode']) . ';';
        echo CSVkonform($order['delivery_city']) . ';';
        echo CSVkonform($order['delivery_country']) . ';';
        echo CSVkonform($order['customers_telephone']) . ';';
        echo ';';
        //keine Faxangaben
        echo CSVkonform($order['customers_email_address']) . ';';
        echo "\n";
        $return = 0;
    } else {
        $return = 5;
    }
}
echo $return;
logge($return);
                break;
            case 'invoice':
                $Bestellung->zahlungsweise = "Zahlungsweise: Auf Rechnung";
                break;
            default:
                $Bestellung->zahlungsweise = "Zahlungsweise: {$Bestellung->payment_method}";
                break;
        }
        echo CSVkonform($Bestellung->orders_id) . ';';
        echo CSVkonform($Bestellung->orders_id) . ';';
        echo CSVkonform($Bestellung->customers_id) . ';';
        echo CSVkonform($Bestellung->orders_id) . ';';
        echo CSVkonform($VersandKey) . ';';
        echo ';';
        //VersandInfo
        echo ';';
        //Versanddatum
        echo ';';
        //Tracking Nr
        echo CSVkonform($Bestellung->zahlungsweise) . ';';
        echo ';';
        //Abgeholt
        echo ';';
        //Status
        echo CSVkonform($Bestellung->ErstelltDatumF) . ';';
        echo CSVkonform($Bestellung->orders_id) . ';';
        echo CSVkonform($Bestellung->comments) . ';';
        echo "\n";
    }
}
logge($return);
            $Kunde->customers_id = 10000000 - $Kunde->orders_id;
        }
        echo CSVkonform($Kunde->customers_id) . ';';
        echo CSVkonform($Kunde->customers_id) . ';';
        echo ';';
        echo '"*****";';
        echo CSVkonform($Kunde->cAnrede) . ';';
        echo ';';
        //Titel
        echo CSVkonform($Kunde->billing_firstname) . ';';
        echo CSVkonform($Kunde->billing_lastname) . ';';
        echo CSVkonform($Kunde->billing_company) . ';';
        echo CSVkonform($Kunde->billing_street_address) . ';';
        echo CSVkonform($Kunde->billing_postcode) . ';';
        echo CSVkonform($Kunde->billing_city) . ';';
        echo CSVkonform($Kunde->billing_country) . ';';
        echo CSVkonform($Kunde->customers_telephone) . ';';
        echo CSVkonform($Kunde->customers_fax) . ';';
        echo CSVkonform($Kunde->customers_email_address) . ';';
        echo CSVkonform($Kunde->cHaendler) . ';';
        echo ';';
        //Rabatt
        echo CSVkonform($Kunde->customers_vat_id) . ';';
        echo CSVkonform($Kunde->cNewsletter) . ';';
        echo "\n";
    } else {
        $return = 5;
    }
}
echo $return;
logge($return);
            echo CSVkonform(intval($_POST['KeyBestellung'])) . ';';
            echo CSVkonform(getEsArtikel($BestellungPos->products_id)) . ';';
            echo CSVkonform($BestellungPos->products_name) . ';';
            echo CSVkonform($BestellungPos->products_price - $aufpreis) . ';';
            echo CSVkonform($BestellungPos->products_tax) . ';';
            echo CSVkonform($BestellungPos->products_quantity) . ';';
            echo "\n";
        }
        //letzte Position Versand
        $orders_totaltable = $oostable['orders_total'];
        $cur_query = xtc_db_query("SELECT *\n                                           FROM {$orders_totaltable}\n                                           WHERE class=\"ot_shipping\"\n                                             AND orders_id=" . intval($_POST['KeyBestellung']));
        if ($Versand = mysql_fetch_object($cur_query)) {
            //mappe bestellpos
            $kBestellPos = setMappingBestellPos(0);
            //hole versand mwst aus einstellungen
            $eazysales_einstellungenstable = $oostable['eazysales_einstellungen'];
            $cur_query = xtc_db_query("SELECT versandMwst FROM {$eazysales_einstellungenstable}");
            $einstellungen = mysql_fetch_object($cur_query);
            echo CSVkonform($kBestellPos) . ';';
            echo CSVkonform(intval($_POST['KeyBestellung'])) . ';';
            echo CSVkonform("0") . ';';
            echo CSVkonform($Versand->title) . ';';
            echo CSVkonform($Versand->value) . ';';
            echo CSVkonform($einstellungen->versandMwst) . ';';
            echo CSVkonform("1") . ';';
            echo "\n";
        }
    }
}
echo $return;
logge($return);
        $eazysales_einstellungenstable = $oostable['eazysales_einstellungen'];
        $cur_query = xtc_db_query("SELECT languages_id FROM {$eazysales_einstellungenstable}");
        $einstellungen = mysql_fetch_object($cur_query);
        //hole orders_products_id
        $orders_products_id = getFremdBestellPos(intval($_POST['KeyBestellPos']));
        //hole alle Eigenschaften, die ausgew�lt wurden zu dieser bestellung
        $orders_productstable = $oostable['orders_products'];
        $orders_products_attributestable = $oostable['orders_products_attributes'];
        $cur_query = xtc_db_query("SELECT orders_products_attributes.*, orders_products.products_tax, orders_products.products_id\n                                           FROM {$orders_products_attributestable},\n                                                {$orders_productstable}\n                                           WHERE orders_products_attributes.orders_products_id=" . $orders_products_id . "\n                                             AND orders_products.orders_products_id=orders_products_attributes.orders_products_id\n                                           ORDER BY orders_products_attributes.orders_products_id");
        while ($WarenkorbPosEigenschaft = mysql_fetch_object($cur_query)) {
            $preisprefix = 1;
            if ($WarenkorbPosEigenschaft->price_prefix == "-") {
                $preisprefix = -1;
            }
            //hole attribut
            $products_attributestable = $oostable['products_attributes'];
            $products_optionstable = $oostable['products_options'];
            $products_options_valuestable = $oostable['products_options_values'];
            $attribut_query = xtc_db_query("SELECT products_attributes.products_attributes_id \n                                                        FROM {$products_attributestable},\n                                                             {$products_optionstable},\n                                                             {$products_options_valuestable}\n                                                        WHERE products_attributes.products_id=" . $WarenkorbPosEigenschaft->products_id . " \n                                                          AND products_attributes.options_id=products_options.products_options_id \n                                                          AND products_attributes.options_values_id=products_options_values.products_options_values_id \n                                                          AND products_attributes.options_values_price=" . $WarenkorbPosEigenschaft->options_values_price . " \n                                                          AND products_options.products_options_name=\"" . $WarenkorbPosEigenschaft->products_options . "\" \n                                                          AND products_options.language_id=" . $einstellungen->languages_id . " \n                                                          AND products_options_values.products_options_values_name=\"" . $WarenkorbPosEigenschaft->products_options_values . "\" \n                                                          AND products_options_values.language_id=" . $einstellungen->languages_id);
            $attribut_arr = mysql_fetch_row($attribut_query);
            echo CSVkonform($WarenkorbPosEigenschaft->orders_products_attributes_id) . ';';
            echo CSVkonform(intval($_POST['KeyBestellPos'])) . ';';
            echo ';';
            echo CSVkonform(getEsEigenschaftsWert($attribut_arr[0], getEsArtikel($WarenkorbPosEigenschaft->products_id))) . ';';
            echo CSVkonform(($WarenkorbPosEigenschaft->options_values_price + $WarenkorbPosEigenschaft->options_values_price * $WarenkorbPosEigenschaft->products_tax / 100) * $preisprefix) . ';';
            echo "\n";
        }
    }
}
echo $return;
logge($return);