<?
define("PARTNER_AUTHORIZATION",1);
include("../../../includes/common.php");

/*PAGE TITLE*/
$page_title = "Рекламные материалы";

$header = "Рекламные материалы";


$table_headers = Array(
	"name"=>Array("Название"),
	"code"=>Array("HTML код","align=center"),		
	"preview"=>Array("Предпросмотр","align=center")		
);


$table_items = Array();

$query = "select * from exchanger_ads where status=1";

$res = mysql_query($query);
echo mysql_error();
$itter =$pager['start_item'];
$i=0;

while ($row = mysql_fetch_object($res)){
	
	$code = str_replace("QUERY_STR","id=".$PARTNER_ID,stripslashes($row->html_code));
	
	$table_items[$itter] = Array(
		"itter"=>array($itter,"align=center"),
		"id"=>Array($row->id,"align=center"),
		"name"=>Array(stripslashes($row->name)),
		"code"=>Array("<textarea cols=30 rows=5 onClick='this.select();'>".htmlspecialchars($code)."</textarea>","align=center"),
		"preview"=>Array($code,"align=center")
	);
	$itter++;
}

$smarty->assign('page_title',"Partners");

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

/* table template */
$smarty->assign('pager',$pager);
$smarty->assign('table_headers',$table_headers);
$smarty->assign('table_items',$table_items);
$smarty->assign('table_width',"90%");

$smarty->assign('page_title',$page_title);
$smarty->assign('error',$error);

/* table template */
$smarty->assign('top_menu_tpl',"partner_ads_menu.tpl");
$smarty->assign('main_tpl',"partner_ads.tpl");

$smarty->assign('browser_title',$browser_title);
$smarty->assign('page_title',$page_title);
$smarty->assign('page_meta',$page_meta);
$smarty->assign('errors',$err_arr);

$smarty->assign('PARTNER_ID',$PARTNER_ID);
$smarty->assign('partner_comission',round($PARTNER_DATA['comission_perc']*100,2));

/* display content */
$smarty->display('partner_index.tpl');
?>