<?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 product-group">
		<div class="navrow">
			<ul class="navrow_ul">
				<li class="active"><a href="javascript:;"><?php echo $actmsg;?>配件套餐</a></li>
			</ul>
        </div>
		<div class="form-wrapper">
		<form method="post" action="" id="newPackForm">
		<div class="marauto">
				<div class="txt_row">
					<div class="txt_main">
						<label class="txt_title"><i class="required">*</i>套餐标题</label>
						<input type="text" class="form-control" name="name" value="<?php echo $pack['prpa_name'];?>">
					</div>
				</div>
				<div class="txt_row">
					<div class="txt_main">
						<label class="txt_title"><i class="required">*</i>一口价</label>
						<input type="text" class="form-control" name="price" value="<?php if($pack['prpa_price']){echo sprintf("%.2f",$pack['prpa_price']);}?>">
					</div>
				</div>
				<div class="txt_row">
					<div class="txt_main">
						<label class="txt_title"><i class="required">*</i>时间范围</label>
						<input value="<?php if($pack['prpa_btime']){echo date("Y-m-d H:i:s",$pack['prpa_btime']);}?>" type="hidden" name="bTime"/>
						<input value="<?php if($pack['prpa_etime']){echo date("Y-m-d H:i:s",$pack['prpa_etime']);}?>" type="hidden" name="eTime"/>
						<input value="<?php if(!empty($pack['prpa_btime'])){ echo date('Y-m-d H:i:s',$pack['prpa_btime']).' - ';}?><?php if(!empty($pack['prpa_etime'])){ echo date('Y-m-d H:i:s',$pack['prpa_etime']);}?>" type="text" readonly id="timeRange" name="timeRange" class="form-control"/>
					</div>
				</div>

				<div class="txt_row">
					<div class="txt_main">
						<label class="txt_title"><i class="required">*</i>运费模板</label>
						<label>
						<?php if(!empty($freight)){ ?>
						<?php foreach($freight as $k=> $v){ ?>
							<label>
								<input type="radio" <?php if(!$pack['prpa_frt_id']&&$k==0){echo 'checked';}?> name="frtId" value="<?php echo $v['frt_id'];?>" <?php if($v['frt_id']==$pack['prpa_frt_id']){echo 'checked';}?>>
								<?php echo $v['frt_name'];?>
							</label>
						<?php } ?>
						<?php } ?>
					</div>
				</div>

				<div class="txt_row">
					<div class="txt_main">
					<label class="txt_title"><i class="required">*</i>参与满减</label>
					<label>
						<input type="radio" name="manjian" value="Y" <?php if($pack['prpa_manjian']=='Y'){echo 'checked';}?> checked>是
					</label>
					<label>
						<input type="radio" name="manjian" value="N" <?php if($pack['prpa_manjian']=='N'){echo 'checked';}?>>否
					</label>
					</div>
				</div>

				<div class="txt_row">
					<div class="txt_main add-god-tit" >
						<label class="txt_title"><i class="required">*</i>搭配宝贝</label>
					</div>
					<div id="goodsMainTab" class="goods_main">
						<table class="table table-condensed">
					      <thead>
					        <tr>
					          <th>操作</th>
					          <th>配件信息</th>
					          <th>价格</th>
					          <th>库存</th>
					        </tr>
					      </thead>
					      <tbody>
							<?php if(!empty($pack['prpa_pro'])){ ?>
					      	<?php foreach($pack['prpa_pro'] as $v){ ?>
					        <tr>
					          <td>
					          	<p><a onclick="removechecked(this)" href="javascript:;">删除</a></p>
					          </td>
					          <td>
					      		<input type="hidden" class="proId" value="<?php echo $v['pro_id'];?>" name="proId[]"/>
					          	<a href="/item/index?proId=<?php echo $v['pro_id'];?>" target="_blank">
					          		<?php if(!empty($v['spi_path']) && !empty($v['spi_name'])){?>
					          		<img class="shop-log" src="<?php echo LibFc::ImgRoute([$v['spi_path'],$v['spi_name'],100],'pro');?>">
					          		<?php }else{?>
					                    <img class="shop-log" src="/static/images/noimg.png">
					                <?php }?>
					          	<a>
					          	<a class="name" href="/item/index?proId=<?php echo $v['pro_id'];?>" target="_blank"><?php echo $v['pro_name'];?></a>
					          </td>
					          <td><?php echo sprintf("%.2f",$v['pro_sale_price']);?></td>
					          <td><?php echo $v['pro_count'];?></td>
					        </tr>
					        <?php } ?>
					        <?php }else{?>
					        	<tr>
						            <td class="center" colspan="6"><span class="orange">点击下面按钮去选择配件吧</span></td>
						        </tr>
					        <?php }?>
					      </tbody>
					    </table>
					</div>
				</div>
				<button onclick="clickToChoiceGods()" type="button" class="btn btn-success add-dapei-paobei">添加搭配宝贝</button>
				<div class="txt_row">
					<div class="txt_main add-god-tit" >
						<label class="txt_title"></label>
					</div>
					<div class="goods_main goods-ajax-main">
					</div>
				</div>
			</div>
		</form>
		</div>
		<div class="clear"></div>
		<button type="button" class="btn btn-info save-pack-change">保存</button>
		<button type="button" onclick="window.history.go(-1);" class="btn return-pack">返回</button>
		<button type="button" style="margin-top: 12px;display: none;" class="btn btn-danger error_notice">结束时间不得在开始时间之前！</button>
	</div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footAll.php');?>
<script type="text/javascript">
$(document).ready(function(){
	<?php if($edited){?>
		$(".add-pack-notice").fadeIn(1000);
		$(".add-pack-notice").fadeOut(1000);
	<?php }?>
	//促销时间
	laydate.render({
	  type: 'datetime',
	  range: true
	  ,elem: '#timeRange'
	  ,done: function(value, date){
		$("input[name='bTime']").val(value.slice(0,19));
		$("input[name='eTime']").val(value.slice(22));
	  }
	}); 
});
//注册表单验证
validatePackForm();

$(".save-pack-change").click(function(){
	if(validatePackForm().form()) {
		if($(".proId").length<=1){
			MESSAGE.alert('请添加至少两个搭配宝贝！');
			return false;
		}
		$("#newPackForm").submit();
	}
});
</script>





