<?php
require_once '../bbs/include/common.inc.php';
require_once 
"../bbs/include/discuzcode.func.php";
require_once 
"../bbs/include/global.func.php";
require_once 
"../bbs/func.php";
require_once 
"func.php";

$url $_GET["url"];
$cstId $_GET["cstId"];
$tab $_GET["tab"];

if(
$url != ""){
    
$strSql "select * from customer where url='$url'";
}
else{
    
$strSql "select * from customer where cstId='$cstId'";
}
$result mysql_query($strSql);
$rs mysql_fetch_array($result);
if (
$rs != "") {
    
$cstId $rs["cstId"];
    
$url $rs["url"];
    
$cstName $rs["cstName"];
    
$allName $rs["allName"];
    
$typeId $rs["typeId"];
    
$cityId $rs["cityId"];
    
$scope $rs["scope"];
    
$licenceNo $rs["licenceNo"];
    
$address $rs["address"];
    
$tel $rs["tel"];
//    $mobile = $rs["mobile"];
//    $email = $rs["email"];
    
$qq $rs["qq"];
    
$msn $rs["msn"];
    
$contact $rs["contact"];
    
$linkman $rs["linkman"];
    
$linkNo $rs["linkNo"];
    
$logo $rs["logo"];
    
$content $rs["content"];
    
//$content = str_replace("\n","<br />",$content);
    
$content discuzcode($content00);
    
$bookcontact $rs["bookcontact"];
    
//$bookcontact = str_replace("\n","<br />",$bookcontact);
    
$bookcontact discuzcode($bookcontact00);
    
$workTime $rs["workTime"];
    
$driver $rs["driver"];
    
//$driver = preg_replace("/\[img\](.+?)\[\/img\]/i", "<img src=\"$1\" border=\"0\">", $driver);
    
$driver discuzcode($driver00);
    
$isSpecial $rs["isSpecial"];
    
$isConfirm $rs["isConfirm"];
    
$credits $rs["credits"];
    
$area $rs["area"];
    
$mapnid $rs["mapnid"];
}
else{
    
header("Location: /shop");
}

$sql "update customer set hits=hits+1 where cstId='$cstId'";
mysql_query($sql);

include(
"newheader.php");
?>
                   <tr>
                     <td>
<!---->
                     <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
                       <tr>
                         <td width="700" height="30" bgcolor="#f2f2f2" class="title02"> 商铺简介</td>
                         <td width="80" bgcolor="#f2f2f2">&nbsp;</td>
                       </tr>
                       <tr>
                         <td height="123" colspan="2" valign="top"><br>
                           <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
                           <tr>
                             <td><span class="line01"><?=$content?></span></p></td>
                           </tr>
                         </table>                           <p><BR>
                         </p>
                         </td>
                       </tr>
                     </table>
                     <?php
                     $sql 
"select * from product where cstId = '$cstId' and begindate <= current_timestamp and (enddatelimits = 1 or (enddatelimits = 0 and enddate >= current_timestamp)) and needaudit = 0 order by displayorder desc, createdate desc limit 4";
                     
