<?php require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php
 
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE ap2 SET radoc=%s, raindex=%s, raflag=%s, ratshow=%s, ramark=%s, raicon=%s, raaddr=%s WHERE adid=%s",
                       GetSQLValueString($_POST['radoc'], "text"),
                       GetSQLValueString($_POST['raindex'], "int"),
                       GetSQLValueString($_POST['raflag'], "text"),
					   GetSQLValueString($_POST['ratshow'], "text"),
					   GetSQLValueString($_POST['ramark'], "int"),
					   GetSQLValueString($_POST['raicon'], "int"),
					   GetSQLValueString($_POST['raaddr'], "text"),
                       GetSQLValueString($_POST['adid'], "int"));

  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error());

  $updateGoTo = $_POST['url'];
  //header(sprintf("Location: %s", $updateGoTo));
   $write='資料已更新...'; 
  echo  "<script>alert('".$write."');location.href='".$updateGoTo."';</script>";
}

$colname_Rt2 = "-1";
if (isset($_GET['id'])) {
  $colname_Rt2 = $_GET['id'];
}
mysql_select_db($database_BE2, $BE2);
$query_Rt2 = sprintf("SELECT * FROM ap2 WHERE adid = %s", GetSQLValueString($colname_Rt2, "int"));
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2 = mysql_num_rows($Rt2);
?>
   <div class="row">
 <div class="col-md-12">
				
 <div class="panel panel-default">
        <div class="panel-heading">
							<h3 class="panel-title">編輯-廣告頁面模塊</h3>
						</div>  
<form action="" method="post" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <th width="143" align="right" nowrap="nowrap"><span class="font2">廣告區塊說明</span>:</th>
      <td width="362"><input type="text" name="radoc" value="<?php echo htmlentities($row_Rt2['radoc'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">模塊橫幅標題顯示:</span></th>
      <td><select name="ratshow" id="ratshow">
        <option value="Y" <?php if (!(strcmp("Y", $row_Rt2['ratshow']))) {echo "selected=\"selected\"";} ?>>顯示標題</option>
        <option value="N" <?php if (!(strcmp("N", $row_Rt2['ratshow']))) {echo "selected=\"selected\"";} ?>>不顯示標題</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">模塊橫幅標題左上圖示:</span></th>
      <td><select name="raicon" id="raicon">
        <option value="0" <?php if ($row_Rt2['raicon']==0){echo "selected=\"selected\"";} ?>>不用</option>
        <option value="1" <?php if ($row_Rt2['raicon']==1){echo "selected=\"selected\"";} ?>>start</option>
        <option value="2" <?php if ($row_Rt2['raicon']==2){echo "selected=\"selected\"";} ?>>hot</option>
        <option value="3" <?php if ($row_Rt2['raicon']==3){echo "selected=\"selected\"";} ?>>new</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">圖形物件標題顯示:</span></th>
      <td><select name="ramark" id="ramark">
        <option value="0" <?php if ($row_Rt2['ramark']==0){echo "selected=\"selected\"";} ?>>不顯示</option>
        <option value="1" <?php if ($row_Rt2['ramark']==1){echo "selected=\"selected\"";} ?>>上標</option>
        <option value="2" <?php if ($row_Rt2['ramark']==2){echo "selected=\"selected\"";} ?>>下標</option>
        <option value="3" <?php if ($row_Rt2['ramark']==3){echo "selected=\"selected\"";} ?>>圖形內標</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">廣告區塊排列序</span>:</th>
      <td><input name="raindex" type="text" value="<?php echo htmlentities($row_Rt2['raindex'], ENT_COMPAT, 'utf-8'); ?>" size="10" maxlength="4" /></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">模塊位置:</span></th>
      <td><select name="raaddr" id="raaddr">
        <option value="M" <?php if ($row_Rt2['raaddr']=='M'){echo "selected=\"selected\"";} ?>>主區域</option>
        <option value="L" <?php if ($row_Rt2['raaddr']=='L'){echo "selected=\"selected\"";} ?>>左方區域(如果有)</option>
        <option value="R" <?php if ($row_Rt2['raaddr']=='R'){echo "selected=\"selected\"";} ?>>右方區域(如果有)</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">使用</span>:</th>
      <td><select name="raflag">
        <option value="Y" <?php if (!(strcmp("Y", htmlentities($row_Rt2['raflag'], ENT_COMPAT, 'utf-8')))) {echo "SELECTED";} ?>>使用</option>
        <option value="N" <?php if (!(strcmp("N", htmlentities($row_Rt2['raflag'], ENT_COMPAT, 'utf-8')))) {echo "SELECTED";} ?>>暫停使用</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right">&nbsp;</th>
      <td><input type="submit" value="更新記錄" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="adid" value="<?php echo $row_Rt2['adid']; ?>" />
  <input name="url" type="hidden" id="url" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
</form>
<div id="back"><a href="javascript:history.back();"><img src="images/back.gif" alt="回上一頁" title="回上一頁" width="115" height="32" border="0"></a></div> 

   </div>
  </div>
 </div>  
<?php
mysql_free_result($Rt2);
?>
