<?php
use \common\libs\MyLib;
?>
<form id="theFrm">
    <input type="hidden" name="id" value="<?=$pay_info->id?>">
    <p>&nbsp;</p>
    <h2 align="center"><?=date("Y年m月",strtotime($pay_date.'-01'))?>财务工资</h2>
    <h3 align="center">应发工资：<span><?=number_format($pay_info->should_pay,2)?></span> 元 <span style="color:#ff0000;">实发工资：<span><?=number_format($pay_info->real_pay,2)?></span> 元</span></h3>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td align="center" colspan="11" height="25" class="bg_tr">基本信息</td>
        </tr>
        <tr>
            <td height="25" class="bg_tr">职务</td>
            <td height="25" class="bg_tr">姓名</td>
            <td height="25" class="bg_tr">入职时间</td>
            <td height="25" class="bg_tr">工作制</td>
            <td height="25" class="bg_tr">试用工资</td>
            <td height="25" class="bg_tr">转正时间</td>
            <td height="25" class="bg_tr">转正工资</td>
            <td height="25" class="bg_tr">基本工资</td>
            <td height="25" class="bg_tr">职务工资</td>
            <td height="25" class="bg_tr">岗位工资</td>
            <td height="25" class="bg_tr">工资调整</td>
        </tr>
        <tr>
            <td height="25" class="td_bg"><?=$group_info?$group_info->getPath():''?></td>
            <td height="25" class="td_bg"><?=$user_info->getShowName()?></td>
            <td height="25" class="td_bg"><?=$user_info->enter_date?></td>
            <td height="25" class="td_bg"><?=$user_info->worktype?$user_info->worktype->name:''?></td>
            <td height="25" class="td_bg"><?=$user_info->try_pay?></td>
            <td height="25" class="td_bg"><?=$user_info->job_date?></td>
            <td height="25" class="td_bg"><?=$group_info?($group_info->base_pay + $group_info->job_pay + $group_info->station_pay + $user_info->ext_pay):$user_info->ext_pay?></td>
            <td height="25" class="td_bg"><?=$group_info?$group_info->base_pay:''?></td>
            <td height="25" class="td_bg"><?=$group_info?$group_info->job_pay:''?></td>
            <td height="25" class="td_bg"><?=$group_info?$group_info->station_pay:''?></td>
            <td height="25" class="td_bg"><?=$user_info->ext_pay?></td>
        </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td align="center" colspan="12" height="25" class="bg_tr">应发</td>
        </tr>
        <tr>
            <td align="center" colspan="2" height="25" class="bg_tr">试用( <?=$try_pay?> 元)</td>
            <td align="center" colspan="12" height="25" class="bg_tr">转正( <?=$true_pay?> 元)</td>
        </tr>
        <tr>
            <td height="25" class="bg_tr">出勤天数</td>
            <td height="25" class="bg_tr">加班</td>
            <td height="25" class="bg_tr">出勤天数</td>
            <td height="25" class="bg_tr">加班</td>
            <td height="25" class="bg_tr">社保</td>
            <td height="25" class="bg_tr">提成</td>
        </tr>
        <tr>
            <td height="25" class="td_bg"><?=$pay_info->try_attendance_days?></td>
            <td height="25" class="td_bg"><?=$pay_info->try_extjob_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->attendance_days?></td>
            <td height="25" class="td_bg"><?=$pay_info->extjob_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->give_social_pay?></td>
            <td height="25" class="td_bg"><?=number_format($pay_info->commission,2)?></td>
        </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td align="center" colspan="12" height="25" class="bg_tr">财务信息</td>
        </tr>
        <tr>
            <td height="25" class="bg_tr">话费</td>
            <td height="25" class="bg_tr">公交</td>
            <td height="25" class="bg_tr">奖金</td>
            <td height="25" class="bg_tr">营业额</td>
        </tr>
        <tr>
            <td height="25" class="td_bg"><?=$pay_info->calls?></td>
            <td height="25" class="td_bg"><?=$pay_info->bus?></td>
            <td height="25" class="td_bg"><?=$pay_info->bonus?></td>
            <td height="25" class="td_bg"><?=$pay_info->turnover?></td>
        </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td align="center" colspan="10" height="25" class="bg_tr">应扣</td>
        </tr>
        <tr>
            <td height="25" class="bg_tr">迟到</td>
            <td height="25" class="bg_tr">事假</td>
            <td height="25" class="bg_tr">病假</td>
            <td height="25" class="bg_tr">社保</td>
            <td height="25" class="bg_tr">罚款</td>
            <td height="25" class="bg_tr">电费</td>
            <td height="25" class="bg_tr">离职押金</td>
            <td height="25" class="bg_tr">公积金</td>
            <td height="25" class="bg_tr">全勤(钱数或百分比)</td>
            <td height="25" class="bg_tr">通时(钱数或百分比)</td>
        </tr>
        <tr>
            <td height="25" class="td_bg"><?=$pay_info->late_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->leave_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->sick_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->social_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->fine_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->electricity_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->deposit?></td>
            <td height="25" class="td_bg"><?=$pay_info->public_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->full_attendance_pay?></td>
            <td height="25" class="td_bg"><?=$pay_info->pass_time_pay?></td>
        </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
        <tr>
            <td align="center" colspan="5" height="25" class="bg_tr">财务统计</td>
        </tr>
        <tr>
            <td height="25" align="center" class="bg_tr">我的新保</td>
            <td height="25" align="center" class="bg_tr">我的续保</td>
            <td height="25" align="center" class="bg_tr">我的提成</td>
            <td height="25" align="center" class="bg_tr">送单合计</td>
            <td height="25" align="center" class="bg_tr">本月出单</td>
        </tr>
        <tr>
            <td height="25" align="center" class="td_bg"><?=$my_type1_query->count()?></td>
            <td height="25" align="center" class="td_bg"><?=$my_type3_query->count()?></td>
            <td height="25" align="center" class="td_bg"><?=$type_query->count()?></td>
            <td height="25" align="center" class="td_bg"><?=$type3_query->count()?></td>
            <td height="25" align="center" class="td_bg"><?=$pay_order_users->count()?></td>
        </tr>
    </table>
    <?php if($my_type1_query->count() > 0) { ?>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr>
                <td align="center" colspan="12" height="25" class="bg_tr">我的新保</td>
            </tr>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr">序号</td>
                <td height="25" align="center" class="bg_tr">车牌号</td>
                <td height="25" align="center" class="bg_tr">商业净保费</td>
                <td height="25" align="center" class="bg_tr">提奖</td>
                <td height="25" align="center" class="bg_tr">应提金额</td>
                <td height="25" align="center" class="bg_tr">优惠金额</td>
                <td height="25" align="center" class="bg_tr">免费礼券</td>
                <td height="25" align="center" class="bg_tr">免费礼品</td>
                <td height="25" align="center" class="bg_tr">自费礼券</td>
                <td height="25" align="center" class="bg_tr">自费礼品</td>
                <td height="25" align="center" class="bg_tr">实提金额</td>
                <td height="25" align="center" class="bg_tr">详情</td>
            </tr>
            <?php
            $should_pay = 0;
            $real_pay = 0;
            foreach($my_type1_query->each() as $index=>$pay_order) {
                $order_info = $pay_order->order;
                $caiwu_info = $order_info->caiwu;
                $rate = $caiwu_info->rate1;
                $money = $caiwu_info->money1;
                $should_pay += $pay_order->should_pay;
                $real_pay += $pay_order->real_pay;
                ?>
                <tr>
                    <td width="50" height="25" align="center" class="td_bg"><?=$index?></td>
                    <td height="25" align="center" class="td_bg"><?=$pay_order->order->car_no?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->order->total1_clear,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=$rate?>%</td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->should_pay,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->order->total1_dis,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(1,1)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(1,0)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(0,1)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(0,0)?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->real_pay,2)?></td>
                    <td height="25" align="center" class="td_bg">[<a href="/insurer/info?id=<?=$order_info->id?>" target="_blank">详情</a>]</td>
                </tr>
                <?php
            }
            ?>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"><?=number_format($should_pay,2)?></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"><?=number_format($real_pay,2)?></td>
                <td height="25" align="center" class="bg_tr"></td>
            </tr>
        </table>
    <?php } ?>
    <?php if($my_type3_query->count() > 0) { ?>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr>
                <td align="center" colspan="12" height="25" class="bg_tr">我的续保</td>
            </tr>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr">序号</td>
                <td height="25" align="center" class="bg_tr">车牌号</td>
                <td height="25" align="center" class="bg_tr">商业净保费</td>
                <td height="25" align="center" class="bg_tr">提奖</td>
                <td height="25" align="center" class="bg_tr">应提金额</td>
                <td height="25" align="center" class="bg_tr">优惠金额</td>
                <td height="25" align="center" class="bg_tr">免费礼券</td>
                <td height="25" align="center" class="bg_tr">免费礼品</td>
                <td height="25" align="center" class="bg_tr">自费礼券</td>
                <td height="25" align="center" class="bg_tr">自费礼品</td>
                <td height="25" align="center" class="bg_tr">实提金额</td>
                <td height="25" align="center" class="bg_tr">详情</td>
            </tr>
            <?php
            $should_pay = 0;
            $real_pay = 0;
            foreach($my_type3_query->each() as $index=>$pay_order) {
                $order_info = $pay_order->order;
                $caiwu_info = $order_info->caiwu;
                $rate = $caiwu_info->rate3;
                $money = $caiwu_info->money3;
                $should_pay += $pay_order->should_pay;
                $real_pay += $pay_order->real_pay;
                ?>
                <tr>
                    <td width="50" height="25" align="center" class="td_bg"><?=$index?></td>
                    <td height="25" align="center" class="td_bg"><?=$pay_order->order->car_no?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->order->total1_clear,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=$rate?>%</td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->should_pay,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->order->total1_dis,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(1,1)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(1,0)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(0,1)?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->getGiftPrice(0,0)?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->real_pay,2)?></td>
                    <td height="25" align="center" class="td_bg">[<a href="/insurer/info?id=<?=$order_info->id?>" target="_blank">详情</a>]</td>
                </tr>
                <?php
            }
            ?>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"><?=number_format($should_pay,2)?></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"><?=number_format($real_pay,2)?></td>
                <td height="25" align="center" class="bg_tr"></td>
            </tr>
        </table>
    <?php } ?>
    <?php if($type_query->count() > 0){ ?>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr>
                <td align="center" colspan="12" height="25" class="bg_tr">我的提成</td>
            </tr>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr">序号</td>
                <td height="25" align="center" class="bg_tr">车牌号</td>
                <td height="25" align="center" class="bg_tr">商业净保费</td>
                <td height="25" align="center" class="bg_tr">提奖</td>
                <td height="25" align="center" class="bg_tr">应提金额</td>
                <td height="25" align="center" class="bg_tr">实提金额</td>
                <td height="25" align="center" class="bg_tr">详情</td>
            </tr>
            <?php
            $should_pay = 0;
            $real_pay = 0;
            foreach($type_query->each() as $index=>$pay_order) {
                $order_info = $pay_order->order;
                $caiwu_info = $order_info->caiwu;
                $rate = $caiwu_info->rate1;
                $money = $caiwu_info->money1;
                if($pay_order->type == 2) {
                    $rate = $caiwu_info->rate2;
                    $money = $caiwu_info->money2;
                }
                $should_pay += $pay_order->should_pay;
                $real_pay += $pay_order->real_pay;
                ?>
                <tr>
                    <td width="50" height="25" align="center" class="td_bg"><?=$index?></td>
                    <td height="25" align="center" class="td_bg"><?=$pay_order->order->car_no?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->order->total1_clear,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=$rate?>%</td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->should_pay,2)?></td>
                    <td height="25" align="center" class="td_bg"><?=number_format($pay_order->real_pay,2)?></td>
                    <td height="25" align="center" class="td_bg">[<a href="/insurer/info?id=<?=$order_info->id?>" target="_blank">详情</a>]</td>
                </tr>
                <?php
            }
            ?>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"><?=number_format($should_pay,2)?></td>
                <td height="25" align="center" class="bg_tr"><?=number_format($real_pay,2)?></td>
                <td height="25" align="center" class="bg_tr"></td>
            </tr>
        </table>
    <?php } ?>
    <?php if($type3_query->count() > 0) { ?>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
            <tr>
                <td align="center" colspan="7" height="25" class="bg_tr">送单统计</td>
            </tr>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr">序号</td>
                <td height="25" align="center" class="bg_tr">车牌号</td>
                <td height="25" align="center" class="bg_tr">被保险人</td>
                <td height="25" align="center" class="bg_tr">送单地址</td>
                <td height="25" align="center" class="bg_tr">时间</td>
                <td height="25" align="center" class="bg_tr">送单提成</td>
                <td height="25" align="center" class="bg_tr">详情</td>
            </tr>
            <?php
            $real_pay = 0;
            foreach($type3_query->each() as $index=>$pay_order) {
                $order_info = $pay_order->order;
                $send_info = $order_info->sendLog;
                $real_pay += $pay_order->real_pay;
                ?>
                <tr>
                    <td width="50" height="25" align="center" class="td_bg"><?=$index?></td>
                    <td height="25" align="center" class="td_bg"><?=$order_info->car_no?></td>
                    <td height="25" align="center" class="td_bg"><?=MyLib::substr_cut($order_info->id_man,15)?></td>
                    <td height="25" align="left" class="td_bg">
                        <?=$order_info->direction1?$order_info->direction1->name:''?>
                        <?=$order_info->range1?$order_info->range1->name:''?>
                        <?=$order_info->city1?$order_info->city1->name:''?>
                        <?=$order_info->district1?$order_info->district1->name:''?>
                        <?=$order_info->send_address1?>
                    </td>
                    <td height="25" align="center" nowrap class="td_bg"><?=date('Y-m-d H:i:s',$send_info->send_time)?></td>
                    <td height="25" align="center" nowrap class="td_bg"><?=number_format($pay_order->real_pay,2)?></td>
                    <td height="25" align="center" nowrap class="td_bg">[<a href="/insurer/info?id=<?=$order_info->id?>" target="_blank">详情</a>]</td>
                </tr>
                <?php
            }
            ?>
            <tr>
                <td width="50" height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"></td>
                <td height="25" align="center" class="bg_tr"><?=number_format($real_pay,2)?></td>
                <td height="25" align="center" class="bg_tr"></td>
            </tr>
        </table>
    <?php } ?>
    <div align="center">
        <input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
    </div>
</form>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.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" src="/js/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="/js/artDialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript" language="javascript">
    $(function () {
        //返回按钮
        $('#back-btn').click(function(){
            window.location.href='/finance/pay3-list?<?=$back_params?>';
        });
    })
</script>