$query $db->query($sql);
                     if(
$db->num_rows($query) > 0){
                     
?>
                       <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
                       <tr>
                         <td width="690" height="30" bgcolor="#f2f2f2" class="title02"> 产品橱窗</td>
                         <td width="90" bgcolor="#f2f2f2"><a href="product.php?cstId=<?=$cstId?>">更多产品&gt;&gt;</a></td>
                       </tr>
                       <tr>
                         <td height="40" colspan="2"><table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
                           <tr>
                             <?php
                             
while($rs $db->fetch_array($query)){
                             
?>
                             <td width="150" align="center">
                             <table width="145" border="0" cellpadding="3" cellspacing="0">
                               <tr>
                                 <td colspan="2" align="center">
                              <table width="130" height="130" border="0" cellpadding="0" cellspacing="0" class="frame02">
                              <tr>
                              <td align="center">
                              <a href="../mall/product.php?productId=<?=$rs["productId"]?>"><img src="<?=getPreviewFile("mall/images/product/$rs[pic]"120120)?>" class="frame01" /></a>
                              </td>
                              </tr>
                              </table>
                                 </td>
                               </tr>
                               <tr>
                                 <td colspan="2">
                                       <div align="center" title="<?=$rs["prodName"]?>"><a href="../mall/product.php?productId=<?=$rs["productId"]?>"><?=getLengthStr($rs["prodName"], 19)?></a></div>
                                 </td>
                               </tr>
                               <tr>
                                 <td colspan="2" align="center">¥<span class="del" style="font-family: Times New Roman"><?=sprintf("%.2f"$rs["price"])?></span>&nbsp;<span align="center" class="price" style="font-family: Times New Roman">¥<?=sprintf("%.2f"$rs["idoprice"])?></span></td>
                               </tr>
                               <tr>
                                 <td colspan="2"><table width="130" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF">
                                     <tr>
                                       <td width="61" height="18" valign="bottom" bgcolor="#b15caf"> <a href="../mall/product.php?productId=<?=$rs["productId"]?>"><div align="center" class="text01">查看详情</div></a></td>
                                       <td width="63" valign="bottom" bgcolor="#b15caf"> <a href="../mall/product.php?productId=<?=$rs["productId"]?>"><div align="center" class="text01">免费预订</div></a></td>
                                     </tr>
                                 </table></td>
                               </tr>
                             </table>
                             </td>
                             <?php
                             
}
                             
?>
                               </tr>
                             </table></td>
                           </tr>
                         </table>
                         <?php
                         
}
                           
$sql "select * from cstinfo where typeId = 2 and cstId = '$cstId' order by displayorder desc, createDate desc limit 10";
                           
$query $db->query($sql);
                           if(
$db->num_rows($query) > 0){
                         
?>
                       <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
                       <tr>
                         <td width="690" height="30" bgcolor="#f2f2f2" class="title02"> 优惠活动</td>
                         <td width="90" bgcolor="#f2f2f2"><a href="price.php?cstId=<?=$cstId?>">全部报价&gt;&gt;</a> </td>
                       </tr>
                       <tr>
                        <td colspan="2" style="height: 5px">
                       </tr>
                       <?php
                           
while($rs $db->fetch_array($query)){
                                
$title $rs["title"];
                                
$content $rs["content"];
                                
$content discuzcode($content00);
                           
?>
                           <tr>
                             <td width="690" colspan=2>
                                <table border="0" width="100%">
                                    <tr>
                                        <td width="20px"></td>
                                        <td style="line-height: 22px">
                                            <font color="red" style="font-size: 14px"><strong>[<?=$title?>]</strong></font><br>
                                            通过 <img src="images/button_kefu.gif" width="70" height="20" align="absmiddle" title="010-58699530 58699230" /> 或 <a href="booking.php?cstId=<?=$cstId?>"><img src="images/button_yuyue.gif" width="70" height="20" align="absmiddle" border="0" /></a> 可<strong class="STYLE1">免费预订</strong><img src="images/icon_te.gif" width="11" height="14" align="absmiddle">特约商家产品和服务,并享受IdoIdo会员特别优惠待遇<br><br>
                                            <?=$content?><br><br>
                                        </td>
                                    </tr>
                                </table>
                             </td>
                           </tr>
                           <?php
                            
}
                            
?>
                     </table>
                     <?php
                     
}
                    
$sql "select * from album where cstId = '$cstId' order by createdate desc limit 4";
                    
