<?php  require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php
if (isset($_GET['check_id'])) {
  $deleteSQL = sprintf("DELETE FROM regformuser WHERE rid = '%s'",$_GET['check_id']);
  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($deleteSQL, $BE2) or die(mysql_error());

}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_Rt2 = 25;
$pageNum_Rt2 = 0;
if (isset($_GET['pageNum_Rt2'])) {
  $pageNum_Rt2 = $_GET['pageNum_Rt2'];
}
$startRow_Rt2 = $pageNum_Rt2 * $maxRows_Rt2;

$colname_Rt2 = "-1";
if (isset($_GET['keyword'])) {
  $colname_Rt2 = $_GET['keyword'];
}


mysql_select_db($database_BE2, $BE2);
if ($colname_Rt2=='-1') {
 $query_Rt2 = "SELECT * FROM regformuser ORDER BY rid DESC";
} else {
 $query_Rt2 = sprintf("SELECT * FROM regformuser WHERE companyname like '%s' ORDER BY rid DESC",'%'.$colname_Rt2.'%');
}

$query_limit_Rt2 = sprintf("%s LIMIT %d, %d", $query_Rt2, $startRow_Rt2, $maxRows_Rt2);
$Rt2 = mysql_query($query_limit_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);

if (isset($_GET['totalRows_Rt2'])) {
  $totalRows_Rt2 = $_GET['totalRows_Rt2'];
} else {
  $all_Rt2 = mysql_query($query_Rt2);
  $totalRows_Rt2 = mysql_num_rows($all_Rt2);
}
$totalPages_Rt2 = ceil($totalRows_Rt2/$maxRows_Rt2)-1;

$queryString_Rt2 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Rt2") == false && 
        stristr($param, "totalRows_Rt2") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Rt2 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Rt2 = sprintf("&totalRows_Rt2=%d%s", $totalRows_Rt2, $queryString_Rt2);
?>
<script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
 
<form id="form1" name="form1" method="GET" action="">
  姓名快速搜尋
    <input type="text" name="keyword" id="keyword" />
<input type="submit" name="Submit" value="送出" />
<input name="act" type="hidden" id="act" value="registerformuser_show" />
</form>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <th width="10%" height="28" nowrap class="font2">行業別</th>
    <th width="10%" nowrap class="font2">公司商店名</th>
    <th width="7%" nowrap class="font2">統一編號</th>
    <th width="8%" nowrap class="font2">公司電話</th>
    <th width="8%" nowrap class="font2">傳真電話</th>
    <th width="14%" nowrap class="font2">聯絡人</th>
    <th width="10%" nowrap class="font2">聯絡人電話</th>
    <th width="8%" nowrap class="font2">登錄時間</th>
    <th width="5%" nowrap class="font2">廣告</th>
    <th width="6%" nowrap class="font2">已處理</th>
    <th width="7%" nowrap class="font2">開通</th>
    <th width="7%" nowrap class="font2">刪除</th>
  </tr>
    <tr>
    <td height="3" colspan="12" background="images/dot3.gif"></td>
  </tr>
  <?php do { ?>
    <tr onMouseOver="this.style.backgroundColor='#2172A1';" onMouseOut=this.style.backgroundColor="#fff">
      <td height="27"><?php echo $row_Rt2['item']; ?></td>
      <td><? if($row_Rt2['rshow']=="Y"){?><a href="/<?= $row_Rt2['companyname']; ?>" target="_blank"> <? } ?><?= $row_Rt2['companyname']; ?><? if($row_Rt2['rshow']=="Y"){?></a> <? }?></td>
      <td><?= $row_Rt2['idnumber']; ?></td>
      <td><?= $row_Rt2['phone1']; ?></td>
      <td><?= $row_Rt2['fax']; ?></td>
      <td nowrap="nowrap"><?php echo $row_Rt2['myname']; ?></td>
      <td nowrap="nowrap"><?php echo $row_Rt2['phone2']; ?></td>
      <td nowrap="nowrap"><?php echo $row_Rt2['rdate']; ?></td>
      <td align="center" nowrap="nowrap"><a href="main.php?act=storeadv&webid=71&rid=<?= $row_Rt2['rid']; ?>"><img src="images/icon_11.gif" width="31" height="31" /></a></td>
      <td align="center"><img src="images/<?= $row_Rt2['stat']; ?>.png" width="32" height="32" /></td>
      <td align="center"><a href="main.php?act=registerformuser_edit&id=<?php echo $row_Rt2['rid']; ?>"><img src="images/<?= $row_Rt2['rshow']; ?>.png" width="32" height="32" /></a></td>
      <td align="center"><a href="javascript:if(confirm('確實要刪除嗎?'))location='main.php?act=registerformuser_show&<?php echo  "check_id=".$row_Rt2['rid']."&pageNum_Rt2=".$pageNum_Rt2 ?>'"><img src="images/del.png" alt="刪除" title="刪除" width="16" height="16" border="0" /></a></td>
    </tr>
  <tr>
    <td height="2" colspan="12" background="images/dot3.gif"></td>
  </tr>	
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); ?>

  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="4">&nbsp;</td>
    <td colspan="2">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="12"><table width="697" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="34%">總筆數：<?php echo $totalRows_Rt2 ?>筆 </td>
                  <td width="66%"><div id="font_s">
                      <p>
                        <?php if ($pageNum_Rt2 > 0) { // Show if not first page ?>
                        <a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, max(0, $pageNum_Rt2 - 1), $queryString_Rt2); ?>"><img src="images/First.gif" alt="上一頁" title="上一頁" width="18" height="13" border="0" /></a>
                        <?php } // Show if not first page ?>
                        第
                        <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('self',this,0)">
                          <? for($i=0;$i<=$totalPages_Rt2;$i++){?>
                          <option value="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, $i, $queryString_Rt2); ?>" <? if($pageNum_Rt2==$i){ ?>selected="selected" <? }?>><? echo $i+1 ;?></option>
                          <? }?>
                        </select>
                        頁
                        <?php
	    //分頁程式
if($totalPages_Rt2<9){
		 $start=0;
		 $end=$totalPages_Rt2;
		}else{  
	    $start=$pageNum_Rt2-5;
		$end=$pageNum_Rt2+5;
        if ($start<0){
		 $start=0;
		 $end=10; } 
		 else { $end=$start+10 ;}
		 if ($end>$totalPages_Rt2){ 
		   $start = $end-$totalPages_Rt2-5;
		   $end=$totalPages_Rt2;
		   }
		 if ($end-$start>10){ 
		   $start = $end-10;
		   }  
		 }
		   
		for($i=$start;$i<=$end;$i++){
		if($i==$pageNum_Rt2){ echo "[".($i+1)."]";} else {?>
                        <a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, min($totalPages_Rt2, $i), $queryString_Rt2); ?>"> <? echo $i+1 ;?></a>
                        <?	}   }  ?>
                        <?php if ($pageNum_Rt2 < $totalPages_Rt2) { // Show if not last page ?>
                        <a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, min($totalPages_Rt2, $pageNum_Rt2 + 1), $queryString_Rt2); ?>"><img src="images/Next.gif" alt="下一頁" title="下一頁" width="14" height="13" border="0" /></a>
                        <?php } // Show if not last page ?>
                    </p>
                  </div></td>
                </tr>
    </table></td>
  </tr>
</table>
 
<?php
mysql_free_result($Rt2);
?>
