promotion.html 6.79 KB
{template 'common/header'}
{template 'common'}
<ul class="nav nav-tabs">
	<li {if $operation == 'display' && $modules!='promotion'} class="active" {/if}><a href="{php echo $this->createWebUrl('adv',array('op' =>'display'))}">幻灯片</a></li>
	<li {if $operation == 'post' && $modules!='promotion'} class="active" {/if}><a href="{php echo $this->createWebUrl('adv',array('op' =>'post'))}">{if !empty($adv['id']) && $operation== 'post'}编辑{else}添加{/if}幻灯片</a></li>
	<li{if $operation == 'display' && $modules!='adv'} class="active" {/if}><a href="{php echo $this->createWebUrl('promotion',array('op' =>'display'))}">促销活动管理</a></li>
	<li{if $operation == 'post' && $modules!='adv'} class="active" {/if}><a href="{php echo $this->createWebUrl('promotion',array('op' =>'post'))}">{if !empty($pro['id']) && $operation== 'post'}编辑{else}添加{/if}促销活动</a></li>
</ul>
{if $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="{$pro['id']}" />
		<div class="panel panel-default">
			<div class="panel-heading">促销活动设置</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">*促销活动名称</label>
					<div class="col-sm-3 col-xs-12">
						<input type="text" name="promotionname" id="promotionname" class="form-control" value="{$pro['pname']}" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">促销活动类型</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input name="radioPromotionType" type="radio" value="0" {if $pro['promoteType']==0} checked="checked" {/if} onclick="to_change()">满件免运费</label>
						<label class="radio-inline"><input name="radioPromotionType" type="radio"  value="1" {if $pro['promoteType']==1}checked="checked"{/if} onclick="to_change()">满额免运费</label>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span id='money' {if $pro['promoteType']==0} style='display:none;'{/if}>*满足金额 </span>	<span id='num' {if $pro['promoteType']==1} style='display:none;'{/if} >*满足单数</span></label>
					<div class="col-sm-2 col-xs-12">
						<div class="input-group">
							<input type="text" name="promotionmoney" id="promotionmoney" onkeyup="value=this.value.replace(/\D+/g,'')" class="form-control" value="{php echo (int)$pro['condition']}" />
							<span id='shu' class="input-group-addon">{if $pro['promoteType']==0}件{else}元{/if}</span>
						</div>
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">起始日期</label>
					<div class="col-sm-3 col-xs-12">
						{php echo tpl_form_field_date('start_time', !empty($pro['starttime']) ? date('Y-m-d H:i',$pro['starttime']) : date('Y-m-d H:i'), 1)} 
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">终止日期</label>
					<div class="col-sm-3 col-xs-12">
						{php echo tpl_form_field_date('end_time', !empty($pro['endtime']) ? date('Y-m-d H:i',$pro['endtime']) : date('Y-m-d H:i'), 1)}
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">描述</label>
					<div class="col-sm-6 col-xs-12">
						<textarea name="description" class="form-control" style="height:100px;" cols="70">{$pro['description']}</textarea>
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
					<div class="col-sm-3 col-xs-12"></div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
					<div class="col-sm-3 col-xs-12">
						<input name="submit" type="submit" value="提交" class="btn btn-primary">
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>
			</div>
		</div>
	</form>
</div>

<script language='javascript'>
	function to_change(){
		var obj  = document.getElementsByName('radioPromotionType');
		for(var i=0;i<obj.length;i++){
			if(obj[i].checked==true){
				if(obj[i].value==0){
					document.getElementById('num').style.display="block";
					document.getElementById('shu').innerText="件";
					document.getElementById('money').style.display="none";
				}else if(obj[i].value==1){
					document.getElementById('num').style.display="none";
					document.getElementById('shu').innerText="元";
					document.getElementById('money').style.display="block"; 
				}
			}
		}
	}
	
	function formcheck() {
		if ($("#promotionname").isEmpty()) {
			Tip.focus("promotionname", "请填写促销活动名称!", "right");
			return false;
		}
		if ($("#promotionmoney").isEmpty() || $("#promotionmoney").val()<1) {
			Tip.focus("promotionmoney", "促销活动条件不能为空或0!", "right");
			return false;
		}
		return true;
	}
</script>

{elseif $operation == 'display'}
<div class="main">
	<div class="panel panel-default">
		<div class="panel-heading">促销活动列表</div>
		<div class="panel-body">
			<div class="form-group">
        <table class="table table-hover">
            <thead class="navbar-inner">
                <tr>
                    <th style="width:30px;">ID</th>
                    <th style="width:200px;">名称</th>					
                    <th style="width:100px;">类型</th>
                    <th >开始时间</th>
                    <th >结束时间</th>
					<th >满足条件</th>
					<th >描述</th>
					<th >操作</th>
                </tr>
            </thead>
            <tbody>
        	{loop $prolist $proitem}
                <tr>
					<td>{$proitem['id']}</td>
                    <td>{$proitem['pname']}</td>
                    <td>{if $proitem['promoteType']==0 }满件免运费{else}满额免运费{/if}</td>
                    <td>{php echo date('Y-m-d H:i:s', $proitem['starttime']);}</td>
                    <td>{php echo date('Y-m-d H:i:s', $proitem['endtime']);}</td>
					<td>{if $proitem['promoteType']==0 }满<span style="color:#FF0000">{php echo (int)$proitem['condition']}</span>件免运费{else}满<span style="color:#FF0000">{php echo  $proitem['condition']}</span>元免运费{/if}</td>
					<td>{$proitem['description']}</td>
                    <td style="text-align:left;"><a href="{php echo $this->createWebUrl('promotion', array('op' => 'post', 'id' => $proitem['id']))}">修改</a> <a href="{php echo $this->createWebUrl('promotion', array('op' => 'delete', 'id' => $proitem['id']))}">删除</a> </td>
                </tr>
               {/loop}
            </tbody>
        </table>
        {$pager}
			</div>
		</div>
	</div>
</div>

{/if}
{template 'common/footer'}