<?
putenv("NLS_LANG=TRADITIONAL CHINESE_TAIWAN.AL32UTF8");
/*********************map*********************/

    require_once('../map/GoogleMapAPI.class.php');
    $map = new GoogleMapAPI('map');

    $map->setDSN('mysql://project:gp9806gun@140.117.71.186/project');

    $map->setAPIKey('ABQIAAAA-fZzs3imoScYLbCOBKQlzRTDQbFKLWBUv-hmAr6_O3aN5ZraihS617SXs678fe0xileB-cptWVBJ5w');
     
	 $map->setWidth('350px');
	 $map->setHeight('350px');
	$map->setZoomLevel(10);
	 $map->disableSidebar(); 

	   $map->disableDirections();
	
   
	
/*******************************************************/	

if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
session_start();
$id=$_SESSION['mAccount'];
 $mid=$_SESSION['mId'];
}

 
include("../db.php");
require_once("../function.php");


$ans3=CheckID();
$aId=$_GET['aId'];

if($_SESSION['mAccount']==''){

url_session($aId,$c='aId');

}
url_session($aId,$c='aId');
$res = oci_parse($conn,"SELECT * FROM ACTIVITY NATURAL JOIN MEMBER NATURAL JOIN MAP NATURAL JOIN TYPE WHERE AID='$aId'") or die('Insert error');

oci_execute($res);

$row=oci_fetch_object($res);




function check_raise($mid,$aId,$conn)
{
$check = oci_parse($conn,"select MID from RAISE where AID='$aId' and MID='$mid'") or die('Insert error');

oci_execute($check);

$che=oci_fetch_all($check,$result);
if($che==0){
return ok;
}
else{return no;}
}


function check_main($mid,$aId,$conn)
{

$check = oci_parse($conn,"select MID from ACTIVITY where AID='$aId' and MID='$mid'") or die('Insert error');

oci_execute($check);

$che=oci_fetch_all($check,$result);
if($che==0){
return ok;
}
else{return no;}
}
//echo $row->lon.$row->lat;

?>
<!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">
<title>JUME(Join You And Me)揪咪揪團活動網</title>
<?
if($_SESSION['mId']!=''){
echo "<link rel=\"stylesheet\" href=\"../thick/f_thickbox.css\" type=\"text/css\" media=\"screen\" />
<style type=\"text/css\" media=\"all\">@import \"../thick/f_thickbox.css\";</style>";
}
?>

