<?php include_once(mvc::$cfg['PATH_TPL'].'public/topSeller.php');?>
<div class="maintb">
	<?php include_once(mvc::$cfg['PATH_TPL'].'seller/leftMenu.php');?>
	<div class="main_middle">
		<div class="mod-main ">
			<div class="mod-main-nav-box " id="my_mod-main-nav-box">
				<a href="/seller/addtemplate" class="btn btn-primary btn-sm active btn-info" role="button">添加新运费模板</a>
			</div>
			<div class="template">
				<form method="post" id="template_form" onsubmit="return SETTEMPLATE.checkTemplate('template_form')">
					<div class="txt_row">
						<div class="txt_main">
							<label class="txt_title"><i class="required">*</i>模板名称</label>
							<input type="text" value="<?php echo $detail[0]['frt_name'];?>" class="form-control" name="name" maxlength="32" placeholder="请输入用户名" autocomplete="off" />
							<span><a class="a_blue" href="">运费计算器</a></span>
						</div>
					</div>
					<div class="txt_row">
						<div class="txt_main">
							<label class="txt_title"><i class="required">*</i>产品地址</label>
							<span id="province_box"></span>
						</div>
					</div>
					<div class="txt_row">
						<div class="txt_main">
							<label class="txt_title"><i class="required">*</i>发货时间</label>
							<select name="send_hour" id="send_hour" class="form-control">
								<option <?php if ($detail[0]['frt_send_hour']==12){?> selected="" <?php }?> value="12">12小时</option>
								<option <?php if ($detail[0]['frt_send_hour']==24){?> selected="" <?php }?> value="24">24小时</option>
								<option <?php if ($detail[0]['frt_send_hour']==48){?> selected="" <?php }?> value="48">48小时</option>
							</select>
						</div>
					</div>
					<div class="txt_row">
						<div class="txt_main">
							<label class="txt_title">是否包邮</label>
							<label>
								<input type="radio" checked="" id="free1" value="N" name="is_free" /><b>自定义运费</b></label>
							<label>
								<input type="radio" id="free2" <?php if ($detail[0]['frt_is_free']=='Y'){?> checked="" <?php }?> value="Y" name="is_free" /><b>包邮</b>
							</label>
						</div>
					</div>
					<div class="txt_row">
						<div class="txt_main">
							<label class="txt_title">计价方式</label>
							<label>
								<input type="radio" checked="" id="method1" value="0"  name="method" /><b>数量</b></label>
							<label>
								<input type="radio" id="method2" <?php if ($detail[0]['frt_valuation_method']=='1'){?> checked="" <?php }?> value="1" onclick="removeHtml(this);" name="method" /><b>重量</b>
							</label>
						</div>
					</div>
					<div id="express1" class="express_table">
						<div class="txt_row">
							<div class="txt_main imgcode_box">
								<label class="txt_title"><i class="required">*</i>运送方式</label>
								<label>
									<input type="checkbox" <?php if ($detail[0]['frt_id']){?> checked="" <?php }?> onclick="SETTEMPLATE.showTable(this,'express1');" name="default[0][send_method]" value="0" /><b>快递</b>
								</label>
							</div>
							<div class="table_content">
								<?php if ($detail[0]['frt_is_free']==N){?>
									<table class="table my_list martb10" id="">
									<?php foreach ($detail[0]['link'] as $k => $v){?>
										<?php if ($v['ftl_shipping_method']==0 && $v['ftl_default']=='Y'){?>
										<thead>
											<tr>
												<th colspan="7">
													默认运费
													<input class="form-control myinput" type="text" value="<?php echo $v['ftl_begin_count'];?>" name="default[0][<?php echo $v['ftl_id'];?>][num]">
													<method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>内
													<input class="form-control myinput" value="<?php echo $v['ftl_begin_money'];?>" name="default[0][<?php echo $v['ftl_id'];?>][price]" type="text">元，每增加
													<input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" name="default[0][<?php echo $v['ftl_id'];?>][addnum]" type="text">
													<method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>，增加运费
													<input class="form-control myinput" value="<?php echo $v['ftl_next_money'];?>" name="default[0][<?php echo $v['ftl_id'];?>][addprice]" type="text">元
												</th>
											</tr>
										</thead>
										<?php }?>
									<?php }?>
										<tbody>
											<tr>
												<th colspan="2">运送到</th>
												<th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
												<th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
												<th width="100px">续<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
												<th width="100px">续<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
												<th width="85px">操作</th>
											</tr>
											<?php foreach ($detail[0]['link'] as $k => $v){?>
											<?php if ($v['ftl_shipping_method']=='0' && $v['ftl_default']=='N'){?>
											<tr>
												<td>
													<?php echo trim($v['path']);?>
													<input class="form-control myinput" num="<?php echo $v['ftl_id'];?>" value="<?php echo $v['ftl_cities'];?>" type="hidden" name="default[0][<?php echo $v['ftl_id'];?>][area]">
												</td>
												<td width="50px">
													<a class="a_blue" href="javascript:" onclick="SETTEMPLATE.show(this,0,2)">编辑</a>
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_begin_count'];?>" num="<?php echo $v['ftl_id'];?>" type="text" name="default[0][<?php echo $v['ftl_id'];?>][begin_count]">
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_begin_money'];?>" num="<?php echo $v['ftl_id'];?>" name="default[0][<?php echo $v['ftl_id'];?>][begin_money]" type="text">
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" num="<?php echo $v['ftl_id'];?>" name="default[0][<?php echo $v['ftl_id'];?>][next_count]" type="text">
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_next_money'];?>" num="<?php echo $v['ftl_id'];?>" name="default[0][<?php echo $v['ftl_id'];?>][next_money]" type="text">
												</td>
												<td>
													<a class="a_blue mar5" href="javascript:void(0)" onclick="deleteCity(this)">删除</a>
												</td>
											</tr>
											<?php }?>
											<?php }?>
										</tbody>
										<tfoot>
											<tr>
												<th colspan="7">
													<a class="a_blue" href="javascript:void(0)" onclick="SETTEMPLATE.show(this,express1,1)">为指定地区城市设置运费</a>
												</th>
											</tr>
										</tfoot>
									</table>
								
								<?php }?>
							</div>
						</div>
					</div>
					<div id="express2" class="express_table dowm">
						<div class="txt_row">
							<div class="txt_main imgcode_box">
								<label>
									<input type="checkbox" <?php if ($detail[0]['frt_id']){?> checked="" <?php }?> onclick="SETTEMPLATE.showTable(this,'express2');" name="default[1][send_method]" value="1" /><b>EMS</b>
								</label>
							</div>
							<div class="table_content">
								<?php if ($detail[0]['frt_is_free']=='N'){?>
									<table class="table my_list martb10" id="">
									<?php foreach ($detail[0]['link'] as $k => $v){?>
										<?php if ($v['ftl_shipping_method']=='1' && $v['ftl_default']=='Y'){?>
										<thead>
											<tr>
												<th colspan="7">
													默认运费
													<input class="form-control myinput" type="text" value="<?php echo $v['ftl_begin_count'];?>" name="default[1][<?php echo $v['ftl_id'];?>][num]">
													<method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>内
													<input class="form-control myinput" value="<?php echo $v['ftl_begin_money'];?>" name="default[1][<?php echo $v['ftl_id'];?>][price]" type="text">元，每增加
													<input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" name="default[1][<?php echo $v['ftl_id'];?>][addnum]" type="text">
													<method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>，增加运费
													<input class="form-control myinput" value="<?php echo $v['ftl_next_money'];?>" name="default[1][<?php echo $v['ftl_id'];?>][addprice]" type="text">元
												</th>
											</tr>
										</thead>
										<?php }?>
									<?php }?>
										<tbody>
											<tr>
												<th colspan="2">运送到</th>
												<th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
												<th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
												<th>续{if $detail[0]['frt_valuation_method']=='1'}重{else}件{/if}数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
												<th width="100px">续<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
												<th width="85px">操作</th>
											</tr>
											<?php foreach ($detail[0]['link'] as $k => $v){?>
											<?php if ($v['ftl_shipping_method']=='1' && $v['ftl_default']=='N'){?>
											<tr>
												<td>
													<?php echo trim($v['path']);?>
													<input class="form-control myinput" num="<?php echo $v['ftl_id'];?>" value="<?php echo $v['ftl_cities'];?>" type="hidden" name="default[1][<?php echo $v['ftl_id'];?>][area]">
												</td>
												<td width="50px">
													<a class="a_blue" href="javascript:" onclick="SETTEMPLATE.show(this,0,2)">编辑</a>
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_begin_count'];?>" num="<?php echo $v['ftl_id'];?>" type="text" name="default[1][<?php echo $v['ftl_id'];?>][begin_count]">
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_begin_money'];?>" num="<?php echo $v['ftl_id'];?>" name="default[1][<?php echo $v['ftl_id'];?>][begin_money]" type="text">
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" num="<?php echo $v['ftl_id'];?>" name="default[1][<?php echo $v['ftl_id'];?>][next_count]" type="text">
												</td>
												<td>
													<input class="form-control myinput" value="<?php echo $v['ftl_next_money'];?>" num="<?php echo $v['ftl_id'];?>" name="default[1][<?php echo $v['ftl_id'];?> ][next_money]" type="text">
												</td>
												<td>
													<a class="a_blue mar5" href="javascript:void(0)" onclick="deleteCity(this)">删除</a>
												</td>
											</tr>
											<?php }?>
											<?php }?>
										</tbody>
										<tfoot>
											<tr>
												<th colspan="7">
													<a class="a_blue" href="javascript:void(0)" onclick="SETTEMPLATE.show(this,express2,1)">为指定地区城市设置运费</a>
												</th>
											</tr>
										</tfoot>
									</table>
								
								<?php }?>
							</div>
						</div>
					</div>
					<div class="txt_row">
						<div class="txt_main">
							<label class="txt_title"></label>
							<label>
								<input type="checkbox" name="frt_default" value="Y"  <?php if ($detail[0][ 'frt_default']=='Y'){?> checked <?php }?>/><b>设为默认模板</b>
							</label>
						</div>
					</div>
					<input type="hidden" name="tid" value="<?php echo $detail[0]['frt_id'];?>">
					<input type="hidden" <?php if ($detail[0]['frt_id']){?> value="edit" <?php }else{?> value="add" <?php }?> name="tag">
					<div class="txt_tips login_error"></div>
					<div class="sub_btns">
						<input type="submit" class="btn btn-danger" value="提交">
					</div>
				</form>
			</div>
		</div>
		<div class="clear"></div>
	</div>
</div>
<!-- Modal -->
<div class="modal" id="template_box" tabindex="-1" role="dialog" aria-labelledby="template_box">
	<div class="modal-dialog modal-lg" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">选择地区</h4>
			</div>
			<div class="modal-body" id="mymodal"></div>
			<div class="modal-footer center"></div>
		</div>
	</div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footAll.php');?>
<script type="text/javascript" src="/static/js/collhop.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<script type="text/javascript" src="/static/js/addr.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<script>
$(document).ready(function() {
	ADDR.init('province_box',"<?php echo $detail[0]['frt_send_pct'];?>", 'province');
	$('[type="radio"]').on('click',function(e){
		var temp=$(this).attr('id');
		var method="removeHtml('"+temp+"');";
		e.preventDefault()
		MESSAGE.confirm('改变选项将清空已填写的运送方式，请慎重操作',method);		
	})
})
</script>
