<?php include_once(mvc::$cfg['PATH_TPL'] . 'public/headBase.php'); ?>
<div class="layui-fluid">
    <form method="post" class="layui-form set-form">
    <table class="layui-table" style="width: 1200px;">
            <tr>
                <th class="TextRight" colspan="14">
                    <div class="layui-inline">
                        <label class="layui-form-label"  style="font-size: 12px;">业务员</label>
                        <div class="layui-input-block" style="width: 150px !important;">
                            <select name="usr_id" lay-filter="usr_id" id="usr_id" lay-search>
                                <option value="">请选择</option>
                                <?php foreach($salesArr as $skey => $sArr){?>
                                    <optgroup  label="<?=$skey?>">
                                        <?php foreach($sArr as $kk => $vv){?>
                                            <option value="<?=$kk?>"  <?=$Params['usr_id']==$kk?'selected':''?>><?=$vv?></option>
                                        <?php }?>
                                    </optgroup>
                                <?php }?>
                            </select>
                        </div>
                    </div>  
                    <div class="layui-inline">
                        <label class="layui-form-label"  style="font-size: 12px;">年度</label>
                        <div class="layui-input-block" style="width: 150px !important;">
                            <select name="year" style="width: 100px;" lay-filter="y" id="y">
                                <?php foreach ($yearsArr as $key => $val) {?>
                                    <option value="<?=$val?>" <?=$val==$Params['year']?'selected':''?>><?=$val?></option>
                                <?php }?>
                            </select>
                        </div>
                    </div>
                </th>
            </tr>
			<tr>
                
				<th class="TextRight" width="100">
                    业务员目标
				</th>

                <?php if(!empty($monthsArr)){ ?>
                    <?php foreach ($monthsArr as $key => $val) {?>
                        <th><?=$val?></th>
                    <?php }?>
                <?php }?>
			</tr>

            <?php if(empty($arr)){?>
                <tr>
                    <td colspan="14" style="text-align: center;">暂无数据</td>
                </tr>
            <?php }else{?>
                <?php foreach($arr as $k=>$item){?>
                <tr>
                    <td class="TextRight"><?=$item['au_name']?></td>
                 
                    <?php foreach ($monthsArr as $key => $val) {?>
                        <th>
                            <input class="layui-input" name="months[<?=$item['au_uid']?>][<?=$Params['year'].$key?>]" value="<?=$item['month'][$Params['year'].$key]?:''?>">
                        </th>
                    <?php }?>
                </tr>
                <?php }?>
            <?php }?>
		</table>
        <?php if(!empty($arr)){?>
        <div class="layui-form-item submit-box">
            <div class="layui-input-block">
                <button class="layui-btn submit-btn" lay-submit lay-filter="btn-submits">立即提交</button>
            </div>
        </div>
        <?php }?>
    </form>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'] . 'public/footBase.php'); ?>
<script type="text/javascript">
    layui.use(['form'],function(){
        var form = layui.form;
        // form.on('select(m)',function(data){
        //     var usr_id = $("#usr_id").val();
        //     var year = $('#y').val()
        //     var month = data.value;
        //     location.href= SELF_URI+'index/userTarget?year='+year+'&month='+month+'&usr_id='+usr_id;
        // });

        form.on('select(y)',function(data){
            var usr_id = $("#usr_id").val();
            // var month = $('#m').val();
            var year = data.value;
            location.href= SELF_URI+'index/userTarget?year='+year+'&usr_id='+usr_id;
        });

        form.on('select(usr_id)',function(data){
            var year = $('#y').val();
            // var month = year+$('#m').val();
            location.href= SELF_URI+'index/userTarget?year='+year+'&usr_id='+data.value;
        });

        form.render();
    })
</script>