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


/*PAGE TITLE*/
$page_title = "Список рекламных материалов - баннеров";

$header = "Список баннеров";

if(isset($_POST['Submite'])){
//	print_r($_POST);
	reset($_POST);
	foreach($_POST as $k => $v){
		if($k != 'Submite'){
			$CODES_ARRAY .= $v.",";
		}
	}
	$CODES_ARRAY = substr($CODES_ARRAY, 0, strlen($CODES_ARRAY)-1);
	$js_code = "<script src=\"http://".$SETTINGS['site_url']."/banners.php?id=2&pid=".$PARTNER_ID."&codes=".$CODES_ARRAY."\" language=\"javascript\" type=\"text/javascript\"></script>";
	$smarty->assign('js_code', htmlspecialchars($js_code));

}else{
$codes_arr = Array(
		"WMR"=>1,
		"WMZ"=>2,
		"WME"=>3,
		"WMU"=>4,
		"YMRMAN"=>5,
		"EGOLD"=>7,
		"ESILVER"=>8,
		"EPLATINUM"=>9,
		"EPALLADIUM"=>10,
		"MEGABIZ"=>38,
		"SMPIN"=>39,
		"MM"=>40
		);
$codes = Array();
$itter = 0;
foreach($codes_arr as $k => $v){
	foreach($codes_arr as $kk => $vv){
		$sql = "select 
			  ex_exchanges.ex_currency2_id,
			  ex_currencies.name as curr2,
			  ex_currencies.code as curr2_code,
			  curr.name as curr1,
			  curr.code as curr1_code
			from
			  (ex_exchanges left outer join ex_currencies curr on curr.id = ex_exchanges.ex_currency1_id)
			  left outer join ex_currencies on ex_currencies.id = ex_exchanges.ex_currency2_id
			where 
			  ex_currency1_id=$codes_arr[$kk] and ex_currency2_id=$codes_arr[$k]";
		$row = mysql_fetch_object(mysql_query($sql));
		$codes[$itter]['codes2'] = $row->curr2_code;
		$codes[$itter]['names2'] = $row->curr2;
		$codes[$itter]['codes1'] = $row->curr1_code;
		$codes[$itter]['names1'] = $row->curr1;
		$itter++;
	}
}
}// END if isset $_POST

// codes of currencies
$smarty->assign('codes',$codes);

$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('main_tpl',"partner_banners.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');
?>