<?php
define('IN_OUN', true); 
include_once( "./includes/command.php");
include_once( ROOT_PATH."includes/item_set.php"); 
include_once( ROOT_PATH."includes/shopcomm.php");  

/* 评论数量 */
$where_comms = "praid  = '".$praid."' AND states <> 1 AND domain_id='".$_SESSION[$un_domain_id]."'";
$db_table = $pre."pravail_product_comms";
$sql = "SELECT COUNT(*) as count FROM ".$db_table." 
		where ".$where_comms;
$rowpra['comms'] = $oPub->getOne($sql); 
/* 产品页显示的模块 */
$Ahome["nowNave"]  = '<A HREF="./">'.$Aconf['web_title'].'首页</A> > <A HREF="'.$rowpra['pravail_url'].'">商家列表</a>><a href="'.$rowpra['pra_name_url'].'">'.$rowpra[pra_name].'</a>'; 
$Aconf["header_title"] = $rowpra[pra_name].'|'.$Aconf['header_title']; 
/* 找到所有的自定义分类 select start*/
$db_table = $pre."pravail_productcat";
$sql = "SELECT prapcid,name  FROM ".$db_table." where praid  = '".$praid."'  AND domain_id=".$_SESSION[$un_domain_id]." ORDER BY prapcid ASC";
$Strppcat = '';
$AnormAll = $oPub->select($sql);
while( @list( $key, $value ) = @each( $AnormAll) ) {
	$db_table = $pre."pravail_producttxt";
	$sql = "SELECT COUNT(*) as count FROM ".$db_table." 
            where prapcid  = '".$value[prapcid]."' 
	        AND domain_id='".$_SESSION[$un_domain_id]."'";
    $tmp = $oPub->getOne($sql);
	$count = ($tmp)?$tmp:0;
	if($Aconf['rewrite']){ 
		$AnormAll[$key]['shop_h'] = 'shop_h-'.$praid.'a'.$value[prapcid].'-0.html';
	}else{ 
		$AnormAll[$key]['shop_h'] = 'shop_h.php?id='.$praid.'a'.$value[prapcid];
	} 
	$AnormAll[$key]['count'] = $count;
}
$rowpra['productcat'] =  $AnormAll;unset($AnormAll);
/* 促销信息 */
$db_table = $pre."pravail_artitxt ";
$sql = "SELECT arid,name  FROM ".$db_table." 
    where praid  = '".$praid."' 
	AND domain_id=".$_SESSION[$un_domain_id]." 
	AND states <> 1 
	ORDER BY dateadd DESC
	limit 20"; 
$AnormAll = $oPub->select($sql);
while( @list( $key, $value ) = @each( $AnormAll) )
{
	if($Aconf['rewrite']){ 
		$AnormAll[$key]['shop_a'] = 'shop_a-'.$praid.'-'.$value[arid].'.html';
	}else{ 
		$AnormAll[$key]['shop_a'] = 'shop_a.php?id='.$praid.'&arid='.$value[arid];
	}  
}
$rowpra['pravail_artitxt'] = $AnormAll; 


$Ahome["pravail"] = $rowpra; unset($rowpra);
if ((DEBUG_MODE & 2) != 2)
{
    $smarty->caching = true;
}

$cache_id = sprintf('%X', crc32($_SESSION[$un_domain_id].$prid));
if (!$smarty->is_cached($Aconf["displayFile"], $cache_id)) {
	assign_template($Aconf); 
	$smarty->assign('home', $Ahome ); 
	$smarty->assign('user_info', $_SESSION );
	unset($Ahome); 
}
$smarty->display($Aconf["displayFile"], $cache_id); 
?> 