<?php
//  Copyright (c) 2004-2009 randshop
//  http://www.randshop.com
//
//  Unter Lizenz von randshop
//	
//	Letzte Bearbeitung: 17.03.2009


session_start();
	include_once("../../conf/config.inc.php");
	include_once("../../conf/db.inc.php");
	include_once(DATEIPFAD . "includes/shopinitialize.inc.php");
	include_once(DATEIPFAD . "includes/functions.waehrung.inc.php");
	include_once(DATEIPFAD . "includes/functions.artikel.inc.php");
	include_once(DATEIPFAD . "includes/functions.datenblatt.inc.php");
	include_once(DATEIPFAD . "includes/functions.kunden.inc.php");
	include_once(DATEIPFAD . "includes/functions.shopeinstellung.inc.php");
	include_once(DATEIPFAD . "includes/session_register.inc.php");
	include_once(DATEIPFAD . "includes/functions.global.inc.php");
    include_once(DATEIPFAD . "includes/functions.bewertung.inc.php");

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

	include_once(DATEIPFAD . "includes/header.inc.php");

    if ($_POST["artikelid"]) { $Artikelid = $_POST["artikelid"]; }
    if ($_GET["artikelid"]) { $Artikelid = $_GET["artikelid"]; }

    // Artikelinformationen ziehen
    $ArtikelObject = GetArtikelDetail($ArtikelID, $_SESSION["mail"], 1, $_SESSION["languageid"]);
    $tpl_artikelname = $ArtikelObject->artikel_name;

	$KundenObject = GetKundenDetail($_SESSION["mail"]);

	$kundenId = $KundenObject->id;

    $bewertungsEinstellung = GetEinstellungen('', 'bewertungen');
    $anzahlBewertungenHeute = GetAnzahlBewertungenVonKunde($kundenId, true);


for($i=1;$i<=5;$i++) {
	$tpl_optBewertung .= '<option value="'.$i.'">'.$i . '</option>';
}

if($anzahlBewertungenHeute >= $bewertungsEinstellung->bewertungen->maxBewertungenProTag) {
    $tpl_maxBewertungenErreicht = true;
}

if(($_SESSION["com"] == "true") && ($_POST["action"] != "sub")) {
	
	$contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/website/bewertung/formular.tpl";

} else if(($_SESSION["com"] == "true") && ($_POST["action"] == "sub")) {
	
	if(($_POST['sternchen'] !="") && ($_POST['titel'] != "") && ($_POST['rezi'] != "")) {

        AddBewertung($_POST["artikelid"], $kundenId, $_POST["sternchen"], $_POST["rezi"], $_POST["titel"]);

//		$contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/website/bewertung/danke.tpl";
        header("location: " . URLPFAD . "themes/kategorie/detail.php?artikelid=" . $Artikelid);
        exit;

	}	else 	{

		$contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/website/bewertung/allefelderfuellen.tpl";
	
	}
} else {
	
	$contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/website/bewertung/erstanmelden.tpl";

}

	// Letzte globale Zusammenfassung z.B. fuer Warenkorbanzeige, bevor das Template geladen wird.
	include_once(DATEIPFAD . "includes/footer.inc.php");
	
	
	// Template	
    if($mobilestyle) {
        include_once(DATEIPFAD . "templates/" . $rowTemp->name . "/mobile/layout.phtml");
    } else {
        include_once(DATEIPFAD . "templates/" . $rowTemp->name . "/website/index.tpl");
    }
?>

