Просмотр файла www/admin/excurr/balance_hist.php

Размер файла: 4.55Kb
<?
define("ADMIN_AUTHORIZATION",1);
include("../../../includes/common.php");


/*PAGE TITLE*/
$page_title = "История балансов";

$header = "История балансов";

$ex_id = $_GET['ex_id']==""?$_POST['ex_id']:$_GET['ex_id'];

if(!is_numeric($ex_id)){
	$ex_id = -1;
}
$row = mysql_fetch_object(mysql_query("select * from ex_currencies where id=$ex_id"));
if($row->id==""){
	$row = mysql_fetch_row(mysql_query("select min(id) from ex_currencies"));
	if($row[0]==""){
		$_SESSION['ERROR_MSG'] = "Ошибка при работе с балансами валют!";
		header("Location: $SITE_URL/$ADMIN_DIR/index.php");
		exit;
	}
	$ex_id = $row[0];
}

$table = "balance_history";
/* pager start */
$params['query'] = "select count(*) from $table where ex_currency_id=$ex_id";
$params['tables'] = $table;
$params['nocheckfield']=true;
$params['s_prefix'] = $table;
$pager = GetPagerParams($params);
/* pager end */

$curr_row = mysql_fetch_object(mysql_query("select ex_currencies.*, currencies.code as real_curr_code from ex_currencies inner join currencies on currencies.id = ex_currencies.currency_id where ex_currencies.id=$ex_id"));
$smarty->assign("ex_curr_name", $curr_row->name);
$smarty->assign("ex_curr_code", $curr_row->code);

$ex_curr_res = mysql_query("select ex_currencies.*, currencies.code as real_curr_code from ex_currencies inner join currencies on currencies.id = ex_currencies.currency_id");
while ($ex_curr_row = mysql_fetch_object($ex_curr_res))
{
	$ex_currs[] = array("id" => $ex_curr_row->id,
						"name" => $ex_curr_row->name,
						"selected" => ($ex_id==$ex_curr_row->id)?"selected=\"selected\"":"",
						);
}
$smarty->assign("ex_currs", $ex_currs);

//$group_funcs_options=("<option >Выберите действие<option value='./action.php?action=delete_com'> - Удалить</option>");

$table_headers = Array(
	"itter"=>Array("№","width=20 align=center"),
	"change"=>Array("<a href='".$pager['new_sort']."$table".".change_amount' title='Sort'>Изменение</a>",""),
	"balance"=>Array("<a href='".$pager['new_sort']."$table".".balance' title='Sort'>Баланс</a>",""),
	"comments"=>Array("<a href='".$pager['new_sort']."$table".".comments' title='Sort'>Комментарий</a>",""),
	"date"=>Array("<a href='".$pager['new_sort']."$table".".date' title='Sort'>Дата</a>",""),
	//"funcs"=>Array("Операции","width=5% align=center"),
	//"group_funcs"=>Array("<select name=act_sel onChange='SubmitForm();'><option>Выберите действие<option value='./action.php?action=delete_com'>-Удалить</select>")
	);

$search_string = "ex_currency_id=$ex_id";
$query = "
  select * from $table".
  ($search_string?" where $search_string":"")
  ." ORDER BY ".$pager['sort_by']." ".$pager['sort_ord']
  ." LIMIT ".$SETTINGS['admin_items_per_page']." OFFSET ".($pager['start_item']-1);
  

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

while ($row = @mysql_fetch_object($res)){
	$date = getdate($row->date);
	$day = $date['mday'];
	$month = $date['mon'];
	$year = $date['year'];
	$h = $date['hours'];
	$m = $date['minutes'];
	$s = $date['seconds'];
	$year = $date['year'];
	
	$date = $h.":".$m.":".$s."<br><nobr>".$day." ".$MONTH_RUS[$month-1]." ".$year."</nobr>";

	$table_items[$itter] = Array(
		"id"=>array($row->id,""),
		"itter"=>array($itter,"align=center"),
		"change"=>array("<nobr>".($row->change_amount>0?"<font color=green>+".($row->change_amount+0)." $curr_row->real_curr_code</font>":"<font color=red>".($row->change_amount+0)." $curr_row->real_curr_code</font>")."</nobr>", ""),
		"balance"=>array("<nobr>".$row->balance.$curr_row->real_curr_code."</nobr>", ""),
		"comments"=>array(htmlspecialchars(stripslashes($row->comments)), ""),
		"date"=>array($date, ""),
//		"fix"=>array($row->fix, ""),
		//"funcs"=>Array("<nobr><a href='./add_com.php?id=$row->id' title='Редактировать'>$ADMIN_ICONS[edit]</a>&nbsp;<a href='#' onClick=\"if(confirm('Удалить??')){document.location.href='./action.php?action=delete_com&id=$row->id';}return false;\" title='Удалить'>$ADMIN_ICONS[del]</a></nobr>","align=center")
		);
	$itter++;
}

$smarty->assign('page_title',"Комиссии");

$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',"100%");
$smarty->assign('top_menu_tpl',"admin_balance_hist_menu.tpl");
$smarty->assign('main_tpl',"admin_list_table.tpl");
$smarty->assign('use_group_funcs',array_key_exists("group_funcs",$table_headers));

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