<?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 adpage WHERE pid='%s'",$_GET['del_id']);
$Rt2 = mysql_query($delete_SQL, $BE2) or die(mysql_error());
}


$colname_Rt2 = "-1";
if (isset($_GET['keyword']) && $_GET['keyword']<>'') {
 
  $colname_Rt2 = '1';
  
}

mysql_select_db($database_BE2, $BE2);
$sql=" AND a.pdata<>'P' ";

if($myadmin){$sql=""; }
if ($colname_Rt2=='-1') { $query_Rt2 = "SELECT a.*,b.sgid FROM adpage as a left join signup1 as b on a.pid=b.spid where a.pmid=0  order by pindex";}else{
	
	if($_GET['rkey']=='1'){
	  $ss=sprintf("AND pdoc like '%s' order by pindex",'%'.trim($_GET['keyword']).'%');	
	}else{ $ss=sprintf("AND plink like '%s' order by pindex",'%'.trim($_GET['keyword']).'%');	 }
	
	$query_Rt2 = sprintf("SELECT a.*,b.sgid  FROM adpage as a left join signup1 as b on a.pid=b.spid where a.pmid=0 %s ",$ss);
	// echo $query_Rt2;
	}

//$query_Rt2 = "SELECT * FROM adpage where pmid=0 $sql order by pindex";

$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2  = mysql_num_rows($Rt2); 
?>
  <form id="form1" name="form1" method="GET" action="">
 廣告分頁快速搜尋 :
    <input type="radio" name="rkey" id="rkey" value="1" checked="checked" /> 說明
    <input type="radio" name="rkey" id="rkey" value="2"/> 檔名 
    <input type="text" name="keyword" id="keyword" />
    
    <input name="act" type="hidden" id="act" value="setpage" />
<input type="submit" name="Submit" value="送出" />
</form>

  <table width="731" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <th width="4%" nowrap="nowrap" class="font2">ID</th>
      <th width="30%" nowrap="nowrap" class="font2">廣告分頁說明</th>
      <th width="29%" nowrap="nowrap" class="font2">廣告分頁連結</th>
      <th nowrap="nowrap" class="font2">廣告區塊設製</th>
      <th nowrap="nowrap" class="font2">報名表</th>
      <th nowrap="nowrap" class="font2">排列序</th>
      <th nowrap="nowrap" class="font2">刪除</th>
    </tr>
    <?php 
	 if($totalRows_Rt2>0){ 
	  do { ?>
    <tr>
      <td align="center" class="font3"><a href="main.php?act=editpage&amp;id=<?php echo $row_Rt2['pid']; ?>"><img src="images/edit.png" alt="修改項目名稱" title="修改項目名稱" width="16" height="16" border="0" /></a></td>
      <td align="center" class="font3"><?php echo $row_Rt2['pdoc']; ?></td>
      <td align="center" class="font3"><a href="/<?php echo $row_Rt2['plink']; ?>" target="_blank"><?php echo $row_Rt2['plink']; ?></a></td>
      <td width="16%" align="center" class="font3">
      <? if($row_Rt2['pdata']=='Y'){?>
      <a href="main.php?act=ad2&webid=<?php echo $row_Rt2['pid']; ?>"><img src="images/browse.png" alt="編輯圖檔元素" title="編輯圖檔元素" width="32" height="32" /></a>
      <? }else if ($row_Rt2['pdata']=='N'){?>
      <a href="main.php?act=ad2text&webid=<?php echo $row_Rt2['pid']; ?>"><img src="images/html.png" alt="編輯內文" title="編輯內文" width="32" height="32" /></a>
      <? }else{?>
      <img src="images/php.png" alt="php程式" title="php程式" width="32" height="32" />
      <? }?>
      </td>
      <td width="13%" align="center" class="font3">
      <? if($row_Rt2['psignup']=='Y'){
		    if($row_Rt2['sgid']==''){?>
				<a href="main.php?act=add_signup&setid=<?= $row_Rt2['pid']; ?>"><img src="images/sadd.png" width="32" height="32" /></a> 
                <? } else {?> 
				<a href="main.php?act=edit_signup&id=<?= $row_Rt2['sgid']; ?>"><img src="images/sedit.png" width="32" height="32" /></a> 
				<? }
	        }else { echo '&nbsp;' ;}?>
      </td>
      <td width="13%" align="center" class="font3"><?php echo $row_Rt2['pindex']; ?></td>
      <td width="8%" align="center" class="font3"><a href="javascript:if(confirm('確實要刪除嗎?'))location='<? echo 'main.php?act=setpage&del_id='.$row_Rt2['pid'] ;?>'"><img src="images/del.png" alt="刪除項目" width="16" height="16" border="0"/></a></td>
    </tr>
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); 
	 }
	  ?>

  </table>

<?php
mysql_free_result($Rt2);
?>
