<?php
session_start();
require_once "../init.php";
require_once "../authority.inc.php";

$ParentID = $_GET['ParentID'];
$IDProduct = $_GET['IDProduct'];
$PParentID = $_GET['PParentID'];

$arProType = array();
$proType = new ProductType();
$tree = $proType->ShowProTypeTree('0',0,$arProType);

$arProType = array();
$proType = new ProductType2();
$tree2 = $proType->ShowProTypeTree('0',0,$arProType);

$arProType3 = array();
$proType3 = new ProductType5();
$tree3 = $proType3->ShowProTypeTree('0',0,$arProType3);


if($IDProduct){
	$proInfo = $proType->GetProduct($IDProduct);
	$ParentID = $proInfo['ParentID'];
}
$hot="pro";



$AgentInfo = load_config(1);



$uppath=isset($_REQUEST["upPath"])?$_REQUEST["upPath"]."/":"/ueditor/php/upload/image";            
$formName=isset($_REQUEST["formName"])?$_REQUEST["formName"]:"form";         
$editName=isset($_REQUEST["editName"])?$_REQUEST["editName"]:"pic";           

$pics = json_decode($proInfo['pics'], true);


$resultpicinfo = iconv('gbk', 'utf-8', $proInfo['picinfo']);

$picinfo = json_decode($resultpicinfo, true);





$alink = json_decode($proInfo['alink'], true);
?>



<!DOCTYPE HTML>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />

<!--[if IE 6]>
<script type="text/javascript" src="../static/h-ui.admin/js/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>增加产品类别</title>
<LINK href="../share/style.css" rel="stylesheet">

 <script type="text/javascript" charset="gbk" src="../ueditor/lang/zh-cn/zh-cn.js"></script>

  <script type="text/javascript" charset="gbk" src="../ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="gbk" src="../ueditor/ueditor.all.min.js"> </script>
<script>

function GetHtml() {
	if (editor.bTextMode)
		return editor.Composition.document.body.innerText
	else {
		editor.cleanHtml;
		return editor.Composition.document.body.innerHTML;
	}
}

function check(form){

   if(form.ProductName.value==""){
       alert("请输入产品名称");
	   form.ProductName.focus();
	   return false;
   }
}

function add_cs_fun()
{
	var str = '<tr><td><input name="product_new_name[]" type="text" value=""></td><td><input name="product_new_info[]" type="text" value=""></td></tr>';
	$('#product_info_show table').append(str);
}

function del_cs_fun()
{
	alert('del');
}
</script>

