<style>

.dhmgl_box {
    width: 100%;
    min-width: 960px;
    padding: 0px 30px;
    overflow: hidden;
}
.registertit div.form-group .help-block {
  margin-left: 111px;
}
.registertit div.form-group .form-control-feedback {
  top: 0px !important;
  right: 16px;
}
</style>

	<div class="col-md-10" role="main">
        <nav class="breadcrumb"></i> 五折卡模块<span class="c-gray en">&gt;</span>兑换码管理</nav>
        <div class="title-box">
            <p class="t-p"  style="font-size: 28px; color: #7d7d7d;vertical-align: middle; padding-top: 15px; padding-bottom: 15px;">兑换码管理</p>
        </div>
		<div class="dhmgl_box">  
             <div class="form_head">
                    <span class="form_tle">兑换码管理</span>
                    <div class="form_btn">
                        <button class="form_btn_A" data-toggle="modal" data-target="#newcode">新增兑换码</button>
                        <button class="form_btn_B" onclick= "javascript:location.href='<?php echo site_url('admin/code/export');?>'">导出Excel</button>
                    </div>
            </div>                  
            <form method='post' action='<?php echo site_url('admin/code/index');?>' id='search'> 
        		<div class="screening">
        			<span>使用情况：</span>
        			<select name="status" class="selectmr" >
                        <?php foreach($status as $value => $name) {  ?>
        	            <option value="<?php echo $value;?>" <?php if($value == $cur_status){ ?> selected = "selected" <?php }?> ><?php echo $name;?></option>
                        <?php } ?>
                    </select>
                    <span>有效期：</span>
        			<select name="expires" class="selectmr">
                        <?php foreach($expires as $value => $name) {  ?>
                        <option value="<?php echo $value;?>" <?php if($value == $cur_expires){ ?> selected = "selected" <?php }?> ><?php echo $name;?></option>
                        <?php } ?>
                    </select>
                    <span>时长：</span>
        			<select name="duration" class="selectmr">
                       <?php foreach($duration as $value => $name) {  ?>
                        <option value="<?php echo $value;?>" <?php if($value == $cur_duration){ ?> selected = "selected" <?php }?> ><?php echo $name;?></option>
                        <?php } ?>
                    </select>
                    <span>生成时间：</span>
        			<input type="text" name="sctime" class="datepicker h5a-input form-control dateinput" value="<?php echo $cur_sctime;?>" readonly></input>
                    <button class="serach" type="button" onclick='search.submit()'><img src="<?php echo asset_url('images/search.png');?>" alt=""></button>
                    <a href="<?php echo site_url('admin/code/index');?>" class="empty">清空</a>
        		</div>
            </form>
    		<div class="m_table_box" style="width:auto;margin-left:0px;">
                <table>
                    <thead>
                        <tr>
                            <th class="s-thead">兑换码</th>
                            <th class="s-thead">时长</th>
                            <th class="s-thead">生成时间</th>
                            <th class="s-thead">有效期</th>
                            <th class="s-thead">使用状况</th>
                            <th class="s-thead">激活用户</th>
                            <th class="s-thead">备注</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($codeinfo as $v):?>
                         <tr>
    	                    <td><?php echo $v['code'];?></td>
    	                    <td><?php echo $v['duration'];?>天</td>
    	                    <td><?php echo $v['create_time'];?></td>
    	                    <td><?php echo $v['expires'];?>个月</td>
    	                    <td><?php echo $v['status'];?></td>
    	                    <td><?php echo $v['username'] ? $v['username'] : '&nbsp;';?></td>
    	                    <td><?php echo $v['note'];?></td>
                        </tr>
                        <?php endforeach;?>                 
                    </tbody>
                </table>
                <?php echo $pageinfo;?>
            </div>
        </div>    
	</div>


    <!--生成兑换码弹出框-->
    <div class="modal fade equity" id="newcode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="top:9%;height:365px;width:350px;border-radius: 0;">
        <div class="modal-dialog modal-dialog1" style="width:100%!important;margin:0px!important;">
            <form action="<?php echo site_url('admin/code/generate');?>" method="post" class="registerForm registertit">
                <p class="code-title">生成兑换码</p>
                <div class="form-group">
                    <span class="dianm">*时长：</span>
                    <div class="examp examp1">
                        <select name="duration" class="selectmr clearselect dhm_tc_slt" name="country" data-bv-notempty data-bv-notempty-message="请选择一项" >
                            <option value="">请选择</option>
                            <option value="7">7天</option>
                            <option value="30">30天</option>
                            <option value="90">90天</option>
                            <option value="180">180天</option>
                            <option value="365">365天</option>
                        </select>
                    </div>
                </div>
                <div class="form-group" style="margin-top:13px;">
                    <span class="dianm">*生成数量：</span>
                    <div class="examp examp1">
                        <input type="text"  maxlength="3" class="h5a-input form-control input-sm dhm_tc_ipt" name="number">
                        <div class="lr_ts" style="float:none;margin-top: 8px;padding-left: 10px;">
                         <img src="<?php echo asset_url('images/tips.png');?>" alt="" style="width: 14px;">
                         <span style="font-size:12px;">提示：最多生成999个兑换码</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <span class="dianm">*有效期：</span>
                    <div class="examp examp1">
                        <select name="expires" class="selectmr dhm_tc_slt" name="country" data-bv-notempty data-bv-notempty-message="请选择一项" >
                            <option value="">请选择</option>
                            <option value="1">1个月</option>
                            <option value="3">3个月</option>
                            <option value="6">6个月</option>
                            <option value="12">12个月</option>
                        </select>
                    </div>
                </div>
                <div class="form-group" style="margin-top:13px;">
                    <span class="dianm">*备注：</span>
                    <div class="examp examp1">
                        <input type="text" id="" maxlength="20" class="h5a-input form-control input-sm dhm_tc_ipt" name="note"  required data-bv-notempty-message="备注不能为空">
                        <div class="lr_ts" style="float:none; margin-top: 8px; padding-left: 10px;">
                         <img src="<?php echo asset_url('images/tips.png')?>" alt="" style="width: 14px;">
                         <span style="font-size:12px;">提示：请输入不超过20个字符</span>
                     </div>
                    </div>
                </div>
                <div class="equity-button">
                    <button type="submit" class="h5a-btn btn  btn-primary equitycof">确定</button>
                    <button type="button" class="h5a-btn btn  btn-default equityclose" data-dismiss="modal">取消</button>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript" src="<?php echo asset_url('js/paging.js');?>"></script>
    <script>

     jQuery(document).ready(function($) {
         $('.registerForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh',
                excluded : ':disabled'
            },
            
            
            fields: {
                
                number: {
                    message: '兑换数量不正确',
                    validators: {
                        notEmpty: {
                            message: '兑换数量不能是空的'
                        },
　　　　　　　　　　　　regexp: { 
　　　　　　　　　　　　　　　regexp: /^[1-9]\d{0,2}$/, 
　　　　　　　　　　　　　　　message: "兑换数量小于1000"
　　　　　　　　　　　　}
                    }
                }    
            }
        })        
     });

    </script>

