<?

if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
session_start();}//開起SESSION
putenv("NLS_LANG=TRADITIONAL CHINESE_TAIWAN.AL32UTF8");
$id=$_SESSION['mAccount'];
$mid=$_SESSION['mId'];
include("../function.php");
check_login();
if($mid!=''){
	

	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JUME(Join You And Me)揪咪揪團活動網</title>
</head>
<!-- Include Core Datepicker Stylesheet -->		
<link rel="stylesheet" href="css/ui.datepicker.css" type="text/css" media="screen" title="core css file"/>
<link href="../member/style/add_raise.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="../jquery/jquery-1.2.6.js"></script>
<SCRIPT LANGUAGE="JavaScript" src="../jQuery/TbxLenLimit.js"></SCRIPT>
<body>
<center>
<div id="header">
<? include("../member/header2.php"); ?>
</div>

<div id="content"><br>
Hi~<?=$id?>，歡迎您來到"揪咪"，請填寫以下資料開始揪團 
<? 
$aId=$_GET["aId"];
require_once("../db.php");

	
	$sql = oci_parse($conn,"select ANAME,ATIME,END_DATE from ACTIVITY where AID='$aId'") or die('Insert error');
oci_execute($sql);


	

$tmp=oci_fetch_array($sql);
echo "<br>活動名稱<font color='#FF6600' weight='bold'>".$tmp[0]."</font>的揪團";
	$str_1 = oci_parse($conn,"select * from MEMBER where MID='$mid'") or die('Insert error');
oci_execute($str_1);

$row_1=oci_fetch_object($str_1);
?>

 <div id="raisedetail" align="center">
<form action="add_raise_action.php" method="post" id="raise_form" enctype="multipart/form-data"  onsubmit="return valid_add();">
	
<table border="0" id="temp">
<!--
  <tr>
    <th class="must">揪團名稱</th>
	<td><input type="text" name="rTitle" size="30" maxlength="15">(建議15字以內)</td>
  </tr>
  -->
  <tr>
    <th class="must">集合地點</th>
    <td><input type="text" name="rPlace" size="40" maxlength="20">(建議20字以內)</td>
  </tr>
  <tr>
    <th class="must">集合時間</th>
    <td>
	<select name="rTime_a">
		
		<option value="AM">AM</option>
	    <option value="PM">PM</option>
	</select>
	<select name="rTime_b">
	   
	    <option value="1">1點</option>
		<option value="2">2點</option>
		<option value="3">3點</option>
		<option value="4">4點</option>
		<option value="5">5點</option>
		<option value="6">6點</option>
		<option value="7">7點</option>
		<option value="8">8點</option>
		<option value="9">9點</option>
		<option value="10">10點</option>
		<option value="11">11點</option>
		<option value="12">12點</option>
		</select>
	</td>
  </tr>
  <tr>
    <th class="must">集合日期</th>
    <td>
	<?
	$dtoday=date("Y-m-d");
	if($tmp[1]==$dtoday && $tmp[2]==$dtoday)
	{echo"$tmp[2]";}
	else
	{echo"<input type='text' id='rDate_1' name='rDate' value='選擇日期'>";}
	?> 
<?

	$str = oci_parse($conn,"select * from ACTIVITY where AID='$aId'") or die('Insert error');
oci_execute($str);


$row=oci_fetch_object($str); 
$time1=strtotime($row->END_DATE);
$t=$row->END_DATE;
$time2=strtotime($dtoday);
$time3=$time1-$time2;
$time4=$time3/86400;
?>

  <tr>
    <th class="must">主辦人電話</th>
    <td><input type="text" name="rPhone" size="20" maxlength="15"  value="<?=$row_1->CELLPHONE?>"></td>
  </tr>
  <tr>
    <th>主辦人E-mail</th>
    <td><input type="text" name="rEmail" size="40" maxlength="45" value="<?=$row_1->EMAIL?>"></td>
  </tr> 
  <!--
  <tr>
    <th>主辦人msn</th>
    <td><input type="text" name="rMsn" size="40" maxlength="45" value="<?=$row_1->mMsn?>"></td>
  </tr>    
  -->
  <tr>
  	<th class="must">參加人數上限</th>
	<td><input type="text" name="rLimit" size="5" maxlength="5" id="limit"></td>
  </tr>		
	<!-- Attach the datepicker to dateinput after document is ready -->
	</td>
  </tr>
  <tr>
    <th>備註</th>
    <td>超過將會被截掉喔~<textarea name="rElse" cols="40" rows="5" maxlength="200" class="ShowLen"></textarea></td>
  </tr>

</table>
<input type="hidden" name="rDate" value="<?=$tmp[2]?>">
<input type="hidden" name="mId" value="<?=$mid?>">
<input type="hidden" name="aId" value="<?=$aId?>">
<input type="submit" name="Submit" value="送出"/>

</form>
</div>
</div><!--end #raisedetail-->


</div><!--end content-->
<div id="footer">   
  <div id="footer-in" align="center">
    <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 -->
</center>
</body>
</html>

<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript" charset="utf-8">
      	$('#rDate_1').datepicker({dateFormat: 'yy-mm-dd', showOn: 'both',minDate: "d0", maxDate:<?=$time4?> ,
      		buttonImageOnly: true, buttonImage: 'images/pickup.gif'});
</script>

<script type="text/javascript">
 function valid_add()
	{
		var msg = "";	
		//alert(msg);
		
		var chk="";
        formobj = window.document.getElementById("raise_form");
        
         if (formobj.rTitle.value == ""){
    msg += "請輸入揪團名稱\n";
        }
		if (formobj.rPlace.value == "")
        {
        	  msg += "請輸入集合地點\n";
        }
		
	
	if (formobj.rDate.value == "")
        {
        	  msg += "請輸入集合日期\n";
        }if (formobj.rPhone.value == "")
        {
        	  msg += "請輸入主辦人電話\n";
			  
        }else if(isNaN(formobj.rPhone.value)){
		msg += "主辦人電話錯誤\n";
			  
		}
	<?
	
	if($aId=='2'){
		echo "if($('#limit').val()>1){msg += \"隊友只有1人唷!!\\n\";}";
		
		}	
	?>	
		if (formobj.rEmail.value == "")
        {
        	  msg += "請輸入Email\n";
        }if (formobj.rMsn.value == "")
        {
        	  msg += "請輸入MSN\n";
        }if (formobj.rLimit.value >100 || formobj.rLimit.value <0 || formobj.rLimit.value==""|| isNaN(formobj.rLimit.value) )
        {
        	  msg += "人數輸入錯誤\n";
        }

		if (msg != "" )
        {
	
            alert(msg);
            return false;
        }
        else
        {
			
			return true;
			
        }
		
   }
	
  </script>
 <?
}else{echo "請先登入";}
?>