<?php
use \common\libs\MyLib;
?>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">

</script>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <form id="searchForm">
        <tr>
            <td class="td_bg">
                工号：<input id="name" name="name" type="Text" value="<?=$name?>" style="width:100px;">
                月份：<input name="year" id="year" class="Wdate" type="Text" onclick="WdatePicker({dateFmt:'yyyy'})" value="<?=$year?>" style="width:100px;" /> 年
                <select name="month" id="month">
                    <option value="01" <?=$month=='01'?'selected':''?>>01</option>
                    <option value="02" <?=$month=='02'?'selected':''?>>02</option>
                    <option value="03" <?=$month=='03'?'selected':''?>>03</option>
                    <option value="04" <?=$month=='04'?'selected':''?>>04</option>
                    <option value="05" <?=$month=='05'?'selected':''?>>05</option>
                    <option value="06" <?=$month=='06'?'selected':''?>>06</option>
                    <option value="07" <?=$month=='07'?'selected':''?>>07</option>
                    <option value="08" <?=$month=='08'?'selected':''?>>08</option>
                    <option value="09" <?=$month=='09'?'selected':''?>>09</option>
                    <option value="10" <?=$month=='10'?'selected':''?>>10</option>
                    <option value="11" <?=$month=='11'?'selected':''?>>11</option>
                    <option value="12" <?=$month=='12'?'selected':''?>>12</option>
                </select>
                <select name="group_id" id="group_id">
                    <option value="">-全部员工-</option>
                    <?php foreach($old_group as $k=>$v){ ?>
                        <option value="<?=$v->id?>" <?=$group_id==$v->id?'selected':''?>><?=$v->name?></option>
                    <?php } ?>
                </select>

                <input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索">
            </td>
        </tr>
    </form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td align="center" class="bg_tr" nowrap>职位</td>
        <td align="center" class="bg_tr" nowrap>详细</td>
    </tr>
    <?php foreach($user_list as $k=>$v){ ?>
        <tr>
            <td width="100" align="center" class="bg_tr" nowrap><?php echo $group_items[$k]; ?></td>
            <td align="center" class="td_bg" nowrap>
                <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
                    <tr class="bg_tr" align="center">
                        <td width="25%">工号</td>
                        <td width="25%">姓名</td>
                        <td width="25%">工资</td>
                        <td width="25%">详情</td>
                    </tr>
                    <?php foreach($v as $key=>$val){
                        if($val['group_id'] != $k)
                        continue;
                    ?>
                    <tr class="td_bg" align="center">
                        <td width="25%"><?= $val['username'] ?></td>
                        <td width="25%"><?= $val['name'] ?></td>
                        <td width="25%">￥xx</td>
                        <td width="25%"><input type="button" class="user-detail" group="<?=$val['group_id']?>" data="<?=$val['id']?>" value="详情"></td>
                    </tr>
                    <?php } ?>
                </table>
            </td>
        </tr>
    <?php } ?>
</table>
<script>
    //详情
    $('.user-detail').click(function(){
        var params = $('#searchForm').serialize();
        var user_id = $(this).attr('data');
        var group_id = $(this).attr('group');
        window.location.href="/finance/pay-list-new-detail?user_id="+user_id+"&group_id="+group_id+"&year=<?=$year?>&month=<?=$month?>"+"&back_params="+encodeURIComponent(params);
    });
    //搜索
    $('#search-btn').click(function(){
        var params = $('#searchForm').serialize();
        window.location.href = "/finance/pay-list-new?"+ params;
    });
</script>
