<?php require_once('../Connections/BE2.php'); ?>
<?php
if (!isset($_SESSION)){ session_start(); }
    if( isset($_POST["MM_update"])&&($_POST["MM_update"] == "fp1")){
	 
	$idpath= sprintf("%07d",$_SESSION['login_memid']) ;
    $wwwpath='/www2/skybni';
    $picpath= "/shop/img/";  
	   
	$wimg=$_POST['wimg'];   
    $tfile="fileToUpload1";
    $wimgext=$_POST['wimgext'];
  
    if($_FILES[$tfile]["name"]<>''){
		   $ext= explode('.',$_FILES[$tfile]['name']) ;
	       $imgext=strtolower($ext[count($ext)-1]); //取最後一筆
		   $wimgext=$imgext;
		   $pic=$wwwpath.$picpath.$wimg.".".$wimgext;
		   move_uploaded_file($_FILES[$tfile]["tmp_name"],$pic);
    }  

 
		  $updateSQL = sprintf("UPDATE webshop SET wtitle=%s,wlink=%s,wimgext=%s,wuse=%s  WHERE coid=1 AND wid=%s ",
                       GetSQLValueString($_POST['wtitle'], "text"),
					   GetSQLValueString($_POST['wlink'], "text"),
					   GetSQLValueString($wimgext, "text"),
					   GetSQLValueString($_POST['wuse'], "text"),
					   GetSQLValueString($_POST['wid'], "int")); //$_SESSION['login_memid']
		
		 
   mysql_select_db($database_BE2, $BE2);
   $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error());
   $msg='更新完成....' ;
   $updateGoTo = "main.php?act=netshop";
   echo  "<script>alert('".$msg."');location.href='".$updateGoTo."';</script>";	
	  
   } 
 
 //update `member` set company_title=mem_name WHERE mem_auto>10 and mem_auto<26
 
 
$id=-1;
$id= (isset($_GET["id"]))?$_GET["id"]:-1;
 	
 mysql_select_db($database_BE2, $BE2);
 $query_Rt3 = sprintf("SELECT * FROM webshop WHERE coid=1 AND wid='%s' " ,$id);
// $query_Rt3 = sprintf("SELECT * FROM webshop WHERE wid= '%s' ",$id); 
 $Rt3 = mysql_query($query_Rt3, $BE2) or die(mysql_error());
 $row_Rt3 = mysql_fetch_assoc($Rt3);
 $totalRows_Rt3 = mysql_num_rows($Rt3);
 $canedit=true;
 
?>
<style>
     .box2{
         border-width:3px;
		 border-style:dashed;
		 border-color:#FFAC55;
		 padding:5px;
    } 
	
	img{
        max-width: 100%;
        max-height: 100%;
        display: block; /* remove extra space below image */
    }
    .box{
        width: 250px;        
        border: 5px solid black;
    }    
    .box.large{
        height: 300px;
    }
    .box.small{
        height: 100px;
    }
</style>
    <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="fp1" id="fp1" enctype="multipart/form-data">		
 
           <table width="666" border="0">
  <tr>
    <td width="143"> 說明: </td>
    <td width="420"> 
      <input type="text" name="wtitle" id="wtitle" value="<?= isset($row_Rt3['wtitle'])?$row_Rt3['wtitle']:""; ?>" size="60"/>
     </td>
    <td width="89">&nbsp;</td>
  </tr>
  <tr>
    <td> 
       連結: 
    </td>
    <td> 
      <input name="wlink" type="text" id="wlink" value="<?= $row_Rt3['wlink'] ; ?>" size="60"  />
     </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td nowrap="nowrap">開放使用者編輯: </td>
    <td>
      <? $ss= isset($row_Rt3['wuse'])?$row_Rt3['wuse']:"Y"; ?>
      啟用
      <input name="wuse" type="radio" id="wuse" value="Y" <?= ($ss=='Y')?'checked="checked"':'' ?> />
      不啟用
  <input type="radio" name="wuse" id="wuse" value="N" <?= ($ss=='N')?'checked="checked"':'' ?>/>
      </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>圖檔:</td>
    <td> <input name="fileToUpload1" type="file" id="fileToUpload1" />
    <span class="help-block"> Size 350 x 350 dpi </span> </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td> 
     
        <input type="hidden" name="wid" id="wid" value="<?= isset($row_Rt3['wid'])?$row_Rt3['wid']:0; ?>" />
        <input type="hidden" name="wimg" id="wimg" value="<?= isset($row_Rt3['wimg'])?$row_Rt3['wimg']:"" ?>" />
        <input type="hidden" name="wimgext" id="wimgext" value="<?= isset($row_Rt3['wimgext'])?$row_Rt3['wimgext']:""; ?>" />
        <input type="hidden" name="windex" id="windex" value="<?= $id ?>" />
        <?= $row_Rt3['wimg'].'.'.$row_Rt3['wimgext']  ?>
       </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input type="hidden" id="coid" name="coid" value="<?= $row_Rt3['coid'] ; ?>" />
    <input type="hidden" name="MM_update" value="fp1" /></td>
    <td><button type="submit" class="btn btn-primary">保存</button></td>
    <td>&nbsp;</td>
  </tr>
</table>

 </form>          
           
  <img name="simg" id="simg" src="/ecard/img/<?= $row_Rt3['wimg'].'.'.$row_Rt3['wimgext']  ?>"  alt="" /> 
                  
<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>   
        
  
 
<!-- end: Content -->
       <?php
mysql_free_result($Rt3);

?>
