<?php
use \common\libs\MyLib;
use \common\models\PriceT;
?>
<link href="/css/tabs.css" rel="stylesheet" type="text/css">
<link href="/css/account.css" rel="stylesheet" type="text/css">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td colspan="13" height="22" class="td_bg">
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                <TBODY>
                <TR>
                    <TD height="30" align="center" class=tab-on id=navcell onclick=switchCell(1) name="navcell">账单信息</TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(2) name="navcell">操作记录</TD>
                    <TD height="30" class=tab-none>&nbsp;</TD>
                </TR>
                </TBODY>
            </TABLE>
        </td>
    </tr>
    <tr>
        <td height="22" colspan="2" class="td_bg">
            <table width="100%" align="center" height="120" border="0" cellpadding="0" cellspacing="0" id="mainTable">
                <tr>
                    <td height="120" valign="top" class="td_bg">
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
                            <TR>
                                <TD vAlign=top>
                                    <div class="big_box">
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('Box1')">
                                                <span id="OnBox1Title">维修信息</span>
                                                <span id="OffBox1Title" style="color:black;display:none;">维修信息</span>
                                                <span id="OnBox1">▼</span>
                                                <span id="OffBox1" style="color:black;display:none;">▲</span>
                                            </h3>
                                        </div>
                                        <form id="Box1">
                                            <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                                <input type="hidden" name="car_id" value="">
                                                <tr>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">车牌号码</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->car_no ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">发动机号</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->engine_no ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">车架号</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->car_frame_no ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">新车购置价</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->new_car_purchase_price ?></td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">品牌</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->brand?$fixcar->brand->name:'' ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">车型</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->series?$fixcar->series->name:'' ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">排量</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->displacement?$fixcar->displacement->name:'' ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">年份</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->car_year ?></td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">被保险人</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->id_man ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">电话</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->id_phone ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">联系人</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->link_man ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">电话</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->link_phone ?></td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">保养时间</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->service_date ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">驾驶证时间</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->driving_date ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">保险时间</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->insurance_date ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr"></td>
                                                    <td height="20" class="td_bg"></td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">保险公司</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->company ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">商业保单号</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->insurer1_no ?></td>
                                                    </td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">交强保单号</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->insurer2_no ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">险项</td>
                                                    <td height="20" class="td_bg">明细</td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="60" height="25" class="bg_tr">接车日期</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->receive_date ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">交车方式</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->receive_type ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">事故类型</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->accident_type ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">责任</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->responsibility ?></td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="60" height="25" class="bg_tr">代步车</td>
                                                    <td height="20" class="td_bg">
                                                        <select name="replace_car_id" disabled>
                                                            <option value="1" <?= (1 === $fixcar->replace_car_id || 0 === $fixcar->replace_car_id) ? 'selected' : '' ?>>不需要</option>
                                                            <option value="2" <?= 2 === $fixcar->replace_car_id ? 'selected' : '' ?>>京A74110</option>
                                                        </select>
                                                    </td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">接车司机</td>
                                                    <td height="20" class="td_bg" colspan="5">
                                                        <select name="driver_id" disabled>
                                                            <option value="">请选择</option>
                                                            <?php foreach($drivers as $item): ?>
                                                                <option value="<?= $item->id ?>" <?= $item->id == $fixcar->driver_id ? 'selected' : '' ?>><?= $item->getShowName() ?></option>
                                                            <?php endforeach; ?>
                                                        </select>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="60" height="25" class="bg_tr">地址</td>
                                                    <td class="td_bg" colspan="7">
                                                        <div align="left">
                                                            <?= $fixcar->address ?>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">接车里程数</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->receive_mileage ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">接车油表数</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->receive_oil ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">进厂里程数</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->factory_mileage ?></td>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">进厂油表数</td>
                                                    <td height="20" class="td_bg"><?= $fixcar->factory_oil ?></td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" width="100" height="25" class="bg_tr">预计出厂时间</td>
                                                    <td height="20" class="td_bg" colspan="7"><input class="Wdate" name="" type="Text" value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" value="<?= $fixcar->finish_date ?>"/></td>
                                                </tr>
                                            </table>
                                        </form>
                                    </div>
                                </TD>
                            </TR>
                            <TR>
                                <TD vAlign=top>
                                    <div class="big_box">
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('Box2')">
                                                <span id="OnBox2Title" style="display:none;">手续信息</span>
                                                <span id="OffBox2Title" style="color:black;">手续信息</span>
                                                <span id="OnBox2" style="display:none;">▼</span>
                                                <span id="OffBox2" style="color:black;">▲</span>
                                            </h3>
                                        </div>
                                        <form id="Box2" style="display:none;">
                                            <h4>交接物品</h4>
                                            <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                                <tr>
                                                    <td style="text-align:center;" height="25" class="bg_tr">行驶本</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->driving_this == 1){ echo 'checked="true"'; } ?> disabled />原件</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->driving_this == 2){ echo 'checked="true"'; } ?> disabled />复印件</td>
                                                    <td style="text-align:center;" height="25" class="bg_tr">驾驶本</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->driver_licesne == 1){ echo 'checked="true"'; } ?> disabled />原件</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->driver_licesne == 2){ echo 'checked="true"'; } ?> disabled />复印件</td>
                                                    <td style="text-align:center;" height="25" class="bg_tr">身份证</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->identity_card_paper == 1){ echo 'checked="true"'; } ?> disabled />原件</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->identity_card_paper == 2){ echo 'checked="true"'; } ?> disabled />复印件</td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:center;" height="25" class="bg_tr">车钥匙</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->car_key == 1){ echo 'checked="true"'; } ?> disabled />原件</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->car_key == 2){ echo 'checked="true"'; } ?> disabled />复印件</td>
                                                    <td style="text-align:center;" height="25" class="bg_tr">保险单</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->policy_of_insurance == 1){ echo 'checked="true"'; } ?> disabled />原件</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->policy_of_insurance == 2){ echo 'checked="true"'; } ?> disabled />复印件</td>
                                                    <td style="text-align:center;" height="25" class="bg_tr">交警证明</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->police_to_prove == 1){ echo 'checked="true"'; } ?> disabled />原件</td>
                                                    <td align="center" height="20" class="td_bg"><input type="radio" <?php if($fixcar->police_to_prove == 2){ echo 'checked="true"'; } ?> disabled />复印件</td>
                                                </tr>
                                            </table>
                                            <h4>随车附件</h4>
                                            <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                                <tr>
                                                    <td align="center" height="20" class="td_bg"><input type="checkbox" <?php if(in_array(1,$fixcar->followCar)){ echo 'checked="true"'; } ?> disabled />备胎</td>
                                                    <td align="center" height="20" class="td_bg"><input type="checkbox" <?php if(in_array(2,$fixcar->followCar)){ echo 'checked="true"'; } ?> disabled />工具</td>
                                                    <td align="center" height="20" class="td_bg"><input type="checkbox" <?php if(in_array(3,$fixcar->followCar)){ echo 'checked="true"'; } ?> disabled />警告牌</td>
                                                    <td align="center" height="20" class="td_bg"><input type="checkbox" <?php if(in_array(4,$fixcar->followCar)){ echo 'checked="true"'; } ?> disabled />灭火器</td>
                                                    <td class="td_bg" colspan="7"></td>
                                                </tr>
                                            </table>
                                            <h4>图片</h4>
                                            <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                                <tr>
                                                    <td align="center" height="150" class="td_bg">
                                                        <img src="/images/print_view.jpg" width="200" height="100" />
                                                    </td>
                                                    <td align="center" height="150" class="td_bg">
                                                        <img src="/images/print_view.jpg" width="200" height="100" />
                                                    </td>
                                                    <td align="center" height="150" class="td_bg">
                                                        <img src="/images/print_view.jpg" width="200" height="100" />
                                                    </td>
                                                    <td align="center" height="150" class="td_bg">
                                                        <img src="/images/print_view.jpg" width="200" height="100" />
                                                    </td>
                                                    <td align="center" height="150" class="td_bg">
                                                        <img src="/images/print_view.jpg" width="200" height="100" />
                                                    </td>
                                                </tr>
                                            </table>
                                            <h4>备注</h4>
                                            <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                                <tr>
                                                    <td style="text-align:center;" height="25" class="bg_tr">备注</td>
                                                    <td colspan="20" height="20" class="td_bg">
                                                        <div align="left">
                                                            <textarea name="remark" style="width:700px; height: 30px;"><?= \yii\helpers\Html::encode($fixcar->remark) ?></textarea>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </table>
                                        </form>
                                    </div>
                                </TD>
                            </TR>
                            <TR>
                                <TD vAlign=top>
                                    <div class="big_box">
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('Box3')">
                                                <span id="OnBox3Title" style="display:none;">用料信息</span>
                                                <span id="OffBox3Title" style="color:black;">用料信息</span>
                                                <span id="OnBox3" style="display:none;">▼</span>
                                                <span id="OffBox3" style="color:black;">▲</span>
                                            </h3>
                                        </div>
                                        <form id="Box3" style="display:none;">
                                            <?php if(count($items)>0): ?>
                                                <?php if(isset($items[1])): ?>
                                                <h4>更换清单</h4>
                                                <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
                                                       style="table-layout: fixed;">
                                                    <tr>
                                                        <td width="50" align="center" class="bg_tr" nowrap>序号</td>
                                                        <td width="100" align="center" class="bg_tr" nowrap>零件名</td>
                                                        <td width="100" align="center" class="bg_tr" nowrap>报案号</td>
                                                        <td width="80" align="center" class="bg_tr" nowrap>保险定价</td>
                                                        <td width="50" align="center" class="bg_tr" nowrap>单价</td>
                                                        <td width="80" align="center" class="bg_tr" nowrap>数量</td>
                                                        <td width="100" align="center" class="bg_tr" nowrap>结算方式</td>
                                                    </tr>
                                                    <?php foreach ($items[1] as $index => $item): ?>
                                                        <?php $store = \common\models\StoreRoom::findOne($item['fk_id']); ?>
                                                        <tr>
                                                            <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                                                            <td align="center" class="td_bg" style="word-break: break-all"><?= $store->category->name ?></td>
                                                            <td align="center" class="td_bg" style="word-break: break-all"><?= is_null($item['report_id']) ? '--' : \common\models\FixCarReport::findOne($item['report_id'])->report_no ?></td>
                                                            <td align="center" class="td_bg" nowrap><?= $item['insurance_price'] ?>元</td>
                                                            <td align="center" class="td_bg" style="word-break: break-all"><?= number_format($store->price * ($store->fixCarScale->scale/100+1),2) ?>元</td>
                                                            <td align="center" class="td_bg" nowrap><?= $item['count'] ?></td>
                                                            <td align="center" class="td_bg" nowrap><?= $item['pay_type'] == 1 ? '保险理赔' : '自费维修' ?></td>
                                                        </tr>
                                                    <?php endforeach; ?>
                                                </table>
                                                <?php endif; ?>
                                                <?php if(isset($items[2])): ?>
                                                    <?php $group_name =[1=>'微伤',2=>'轻度',3=>'中度',4=>'重度'] ?>
                                                    <h4>维修清单</h4>
                                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
                                                           style="table-layout: fixed;">
                                                        <tr>
                                                            <td width="50" align="center" class="bg_tr" nowrap>序号</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>修理项目</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>报案号</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>修理分组</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>损伤程度</td>
                                                            <td width="50" align="center" class="bg_tr" nowrap>单价</td>
                                                            <td width="80" align="center" class="bg_tr" nowrap>数量</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>结算方式</td>
                                                        </tr>
                                                        <?php foreach ($items[2] as $index => $item): ?>
                                                            <?php $project = \common\models\FixCarProject::findOne($item['fk_id']) ?>
                                                            <tr>
                                                                <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= $project->category->name ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= is_null($item['report_id']) ? '--' : \common\models\FixCarReport::findOne($item['report_id'])->report_no ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= $project->group->name ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= 7 == $project->group_id ? $group_name[$project->car_price] : '--' ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= $project->price ?>元</td>
                                                                <td align="center" class="td_bg" nowrap><?= $item['count'] ?></td>
                                                                <td align="center" class="td_bg" nowrap><?= $item['pay_type'] == 1 ? '保险理赔' : '自费维修' ?></td>
                                                            </tr>
                                                        <?php endforeach; ?>
                                                    </table>
                                                <?php endif; ?>
                                                <?php if(isset($items[3])): ?>
                                                    <?php $group_name =[1=>'微伤',2=>'轻度',3=>'中度',4=>'重度'] ?>
                                                    <h4>辅料清单</h4>
                                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
                                                           style="table-layout: fixed;">
                                                        <tr>
                                                            <td width="50" align="center" class="bg_tr" nowrap>序号</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>辅料名</td>
                                                            <td width="50" align="center" class="bg_tr" nowrap>单价</td>
                                                            <td width="80" align="center" class="bg_tr" nowrap>数量</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>结算方式</td>
                                                        </tr>
                                                        <?php foreach ($items[3] as $index => $item): ?>
                                                            <?php $store = \common\models\StoreRoom::findOne($item['fk_id']); ?>
                                                            <tr>
                                                                <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= $store->category->name ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= $store->price ?>元</td>
                                                                <td align="center" class="td_bg" nowrap><?= $item['count'] ?></td>
                                                                <td align="center" class="td_bg" nowrap><?= $item['pay_type'] == 1 ? '保险理赔' : '自费维修' ?></td>
                                                            </tr>
                                                        <?php endforeach; ?>
                                                    </table>
                                                <?php endif; ?>
                                                <?php if(isset($items[6])): ?>
                                                    <?php $group_name =[1=>'微伤',2=>'轻度',3=>'中度',4=>'重度'] ?>
                                                    <h4>保养清单</h4>
                                                    <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
                                                           style="table-layout: fixed;">
                                                        <tr>
                                                            <td width="50" align="center" class="bg_tr" nowrap>序号</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>零件名/维修项目</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>报案号</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>修理分组</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>损伤程度</td>
                                                            <td width="50" align="center" class="bg_tr" nowrap>单价</td>
                                                            <td width="80" align="center" class="bg_tr" nowrap>数量</td>
                                                            <td width="100" align="center" class="bg_tr" nowrap>结算方式</td>
                                                        </tr>
                                                        <?php foreach ($items[6] as $index => $item): ?>
                                                            <?php $store = $project = null; ?>
                                                            <?php $project = \common\models\FixCarProject::findOne($item['fk_id']) ?>
                                                            <tr>
                                                                <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all">
                                                                    <?= $project->category->name ?>
                                                                </td>
                                                                <td align="center" class="td_bg" style="word-break: break-all"><?= is_null($item['report_id']) ? '--' : \common\models\FixCarReport::findOne($item['report_id'])->report_no ?></td>
                                                                <td align="center" class="td_bg" style="word-break: break-all">
                                                                    <?= $project->group->name ?>
                                                                </td>
                                                                <td align="center" class="td_bg" style="word-break: break-all">--</td>
                                                                <td align="center" class="td_bg" style="word-break: break-all">
                                                                    <?= $project->price ?>
                                                                    元</td>
                                                                <td align="center" class="td_bg" nowrap><?= $item['count'] ?></td>
                                                                <td align="center" class="td_bg" nowrap><?= $item['pay_type'] == 1 ? '保险理赔' : '自费维修' ?></td>
                                                            </tr>
                                                        <?php endforeach; ?>
                                                    </table>
                                                <?php endif; ?>
                                                <?php if(isset($items[5])): ?>
                                                    <?php $group_name =[1=>'微伤',2=>'轻度',3=>'中度',4=>'重度'] ?>
                                                        <h4>美容装饰</h4>
                                                        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"
                                                               style="table-layout: fixed;">
                                                            <tr>
                                                                <td width="50" align="center" class="bg_tr" nowrap>序号</td>
                                                                <td width="100" align="center" class="bg_tr" nowrap>零件名/维修项目</td>
                                                                <td width="100" align="center" class="bg_tr" nowrap>修理分组</td>
                                                                <td width="100" align="center" class="bg_tr" nowrap>损伤程度</td>
                                                                <td width="50" align="center" class="bg_tr" nowrap>单价</td>
                                                                <td width="80" align="center" class="bg_tr" nowrap>数量</td>
                                                                <td width="100" align="center" class="bg_tr" nowrap>结算方式</td>
                                                            </tr>
                                                            <?php foreach ($items[5] as $index => $item): ?>
                                                                <?php $store = $project = null; ?>
                                                                <?php $project = \common\models\FixCarProject::findOne($item['fk_id']) ?>
                                                                <tr>
                                                                    <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                                                                    <td align="center" class="td_bg" style="word-break: break-all">
                                                                        <?= $project->category->name ?>
                                                                    </td>
                                                                    <td align="center" class="td_bg" style="word-break: break-all">
                                                                        <?= $project->group->name ?>
                                                                    </td>
                                                                    <td align="center" class="td_bg" style="word-break: break-all">--</td>
                                                                    <td align="center" class="td_bg" style="word-break: break-all">
                                                                        <?= $project->price ?>
                                                                        元</td>
                                                                    <td align="center" class="td_bg" nowrap><?= $item['count'] ?></td>
                                                                    <td align="center" class="td_bg" nowrap><?= $item['pay_type'] == 1 ? '保险理赔' : '自费维修' ?></td>
                                                                </tr>
                                                            <?php endforeach; ?>
                                                        </table>
                                                    <?php endif; ?>
                                                <?php endif; ?>
                                        </form>
                                    </div>
                                </TD>
                            </TR>
                            <TR>
                                <TD vAlign=top>
                                    <div class="big_box">
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('Box4')">
                                                <?php if($fixcar->status == 15){ ?>
                                                    <span id="OnBox4Title">账单结算</span>
                                                    <span id="OffBox4Title" style="color:black;display:none;">账单结算</span>
                                                    <span id="OnBox4">▼</span>
                                                    <span id="OffBox4" style="color:black;display:none;">▲</span>
                                                <?php }else{ ?>
                                                    <span id="OnBox4Title" style="display:none;">账单结算</span>
                                                    <span id="OffBox4Title" style="color:black;">账单结算</span>
                                                    <span id="OnBox4" style="display:none;">▼</span>
                                                    <span id="OffBox4" style="color:black;">▲</span>
                                                <?php } ?>

                                            </h3>
                                        </div>
                                        <form id="Box4" <?php if($fixcar->status == 15){ echo 'style="display:block;"'; }else{ echo 'style="display:none;"'; } ?>>
                                            <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="table-layout: fixed;">
                                                    <input type="hidden" name="fix_id" value="<?= $fixcar->id ?>">
                                                <input type="hidden" name="finance_id" value="<?= $carfinance ? $carfinance->id : 0 ?>">
                                                    <tr>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">车牌号</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="text" name="car_no" value="<?= $fixcar->car_no ?>" readonly>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">车主姓名</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="text" name="id_man" value="<?= $fixcar->id_man ?>" readonly>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">发动机号</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="text" name="engine_no" value="<?= $fixcar->engine_no ?>" readonly>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">车架号</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="text" name="car_frame_no" value="<?= $fixcar->car_frame_no ?>" readonly>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">进厂日期</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="text" name="enter_the_factory_time" value="<?= $fixcar->receive_date ?>" readonly>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">出厂日期</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="text" name="finish_date" value="<?= $fixcar->finish_date ?>" readonly>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">应结金额</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="text" class="should" id="total_price" name="total_price" value="<?= $report ? $report->zhuche_money : $total_price ?>"/>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">到账金额</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="Text" oninput="Pdisparity()" class="real" name="real_price" value="<?= $carfinance ? $carfinance->real_price : 0 ?>"/><span style="color:red;">  * 只能精确到两位小数</span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">结算差价</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="Text" class="disparity" id="gap_price" name="gap_price" value="<?= $carfinance ? $carfinance->gap_price : 0 ?>" readonly /><span style="color:red;">  * 此处自动计算</span>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">差额原因</td>
                                                        <td height="20" class="td_bg"><textarea style="width:450px;height:25px;" name="gap_reason"><?= $carfinance ? $carfinance->gap_reason : '' ?></textarea></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="60" height="25" class="bg_tr">支付方式</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="pay_type">
                                                                <option value="">请选择支付方式</option>
                                                                <option value="1" <?= $carfinance ? (1 === $carfinance->pay_type ? 'selected' : '') : '' ?>>网银</option>
                                                                <option value="2" <?= $carfinance ? (2 === $carfinance->pay_type ? 'selected' : '') : '' ?>>支票</option>
                                                                <option value="3" <?= $carfinance ? (3 === $carfinance->pay_type ? 'selected' : '') : '' ?>>刷卡</option>
                                                                <option value="4" <?= $carfinance ? (4 === $carfinance->pay_type ? 'selected' : '') : '' ?>>现金</option>
                                                                <option value="5" <?= $carfinance ? (5 === $carfinance->pay_type ? 'selected' : '') : '' ?>>微信</option>
                                                                <option value="6" <?= $carfinance ? (6 === $carfinance->pay_type ? 'selected' : '') : '' ?>>支付宝</option>
                                                            </select>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">银行</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="banks">
                                                                <option value="">请选择银行</option>
                                                                <option value="1" <?= $carfinance ? (1 === $carfinance->banks ? 'selected' : '') : '' ?>>不需要选择</option>
                                                                <option value="2" <?= $carfinance ? (2 === $carfinance->banks ? 'selected' : '') : '' ?>>北京银行</option>
                                                                <option value="3" <?= $carfinance ? (3 === $carfinance->banks ? 'selected' : '') : '' ?>>中国农业银行</option>
                                                                <option value="4" <?= $carfinance ? (4 === $carfinance->banks ? 'selected' : '') : '' ?>>中国建设银行</option>
                                                                <option value="5" <?= $carfinance ? (5 === $carfinance->banks ? 'selected' : '') : '' ?>>中国工商银行</option>
                                                                <option value="6" <?= $carfinance ? (6 === $carfinance->banks ? 'selected' : '') : '' ?>>浦发银行</option>
                                                                <option value="7" <?= $carfinance ? (7 === $carfinance->banks ? 'selected' : '') : '' ?>>平安银行</option>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="60" height="25" class="bg_tr">支付状态</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="pay_state">
                                                                <option value="">请选择支付状态</option>
                                                                <option value="1" <?= $carfinance ? (1 === $carfinance->pay_state ? 'selected' : '') : '' ?>>已支付，已到帐</option>
                                                                <option value="2" <?= $carfinance ? (2 === $carfinance->pay_state ? 'selected' : '') : '' ?>>已支付，未到账</option>
                                                                <option value="3" <?= $carfinance ? (3 === $carfinance->pay_state ? 'selected' : '') : '' ?>>挂账</option>
                                                                <option value="4" <?= $carfinance ? (4 === $carfinance->pay_state ? 'selected' : '') : '' ?>>已推案，未到账</option>
                                                                <option value="5" <?= $carfinance ? (5 === $carfinance->pay_state ? 'selected' : '') : '' ?>>未推案，未到账</option>
                                                            </select>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">报案号</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="baoanhao">
                                                                <option value="<?= $report ? $report->report_no : '' ?>" ><?= $report ? $report->report_no : '无' ?></option>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="60" height="25" class="bg_tr">挂账金额</td>
                                                        <td height="20" class="td_bg"><input type="Text" name="bill_price" value="<?= $carfinance ? $carfinance->bill_price : '' ?>" /></td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">用券编号</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="gift_no">
                                                                <?php if($gift_items): ?>
                                                                    <option value="">请选择代金券</option>
                                                                    <?php foreach($gift_items as $k=>$v): ?>
                                                                        <option value="<?=sprintf("%07d",$v->code)?>"><?= $v->type->name ?></option>
                                                                    <?php endforeach; ?>
                                                                    <?php else: ?>
                                                                    <option value="">无代金券</option>
                                                                <?php endif; ?>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="60" height="25" class="bg_tr">维修账单明细</td>
                                                        <td height="20" class="td_bg">
                                                            <input type="button" class="ACT_btn" onclick="check(<?= $fixcar->status ?>,<?= 15 === $fixcar->status ? 4 : '' ?>)" value=" 详情 ">
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">明细审核通过</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="examine">
                                                                <option value="">--请选择--</option>
                                                                <option value="1" <?= $carfinance ? (1 === $carfinance->examine ? 'selected' : '') : '' ?>>未通过</option>
                                                                <option value="2" <?= $carfinance ? (2 === $carfinance->examine ? 'selected' : '') : '' ?>>通过</option>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="text-align:center;" width="60" height="25" class="bg_tr">业务类型</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="business_type">
                                                                <option value="">请选择业务类型</option>
                                                                <option value="1" <?= $carfinance ? (1 === $carfinance->business_type ? 'selected' : '') : '' ?>>自费板喷</option>
                                                                <option value="2" <?= $carfinance ? (2 === $carfinance->business_type ? 'selected' : '') : '' ?>>自费保养</option>
                                                                <option value="3" <?= $carfinance ? (3 === $carfinance->business_type ? 'selected' : '') : '' ?>>保险理赔</option>
                                                            </select>
                                                        </td>
                                                        <td style="text-align:center;" width="100" height="25" class="bg_tr">保险公司</td>
                                                        <td height="20" class="td_bg">
                                                            <select name="company">
                                                                <option value="">请选择保险公司</option>
                                                                <option value="人保" <?= $carfinance ? ( '人保'=== $carfinance->company ? 'selected' : '') : '' ?>>人保</option>
                                                                <option value="平安" <?= $carfinance ? ( '平安'=== $carfinance->company ? 'selected' : '') : '' ?>>平安</option>
                                                            </select>
                                                        </td>
                                                    </tr>
                                                </table>
                                        </form>
                                    </div>
                                </TD>
                            </TR>
                            <tr>
                                <td height="22" colspan="2" align="center" class="td_bg">
                                    <input type="button" class="<?= 15 === $fixcar->status ? 'ACT_btn' : 'ACT_btn2'  ?>" onclick="check(<?= $fixcar->status ?>,1)" value=" 打印送车单 ">
                                    <input type="button" class="<?= 15 === $fixcar->status ? 'ACT_btn' : 'ACT_btn2'  ?>" onclick="check(<?= $fixcar->status ?>,2)" value=" 保存 ">
                                    <input type="button" class="<?= 15 === $fixcar->status ? 'ACT_btn' : 'ACT_btn2'  ?>" onclick="submitBtn(<?= $fixcar->status ?>)" value=" 提交 ">
                                    <input type="button" class="ACT_btn js-back-btn" value=" 返回 ">
                                </td>
                            </tr>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD vAlign=top>
                                    <div id="car_history_list"></div>
                                </TD>
                            </TR>
                            <tr>
                                <td height="22" colspan="2" align="center" class="td_bg">
                                    <input type="button" class="ACT_btn js-back-btn" value=" 返回 ">
                                </td>
                            </tr>
                        </TABLE>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<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" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript" language="javascript">
        //返回
        $('.js-back-btn').click(function(){
            window.location.href = '/fix-car-finance/list-accounts';
        });


    //自动计算差价
    function Pdisparity(){
        var should = Number($(".should").val());
        var real = Number($(".real").val());

        if(real > should){
            var disparity = ' 请认真核对 ';
        }else{
            var disparity = should - real;
            var disparity = disparity.toFixed(2);
        }

        $(".disparity").val(disparity);
    }

    //点击隐藏显示
    function show(a){

        $("#"+a).slideToggle(function(){
            $("#Off"+a+",#Off"+a+"Title").toggle();
            $("#On"+a+",#On"+a+"Title").toggle();
        });
    }

    //检查是否可以操作
    function check(num,type){
        if(num !== 15) return false;
        var acc_id = <?= $fixcar->id ?>,
            isAjax = false;
        switch(type){
            case 1:
                window.open('/fix-car-finance/car-send?acc_id='+acc_id);
                break;
            case 2:
                isAjax = true;
                break;
            case 4:
                //结算单打印
                window.open('/fix-car-finance/print-send?acc_id='+acc_id);
                break;
        }

        if(!isAjax) return false;

        var params = $('#Box4').serialize();
        $.post('/fix-car-finance/create',params + '&type='+type,function(data){
            alert(data.msg);
            if(data.success){
                location.reload();
            }
        },'json');
    }
    function submitBtn(num){
        if(15 !== num) return false;
        var acc_id = <?= $fixcar->id ?>;

        $.post('/fix-car-finance/update',{fix_id:acc_id},function(data){
            alert(data.msg);
            if(data.success){
                location.reload();
            }
        },'json');
    }
    function anniu(a){

        $('.disabled').removeAttr("disabled");
        var params  = $("#Box4").serialize();
        var params = params+'&type='+a;
        $.post('/fix-car-finance/cashier-to-acc',params,function(obj){
            alert(obj.msg);
            if(obj.success) {
                $('.js-back-btn').click();
            }
        },'json');
    }
</script>