<link href="../member/style/activity_show_detail.css" rel="stylesheet" type="text/css" media="screen" />
<script src='../jQuery/jquery-1.2.6.js' type='text/javascript'></script>
<?
/*
if($_SESSION['mId']!='')
echo "<script type=\"text/javascript\" src=\"../thick/thickbox.js\"></script>";
*/
?>
<style type="text/css">
h2.font{ font-family: "細明體"; font-weight: bold; color: #e1e97e; letter-spacing: 3px; height: 45px; }
</style>
</head>

<body onload="onLoad()">

<div id="header">
<? include("../member/header2.php"); ?>
</div>

<div id="content">

<div id="raisetable">
<input name="aId" type="hidden" value="<?=$row->AID ?>">	
<div id="raisedetail" align="center">
<br/><br/><br/><br/>
<table border="0" id="temp" align="center">
  <tr >
    <th scope="row" class="must">活動名稱</th>
    <td ><?=$row->ANAME?></td>
    <td   rowspan="6"><?
	//$map->printOnLoad() ;
//	echo $row->lon.$row->lat;
   if($row->LON!='' && $row->LAT!=''){

	$map->addMarkerByCoords($row->LON,$row->LAT,'$row->content','<b>活動名稱:'.$row->ANAME.'</b><br>活動內容<br>'.$row->CONTENT);
	}
	else{
	  $map->setMarkerIcon('http://localhost/map/Icons/jume.png','http://localhost/map/Icons/mm_20_shadow.png',0,0,10,10);
	 	 $map->addMarkerIcon('http://localhost/map/Icons/jume.png','http://localhost/map/Icons/mm_20_shadow.png',0,0,10,10); 
		 $map->addMarkerByCoords(120.265039,22.628032,'>.^ 我是揪咪!?');
	
	}
	  $map->printHeaderJS(); 
     $map->printMapJS();
	//$map->setCenterCoords($row->lon,$row->lat);
  $map->printMap();
  ?>
        <div id="map" style="width:400; height:150; "></div></td>
  </tr>
  <tr >
    <th scope="row" class="must">開始時間</th>
    <td><?=$row->ATIME?></td>
  </tr>
  <tr align="left">
    <th scope="row" class="must">結束時間</th>
    <td><?=$row->END_DATE?></td>
  </tr>
  <!--
    <tr align="left">
    <th scope="row" class="must">活動場地</th>
    <td><?=$row->aPlace?></td>
  </tr>
  -->
  <tr align="left">
    <th scope="row" class="must">活動地址</th>
    <td><?=$row->ADDRESS?></td>
  </tr>
  <tr align="left">
    <th>活動圖片</th>
    <td id="adpic"><? 

	$sql = oci_parse($conn,"SELECT PPATH FROM PICTURE WHERE AID='$aId'") or die('Insert error');


	oci_execute($sql);

$row2=oci_fetch_array($sql);

	
	if($row2[0]!=''){
	echo "<img src='$row2[0]' width='250' height='300' border='0'>";
	}else{echo "<img src='picture/original.png' target='_blank' width='200' height='150' border='0'>";}
	?>
        <!--<div id="pic" style="width:200; height:100;"></div>-->
    </td>
  </tr>
  <!--
  <tr align="left">
    <th>主辦單位</th>
    <td><?=$row->host?></td>
  </tr>
  -->
  <tr align="left"> </tr>
  <tr align="left">
    <th>活動內容</th>
    <td colspan="2"><?=$row->ACONTENT?></td>
  </tr>
  <!--
  <tr align="left">
    <th>活動費用</th>
    <td><?=$row->fees?></td>
  </tr>
  -->
  <tr align="left">
    <th>類別</th>
    <td><? if($row->TID==1){echo "Shopping";}
	       if($row->TID==2){echo "Party";}
		   if($row->TID==3){echo "Food";}
		   if($row->TID==4){echo "Travel";}
		   if($row->TID==5){echo "Sports";}
		   if($row->TID==6){echo "Educate";}?>
    </td>
  </tr>
  <!--
  <tr align="left">
    <th>相關網站</th>
    <td><?=$row->website?></td>
  </tr>
  <tr align="left">
    <th>聯絡電話</th>
    <td><?=$row->aPhone?></td>
  </tr>
  -->
  <tr align="left">
    <th>發佈會員</th>
    <td><? 
	      
		echo "<a href=\"../member/show_member_detail.php?mId=$row->MID\">".$row->MACCOUNT."</a>";
	          
		 
		
		
	?>
	<?

	
	if($_SESSION['mId']!=''&&$_SESSION['mId']!=$row->MID){
		echo "<a href='../raise/send.php?height=260&width=350&mId=".$row->MID."' class=\"thickbox\" title=\"傳送訊息給$row->MACCOUNT\"><img src='../images/messenge.png' border='0'></a>";
	
}?>
    </td>
  </tr>

</table></div><!--end raisedetail-->
</div><!--end raisetable-->
  
<br/>
<!--此活動的揪團-->	
<div id="raise_show">
<div id="raiseshow">
<table border="0" width="730"><tr>
<?
	$dtoday=date("Y-m-d");
    
	$str_10 = oci_parse($conn,"select RAISE.RID,RAISE.MID,MEMBER.MACCOUNT from RAISE left outer join MEMBER on RAISE.MID=MEMBER.MID where RAISE.AID='$aId'") or die('Insert error');

oci_execute($str_10);


	$row_10=oci_num_rows($str_10);
	if($row_10==''){echo"目前沒有此活動揪團";}
	else{
	echo"<td colspan='10' >這個活動的揪團有：</td></tr>
  		<tr>";
		for($i=0;$i<5;$i++){
    		if(list($rId,$rmId,$mAccount)=oci_fetch_row($str_10)){
				echo"<td><a href=\"../raise/show_raise_detail.php?rId=$rId\">第".($i+1)."團</a><br>
				主揪：<a href='../member/show_member_detail.php?mId=$rmId'>$mAccount</a><br>";
					
				echo"</td>";
			}
		}
	    if($row_10>'5'){echo"<tr><td colspan='5' align='right'><a href='../activity/all_take_show.php?aId=$aId'>>>此活動的更多揪團</a></td></tr>";}
		}
	
	?>
	
	</tr></table>
	</div><!--end raiseshow-->
	</div><!--end raise_show-->
<br/>
<!--此發佈者發佈的活動-->		
<div id="member_show">
<div id="membershow">
<table border="0" width="730"><tr>
<?
    $r_mem=$row->MID;
	$r_res = oci_parse($conn,"select AID,ANAME from ACTIVITY where MID='$r_mem' and AID <> '$aId' order by aId desc") or die('Insert error');

oci_execute($r_res);

   
	$row_res=oci_num_rows($r_res);
	if($row_res==''){echo"發佈這個活動的會員最近期沒有發佈活動";}
	else{echo"<td colspan='10' >發布會員最近發佈過的五筆活動</td></tr>
         <tr>"; 
  		for($j=0;$j<5;$j++){
			if(list($r_aId,$r_aName)=mysql_fetch_row($r_res)){
			
			$tmp = oci_parse($conn,"select * from PICTURE where AID='$r_aId'") or die('Insert error');
           oci_execute($tmp);
         	$r_pic=oci_num_rows($tmp);
			
		
	
			echo "<td><a href='activity_show_detail.php?aId=$r_aId'>";
				if($r_pic==''){
				echo "<img src='picture/original.png' target='_blank' width='80' height='70' border='0'><br>";}
				else {
				$tmp = oci_parse($conn,"select PPATH from PICTURE where AID='$r_aId'") or die('Insert error');
             oci_execute($tmp);
         	$pic=oci_num_rows($tmp);
					
					echo "<img src='$pic[0]' target='_blank' width='80' height='70' border='0'><br>";}
				echo $r_aName."</a></td>";

			}
		}
		//if($row_res>'5'){echo"<tr><td colspan='5' align='right'><a href='#'>>>More</a></td></tr>";}
	}
	?>
	
	</tr></table>
	</div><!--end membershow-->
	</div><!--end member_show-->	
 	

</div><!--end content-->
<div id="footer">
  
  <div id="footer-in" align="center">
  <br/><a href="activity_show.php"><img src="../member/images/back_activity.png"  border="0"/></a>
    
	<? 
	
 	$ans=check_main($mid,$aId,$conn);
 	$ans2=check_raise($mid,$aId,$conn);
	if($ans=='no'&&$ans3=='ok'){

if($row->END_DATE >= $dtoday){
	
echo "<a href='edit_activity.php?aId=$aId'><img src='../member/images/edit_act.png'  border='0'/></a>";
}
}
if($ans2=='ok'&&$ans3=='ok'){
if($row->END_DATE >= $dtoday){
echo "<a href='../raise/add_raise.php?aId=$aId'><img src='../member/images/raise_group.png'  border='0'/></a>";
}  
//echo "<p>管理揪團</p>";
}


?> 
<?
/*
echo "<br><br>";
putenv("TZ=Asia/Taipei");
if(empty($Act))
{
$Act=1;
}
$d1=date("Y-m-d H:i:s");
$d2=date("Y");
$d3=date("m");
$aIp=($_SERVER["REMOTE_ADDR"]);
$aId=$_GET['aId'];
$str=mysql_query("select * from counter where aId='$aId' order by ctymdhis desc limit 0,1 ");
$row=mysql_fetch_object($str);
$time1=strtotime($d1);
$time2=strtotime($row->ctymdhis);
$timedif=$time1-$time2;
 if($timedif%86400==0)
    $day=(int)$timedif/86400;
 else
 {
    $day=(int)($timedif-($second=$timedif%86400))/86400;
    if($second%3600==0)
       $hours=(int)$second/3600;
    else
    {
     $hours=(int)($second-($second=$second%3600))/3600;
     if($second%60==0)
        $mine=(int)$second/60;
     else
     {
        $mine=(int)($second-($second%60))/60;
        $second=$second%60;
     }
    }
 }
  //echo $day.'天'.$hours.'時'.$mine.'分'.$second.'秒';
if($aIp==$row->aIp&&$mine<=30)
{
$str=mysql_query("select count(*) from counter where ctymd='$dtoday'&& aId='$aId'");
list($numt1)=mysql_fetch_row($str);

$str=mysql_query("select count(*) from counter where aId='$aId'");
list($numt2)=mysql_fetch_row($str);

echo "今日瀏覽次數：$numt1<br/>";
echo "目前瀏覽次數：$numt2";
}
else{
mysql_query("INSERT INTO counter (ctprikey,ctymd,ctymdhis,cty,ctm,aIp,aId,ctact)VALUES(null,'$dtoday','$d1','$d2','$d3','$aIp','$aId','$Act')");

$str=mysql_query("select count(*) from counter where ctymd='$dtoday'&& aId='$aId'");
list($numt1)=mysql_fetch_row($str);

$str=mysql_query("select count(*) from counter where aId='$aId'");
list($numt2)=mysql_fetch_row($str);

echo "今日瀏覽次數：$numt1<br/>";
echo "目前瀏覽次數：$numt2";
}
*/
?>    
    <br/>
    <br/><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 -->
</div><!-- end div#wrapper -->
</body>
</html>


<?
if($_SESSION['mId']!='')
echo "<script type=\"text/javascript\" src=\"../thick/thickbox.js\"></script>";
?>