<script src='../share/global.js'></script>

        <style type="text/css">
            a{cursor:pointer;color:#333;}
            body{background: #fff none repeat scroll 0 0; color: #333; font: 12px/1.5 "Microsoft YaHei","Helvetica Neue",Helvetica,STHeiTi,sans-serif; background-position: left top; background-repeat: repeat; background-attachment: scroll;}
            .clearfix:after{visibility:hidden; display:block; font-size:0; content:" "; clear:both; height:0}
            *:first-child+html .clearfix{zoom:1}
            ul,li{list-style: none;padding:0;margin:0}

            /**********上传样式***********/

            .progress{position:relative;padding: 1px; border-radius:3px; margin:30px 0 0 0;}
            .bar{background-color: green; display:block; width:0%; height:20px; border-radius:3px;}
            .percent{position:absolute; height:20px; display:inline-block;top:3px; left:2%; color:#fff}
            .progress{
                height: 100px;
                padding: 30px 0 0;
                width:100px;
                border-radius: 0;
            }
            .btnw{-webkit-border-radius:3px; -moz-border-radius:3px; -ms-border-radius:3px; -o-border-radius:3px; border-radius:3px;
                 background-color:#ff8400; color:#fff; display:inline-block; height:28px; line-height:28px; text-align:center; padding:0 12px; 
                 transition:background-color .2s linear 0s; border:0; cursor:pointer;text-decoration: none}
  .btnw a{color:#fff;}
            .btnw:hover{background-color:#e95a00; text-decoration:none;color:#fff;}
            .photos_area .item {
                float: left;
                margin: 0 10px 10px 0;
                position: relative;
            }
            .photos_area .item{position: relative;float:left;margin:10 10px 10px 0;}
            .photos_area .item img{border: 1px solid #cdcdcd;width:230px;height:150px;}
            .photos_area .operate1{background: none; top: -40px; padding:5px 0; left: 0; position: absolute; width: 230px; z-index: 5; line-height: 21px; text-align: center;}
            .photos_area .operate1 input{width:90px;padding:0px;margin:0px}
.photos_area .operate{background: rgba(33, 33, 33, 0.7) none repeat scroll 0 0; bottom: 0; padding:5px 0; left: 0; position: absolute; width: 230px; z-index: 5; line-height: 21px; text-align: center;}
            .photos_area .operate i{cursor: pointer; display: inline-block; font-size: 0; height: 12px; line-height: 0; margin: 0 5px; overflow: hidden; width: 12px; background: url("images/icon_sucaihuo.png") no-repeat scroll 0 0;}
            .photos_area .operate .toright{background-position: -13px -13px; position: relative;top:1px;}
            .photos_area .operate .toleft{background-position: 0 -13px; position: relative;top:1px;}
            .photos_area .operate .del{background-position: -13px 0; position: relative;top:0px;}
            .photos_area .preview{background-color: #fff; font-family: arial; line-height: 90px; text-align: center; z-index: 4; left: 0; position: absolute; top: 0; height: 90px; overflow: hidden; width: 90px;}
            td{padding: 20px 0}
        </style>
</head>
<body>


<div id="topLink">
<div id="topInfo">
	
</div>
</div>
<!--子导航--><div class="page-container">


      <form action="pro_class_save.php" method="post" onSubmit="return check(this)"  id="form" name="form1" enctype="multipart/form-data">
        <table width="100%"  border="0" cellpadding="0" cellspacing="0" id="table" class="table table-border table-bordered table-bg table-hover table-sort">
          <tr id="tr">
            <td colspan="2">增加产品类别</td>
          </tr>
         
          <tr>
            <td align="right" width=90px>所属父类:</td>
            <td>
			    <select name="ParentID">
                <option value='0'>--设为根类--</option>
                <?
			    for($i=0;$i<count($tree);$i++){
					$selected = ($ParentID==$tree[$i]['IDProduct'])?"selected":"";
                    echo "<option value='".$tree[$i]['IDProduct']."' $selected>".$tree[$i]['Disp']."</option>";
			    }
			    ?>
                </select>
			</td>
          </tr>


		   <tr style="display:none;">
            <td align="right" width=90px>所属xx父类:</td>
            <td>
			    <select name="PParentID">
               
                <?
			    for($i=0;$i<count($tree);$i++){
					$selected = ($PParentID==$tree[$i]['IDProduct'])?"selected":"";
                    echo "<option value='".$tree[$i]['IDProduct']."' $selected>".$tree[$i]['Disp']."</option>";
			    }
			    ?>
                </select>
			</td>
          </tr>
		  <tr>
            <td align="right">产品类型:</td>
            <td>
                <select name='Type'>
					<option value='class'>产品类</option>
					<option value='product' <?=$proInfo['Type']=='product'?'selected':''?>>实际产品</option>
				</select>
            </td>
          </tr>
		   <tr>
            <td align="right">所属语言:</td>
            <td>
                <select name='lang'>
				
    <option value='Chinese'>--默认中文--</option>
                <?
			    for($i=0;$i<count($tree3);$i++){
					$selected = ($proInfo['lang']==$tree3[$i]['ProductName'])?"selected":"";
					if($tree3[$i]['ProductName']!="Chinese"){
                    echo "<option value='".$tree3[$i]['ProductName']."' $selected>".$tree3[$i]['Disp']."</option>";
					}
			    }
			    ?>

				</select>
            </td>
          </tr>
          <tr>
            <td align="right">产品名称:</td>
            <td><input name="ProductName" type="text" class="inputline" value="<?=$proInfo['ProductName']?>"><font color='red'>*</font></td>
          </tr>
<tr>
            <td align="right">产品品牌:</td>
            <td><input name="Productpp" type="text" class="inputline" value="<?=$proInfo['Productpp']?>"><font color='red'>*</font></td>
          </tr>
		  <tr>
            <td align="right">产品价格:</td>
            <td>
			<? 
			if($_CFG[AgentType]){
				$LevelArr = explode(",",$_CFG[AgentType]);
				$prices = explode(",",$proInfo['Price']);
				for($i=0;$i<count($LevelArr);$i++){
					echo $LevelArr[$i].":";
					echo "<input style=\"width:55px\" type=\"text\" name=\"price[]\" value=\"".$prices[$i]."\">";
				}
			}
			?>
          </tr>
		  <tr>
            <td align="right">续费价格:</td>
            <td>
			<? 
			if($_CFG[AgentType]){
				$LevelArr = explode(",",$_CFG[AgentType]);
				$renew_prices = explode(",",$proInfo['Renew_Price']);
				for($i=0;$i<count($LevelArr);$i++){
					echo $LevelArr[$i].":";
					echo "<input style=\"width:55px\" type=\"text\" name=\"renew_price[]\" value=\"".$renew_prices[$i]."\">";
				}
			}
			?>
          </tr>
	
		
	
		  <tr>
            <td align="right">产品上下架:</td>
            <td><select name='show_index'>
					
					<option value='0' <?=$proInfo['show_index']==0?'selected':''?>>上架</option>
<option value='1' <?=$proInfo['show_index']==1?'selected':''?>>下架</option>
				</select></td>
          </tr>


	  <tr>
            <td align="right">产品图片:</td>
            <td>
 <input type="hidden" name="upPath" value="<?=$uppath?>">
          <input type="hidden" name="editName" value="<?=$editName?>">
          <input type="hidden" name="formName" value="<?=$formName?>">
			<input  type="file" name="file1"  class="inputline" > (如不修改请不要上传,只能上传图片文件或flash文件)
 <input name="OldLogo" type="hidden" value="<?=$proInfo['pic']?>">
		 <input name="DelOldLogo" id="DelOldLogo" type="checkbox" value="1" onchange="this.form.Logo.disabled = this.checked "> <label for='DelOldLogo'><font color='red'> 不需图片(删除)</font></label>
	
		 <? 
		 	if($proInfo['pic']){
			 	$src = $proInfo['pic'];
		   		if(preg_match("/(.swf)$/i",$proInfo['pic'])){
			  		$imagesize = getimagesize($src);
			  		echo "<br><br><embed width=140px height=90px src='$src' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='$imagesize[0]' height='$imagesize[1]'></embed>";
		   		}
				else
				{
			  		echo "<br><br><img width=140px height=90px style='padding:3px;border:1px solid #ccc;' src='$src'>";
		   		}
		 	}
			else
			{
				$src = '';
				//默认模板
				$src = "../../skin/".$AgentInfo['Skin']."/resources/no_pic.png";
				$html = "<br><img src='$src'>";
				echo $html;
			}
		 ?>		

</td>
          </tr>



           
           <tr id="logo_area_tr"   class='logo_area_tr' >
                        <td class="td_left">多图展示:</td>
                        <td>
<a class="btnw" id="logo_upload_btn" href="javascript:;" style="margin:30px 30px 60px 30px;">上传商品图片</a><br>
                            <div id="logo_upload_area" style='width:100%'>
                                <div id='photos_area' class="photos_area clearfix">
                                    <?php
                                    if (isset($pics)) {
                                        foreach ($pics as $k=>$v ) {
                                            ?>
                                            <div class='item'>

<div class='operate1'><table ><tr><td style="border:0"> 
                                 
                                     
<input  name="picinfo[]" value='<?=iconv("UTF-8", "GBK", $picinfo[$k])?>'/>   

 </td><td style="border:0"><select name="alink[]" onChange="ChangeClass(this.options[this.selectedIndex].value,this.form)">
				<option value="">选择链接网址</option>
								
 <?
			    for($i=0;$i<count($tree2);$i++){
					$selected = ($alink[$k]=="/index.php?page_id=".$tree2[$i]['IDProduct']."")?"selected":"";
                    echo "<option value='/index.php?page_id=".$tree2[$i]['IDProduct']."' $selected>".$tree2[$i]['Disp']."</option>";
			    }
			    ?>
			</select></td> </tr></table></div> 
                                                <input type='hidden' name='pics[]' value='<?php echo $v; ?>'/>
                                                <img src='<?php echo $v; ?>'  width='100px' height='100px'/>
                                                <div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'  id='<?php echo $v; ?>'>删除</i></div>
                                         
 </div>


    <?php }
} ?>
                                </div>

  </div>

                        </td>

  <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="plupload/plupload.full.min.js"></script>
        <script type="text/javascript">

            var uploader = new plupload.Uploader({
                runtimes: 'gears,html5,html4,silverlight,flash',
                browse_button: 'logo_upload_btn',
                url: "ajax.php",
                flash_swf_url: 'plupload/Moxie.swf',
                silverlight_xap_url: 'plupload/Moxie.xap',
                filters: {
                    max_file_size: '25mb',
                    mime_types: [
                        {title: "files", extensions: "jpg,png,gif,jpeg"}
                    ]
                },
                multi_selection: true,
                init: {
                    FilesAdded: function(up, files) {
                        $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                        var item = '';
                        plupload.each(files, function(file) { //遍历文件
                            item += "<div class='item' id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></div>";
                        });
                        $("#photos_area").append(item);
                        uploader.start();
                    },
                    UploadProgress: function(up, file) { //上传中，显示进度条 
                        var percent = file.percent;
                        $("#" + file.id).find('.bar').css({"width": percent + "%"});
                        $("#" + file.id).find(".percent").text(percent + "%");
                    },
                    FileUploaded: function(up, file, info) {
                        var data = eval("(" + info.response + ")");
                        $("#" + file.id).html("<input type=hidden name='pics[]' value='" + data.src + "'><img src='" + data.src + "' alt='" + data.name + "' width='100px' height='100px'>\n\
            <div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'>删除</i></div>")

                        $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                        if (data.error != 0) {
                            alert(data.error);
                        }
                    },
                    Error: function(up, err) {
                        if (err.code == -601) {
                            alert("请上传jpg,png,gif,jpeg,zip或rar！");
                            $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                        }
                    }
                }
            });
            uploader.init();
            //左右切换和删除图片
            $(function() {
                $(".toleft").live("click", function() {
                    var item = $(this).parent().parent(".item");
                    var item_left = item.prev(".item");
                    if ($("#photos_area").children(".item").length >= 2) {
                        if (item_left.length == 0) {
                            item.insertAfter($("#photos_area").children(".item:last"));
                        } else {
                            item.insertBefore(item_left);
                        }
                    }

                })
                $(".toright").live("click", function() {
                    var item = $(this).parent().parent(".item");
                    var item_right = item.next(".item");
                    if ($("#photos_area").children(".item").length >= 2) {
                        if (item_right.length == 0) {
                            item.insertBefore($("#photos_area").children(".item:first"));
                        } else {
                            item.insertAfter(item_right);
                        }
                    }
                })


                $(".del").live("click", function() {
                    $(this).parent().parent(".item").remove();
 var picurl=this.id;
pics_del(picurl);
                })
            })


    function pics_del(picurl) {



$.get('del.php',{

				 pic	: picurl
				

	});

}
        </script>
        <!-- 以下是统计及其他信息，与演示无关，不必理会 -->

        <style type="text/css">
            .vad { margin: 120px 0 5px; font-family: Consolas,arial,宋体,sans-serif; text-align:center;}
            .vad a { display: inline-block; height: 36px; line-height: 36px; margin: 0 5px; padding: 0 50px; font-size: 14px; text-align:center; color:#eee; text-decoration: none; background-color: #222;}
            .vad a:hover { color: #fff; background-color: #000;}
            .thead { width: 728px; height: 90px; margin: 0 auto; border-bottom: 40px solid #fff;}
        </style>




                    </tr>

		  <tr>
            <td align="right">产品简介:</td>
            <td><input name="ProductIntro" value="<?=$proInfo['ProductIntro']?>" size='78' maxlength="125" type="text" class="inputline"></td>
          </tr>
          <tr>
            <td align="right">产品参数:</td>
            <td>
				<input id="add_cs" type="button" value="添加" onClick="add_cs_fun()" ></br>
                <div id="product_info_show">
                	<?
						if($proInfo['product_info'] != null)
						{
					?>
                    <table class="table table-border table-bordered table-bg table-hover table-sort">
                    	<tr>
                        	<td width="158">参数</td>
                            <td width="219">值</td>
                        </tr>
                    <?
							//print_r($proInfo['product_info']);
							$json_string = $proInfo['product_info'];//iconv("UTF-8", "GBK", $proInfo['product_info']);

							$json_string= iconv('GBK', 'UTF-8', $json_string);


				
							$product_info_arr = json_decode($json_string,true);
							//print_r($product_info_arr);
							if($product_info_arr)
							{
								foreach($product_info_arr as $key=>$info)
								{
					?>
                    				<tr>
                                    	<td><input name="product_new_name[]" type="text" value="<?=iconv("UTF-8", "GBK", $key)?>"></td>
                                        <td><input name="product_new_info[]" type="text" value="<?=iconv("UTF-8", "GBK", $info)?>"></td>
                                    </tr>
                    <?
								}
							}
					?>
                    </table>
                    <?
						}
						else
						{
					?>
                    <table>
                    	<tr>
                        	<td width="158">参数</td>
                            <td width="219">值</td>
                        </tr>
                    </table>
                    <?
						}
					?>
                    
                </div>
            </td>
          </tr>
		  <tr>
            <td align="right">产品详细说明:</td>
            <td>

		
		

  <script id="editor" type="text/plain" style="width:100%;height:500px;"  name="txtDetail"><?=$proInfo['txtDetail']?></script>
		
            </td>
          </tr>
          
          <tr>
            <td colspan="2" align="center">
			<br>

  <input name="edit" type="hidden" value="1">
			<input name="OldIDProduct" type="hidden" value="<?=$proInfo['IDProduct']?>">
			<input name="submit" type="submit" class="bt2" value=" 提 交 ">&nbsp;&nbsp;
			<input name="reset" type="reset" class="bt2" value=" 重 置 ">
			<br><br><br>
			</td>
          </tr>
        </table>
    </form></div>


<script type="text/javascript">
var ue = UE.getEditor('editor');

</script>

<? 
$DB->close();
include "../share/bottom.php"?>
</body>
</html>
