<!--<?php
require($this->getSegmentFile('manage.nav'));
print <<<EOT
-->	
		<div id="contentC" class="fl">
			<script type="text/javascript">
				var product = {
						remove : function(url){
							if(confirm('你确定要删除吗?')){
								setTimeout(function(){
									window.location.href = url;
								},200);
							}
							return false;
						}	
					};
			</script>
			<div class="p15">
<!-- 
EOT;
$operatename = ($_viewer->operatename) ? $_viewer->operatename : '商品添加';
$operate = ($_viewer->operate) ? $_viewer->operate : 'add';
$marketPrice = str_replace(array(' '),'',$_viewer->product['market_price']);
$memberPrice = str_replace(array(' '),'',$_viewer->product['member_price']);
print <<<EOT
-->				
				<div class="nav3 mb10">
					<ul class="cc">
						<li><a href="{$_viewer->baseName}&c=pmanage&dianpuid={$_viewer->dianpuid}">商品管理</a></li>
						<li class="current"><a href="{$_viewer->baseName}&c=pmanage&a={$operate}&dianpuid={$_viewer->dianpuid}&productid={$_viewer->product[productid]}">{$operatename}</a></li>
					</ul>
				</div>
				<h2 class="h1">{$operatename}</h2>
				<form action="{$_viewer->baseUrl}&a={$operate}&dianpuid={$_viewer->dianpuid}" method="post" enctype = "multipart/form-data" name="FORM" onsubmit="return identify.doSubmit(document.FORM)">
				<input type="hidden" name="productid" value="{$_viewer->product[productid]}" />
				<input type="hidden" name="dianpuid" value="{$_viewer->dianpuid}" />
				<input type="hidden" name="step" value="2" />
				<div class="admin_table">
					<table width="100%">
						<tr class="tr1">
							<td class="td1">店铺首页推荐</td>
							<td class="td2">
								<ul class="list_A list_80">
									<li><label><input name="recommend" type="radio" value="1" {$_viewer->checked[1]} > 是</label></li>
									<li><label><input name="recommend" type="radio" value="0" {$_viewer->checked[0]} > 否</label></li>
								</ul>
							</td>
						</tr>
						<tr class="tr1">
							<td class="td1">商品名称<span class="s1">*</span></td>
							<td class="td2"><input onblur="identify.validation(document.FORM,this.id)" id="title" title="商品名称" name="title" value="{$_viewer->product[title]}" type="text" class="input input_wa" /></td>

						</tr>
						<tr class="tr1">
							<td class="td1">市场价<span class="s1">*</span></td>
							<td class="td2"><input onblur="identify.validation(document.FORM,this.id)" id="market_price" title="市场价" name="market_price" value="{$marketPrice}" type="text" class="input input_wa" /> (元)</td>
						</tr>
						<tr class="tr1">
							<td class="td1">会员价<span class="s1">*</span></td>
							<td class="td2"><input onblur="identify.validation(document.FORM,this.id)" id="member_price" title="会员价" name="member_price" value="{$memberPrice}" type="text" class="input input_wa" /> (元)</td>

						</tr>
						<tr class="tr1 vt">
							<td class="td1">商品图片</td>
							<td class="td2">						
							<div class="admin_imgList">
								<ul class="cc">
<!-- 
EOT;
if($_viewer->product[photonum]){
foreach($_viewer->product[photos] as $p){
$checked = ($_viewer->product[photoid] == $p[photoid]) ? 'checked="checked"' : '';
print <<<EOT
-->
								<li>
									<img src="{$p[path]}" height="100" width="100" class="B_img" />
									<p><a href="javascript:;" onclick="product.remove('{$_viewer->baseUrl}&a=deletephoto&photoid={$p[photoid]}&productid={$_viewer->product[productid]}&dianpuid={$_viewer->dianpuid}');" class="fr mr10">删除</a>
									<label><input type="radio" name="cover" value="{$p[photoid]}" {$checked} />设为封面</label></p>
								</li>
<!-- 
EOT;
}}
print <<<EOT
-->
								</ul>
							</div>
<!-- 
EOT;
if($_viewer->product[photoadd]){
for($i=1;$i<=$_viewer->product[photoadd];$i++){
print <<<EOT
-->								
								<p style="padding:3px 0;"><input name="photos_{$i}" type="file" class="input" /></p>
<!-- 
EOT;
}}
print <<<EOT
-->							

							</td>
						</tr>
						<tr class="tr1 vt">
							<td class="td1">商品简介</td>
							<td class="td2">
<!--
EOT;
require($this->getSegmentFile('dmanage.editor'));
print <<<EOT
-->
							</td>
						</tr>
					</table>
				</div>
				<div class="p10 tac"><span class="btn"><span><button type="submit">发 布</button></span></span></div>
				</form>
		</div>
	</div>
<script type="text/javascript">
var identify = {
	doSubmit : function(form){
		if(!this.validation(form,'')) return false;
		var url = '{$_viewer->baseUrl}&a={$operate}&dianpuid={$_viewer->dianpuid}';
		window.location.href = url;
	},
	
	validation : function(form,type){
		if(form == null || form == undefined || form == "") {
			DP.tips('error','非法的请求，请检查后再提交');
			return false;
		}
		if (type == '') {
			VALIDATOR.init(form);
		} else {
			VALIDATOR.init_2(form,type);
		}
       //商品名称
		if(type == '' || type == 'title') {
			VALIDATOR.isRequired('title');
			VALIDATOR.isLetter('title');
			VALIDATOR.isLength('title', 0, 200);
		}		
		if (type == '' || type == 'market_price') VALIDATOR.isRequired('market_price');
		if (type == '' || type == 'member_price') VALIDATOR.isRequired('member_price');		
		if (type == '' || type == 'market_price') VALIDATOR.isPrice('market_price');
		if (type == '' || type == 'member_price') VALIDATOR.isPrice('member_price');
		
		if(!VALIDATOR.result)return false;
		return true;
	}
};
</script>	
	
<!--
EOT;
?>