<?php
/*
 * Powered by http://www.b2b-builder.com
 * copyright:B2Bbuilder
 * Auther:brad zhang
 * Date:2008-12-31
 */
include_once("config/usergroup.php");
include_once("includes/page_utf_class.php");
//=====================================
$id=isset($_GET['id'])?$_GET['id']:NULL;
//---------信息列表---------
$sql=NULL;
if(!empty($_GET['province']))
	$sql=" and province='$_GET[province]'";
if(!empty($dpid))
	$sql=" and province='$dpid'";
if(!empty($dcid))
	$sql=" and city='$dcid'";
if(!empty($id))
	$sql.="and catid like '%,$_GET[id]%'";
//------------------------
$sql="SELECT 
	company,main_pro,company_id,domain,ctype,tel,contact,province,city,country,staff_num,logo,video,ifpay,addr,registered_capital,earnest
	FROM ".COMPANY." WHERE 1 $sql order by rank desc,ifpay desc,uptime desc"; 
//------------------------
$page = new Page;
$page->listRows=!empty($config['list_row'])?$config['list_row']:20;
$page->url=$config['weburl'];
if(!$page->__get('totalRows'))
{
	$db->query($sql);
	$page->totalRows = $db->num_rows();
}
$sql .= "  limit ".$page->firstRow.", ".$page->listRows;
//----------------------
$db->query($sql);
$coml=$db->getRows();
foreach($coml as $key=>$v)
{
	$ifpay=$v['ifpay'];
	if(!empty($group[$ifpay]['minilogo']))
		$coml[$key]['user_type']="<img height=20 src='".$group[$ifpay]['minilogo']."' alt='".$group[$ifpay]['name']."' >";
	else
		$coml[$key]['user_type']='['.$group[$ifpay]['name'].']';
		
	$sqlo="select flag from ".COUNTRY." where id='".$v['country']."'";
	$db->query($sqlo);
	$coml[$key]['country']=$db->fetchField('flag');
}
$infos['list']=$coml;
$infos['pages']=$page->prompt();
$tpl->assign("info",$infos);
//----------------------

$db->query("SELECT * FROM ".COMPANYCAT." WHERE catid='$id'");
$cat=$db->fetchRow();
$tpl->assign("current_cat",$cat['cat']);

$s=$id."00"; $b=$id."99";
$db->query("SELECT * FROM ".COMPANYCAT." WHERE catid>=$s and catid<=$b and isindex='1' ORDER BY nums ASC");
$subcat=$db->getRows();
$tpl->assign("subcat",$subcat);

//------------------------
$companyType=explode('|',$config['companyType']);
$tpl->assign("companyType",$companyType);
//-------------------------
$config['title']=str_replace('[catname]',$cat['cat'],$config['title2']);
$config['keyword']=str_replace('[catname]',$cat['cat'],$config['keyword2']);
$config['description']=str_replace('[catname]',$cat['cat'],$config['description2']);
//===================================
include_once("footer.php");
$tpl->assign("current",$_GET['id']);
$out=tplfetch($cat['template'],$flag);
?>