include "../../system.php";
//總體設定
include "../../function/new_function.php";
//函數庫
include "../system.php";
//程式個別設定
include "../class_unit.php";
//分類unit
include "../class_form.php";
include "../class_form2.php";
include "../../fckeditor/fckeditor.php";
// 編輯主檔路徑
$tool = new My_Tool();
$sam = new guard();
//路徑檢查
$unit = new product_class();
$id = $_GET['id'];
//id
$backurl = $_GET['backurl'];
//回傳路徑
$unit->id = $id;
$unit->table = $pro_class_table;
$unit->get_db_var();
$upid = $unit->upid;
$level = $unit->get_level();
$row = $unit->display();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
function display($id, $action, $check, $upid = 0)
{
    global $pro_class_table;
    global $product_table;
    global $pic_max_size;
    //圖片檔案大小限制
    global $pic_jpg;
    //JPG圖片是否啟用
    global $pic_gif;
    //GIF圖片是否啟用
    global $pic_no_pic;
    //預設圖片
    global $sys_product_pics;
    $row = array();
    $row['upid'] = $upid;
    if ($id != 0 and !empty($id)) {
        $class = new product_class();
        $class->id = $id;
        $class->table = $pro_class_table;
        $class->get_db_var();
        $row = $class->display();
        $level = $class->get_level();
    }
    if (empty($row['pic'])) {
        $row['pic'] = $pic_no_pic;
    }
    if (empty($row['pic2'])) {
        $row['pic2'] = $pic_no_pic;
    }
    $oFCKeditor = new FCKeditor('info');
    //  變數名稱
    $oFCKeditor->BasePath = '../../fckeditor/';
    //主程式資料夾路徑
    $oFCKeditor->Value = $row['info'];
    // 一開始顯示的字
    $oFCKeditor->Width = '700';
    //寬度
    $oFCKeditor->Height = '550';
    //高度
    $oFCKeditor->Config['SkinPath'] = 'skins/silver/';
    //樣板
    $oFCKeditor->ToolbarSet = 'Basic';
    // 工具列配置
    ?>
<script src="../../jquery.js"></script>
<form name="form1" method="post" action="<?php 
    echo $action;
    ?>
"  enctype="multipart/form-data" >
<input type="hidden" name="check" value="<?php 
    echo $check;
    ?>
"/> 
<input type="hidden" name="id"  value="<?php 
    echo $row['id'];
    ?>
"/> 
<input type="hidden" name="upid"  value="<?php 
    echo $row['upid'];
    ?>
"/> 
<input type="hidden" name="pic" value="<?php 
    echo $row['pic'];
    ?>
"  />
<input type="hidden" name="pic2" value="<?php 
    echo $row['pic2'];
    ?>
"  />
			
<div style="text-align:left;padding:5px;">
  <a href="<?php 
    print $_GET['backurl'];
    ?>
">【回頁面管理】</a>
</div>
			
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" id="pro"> 
     <tr>
	    <td class="title"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" />基本資料</td>
     </tr>
     <tr>
       <td height="35" align="left" valign="middle" id="main00"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">名稱:
        </span>
      
          <label>
            <input name="name" type="text" id="name" value="<?php 
    print $row['name'];
    ?>
" size="50" maxlength="30" />
    </label>            
          <span class="ps">(*名稱請勿超過30個字元!)</span></td>
     </tr>
  
	  <tr>
        <td height="35" align="left"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">排序:
              <input name="no" type="text" id="no" value="<?php 
    print $row['no'];
    if (empty($row['no'])) {
        echo '100';
    }
    ?>
" size="5" maxlength="4" />
        </span></td>
      </tr>
	  

<!--產品圖片-單張 Begin-->
  <tr>
	    <td class="title"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" />主要圖片</td>
  </tr>
  <tr>
    <td height="35" align="left" valign="middle" id="main00"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">上傳圖片:
        </span>
          
		  <?php 
    if (!empty($row['pic'])) {
        ?>
		  <div style="padding:3px;">
		    <img src="<?php 
        echo $row['pic'];
        ?>
" width="100" />
		  </div>
		  <?php 
    }
    ?>
		  
          <div>
           <input type="file" name="upload" size="20" /> <span class="ps"> 較長圖片(用於列表畫面) </span>
          </div>
		  
		  
		  <?php 
    if (!empty($row['pic2'])) {
        ?>
		  <div style="padding:3px;">
		    <img src="<?php 
        echo $row['pic2'];
        ?>
" width="100" />
		  </div>
		  <?php 
    }
    ?>
		  
          <div>
           <input type="file" name="upload2" size="20" /> <span class="ps"> 較寬圖片(用於該分類顯示品牌畫面) </span>
          </div>
		  
		              
          <div class="ps">
		  *圖片限
		  <?php 
    if ($pic_jpg == 1) {
        echo "JPG &nbsp;";
    }
    if ($pic_gif == 1) {
        echo "GIF &nbsp;";
    }
    ?>
檔,檔案大小不可超過
		   <?php 
    $size = ceil($pic_max_size / 1024);
    if ($size >= 1024) {
        echo $size = mb_substr($size / 1024, 0, 6, "UTF-8");
        echo "MB";
    } else {
        echo $size;
        echo "KB";
    }
    ?>
		   ! 圖片的最佳顯示比例為長寬比 1 : 1</div></td>
  </tr>
<!--產品圖片 End--> 
	  <tr>
        <td height="35" align="left" class="title"><span class="message"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">品牌簡介:</span></span></td>
      </tr>
      <tr>
        <td height="35" align="left" style='padding:5px;'><textarea name="s_info" cols='60' rows='4'><?php 
    print $row['s_info'];
    ?>
</textarea></td>
      </tr>
      <tr>
        <td height="35" align="left" class="title"><span class="message"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">品牌介紹:</span>
          
          <label> </label>
<span class="style3">(*貼上文件時,請先選擇跳出視窗中的&quot;</span></span><span class="style6">不允許</span><span class="message"><span class="style3">&quot;後,即可在</span></span><span class="style6">空白方框處</span><span class="message"><span class="style3">貼上文件)</span></span></td>
      </tr><TR><TD align="center"><?php 
    $oFCKeditor->Create();
    ?>
</TD>
      </TR>
      
      <TR>
        <TD height="50" align="center"><div align="center">
			          <input type="submit" name="Submit" value="資料確認送出" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			          <input name="Submit2" type="reset" value="重  新  填  寫" />
			          </div></TD>
      </TR>
  </table>
 </form>
	
	
	<?php 
}
<?php

