<?php require_once('../Connections/BE2.php'); ?>
<?  require('system/login.php');  ?>
<?php
if ((isset($_GET['check_id'])) && ($_GET['check_id'] != "")) {
  
  $deleteSQL = sprintf("DELETE FROM signup1 WHERE sgid=%s",$_GET['check_id']);
  mysql_select_db($database_BE2, $BE2);
  $Result1= mysql_query($deleteSQL, $BE2) or die(mysql_error());
   
}


$currentPage = 'main.php?act=list_signup' ;// $_SERVER["PHP_SELF"];

$maxRows_Rt2 = 60;
$pageNum_Rt2 = 0;
if (isset($_GET['pageNum_Rt2'])) {
  $pageNum_Rt2 = $_GET['pageNum_Rt2'];
}
$startRow_Rt2 = $pageNum_Rt2 * $maxRows_Rt2;
//媒體 17 活動 16 最新 15
$kid="71" ;//isset($_GET['kid'])?$_GET['kid']:"";


mysql_select_db($database_BE2, $BE2);
//$query_Rt2 = "SELECT * FROM signup1 WHERE 1 ORDER BY sgid DESC";
$query_Rt2 = "SELECT a.*,count(b.sgid) as sg,sum(b.ck) as sg2,sum(b.ck2) as sg3 FROM signup1 as a left join signupman as b on a.sgid=b.sgid group by a.sgid order by sgid DESC";
$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);
//echo '媒體 17 活動 16 最新 15';

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);

?> 
 
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" bordercolor="#99CCCC" class="font_box12x">
 
  <tr  class="font2">
    <th width="16" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">&nbsp;</th>
    <th width="118" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">活動標題</th>
    <th width="113" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">報名日期</th>
    <th width="108" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">報名起始日期</th>
    <th width="108" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">報名截止日期</th>
    <th width="84" align="center" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">報名人數</th>
    <th width="92" align="center" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">已審核人數</th>
    <th width="73" align="center" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">未處理</th>
    <th width="79" align="center" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">欄位設置</th>
    <th width="72" align="center" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy">匯出人數</th>
    <th width="23" align="center" nowrap="nowrap" bgcolor="#FFFFCC" class="f12blue_gy"></th>
   </tr>
  <? if($totalRows_Rt2 > 0 ){?>
  <?php do { ?>
    <tr>
      <td class="f12grey"><a href="javascript:if(confirm('確實要刪除嗎?'))location='<? echo $currentPage."&check_id=".$row_Rt2['sgid'] ;?>'"><img src="images/del.png" /></a></td>
      <td class="f12grey"><?php echo $row_Rt2['sgname']; ?></td>
      <td class="f12grey"><? echo $row_Rt2['sgdate']; ?></td>
      <td class="f12grey"><?php echo $row_Rt2['sgdates'] ; ?></td>
      <td class="f12grey"><?php echo $row_Rt2['sgdatee'] ; ?></td>
      <td align="center" class="f12grey"><?php echo $row_Rt2['sg'] ; ?></td>
      <td align="center" class="f12grey"><a href="main.php?act=setSignupman&editid=<? echo $row_Rt2['sgid']; ?>&ck2=0"><?php echo $row_Rt2['sg2'] ; ?></a></td>
      <td align="center" class="f12grey"><a href="main.php?act=setSignupman&editid=<? echo $row_Rt2['sgid']; ?>&ck2=1"><?php echo $row_Rt2['sg3'] ; ?></a></td>
      <td align="center" class="f12grey"><a href="main.php?act=setSignup&editid=<? echo $row_Rt2['sgid']; ?>">欄位設置</a></td>
      <td align="center" class="f12grey"><a href="Signupmantoexcel.php?editid=<?php echo $row_Rt2['sgid']; ?>"><img src="images/excel.png" width="28" height="27" border="0" /></a></td>
      <td align="center" class="f12grey">
	  
	  <a href="main.php?act=edit_signup&id=<?php echo $row_Rt2['sgid']; ?>"><img src="images/edit.png" /></a></td>
    </tr>
  <tr>
    <td colspan="11" class="font3"></td>
   </tr> 
    
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); ?>

  <tr>
    <td colspan="11">
      <table border="0" align="center">
        <tr>
          <td width="23%" align="center"><?php if ($pageNum_Rt2 > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, 0, $queryString_Rt2); ?>"><img src="../images/First.gif" border=0></a>
                <?php } // Show if not first page ?>          </td>
          <td width="31%" align="center"><?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/Previous.gif" border=0></a>
                <?php } // Show if not first page ?>          </td>
          <td width="23%" align="center"><?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" border=0></a>
                <?php } // Show if not last page ?>          </td>
          <td width="23%" align="center"><?php if ($pageNum_Rt2 < $totalPages_Rt2) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_Rt2=%d%s", $currentPage, $totalPages_Rt2, $queryString_Rt2); ?>"><img src="../images/Last.gif" border=0></a>
                <?php } // Show if not last page ?>          </td>
        </tr>
      </table></td>
  </tr>
  <? } ?>
</table>
 
<?php
mysql_free_result($Rt2);
?>
