View file www/admin/pincodes/index.php

File size: 3.22Kb
<?php

define("ADMIN_AUTHORIZATION",1);
include("../../../includes/common.php");

/*PAGE TITLE*/
$page_title = "Колекции ПИН-кодов";

$header = "Колекции ПИН-кодов";

$table = "pincode_collections";

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

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

$table_headers = Array(
"itter"=>Array("№","width=20 align=center"),
"name"=>Array("<a href='".$pager['new_sort']."$table".".name' title='Sort'>Название</a>","align=center"),
"pincount"=>Array("Количество кодов","align=center"),
"currency_name"=>Array("<a href='".$pager['new_sort']."currencies.name' title='Sort'>Валюта</a>","align=center"),
"sell_price"=>Array("<a href='".$pager['new_sort']."$table".".price' title='Sort'>Цена продажи</a>","align=center"),
"buy_price"=>Array("<a href='".$pager['new_sort']."$table".".price' title='Sort'>Цена покупки</a>","align=center"),
"funcs"=>Array("Операции","width=5% align=center"),
"group_funcs"=>Array("<select name=act_sel onChange='SubmitForm();'><option>Выберите действие<option value='./action.php?action=delete'>-Удалить</select>")
);

$query = "SELECT pincode_collections.*, currencies.name as 'curr_name', COUNT(pincodes.id) as pincount
FROM `pincode_collections`
LEFT JOIN `currencies` ON pincode_collections.currency_id=currencies.id
LEFT JOIN `pincodes` ON pincode_collections.id=pincodes.collection_id"
.($search_string?" HAVING $search_string":"")
." GROUP BY pincode_collections.id"
." 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;

if(mysql_num_rows($res) > 0)
{
	while ($row = mysql_fetch_object($res)){
		$table_items[$itter] = Array(
		"itter"=>array($itter,"align=center"),
		"id"=>Array($row->id,"align=center"),
		"name"=>Array("<nobr><a href='./listcodes.php?collection_id=$row->id' title='Список ПИН-кодов'>" . $row->name . "</a>","align=center"),
		"pincount"=>Array($row->pincount,"align=center"),
		"currency_name"=>array($row->curr_name, "align=center"),
		"sell_price"=>array($row->sell_price, "align=center"),
		"buy_price"=>array($row->buy_price, "align=center"),
		"funcs"=>Array("<nobr><a href='./add.php?id=$row->id' title='Редактировать'>$ADMIN_ICONS[edit]</a>&nbsp;<a href='#' onClick=\"if(confirm('Удалить??')){document.location.href='./action.php?action=delete&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_pincollections_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');

?>