$query $db->query($sql);
                    if(
$db->num_rows($query) > 0){
                     
?>
                     <table width="780" border="0" align="center" cellpadding="2" cellspacing="0">
                       <tr>
                         <td width="690" height="30" bgcolor="#f2f2f2"><a href="photolist.php?cstId=<?=$cstId?>"><span class="title02"> 美图相册</span></td>
                         <td width="90" bgcolor="#f2f2f2"><a href="photo.php?cstId=<?=$cstId?>">更多相册&gt;&gt;</a></td>
                       </tr>
                       <tr>
                         <td colspan="2"><br>
                           <table width="750" height="160" border="0" align="center" cellpadding="0" cellspacing="0">
                           <tr>
                              <?php
                                
while($rs $db->fetch_array($query)){
                              
?>
                             <td><table width="110" border="0" align="center" cellpadding="2" cellspacing="0">
                               <tr>
                                 <td height="160">
                                <?php
                                $sqlp 
"select * from album_photo where typeId='$rs[typeId]' and cstId='$cstId' order by picId limit 1";
                                
$queryp $db->query($sqlp);
                                
$rsp $db->fetch_array($queryp);
                                
?>
                                <a href="photoview.php?typeId=<?=$rs["typeId"]?>" title="点击查看">
                                <img src="<?=getPreviewFile("shop/cstalbum/$rsp[pic]"120120)?>" border=0>
                                </a>
                                 </td>
                               </tr>
                               <tr>
                                 <td><div align="center" class="style6"><a href="photoview.php?typeId=<?=$rs["typeId"]?>"><?=$rs["typeName"]?></a>( <?=countPhotos($rs["typeId"])?> )</div></td>
                               </tr>
                             </table></td>
                             <?php
                                
}
                            
?>
                           </tr>
                         </table></td>
                       </tr>
                     </table>
                     <?php
                    
}
                    
$sql "select distinct a.tid as url, a.showTitle, b.subject as title, b.author, b.views, b.replies from tags a, cdb_threads b where a.tid = b.tid and a.cstId = '$cstId' and a.showInCst = 1 order by a.tid desc limit 5";
                    
$query $db->query($sql);
                    if(
$db->num_rows($query) > 0){
                     
?>
                     <table width="780" border="0" align="center" cellpadding="2" cellspacing="0">
                       <tr>
                         <td width="690" height="29" bgcolor="#f2f2f2"><span class="title02"> 网友评论</span></td>
                         <td width="90" bgcolor="#f2f2f2"><a href="forum.php?cstId=<?=$cstId?>">全部评论&gt;&gt;</a> </td>
                       </tr>
                       <tr>
                         <td colspan="2"><br>
                           <TABLE cellSpacing="1" cellPadding="5" width="90%" align="center" bgColor="#ffd8ec" border="0">
                             <TBODY>
                               <TR bgColor="#fff4f9">
                                 <TD width="422" height="25" align="middle" bgcolor="#fff4f9"><div align="center"><STRONG>标  题</STRONG></div></TD>
                                 <TD width="113" align="middle" bgColor="#fff4f9"><div align="center"><STRONG>发起人</STRONG></div></TD>
                                 <TD width="58" align="middle" bgColor="#fff4f9"><div align="center"><strong>浏览量</strong></div></TD>
                                 <TD align="middle" width="60"><div align="center"><strong>回复量</strong></div></TD>
                               </TR>
                             <?php
                            
while($rs $db->fetch_array($query)){
                                            
$title $rs["showTitle"];
                                            if(
$title == ""){
                                                
$title $rs["title"];
                                            }
                             
?>
                               <TR bgColor="#ffffff">
                                 <TD height="35" bgcolor="#ffffff"><a href="../bbs/thread-<?=$rs["url"]?>-1-1-0.html" target="_blank"><?=$title?></a></TD>
                                 <TD bgcolor="#ffffff"><div align="center"><?=$rs["author"]?></div></TD>
                                 <TD bgcolor="#ffffff"><div align="center"><?=$rs["views"]?></div></TD>
                                 <TD><div align="center"><?=$rs["replies"]?></div></TD>
                               </TR>
                              <?php
                            
}
                             
?>
                           </TABLE>
                           <br></td>
                       </tr>
                     </table>
                     <?php
                    
}
                    
$sql "select * from cstrefer where cstId = '$cstId' order by logId desc limit 3";
                    
