<?php
$smarty = new Smarty;
$smarty->caching = false;
$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
$smarty->template_dir=DIR_FS_CATALOG.'templates';
$smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/');
$smarty->assign('TITLE',$data["title"]);


$PICPATH = (EXTERN_EBAYPICTURE_SERVER == 1) ? EXTERN_EBAYPICTURE_SERVER_PICURL : EBAY_PICPATH_WEBSERVER;

if(!isset($_SESSION['languages_id'])) $_SESSION['languages_id'] = '2';
if($data['select_set'] == '1'){
	$collies = xtc_get_product_collies($data['products_id']);
	$set_table = '<table border="0">';
	$set_table .= '<tr>';
	for($i=0;$i<sizeOf($collies);$i++){
		$name = xtc_get_products_name($collies[$i]['collie_products_id']);
		$info_query = xtc_db_query("SELECT products_image,products_model FROM products WHERE products_id='".$collies[$i]['collie_products_id']."'");
		$info = xtc_db_fetch_array($info_query);
		$img = '';
		if($info['products_image'] != ''){
			$img = $PICPATH.$info['products_image'];
		}
		$model = '';
		if($info['products_model'] != ''){
			$model = $info['products_model'];
		}
		$set_table .= '<td valign="top" align="center"><font face="arial,helvetica,sans-serif" style="font-size:12px">'.$name;
		if($img != '')
			$set_table .= '<br><img src="'.$img.'" border="0" width="200">';
		if($model != '')
			$set_table .= '<br><i>'.xtc_db_prepare_input($model).'</i>';
		$set_table .= '</td>';
		if(($i+1)%4 == 0 and $i>0)	
			$set_table .= '</tr><tr>';
	}
	$set_table .= '</table>';
	$smarty->assign('SET',$set_table);
}


if($data['relist'] == '1'){
	$description_query = xtc_db_query("SELECT ebay_beschreibung FROM ebay_products WHERE id='".$data['ebay_products_id']."'");
	$description = xtc_db_fetch_array($description_query);
	$smarty->assign('BESCHREIBUNG',$description['ebay_beschreibung']);
}else{
	$smarty->assign('BESCHREIBUNG',$data["description"]);
}
$smarty->assign('HERSTELLER',$ebay_hersteller);


$cID = xtc_get_site_country_id($data['ebay_site']);
$lID = xtc_is_language_installed($cID);
if(!$lID){
	$lID = '2';
}
// ENGLISCHE VARIABLEN
if($lID != 3){
	$languages = xtc_get_languages();
	for ($li = 0, $n = sizeof($languages); $li < $n; $li++) {
		if($languages[$li]['name']=='English'){
			$english = true;
			$english_id = $languages[$li]['id'];

			$pQE = xtc_db_query("SELECT products_extra_text,products_short_description,products_description FROM products_description WHERE products_id='".$data['products_id']."' and language_id='".$english_id."'");
			$pE = xtc_db_fetch_array($pQE);
			$smarty->assign('EXTRATEXT_EN',$pE['products_extra_text']);
			$smarty->assign('KURZBESCHREIBUNG_EN',$pE['products_short_description']);
			$smarty->assign('BESCHREIBUNG_EN',$pE['products_description']);
		}
	}
}
// ENDE ENGLISCHE VARS



$pQ = xtc_db_query("SELECT products_name,products_extra_text,products_short_description FROM products_description WHERE products_id='".$data['products_id']."' and language_id='".$lID."'");
$p =xtc_db_fetch_array($pQ);
$smarty->assign('EXTRATEXT',$p['products_extra_text']);
$smarty->assign('KURZBESCHREIBUNG',$p['products_short_description']);

$smarty->assign('PRODUCTS_NAME',$p['products_name']);
$smarty->assign('AUCTION_PRICE',number_format($data['auctionprice'],2,',','.'));




$smarty->assign('STORE_NAME_ADDRESS',STORE_NAME_ADDRESS);

$gh = new group_handler($lID);
$groups = xtc_get_product_groups($data['products_id']);
$products_characteristics_data = array();
for($i=0;$i<sizeOf($groups);$i++){
	$gID = $groups[$i]['id'];
	$group = new group($gID,$lID);
	if($group->getVisible() == 1){
		for($gi=0;$gi<sizeOf($group->getCharacteristics());$gi++){
			$gc = $group->getCharacteristics($gi);
			if($gc->getVisible() == 1){
				$gcDesc = $gc->getDescription($lID);
				$title = $gcDesc->getTitle();
				$value = $gh->getProductSetValue($data['products_id'],$group->getId(),$gc->getId(),$lID);
				if($value != '')
					$products_characteristics_data[] = array('title'=>$title,'value'=>$value,'no_sets'=>$gc->getNoSets());
			}
		}
	}
}
if(sizeOf($products_characteristics_data)>0){
	$smarty->assign('CHARACTERISTICS',$products_characteristics_data);
}


if( !eregi('http://',$data["picture"]) ){
	$smarty->assign('EBAYBILD',HTTP_SERVER.'images/product_images/ebaycategory_images/'.$data["picture"]);
}else{
	$smarty->assign('EBAYBILD',$data["picture"]);
}

$pic_query = xtc_db_query("SELECT products_image FROM products WHERE products_id='".$data['products_id']."'");
$firstpic = xtc_db_fetch_array($pic_query);
$img_template = 1;
$q = xtc_db_query("SELECT id FROM ebay_template_excludes WHERE ebay_products_id='".$data['ebay_products_id']."' && pic='".$firstpic['products_image']."'");
if(xtc_db_num_rows($q) < 1){
	$smarty->assign('BILD'.$img_template,$PICPATH.$firstpic['products_image']);
	$smarty->assign('BILD'.$img_template.'_file',$firstpic['products_image']);
	$img_template++;
}

$pic_double = array();
$pic_query = xtc_db_query("SELECT image_name FROM products_images WHERE products_id='".$data['products_id']."' order by image_nr");
while($pics = xtc_db_fetch_array($pic_query)){
	if(!in_array($pics["image_name"],$pic_double) ){
		$q = xtc_db_query("SELECT id FROM ebay_template_excludes WHERE ebay_products_id='".$data['ebay_products_id']."' && pic='".$pics["image_name"]."'");
		if(xtc_db_num_rows($q) < 1){
			$smarty->assign('BILD'.$img_template,$PICPATH.$pics["image_name"]);
			$smarty->assign('BILD'.$img_template.'_file',$pics["image_name"]);
			$img_template++;
		}
		$pic_double[] = $pics["image_name"];
	}
}

require_once(DIR_FS_INC.'xtc_get_tax_class_id.inc.php');
$smarty->assign('TAX_RATE',xtc_get_tax_rate(xtc_get_tax_class_id($data['products_id'],STORE_COUNTRY)));


$EBAYAPI = new ebayApi();
$edata = $EBAYAPI->getProductDetails($data['ebay_products_id']);
if($edata['ebay_beschreibung_system'] == 'y'){
        $wrap1 = $edata['ebay_beschreibung'];
}else{
	$wrap1 = $smarty->fetch(CURRENT_TEMPLATE . '/admin/ebay_templates/'.$edata['ebay_template']);
}
require('includes/yes_footer.php');
$wrap1 .= $YESFOOTER;


?>
