<?php

	// Hauptkonfigurationsdatei
	include_once("../../conf/config.inc.php");
	include_once(DATEIPFAD . "conf/db.inc.php");
	if(KUNDENGRUPPEN) {
		include_once(DATEIPFAD . "includes/functions.mod.kundengruppen.inc.php");
	} else {
		include_once(DATEIPFAD . "includes/functions.kundengruppen.inc.php");
	}
	include_once(DATEIPFAD . "includes/functions.artikel.inc.php");
	include_once(DATEIPFAD . "includes/functions.rabattstaffeln.inc.php");
	include_once(DATEIPFAD . "includes/functions.versandart.inc.php");
	include_once(DATEIPFAD . "includes/functions.zahlungsart.inc.php");
	include_once(DATEIPFAD . "includes/functions.kunden.inc.php");
	include_once(DATEIPFAD . "includes/functions.mail.inc.php");
	include_once(DATEIPFAD . "includes/functions.shopeinstellung.inc.php");
	include_once(DATEIPFAD . "includes/functions.warenkorb.inc.php");
	include_once(DATEIPFAD . "includes/functions.land.inc.php");
	include_once(DATEIPFAD . "includes/functions.waehrung.inc.php");
	include_once(DATEIPFAD . "includes/functions.kategorie.inc.php");
	if(RECHNUNGSWESEN) {
		include_once(DATEIPFAD . "includes/functions.mod.bestellungen.inc.php");
	} else {
		include_once(DATEIPFAD . "includes/functions.bestellungen.inc.php");
	}
	if(ARTIKELDOWNLOAD) {
		include_once(DATEIPFAD . "includes/functions.mod.download.inc.php");
	}
	include_once(DATEIPFAD . "includes/functions.global.inc.php");
	include_once(DATEIPFAD . "includes/crypt.inc.php");

	// Spracheninclude
	if (@fopen(DATEIPFAD . "includes/language/langu_" . $_SESSION["langu"] . ".inc.php",r)) {
		include_once(DATEIPFAD . "includes/language/langu_" . $_SESSION["langu"] . ".inc.php");
	} else {
		include_once(DATEIPFAD . "includes/language/langu_de.inc.php");
	}	

	// Bestellung erfolgreich
	$SQLString = "SELECT ";
	$SQLString .= TABLE_BESTELLEN . ".id, ";
	$SQLString .= TABLE_BESTELLEN . ".zahlungsart_id, ";
	$SQLString .= TABLE_BESTELLEN . ".email ";
	$SQLString .= "FROM " . TABLE_BESTELLEN . " ";
	$SQLString .= "WHERE ";
	$SQLString .= "MD5(" . TABLE_BESTELLEN . ".session) = '" . $_POST["pns"] . "' ";
	
	$BestellObject = mysql_fetch_object(errorlogged_mysql_query($SQLString));
	
	// Bestellung erfolgreich
	if ($BestellObject) {
			
		$ZahlungsartObject = GetZahlungsartDetail($BestellObject->zahlungsart_id, $BestellObject->email);
					
		$SQLString = "UPDATE " . TABLE_BESTELLEN . " SET ";
		$SQLString .= TABLE_BESTELLEN . ".status = '" . $ZahlungsartObject->bestellen_status_id . "' ";
		$SQLString .= "WHERE ";
		$SQLString .= TABLE_BESTELLEN . ".id = '" . $BestellObject->id . "' ";
		
		$MySQLQueryReference = errorlogged_mysql_query($SQLString);
				
		// Bestellung einlesen
		$BestellObject = GetBestellenDetail($BestellObject->id);
		$KundenObject = GetKundenDetail($BestellObject->email);
		$WaehrungObject = GetWaehrungDetail();
		
		SaveLogFile($BestellObject);

		if($ZahlungsartObject->bezahlstatus)
		{
			SetBezahlDaten($BestellID);
		}
		
		// ********************************************************************************
		// ** Versand der Best�tigungsmail
		// ********************************************************************************
		
		// Mail an den Kunden
//		SendFakturaMail($BestellObject, $KundenObject, $ShopeinstellungObject, 1, $WaehrungObject, 2);
		
		// Mail an den Shopbetreiber
//		SendFakturaMail($BestellObject, $KundenObject, $ShopeinstellungObject, 1, $WaehrungObject, 3);
		
		
	}
	
?>
