<?
if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
session_start();}//開起SESSION}
$mAccount=$_SESSION['mAccount'];
include("../function.php");
check_login();

?>
<!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>
<!-- 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/edit_raise.css" rel="stylesheet" type="text/css" media="screen" />
<SCRIPT LANGUAGE="JavaScript" src="../jQuery/TbxLenLimit.js"></SCRIPT>
<script type="text/javascript" src="../jquery/jquery-1.2.6.js"></script>
<style type="text/css">
<!--
.style1 {
	font-size: 12px;
	font-weight: bold;
}
-->
</style>
</head>

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

<?

require_once("../db.php");
if(isset($_GET["rId"])){
	$rId=$_GET["rId"];
}else{
	$rId=$_POST["rId"];
}

$str = oci_parse($conn,"select * from RAISE where RID='$rId'") or die('Insert error');
oci_execute($str);
$row=oci_fetch_object($str);
/*
$str=mysql_query("select * from raise where rId='$rId'");
$row=mysql_fetch_object($str);
*/
$str_5 = oci_parse($conn,"select * from ACTIVITY where AID='$row->aId'") or die('Insert error');
oci_execute($str_5);
$row_5=oci_fetch_object($str_5);
/*
$str_5=mysql_query("select * from activity where aId='$row->aId'");
$row_5=mysql_fetch_object($str_5);

CheckrID(($row->mId));
*/
function ChangWord($NewWord){
		// 將 enter 符號換為 <br>
    		$NewWord=str_replace("<br />","",$NewWord);
		// 將 [']+ 符號,換為 `
   		$NewWord=ereg_replace("[']+", "`", $NewWord);
		return $NewWord;
 	}
?>
<div id="content">
 <div id="raisedetail" align="center">
<form action="edit_raise_action.php" method="post" id="raise_form" onsubmit="return valid_add();">

<input type="hidden" name="rId" value="<? echo $rId;?>">
<br>
<p><strong<font color='#FF6600'>修改揪團資料</font></strong></p>
<table border="1" align="center" id="temp">
<!--
  <tr>
    <th class="must">揪團名稱</th>
    <td><? echo"<input type='text' name='rTitle' size='30' maxlength='15' value='$row->RTITLE'" ?>(建議15字以內)</td>
  </tr>
  -->
  <tr>
    <th class="must">集合地點</th>
    <td><? echo"<input type='text' name='rPlace' size='40' maxlength='20' value='$row->RPLACE'>" ?>(建議20字以內)</td>
  </tr>
  <tr>
    <th class="must">集合時間</th>
    <td>
	<? $pre_rTime=explode("-",$row->RTIME);
		$rTime_a=$pre_rTime[0];
		$rTime_b=$pre_rTime[1]; 
	?>
	<select name="rTime_a">
	<? if($rTime_a=='AM'){
		echo"<option value='AM' selected=selected>AM</option>";
   		echo"<option value='PM'>PM</option>";}
	else{
		echo"<option value='AM' >AM</option>";
   		echo"<option value='PM' selected=selected>PM</option>";}
		?>
	</select>
	<select name="rTime_b">
	<? 
	    if($rTime_b=='1'){
       	   echo "<option value='1' selected=selected>1點</option>";}
           else{echo "<option value='1'>1點</option>";}
		if($rTime_b=='2'){
			echo "<option value='2' selected=selected>2點</option>";}
			else{echo "<option value='2'>2點</option>";}
		if($rTime_b=='3'){
       	   echo "<option value='3' selected=selected>3點</option>";}
           else{echo "<option value='3'>3點</option>";}
		if($rTime_b=='4'){
			echo "<option value='4' selected=selected>4點</option>";}
			else{echo "<option value='4'>4點</option>";}
		if($rTime_b=='5'){
			echo "<option value='5' selected=selected>5點</option>";}
			else{echo "<option value='5'>5點</option>";}
		if($rTime_b=='6'){
       	   echo "<option value='6' selected=selected>6點</option>";}
           else{echo "<option value='6'>6點</option>";}
		if($rTime_b=='7'){
			echo "<option value='7' selected=selected>7點</option>";}
			else{echo "<option value='7'>7點</option>";}
		if($rTime_b=='8'){
			echo "<option value='8' selected=selected>8點</option>";}
			else{echo "<option value='8'>8點</option>";}
		if($rTime_b=='9'){
       	    echo "<option value='9' selected=selected>9點</option>";}
           else{echo "<option value='9'>9點</option>";}
		if($rTime_b=='10'){
			echo "<option value='10' selected=selected>10點</option>";}
			else{echo "<option value='10'>10點</option>";}
		if($rTime_b=='11'){
			echo "<option value='11' selected=selected>11點</option>";}
			else{echo "<option value='11'>11點</option>";}
		if($rTime_b=='12'){
       	    echo "<option value='12' selected=selected>12點</option>";}
           else{echo "<option value='12'>12點</option>";}?>
		</select>
	</td>
  </tr>
  <tr>
    <th class="must">集合日期</th>
	<td>
	<? 
	/*
	$dtoday=date("Y-m-d");
	if($row_5->start_date==$dtoday && $row_5->end_date==$dtoday)
	{echo"$row->rDate";}
	else{
	echo"<input type='text' id='rDate_1' name='rDate' value='$row->rDate'>";
	
	}*/
		echo"<input type='text' id='rDate_1' name='rDate' value='$row->RDATE'>";
	?> 
	<? 
	$dtoday=date("Y-m-d");
	$time1=strtotime($row_5->END_DATE);
    $time2=strtotime($dtoday);
    $time3=$time1-$time2;
    $time4=$time3/86400; ?>
	</td>
  </tr>
    <tr>
    <th class="must">主辦人電話</th>
    <td><? echo"<input type='text' name='rPhone' size='20' maxlength='15' value='$row->RPHONE'>"?>
	</td>
  </tr>
    <tr>
    <th>主辦人Email</th>
    <td><? echo"<input type='text' name='rEmail'size='40' maxlength='45' value='$row->REMAIL'>"?>
	</td>
  </tr>
  <!--
  <tr>
    <th>主辦人msn</th>
    <td><? echo"<input type='text' name='rMsn' size='40' maxlength='45' value='$row->rMsn'>"?></td>
  </tr>
  -->
  <tr>
    <th>備註</th>
    <td>超過將會被截掉喔~
    	<textarea name="rElse"  cols="40" rows="5" maxlength="200" class="ShowLen"><?=ChangWord($row->RELSE)?></textarea></td>
  </tr>

  <tr>
  	<th class="must">可參加人數</th>
	<td><? echo"<input type='text' name='rLimit' size='5' maxlength='5' value='$row->RLIMIT'>"?></td>
  </tr>
  <tr><td colspan="2" align="center">
  <!--<input type="hidden" name="rDate" value="<?=$row->rDate?>">-->
  <input type="submit" name="Submit" value="確定修改" />
  <input type='button' value='回管理頁面' onClick="javascript:location.href='ad_main.php?rId=<?=$rId ?>'"></td></tr>
  <tr><td colspan="2" align="center"><p><a href="../activity/activity_show.php">取消修改  回活動列表</a></p></td></tr>
</table>

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

</div ><!--end #content-->
<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>
<!-- Include jQuery -->
<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 (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>