if ($_POST['submit']) {
    $unit = new product_class();
    $tool = new My_Tool();
    $sam = new guard();
    //檢查傳入值--------------------------
    $name = htmlspecialchars(trim($_POST['name']));
    if (empty($name)) {
        $tool->error(get_msg("name_error"));
    } else {
        $name = $sam->var_check($name);
    }
    $unit->table = $pro_class_table;
    $unit->get_vars();
    $buff = array();
    $unit->get_history($unit->upid, $buff);
    $unit->add();
    $tool->show(get_msg("add_success"), $_SERVER['HTTP_REFERER']);
    exit;
}
?>
			 
    <form method="post" action="">
	<input type="hidden" name="upid" value="<?php 
print $_GET['id'];
?>
" />
	類別名稱:<input type="text" name="name" size="20" />
	排序:   <input type="text" name="no" value="100" />
	<input type="submit" name="submit" value="新增類別" />
function display2($id, $action, $check, $upid = 0)
{
    global $pro_class_table;
    global $product_table;
    global $pic_max_size;
    //圖片檔案大小限制
    global $pic_jpg;
    //JPG圖片是否啟用
    global $pic_gif;
    //GIF圖片是否啟用
    global $pic_no_pic;
    //預設圖片
    global $sys_product_pics;
    $row = array();
    $row['upid'] = $upid;
    if ($id != 0 and !empty($id)) {
        $class = new product_class();
        $class->id = $id;
        $class->table = $pro_class_table;
        $class->get_db_var();
        $row = $class->display();
        $level = $class->get_level();
    }
    if (empty($row['pic'])) {
        $row['pic'] = $pic_no_pic;
    }
    ?>
<script src="../../jquery.js"></script>
<form name="form1" method="post" action="<?php 
    echo $action;
    ?>
"  enctype="multipart/form-data" >
<input type="hidden" name="check" value="<?php 
    echo $check;
    ?>
"/> 
<input type="hidden" name="id"  value="<?php 
    echo $row['id'];
    ?>
"/> 
<input type="hidden" name="upid"  value="<?php 
    echo $row['upid'];
    ?>
"/> 
<input type="hidden" name="pic" value="<?php 
    echo $row['pic'];
    ?>
"  />
<input type="hidden" name="pic2" value="<?php 
    echo $row['pic2'];
    ?>
"  />
			
<div style="text-align:left;padding:5px;">
  <a href="<?php 
    print $_GET['backurl'];
    ?>
">【回頁面管理】</a>
</div>
			
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" id="pro"> 
     <tr>
       <td height="35" align="left" valign="middle" id="main00"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">名稱:
        </span>
      
          <label>
            <input name="name" type="text" id="name" value="<?php 
    print $row['name'];
    ?>
" size="50" maxlength="30" />
    </label>            
          <span class="ps">(*名稱請勿超過30個字元!)</span></td>
     </tr>
  
	  <tr>
        <td height="35" align="left"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">排序:
              <input name="no" type="text" id="no" value="<?php 
    print $row['no'];
    if (empty($row['no'])) {
        echo '100';
    }
    ?>
" size="5" maxlength="4" />
        </span></td>
      </tr>
	  

<!--產品圖片-單張 Begin-->
  <tr>
	    <td class="title"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" />主要圖片</td>
  </tr>
  <tr>
    <td height="35" align="left" valign="middle" id="main00"><img src="../../images/add-folder-blue.gif" width="14" height="14" hspace="5" border="0" align="absmiddle" /><span class="style2">上傳圖片:
        </span>
          
		  <?php 
    if (!empty($row['pic'])) {
        ?>
		  <div style="padding:3px;">
		    <img src="<?php 
        echo $row['pic'];
        ?>
" width="100" />
		  </div>
		  <?php 
    }
    ?>
		  
          <label>
           <input type="file" name="upload" size="20" /> <span class="ps">   </span>
          </label> 
		              
          <div class="ps">
		  *圖片限
		  <?php 
    if ($pic_jpg == 1) {
        echo "JPG &nbsp;";
    }
    if ($pic_gif == 1) {
        echo "GIF &nbsp;";
    }
    ?>
檔,檔案大小不可超過
		   <?php 
    $size = ceil($pic_max_size / 1024);
    if ($size >= 1024) {
        echo $size = mb_substr($size / 1024, 0, 6, "UTF-8");
        echo "MB";
    } else {
        echo $size;
        echo "KB";
    }
    ?>
		   ! 圖片的最佳顯示比例為長寬比 1 : 1</div></td>
  </tr>
<!--產品圖片 End--> 
 
      
      <TR>
        <TD height="50" align="center"><div align="center">
			          <input type="submit" name="Submit" value="資料確認送出" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			          <input name="Submit2" type="reset" value="重  新  填  寫" />
			          </div></TD>
      </TR>
  </table>
 </form>
	
	
	<?php 
}