<?php require_once('../Connections/BE2.php'); ?>
<?php
 

 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE tb2 SET bc1=%s, bc2=%s, ec1=%s, bc3=%s, bc4=%s, bc5=%s, bc6=%s, bc8=%s, bc9=%s,bukid=%s, buind=%s , tb2flag=%s , tb2memo=%s WHERE buid=%s",
                       GetSQLValueString($_POST['bc1'], "int"),
                       GetSQLValueString($_POST['bc2'], "text"),
                       GetSQLValueString($_POST['ec1'], "int"),
                       GetSQLValueString($_POST['bc3'], "text"),
                       GetSQLValueString($_POST['bc4'], "text"),
                       GetSQLValueString($_POST['bc5'], "text"),
                       GetSQLValueString($_POST['bc6'], "text"),
                       GetSQLValueString($_POST['bc8'], "text"),
                       GetSQLValueString($_POST['bc9'], "text"),					   
					   GetSQLValueString($_POST['bukid'], "int"),
					   GetSQLValueString($_POST['buind'], "int"),
					   GetSQLValueString($_POST['tb2flag'], "text"),
					   GetSQLValueString($_POST['tb2memo'], "text"),
                       GetSQLValueString($_POST['buid'], "int"));

  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error());

  $updateGoTo =$_POST['url'];// "main.php?act=user";
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_Rt2 = "-1";
if (isset($_GET['id'])) {
  $colname_Rt2 = $_GET['id'];
}
mysql_select_db($database_BE2, $BE2);
$query_Rt2 = sprintf("SELECT * FROM tb2 WHERE buid = %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);
?>
 
<form action="" method="post" name="form1" id="form1">
  <table width="549" align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">ID:</td>
      <td><input name="bc1" type="text" value="<?php echo htmlentities($row_Rt2['bc1'], ENT_COMPAT, 'utf-8'); ?>" size="32" readonly="readonly" />
      <input type="hidden" name="ec1" value="<?php echo htmlentities($row_Rt2['ec1'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">公司名稱:</span></td>
      <td><input type="text" name="bc2" value="<?php echo htmlentities($row_Rt2['bc2'], ENT_COMPAT, 'utf-8'); ?>" size="32" />
      <input name="bc3" type="hidden" value="<?php echo htmlentities($row_Rt2['bc3'], ENT_COMPAT, 'utf-8'); ?>" size="32" />
      <input name="bc4" type="hidden" value="<?php echo htmlentities($row_Rt2['bc4'], ENT_COMPAT, 'utf-8'); ?>" size="32" />
      <input name="bc5" type="hidden" value="<?php echo htmlentities($row_Rt2['bc5'], ENT_COMPAT, 'utf-8'); ?>" size="32" readonly="readonly" /></td>
    </tr>
   <? /*  
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">縣市分區:</span></td>
      <td>&nbsp;</td>
    </tr>
    
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">分區</span>:</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">通訊處:</span></td>
      <td><label for="bukid"></label></td>
    </tr>
    <? */ ?>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">性質</span>:</td>
      <td><select name="bukid" id="bukid">
        <option value="1" <? if($row_Rt2['bukid']==1){ echo 'selected="selected"' ;}?>>測試</option>
        <option value="2" <? if($row_Rt2['bukid']==2){ echo 'selected="selected"' ;}?>>自營</option>
        <option value="3" <? if($row_Rt2['bukid']==3){ echo 'selected="selected"' ;}?>>公司</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td height="22" align="right" nowrap="nowrap"><span class="font2">啟用:</span></td>
      <td><select name="tb2flag" id="tb2flag">
        <option value="Y" <? if($row_Rt2['tb2flag']=='Y'){ echo 'selected="selected"' ;}?>>Y</option>
        <option value="N" <? if($row_Rt2['tb2flag']=='N'){ echo 'selected="selected"' ;}?>>N</option>
 
      </select>
      縣市區域啟用顯示</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">電話FAX</span>:</td>
      <td><input type="text" name="bc6" value="<?php echo htmlentities($row_Rt2['bc6'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">租車業者</span>:</td>
      <td><select name="bc8" id="bc8" >
        <option value="Y" <? if($row_Rt2['bc8']=='Y'){ echo 'selected="selected"' ;}?>>Y</option>
        <option value="N" <? if($row_Rt2['bc8']=='N'){ echo 'selected="selected"' ;}?>>N</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">行業別</span>:</td>
      <td>
      <? 
	   $a2 = "遊覽車公司,遊覽車業者(車主車),旅行社,租車公司,租車車隊,導遊領隊,翻譯員,飯店、民宿業者,餐飲業,修車廠,汽車材料供應商,禮品業,旅遊景點,保險業,其他";
	   $a1= explode(",",$a2); ?> 
	  <select name="bc9" id="bc9" >
       <? for($i=0;$i < count($a1);$i++){ ?>
        <option value="<?= $a1[$i]?>" <?  if($row_Rt2['bc9']==$a1[$i]){ echo 'selected="selected"' ;}?>><?= $a1[$i]?></option>
       <? }?> 
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">排列值</span>:</td>
      <td><input name="buind" type="text" id="buind" value="<?= $row_Rt2['buind']; ?>" size="12" maxlength="5" />
排列值小於1000將會排列在前面</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><span class="font2">備註</span>:</td>
      <td><textarea name="tb2memo" id="tb2memo" cols="60" rows="6"><?php echo htmlentities($row_Rt2['tb2memo'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="更新記錄" /></td>
    </tr>
  </table>
 
  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="buid" value="<?php echo $row_Rt2['buid']; ?>" />
  <input name="url" type="hidden" id="url" value="<?= $_SERVER['HTTP_REFERER']; ?>" />
</form>
 
<?php
mysql_free_result($Rt2);
?>