$query $db->query($sql);
                    if(
$db->num_rows($query) > 0){
                     
?>
                     <table width="780" border="0" align="center" cellpadding="2" cellspacing="0">
                       <tr>
                         <td width="648" height="29" bgcolor="#f2f2f2"><span class="title02"> 最新留言</span></td>
                         <td width="124" bgcolor="#f2f2f2"><table width="130" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF">
                             <tr>
                               <td width="63" valign="bottom" bgcolor="#b15caf"><a href="javascript:ask_onclick()"><div align="center" class="text01">我要留言</div></a></td>
                             </tr>
                         </table></td>
                       </tr>
                       <tr>
                         <td height="241" colspan="2"><br>
                             <table width="740" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#efdeef" class="frame04">
                               <tr>
                                 <td>
                                <?php
                                $i 
0;
                                while(
$rs $db->fetch_array($query)){
                                    
$i++;
                                    if(
$i == 0){
                                        
$bgcolor "#fff5ff";
                                    }
                                    else{
                                        
$bgcolor "#efdeef";
                                    }
                                
?>
                                 <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="<?=$bgcolor?>">
                                     <tr>
                                       <td><table width="660" border="0" align="center" cellpadding="4" cellspacing="4">
                                           <tr>
                                             <td><?=$rs["userName"]?>  
                                               <?=$rs["createDate"]?> </td>
                                           </tr>
                                           <tr>
                                             <td><?=$rs["title"]?><br /><?=str_replace("\n""<br />"$rs["content"])?><br /><br />
                                               掌柜回复: <?=str_replace("\n""<br />"$rs["replyContent"])?> </td>
                                           </tr>
                                       </table></td>
                                     </tr>
                                   </table>
                                  <?php
                                
}
                                    
?>
                                   <br /></td>
                               </tr>
                           </table>
                         <br></td>
                       </tr>
                     </table>
                     <?php
                    
}
                     
?>
                     <table width="780" border="0" align="center" cellpadding="2" cellspacing="0">
                       <tr>
                         <td width="648" height="29" bgcolor="#f2f2f2"><span class="title02"> 快速留言</span></td>
                       </tr>
                       <tr>
                         <td height="241"><br>
                             <table width="740" border="0" align="center" cellpadding="2" cellspacing="0">
                               <tr>
                                 <td>
            <table width="100%" border=0 cellpadding="0" cellspacing="0">
                <form name=thisForm action="ask.php" method="post" onsubmit="return checkForm()">
                <input type=hidden name=cstId value="<?=$cstId?>">
                <input type=hidden name=action value="ok">
                <!--tag list-->
                <tr>
                    <td class="altbg1" align="center">标题:</td>
                    <td class="altbg1" align="left" colspan=2><input type=text name=title size=30>
                    </td>
                </tr>
                <tr>
                    <td class="altbg1" align="center">姓名:</td>
                    <td class="altbg1" align="left" colspan=2><input type=text name=userName>
                    &nbsp;&nbsp;E-mail:<input type=text name=userEmail>
                    </td>
                </tr>
                <tr>
                    <td class="altbg1" align="center">内容:</td>
                    <td class="altbg1" align="left" colspan=2><textarea name=content cols=70 rows=10></textarea></td>
                </tr>
                <tr>
                    <td align=center colspan=3>
                    <input type=submit value=" 提 交 ">
                    </td>
                </tr>
                <!--tag list-->                    
                </form>
            </table>
<script language="javascript">
function checkForm() {
    if (thisForm.title.value == "") {
        alert("请输入标题");
        thisForm.title.focus();
        return false;
    }
    if (thisForm.userName.value == "") {
        alert("请输入姓名");
        thisForm.userName.focus();
        return false;
    }
    if (thisForm.content.value == "") {
        alert("请输入咨询内容");
        thisForm.content.focus();
        return false;
    }
    return true;
}
</script>
                                 </td>
                               </tr>
                           </table>
                         <br></td>
                       </tr>
                     </table>
<!---->
                     </td>
                   </tr>
                 </table>
                 <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="top">&nbsp;</td>
            </tr>
          </table>          </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>