<? if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
session_start();//開起SESSION
$mAccount=$_SESSION['mAccount'];
$mId=$_SESSION['mId'];
}
putenv("NLS_LANG=TRADITIONAL CHINESE_TAIWAN.AL32UTF8");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../member/style/all_act_show.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="../jQuery/jquery-1.2.6.js"></script>	
<title>JUME(Join You And Me)揪咪揪團活動網</title>

</head>
<body>
<div  id="header">
<? include("../member/header2.php");?> 
</div><!--end of div id=header-->
<? 
include("../db.php");
$aType=$_GET['aType'];
require_once("../function.php");
if($_SESSION['mAccount']==''){

url_session($aType,$c='aType');
}
?>
</div>
<div id="content" align="center">
<div id="raisedetail">

<table width="650" align="center" id="temp">
<? 


if($aType=='7')//過期活動
{
$dtoday=date("Y-m-d"); 
$str = oci_parse($conn,"select distinct ACTIVITY.AID,ACTIVITY.ATIME,ACTIVITY.END_DATE,ACTIVITY.ANAME from ACTIVITY left outer join RAISE on ACTIVITY.AID=RAISE.AID order by ACTIVITY.AID desc") or die('Insert error');
oci_execute($str);
//抓活動資訊
echo"
 <tr><th width='150px'>活動圖片</th>
 	<th width='400px'>活動資訊</th>
 	<th width='150px'>此活動揪團數</th>
 </tr>";

$str4 = oci_parse($conn,"select distinct ACTIVITY.AID,ACTIVITY.ATIME,ACTIVITY.END_DATE,ACTIVITY.ANAME from ACTIVITY left outer join RAISE on ACTIVITY.AID=RAISE.AID WHERE END_DATE<'$dtoday' order by ACTIVITY.AID desc") or die('Insert error');
oci_execute($str4);
  //抓過期活動資訊
	$total=oci_fetch_all($str4,$result);
    $show2=ceil($total/12);
    echo "共".$total."筆揪團";
    echo "請選擇頁數";
    for($j=1;$j<=$show2;$j++){//顯示頁數
   	  echo "<a href=all_act_show.php?aType=7&page=$j>$j</a>";
   }
   /*查詢欄位資料*/
   $page=$_GET['page'];
   if(empty($page))$page=1;
   $start2=12*($page-1);
   $start21=$start2+12;
   $str5 = oci_parse($conn,"(select distinct ACTIVITY.AID,ACTIVITY.ATIME,ACTIVITY.END_DATE,ACTIVITY.ANAME from ACTIVITY left outer join RAISE on ACTIVITY.AID=RAISE.AID WHERE END_DATE<'$dtoday' and ROWNUM<$start21 )
   minus
(   select distinct ACTIVITY.AID,ACTIVITY.ATIME,ACTIVITY.END_DATE,ACTIVITY.ANAME from ACTIVITY left outer join RAISE on ACTIVITY.AID=RAISE.AID WHERE END_DATE<'$dtoday'  and ROWNUM<$start2 )
   ") or die('Insert error');
oci_execute($str5);

   /*顯示資料庫資料*/
while(list($aId,$start_date,$end_date,$aName,$aType)=oci_fetch_row($str5)){
	  if($dtoday>$end_date){
echo"
 <tr>
    <td align='left'>";
	
	$pic = oci_parse($conn,"select PPATH from picture where AID='$aId'") or die('Insert error');
oci_execute($pic);
	
	$num_pic=oci_fetch_all($pic,$result);
	if($num_pic!='0'){
	oci_execute($pic);
		list($pPath)=oci_fetch_row($pic);
		echo"<img src='../activity/$pPath' width='150px' height='150'></td>";
		
	}
	else{echo"<img src='../activity/picture/original.png'  width='150' height='150'></td>";}
	echo"<td>活動名稱：$aName</a><br>活動時間：$start_date~$end_date<br>
	<div align='right'><a href='../activity/activity_show_detail.php?aId=$aId'>詳細資訊</a></div></td>";
	
	$join = oci_parse($conn,"select * from RAISE left outer join ACTIVITY on RAISE.AID=ACTIVITY.AID where ACTIVITY.AID='$aId'") or die('Insert error');
oci_execute($join);
	 
	$num_join=oci_fetch_all($join,$result);
	echo"<td align='center'><font size='20'>$num_join</td>
	 </tr>";}}
}
else //type!=7
{
$dtoday_1=date("Y-m-d");

$str_1 = oci_parse($conn,"SELECT DISTINCT ACTIVITY.aId, ACTIVITY.ATIME, ACTIVITY.END_DATE, ACTIVITY.ANAME FROM ACTIVITY LEFT OUTER JOIN RAISE ON ACTIVITY.AID = RAISE.AID WHERE ACTIVITY.TID='$aType' AND END_DATE>='$dtoday' ORDER BY ACTIVITY.AID desc") or die('Insert error');
oci_execute($str_1);
	
//抓沒過期的
echo"
 <tr><th width='150px'>活動圖片</th>
 	 <th width='400px'>活動資訊</th>
 	 <th width='150px'>目前揪團狀況</th>
 </tr>";
 
	$total_else=oci_fetch_all($str_1,$result);
    $show3=ceil($total_else/12);
    echo "共".$total_else."筆揪團";
    echo "請選擇頁數";
    for($j=1;$j<=$show3;$j++){//顯示頁數
   	  echo "<a href=all_act_show.php?aType=$aType&page=$j>$j</a>";
   }
   /*查詢欄位資料*/
   $page=$_GET['page'];
   if(empty($page))$page=1;
   $start3=12*($page-1);
   $start31=$start3+12;
   
   $str5 = oci_parse($conn,"(select distinct ACTIVITY.AID,ACTIVITY.ATIME,ACTIVITY.END_DATE,ACTIVITY.ANAME from ACTIVITY left outer join RAISE on ACTIVITY.AID=RAISE.AID WHERE END_DATE>='$dtoday' AND ACTIVITY.TID='$aType' AND ROWNUM<$start31 )
   minus
(   select distinct ACTIVITY.AID,ACTIVITY.ATIME,ACTIVITY.END_DATE,ACTIVITY.ANAME from ACTIVITY left outer join RAISE on ACTIVITY.AID=RAISE.AID WHERE END_DATE>='$dtoday' AND ACTIVITY.TID='$aType' and ROWNUM<$start3 )
   ") or die('Insert error');
oci_execute($str5);

   /*顯示資料庫資料*/ 
while(list($aId,$start_date,$end_date,$aName,$aType)=oci_fetch_row($str5)){

$str_5 = oci_parse($conn,"select RID,RSTATE from RAISE where AID='$aId'") or die('Insert error');
oci_execute($str_5);
	
	 $num_5=oci_fetch_all($str_5,$result);	
	  		if($dtoday_1<=$end_date){
				echo" <td align='left'>";
				$pic_1 = oci_parse($conn,"select PPATJ from PICTURE where AID='$aId'") or die('Insert error');
oci_execute($pic_1);
				
				$num_pic_1=oci_fetch_all($pic_1,$result);
				if($num_pic_1!='0'){
				oci_execute($pic_1);
					list($pPath)=mysql_fetch_row($pic_1);
						echo"<img src='../activity/$pPath' width='150' height='150'></td>";
					}
				else{echo"<img src='../activity/picture/original.png'  width='150' height='150'></td>";}
	
				echo"<td >活動名稱：$aName</a><br/>活動時間：$start_date~$end_date<br/>
				<div align='right'><a href='../activity/activity_show_detail.php?aId=$aId'>詳細資訊</a></div></td>";		
			
		echo"<td align='center'><font size='20'>$num_5</td></tr>";
			
		}
	}
}



?>

</table>
</div><!--end of div id=raisedetail-->
<div  align="center"><a href="activity_show.php"><? echo "<img src='../member/images/back_activity.png' border='0'>" ;?></a></div>
</div>


<div id="footer">   
  <div id="footer-in" align="center">
   <p>版權資訊</p>
    <p>國立中山大學  資訊管理學系  揪咪揪團網 <a href="mailto:jumemis@yahoo.com.tw">揪咪團隊<img src="../mail/send email.gif" border="0"/></a> 版權所有  Taiwan All Rights Reserved</p> 
  </div><!-- end #footer-in -->
</div><!-- end #footer -->
</body>
</html>
