<?php
function tpl_function_qishi_company_show($params, &$smarty)
{ 
	global $db,$_CFG;
	$arr=explode(',',$params['set']);
	foreach($arr as $str)
	{
	$a=explode(':',$str);
		switch ($a[0])
		{
		case "企业ID":
			$aset['id'] = $a[1];
			break;
		case "列表名":
			$aset['listname'] = $a[1];
			break;
		}
	}
		$time = time();
		$aset=array_map("get_smarty_request",$aset);
		$aset['id']=$aset['id']?intval($aset['id']):0;
		$aset['listname']=$aset['listname']?$aset['listname']:"list";
		$wheresql.=" AND  user_status=1 ";
		$sql = "select * from ".table('company_profile')." WHERE  id=".intval($aset['id']).$wheresql." LIMIT  1";
		$profile=$db->getone($sql);
		if (empty($profile))
		{
			header("HTTP/1.1 404 Not Found"); 
			$smarty->display("404.htm");
			exit();
		}
		else
		{
		$profile['company_url']=url_rewrite('QS_companyshow',array('id'=>$profile['id']));
		$profile['company_profile']=$profile['contents'];
		$profile['description']=cut_str(strip_tags($profile['contents']),50,0,"...");
		if ($profile['logo'])
			{
			$profile['logo']=$_CFG['site_dir']."data/logo/".$profile['logo'];
			}
			else
			{
			$profile['logo']=$_CFG['site_dir']."data/logo/no_logo.gif";
			}
		}
		if ($profile['tag'])
		{
			$tag=explode('|',$profile['tag']);
			$taglist=array();
			if (!empty($tag) && is_array($tag))
			{
				foreach($tag as $t)
				{
				$tli=explode(',',$t);
				$taglist[]=array($tli[0],$tli[1]);
				}
			}
			$profile['tag']=$taglist;
		}
		else
		{
		$profile['tag']=array();
		}
		if($profile['website']){
			if(strstr($profile['website'],"http://")===false){
				$profile['website'] = "http://".$profile['website'];
			}
		}
		$setmeal=get_user_setmeal(intval($_SESSION['parentuid']));
		$setmeal['setmeal_name'] = cut_str($setmeal['setmeal_name'],3,0);
		$smarty->assign('setmeal',$setmeal);
	$smarty->assign($aset['listname'],$profile);
}
function get_user_setmeal($uid)
{
	global $db;
	$uid=intval($uid);
	$sql = "select * from ".table('members_setmeal')."  WHERE uid='{$uid}' AND  effective=1 LIMIT 1";
	return $db->getone($sql);
}
?>