<?php require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php

if(isset($_GET['del_id']) && ( $_GET['del_id']>0 )){
//mysql_select_db($database_BE2, $BE2);
//$delete_SQL = sprintf("delete from ap2 WHERE adid='%s'",$_GET['del_id']);
//$Rt2 = mysql_query($delete_SQL, $BE2) or die(mysql_error());
}

$webid=-1;
if(isset($_GET['webid'])){
	$webid=$_GET['webid'];
	} 


mysql_select_db($database_BE2, $BE2);
$query_Rt2 = "SELECT a.*,b.*,c.*,COUNT(d.xid) as dd FROM cuser AS a,ap1 AS c,c_ap2 AS b LEFT JOIN c_adpic AS d ON d.xid = b.adid WHERE a.cuid = b.webid AND b.raid = c.raid AND a.cuid = '$webid' GROUP BY b.adid ORDER BY b.raco desc";
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2  = mysql_num_rows($Rt2); 
?>
<span class="ti2"><a href="/<?= $row_Rt2['webname']; ?>" target="_blank"><?= $row_Rt2['webname']?></a> <a href="main.php?act=cuser_ad2_add&webid=<?php echo $webid; ?>">新增廣告區塊</a></span>
<? if($myadmin){ echo '<br>'.$query_Rt2; }?> 
<table width="902" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <th width="2%" nowrap="nowrap" class="font2">ID</th>
      <th width="8%" nowrap="nowrap" class="font2">廣告區塊</th>
      <th width="13%" nowrap="nowrap" class="font2">廣告圖檔說明</th>
      <th width="10%" nowrap="nowrap" class="font2">廣告說明</th>
      <th width="12%" nowrap="nowrap" class="font2">前台顯示</th>
      <th width="10%" nowrap="nowrap" class="font2">使用</th>
      <th width="8%" nowrap="nowrap" class="font2">物件標題</th>
      <th width="4%" nowrap="nowrap" class="font2">排列</th>
      <th width="6%" nowrap="nowrap" class="font2">廣告圖</th>
      <th width="8%" nowrap="nowrap" class="font2">位置</th>
      <th width="11%" nowrap="nowrap" class="font2">編輯廣告圖</th>
      <th nowrap="nowrap" class="font2">刪除</th>
    </tr>
    <?php 
	 $pageaddr=array("","首頁上方","首頁中間","服務項目"); 
	 if($totalRows_Rt2>0){ 
	  do { ?>
    <tr>
      <td align="center" class="font3"><a href="main.php?act=cuser_ad2_edit&amp;id=<?php echo $row_Rt2['adid']; ?>"><img src="images/edit.png" alt="修改項目名稱" title="修改項目名稱" width="16" height="16" border="0" /></a></td>
      <td align="center" class="font3"><?php echo $row_Rt2['ra1']." - ".$row_Rt2['raid'] ; ?></td>
      <td class="font3"><?php echo $row_Rt2['ra2']; ?></td>
      <td align="center" class="font3"><?php echo $row_Rt2['radoc']; ?></td>
      <td align="center" class="font3"><?php if($row_Rt2['ratshow']=='N'){ echo '<font color="#0000CC">';} echo $row_Rt2['ratshow']; if($row_Rt2['ratshow']=='N'){ echo '</font>';} ?></td>
      <td align="center" class="font3"><?php if($row_Rt2['raflag']=='N'){ echo '<font color="#FF0000">';} echo $row_Rt2['raflag']; if($row_Rt2['raflag']=='N'){ echo '</font>';} ?></td>
      <td align="center" class="font3"><? $ar1=array("不顯示","上標","下標","圖形內標");
	                                       echo $ar1[$row_Rt2['ramark']];  ?></td>
      <td align="center" class="font3"><?= $row_Rt2['raindex']; ?></td>
      <td align="center" class="font3"><?= $row_Rt2['dd']; ?></td>
      <td align="center" class="font3"><?= $pageaddr[abs($row_Rt2['raco'])]; ?></td>
      <td align="center" class="font3">
      <? if($row_Rt2['ra7']=='Y'){?>
      <a href="main.php?act=cuser_ad_browsetxt&webid=<?= $webid ;?>&id=<?php echo $row_Rt2['adid']; ?>"><img src="images/html.png" alt="編輯內文" title="編輯內文" width="32" height="32" /></a>
      <? }else{?><a href="main.php?act=cuser_ad_browse&webid=<?= $webid ;?>&id=<?php echo $row_Rt2['adid']; ?>"><img src="images/browse.png" alt="編輯圖檔元素" title="編輯圖檔元素" width="32" height="32" /></a><? }?></td>
      <td width="8%" align="center" class="font3"><a href="javascript:if(confirm('確實要刪除嗎?'))location='<? echo 'main.php?act=cuser_ad2&del_id='.$row_Rt2['adid'] ;?>'"><img src="images/del.png" alt="刪除項目" width="16" height="16" border="0"/></a></td>
    </tr>
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); 
	 }
	  ?>
 
    <tr>
      <td colspan="13"></td>
    
    </tr>
  </table>

<?php
mysql_free_result($Rt2);
?>
