require('../include/global_start.inc.php');
if($_GET["tid"]){
require("./tradeinfo.inc.php");
}
elseif($_GET["sid"]||$_GET["action"] == "search"){
require("./trade_sort.inc.php");
}
elseif($_GET["type"]){
if($_GET["type"] != 5)
require("./trade.inc.php");
else
require("./tradebj.inc.php");
}else{
$template->loadtemplate("main","trade_index.html");
$num = 4;
require("../include/recommend_brand.inc.php");
//trade info
//$sql = "select * from ".$tableHead."w_pbinfo where type='供应' order by postdate desc limit 20";
$sql="select * from(select ".$tableHead."w_pbinfo.* from ".$tableHead."w_pbinfo inner join (select a.uid,max(postdate) postdate from ".$tableHead."w_pbinfo a inner join ".$tableHead."w_members b on a.uid=b.uid where b.sgroupid=1 group by a.uid) c on ".$tableHead."w_pbinfo.uid=c.uid and ".$tableHead."w_pbinfo.postdate=c.postdate union all select * from (select tb2.* from ".$tableHead."w_members tb1 inner join ".$tableHead."w_pbinfo tb2 on tb1.uid=tb2.uid and tb1.sgroupid > 1) as d) e where e.type='供应' order by e.postdate desc limit 20";
$db->query($sql);
$template->set_block("main","gpbinfo","gpbinfos");
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'showname'=>strlen($data["showname"])>26?chopstring($data["showname"],13)."...":$data["showname"],
'tid'=>$data["id"],
'postdate'=>date("Y-m-d",$data["postdate"]),
'tr'=>$i%2 == 0?"
":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse("gpbinfos","gpbinfo",true);
$i++;
}
//$sql = "select * from ".$tableHead."w_pbinfo where type='采购' order by postdate desc limit 20";
$sql="select * from(select ".$tableHead."w_pbinfo.* from ".$tableHead."w_pbinfo inner join (select a.uid,max(postdate) postdate from ".$tableHead."w_pbinfo a inner join ".$tableHead."w_members b on a.uid=b.uid where b.sgroupid=1 group by a.uid) c on ".$tableHead."w_pbinfo.uid=c.uid and ".$tableHead."w_pbinfo.postdate=c.postdate union all select * from (select tb2.* from ".$tableHead."w_members tb1 inner join ".$tableHead."w_pbinfo tb2 on tb1.uid=tb2.uid and tb1.sgroupid > 1) as d) e where e.type='采购' order by e.postdate desc limit 20";
$db->query($sql);
$template->set_block("main","qpbinfo","qpbinfos");
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'showname'=>strlen($data["showname"])>26?chopstring($data["showname"],13)."...":$data["showname"],
'tid'=>$data["id"],
'postdate'=>date("Y-m-d",$data["postdate"]),
'tr'=>$i%2 == 0?"":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse("qpbinfos","qpbinfo",true);
$i++;
}
//$sql = "select * from ".$tableHead."w_pbinfo where type='合作' order by postdate desc limit 20";
$sql="select * from(select ".$tableHead."w_pbinfo.* from ".$tableHead."w_pbinfo inner join (select a.uid,max(postdate) postdate from ".$tableHead."w_pbinfo a inner join ".$tableHead."w_members b on a.uid=b.uid where b.sgroupid=1 group by a.uid) c on ".$tableHead."w_pbinfo.uid=c.uid and ".$tableHead."w_pbinfo.postdate=c.postdate union all select * from (select tb2.* from ".$tableHead."w_members tb1 inner join ".$tableHead."w_pbinfo tb2 on tb1.uid=tb2.uid and tb1.sgroupid > 1) as d) e where e.type='合作' order by e.postdate desc limit 20";
$db->query($sql);
$template->set_block("main","hpbinfo","hpbinfos");
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'showname'=>strlen($data["showname"])>26?chopstring($data["showname"],13)."...":$data["showname"],
'tid'=>$data["id"],
'postdate'=>date("Y-m-d",$data["postdate"]),
'tr'=>$i%2 == 0?"":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse("hpbinfos","hpbinfo",true);
$i++;
}
//$sql = "select * from ".$tableHead."w_pbinfo where type='代理' order by postdate desc limit 20";
$sql="select * from(select ".$tableHead."w_pbinfo.* from ".$tableHead."w_pbinfo inner join (select a.uid,max(postdate) postdate from ".$tableHead."w_pbinfo a inner join ".$tableHead."w_members b on a.uid=b.uid where b.sgroupid=1 group by a.uid) c on ".$tableHead."w_pbinfo.uid=c.uid and ".$tableHead."w_pbinfo.postdate=c.postdate union all select * from (select tb2.* from ".$tableHead."w_members tb1 inner join ".$tableHead."w_pbinfo tb2 on tb1.uid=tb2.uid and tb1.sgroupid > 1) as d) e where e.type='代理' order by e.postdate desc limit 20";
$db->query($sql);
$template->set_block("main","dpbinfo","dpbinfos");
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'showname'=>strlen($data["showname"])>26?chopstring($data["showname"],13)."...":$data["showname"],
'tid'=>$data["id"],
'postdate'=>date("Y-m-d",$data["postdate"]),
'tr'=>$i%2 == 0?"":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse("dpbinfos","dpbinfo",true);
$i++;
}
$sql = "select * from ".$tableHead."w_productinfo where price != 0 order by postdate desc limit 20";
$db->query($sql);
$template->set_block("main","ppbinfo","ppbinfos");
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'productname'=>strlen($data["productname"])>26?chopstring($data["productname"],13)."...":$data["productname"],
'pid'=>$data["id"],
'price'=>$data["price"],
'tr'=>$i%2 == 0?"":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse("ppbinfos","ppbinfo",true);
$i++;
}
//hot images
$sql = "select * from ".$tableHead."w_pbinfo where picture != '' and recommend = 1 order by postDate desc limit 3";
$db->query($sql);
$template->set_block("main","NewsImageList","NewsImageLists");
$i = 0;
while ($i<3){
$db->next_record();
$data = $db->Record;
$template->set_var(array(
'num'=>$i,
'style'=>$i?' style="display:none;"':"",
'newsimage'=>$data["newsImage"]?"":"无图片".$i,
'showname'=>strlen($data["showname"])>20?chopstring($data["showname"],10)."...":$data["showname"],
'tid'=>$data["id"]
));
$template->parse("NewsImageLists","NewsImageList",true);
$i++;
}
//news list
$cgnewsid = 16;
$ppnewsid = 55;
$yxnewsid = 19;
//cg news
$sql = "select subject,location,newsImage from ".$tableHead."w_article where (fcid = '$cgnewsid' or cid = '$cgnewsid') and newsImage != '' order by bigimg desc,postDate desc limit 1";
$db->query($sql);
$db->next_record();
$data = $db->Record;
$template->set_var(array(
'cgnewsimage'=>$data["newsImage"]?"":"无图片",
'cgnewsimagearturl'=>$data["location"],
'cgnewssubject'=>strlen($data["subject"])>20?chopstring($data["subject"],10):$data["subject"]
));
$template->set_block("main","cglist","cglists");
$sql = "select location,subject from ".$tableHead."w_article where fcid = '$cgnewsid' or cid = '$cgnewsid' order by postDate desc limit 12";
$db->query($sql);
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'artUrl'=>$data["location"],
'subject'=>strlen($data["subject"])>26?chopstring($data["subject"],13):$data["subject"],
'tr'=>$i%2 == 0?"":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse('cglists','cglist',true);
$i ++;
}
//pp news
$sql = "select subject,location,newsImage from ".$tableHead."w_article where (fcid = '$ppnewsid' or cid = '$ppnewsid') and newsImage != '' order by bigimg desc,postDate desc limit 1";
$db->query($sql);
$db->next_record();
$data = $db->Record;
$template->set_var(array(
'ppnewsimage'=>$data["newsImage"]?"":"无图片",
'ppnewsimagearturl'=>$data["location"],
'ppnewssubject'=>strlen($data["subject"])>20?chopstring($data["subject"],10):$data["subject"]
));
$template->set_block("main","pplist","pplists");
$sql = "select location,subject from ".$tableHead."w_article where fcid = '$ppnewsid' or cid = '$ppnewsid' order by postDate desc limit 12";
$db->query($sql);
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'artUrl'=>$data["location"],
'subject'=>strlen($data["subject"])>26?chopstring($data["subject"],13):$data["subject"],
'tr'=>$i%2 == 0?"":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse('pplists','pplist',true);
$i ++;
}
//yx news
$sql = "select subject,location,newsImage from ".$tableHead."w_article where (fcid = '$yxnewsid' or cid = '$yxnewsid') and newsImage != '' order by bigimg desc,postDate desc limit 1";
$db->query($sql);
$db->next_record();
$data = $db->Record;
$template->set_var(array(
'yxnewsimage'=>$data["newsImage"]?"":"无图片",
'yxnewsimagearturl'=>$data["location"],
'yxnewssubject'=>strlen($data["subject"])>20?chopstring($data["subject"],10):$data["subject"]
));
$template->set_block("main","yxlist","yxlists");
$sql = "select location,subject from ".$tableHead."w_article where fcid = '$yxnewsid' or cid = '$yxnewsid' order by postDate desc limit 12";
$db->query($sql);
$i = 0;
while ($db->next_record()){
$data = $db->Record;
$template->set_var(array(
'artUrl'=>$data["location"],
'subject'=>strlen($data["subject"])>26?chopstring($data["subject"],13):$data["subject"],
'tr'=>$i%2 == 0?"":"",
'tr2'=>$i%2 == 1?"
":""
));
$template->parse('yxlists','yxlist',true);
$i ++;
}
}
$template->set_var(array(
'columncolor'=>"#BA0001"
));
$menusearch = "t";
require('../include/global_end.inc.php');
?>