<?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">
    $(function(){
        $("#save-btn").click(function(){
            if(confirm('是否确认提交?')) {
                var params = $("#theFrm").serialize();
                $.post('/finance/gz-save',params,function(obj){
                    alert(obj.msg);
                    window.location.reload();
                },'json');
            }
        });
        //返回按钮
        $('#back-btn').click(function(){
            window.location.href='/finance/pay-list?year=<?=$year?>&month=<?=$month?>&area_id=<?=$area_id?>&name=<?=$name?>';
        });
    });
</script>
<form id="theFrm">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <input type="hidden" name="sale_id" value="<?=$info->id?>">
    <input type="hidden" name="year" value="<?=$year?>">
    <input type="hidden" name="month" value="<?=$month?>">
    <tr>
        <td class="bg_tr">工号:</td>
        <td class="td_bg"><?=$info->username?></td>
        <td class="bg_tr">真实姓名:</td>
        <td class="td_bg"><?=$info->name?></td>
        <td class="bg_tr">工资月份:</td>
        <td class="td_bg"><?=$year.'-'.$month?></td>
        <td class="bg_tr">商业跟单手续费:</td>
        <td class="td_bg"><?=$total1_rate?></td>
        <td colspan="4" class="td_bg">
            <input type="button" class="act_btn" id="save-btn" name="save-btn" value="保存">
            <input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
        </td>
    </tr>
    <tr>
        <td class="bg_tr">应出勤:</td>
        <td class="td_bg"><input type="text" name="ycq" value="<?=$gz_info->ycq?>" style="width: 70px;"></td>
        <td class="bg_tr">实际出勤:</td>
        <td class="td_bg"><input type="text" name="scq" value="<?=$gz_info->scq?>" style="width: 70px;"></td>
        <td class="bg_tr">应打通时:</td>
        <td class="td_bg"><input type="text" name="yts" value="<?=$gz_info->yts?>" style="width: 70px;"></td>
        <td class="bg_tr">实际通时:</td>
        <td class="td_bg"><input type="text" name="sts" value="<?=$gz_info->sts?>" style="width: 70px;"></td>
        <td class="bg_tr">话补:</td>
        <td class="td_bg"><input type="text" name="hb" value="<?=$gz_info->hb?>" style="width: 70px;"></td>
        <td class="bg_tr">礼品:</td>
        <td class="td_bg"><input type="text" name="lp" value="<?=$gz_info->lp?>" style="width: 70px;"></td>
    </tr>
    <tr>
        <td class="bg_tr">其他工资:</td>
        <td class="td_bg"><input type="text" name="other" value="<?=$gz_info->other?>" style="width: 70px;"></td>
        <td class="bg_tr">推修:</td>
        <td class="td_bg"><input type="text" name="tx" value="<?=$gz_info->tx?>" style="width: 70px;"></td>
        <td class="bg_tr">迟到:</td>
        <td class="td_bg"><input type="text" name="cd" value="<?=$gz_info->cd?>" style="width: 70px;"></td>
        <td class="bg_tr">退保:</td>
        <td class="td_bg"><input type="text" name="tb" value="<?=$gz_info->tb?>" style="width: 70px;"></td>
        <td class="bg_tr">社保:</td>
        <td class="td_bg"><input type="text" name="sb" value="<?=$gz_info->sb?>" style="width: 70px;"></td>
        <td class="bg_tr">保底:</td>
        <td class="td_bg"><input type="text" name="bd" value="<?=$gz_info->bd?>" style="width: 70px;"></td>
    </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="24" align="center" class="bg_tr" nowrap>序号</td>
        <td width="50" align="center" class="bg_tr" nowrap>车牌号码</td>
        <td width="60" align="center" class="bg_tr" nowrap>被保险人</td>
        <td width="60" align="center" class="bg_tr" nowrap>初登日期</td>
        <td width="60" align="center" class="bg_tr" nowrap>保险起期</td>
        <td width="80" align="center" class="bg_tr" nowrap>商业签单</td>
        <td align="center" class="bg_tr" nowrap>跟单手续费</td>
        <td align="center" class="bg_tr" nowrap>提奖</td>
        <td align="center" class="bg_tr" nowrap>提奖金额</td>
        <td width="60" align="center" class="bg_tr" nowrap>交强签单</td>
        <td align="center" class="bg_tr" nowrap>跟单手续费</td>
        <td width="60" align="center" class="bg_tr" nowrap>商交实收</td>
        <td width="60" align="center" class="bg_tr" nowrap>共计签单</td>
        <td width="60" align="center" class="bg_tr" nowrap>实收金额</td>
        <td width="60" align="center" class="bg_tr" nowrap>优惠金额</td>
        <td width="60" align="center" class="bg_tr" nowrap>优惠率</td>
        <td width="60" align="center" class="bg_tr" nowrap>保险公司</td>
        <td width="60" align="center" class="bg_tr" nowrap>正本日期</td>
        <td width="60" align="center" class="bg_tr" nowrap>车主</td>
        <td width="60" align="center" class="bg_tr" nowrap>联系人</td>
        <td width="60" align="center" class="bg_tr" nowrap>详情</td>
    </tr>
    <?php
    $total1_clear = 0;
    $total1_dis = 0;
    $total_tc = 0;
    foreach($items as $index => $item) {
        $total1_clear += $item->total1_clear;
        $total1_dis += $item->total1_dis;
//        $tj = number_format($item->total1_clear * ($item->tijiang - (1-$item->total1_percent)*100) / 100,2);
//        $total_tc += $tj;
        $tj = ($item->total1_clear * ($item->tijiang - (1-$item->total1_percent)*100) / 100);
        $total_tc += $tj;
        ?>
        <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
            <td align="center" class="td_bg"nowrap ><?=$index+1?></td>
            <td class="td_bg" nowrap><?=$item->car_no?></td>
            <td class="td_bg" nowrap><?=$item->id_man?></td>
            <td class="td_bg" nowrap><?=$item->car?$item->car->register_date:''?></td>
            <td class="td_bg" nowrap><?=$item->insurer1_begin_date?></td>
            <td class="td_bg" nowrap><?=$item->total1_clear?></td>
            <td class="td_bg" nowrap><?=$item->total1_rate?></td>
            <td class="td_bg" nowrap><input type="text" name="tj[<?=$item->id?>]" value="<?=$item->tijiang?>" style="width:50px;"></td>
            <td class="td_bg" nowrap><?=$tj?></td>
            <td class="td_bg" nowrap><?=$item->total2?></td>
            <td class="td_bg" nowrap><?=$item->total2_rate?></td>
            <td class="td_bg" nowrap><?=$item->total_real - $item->total3?></td>
            <td class="td_bg" nowrap><?=$item->total_all?></td>
            <td class="td_bg" nowrap><?=$item->total_real?></td>
            <td class="td_bg" nowrap><?=$item->total1_dis?></td>
            <td class="td_bg" nowrap><?=$item->total1_percent?></td>
            <td class="td_bg" nowrap><?=$item->company?$item->company->name:''?></td>
            <td class="td_bg" nowrap><?=$item->print_date?></td>
            <td class="td_bg" nowrap><?=$item->car_man?></td>
            <td class="td_bg" nowrap><?=$item->link_man?></td>
            <td class="td_bg" nowrap>
                [<a href="/insurer/info?id=<?=$item->id?>" target="_blank">详情</a>]
            </td>
        </tr>
        <?php
    }
    ?>
    <tr>
        <td width="24" align="center" class="bg_tr" nowrap></td>
        <td width="50" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="80" align="center" class="bg_tr" nowrap><?=number_format($total1_clear,2)?></td>
        <td align="center" class="bg_tr" nowrap></td>
        <td align="center" class="bg_tr" nowrap></td>
        <td align="center" class="bg_tr" nowrap><?=$total_tc?></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap><?=number_format($total1_dis,2)?></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
        <td width="60" align="center" class="bg_tr" nowrap></td>
    </tr>
</table>
</form>