<div>
    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#order_invoice" aria-controls="order_invoice" role="tab" data-toggle="tab">发票信息</a></li>
        <li role="presentation"><a href="#contract_info" aria-controls="contract_info" role="tab" data-toggle="tab">合同乙方信息</a></li>

        <?php if (!empty($order_info['order_source']) && preg_match('/adtag\=/', $order_info['order_source'])) { ?>
        <li role="presentation"><a href="#adtag_val" aria-controls="adtag_val" role="tab" data-toggle="tab">Adtag值</a></li>
        <?php } ?>

        <?php if (!empty($order_shipping_info) || !empty($order_invoice_shipping_info)) { ?>
        <li role="presentation"><a href="#shipping_info" aria-controls="shipping_info" role="tab" data-toggle="tab">物流信息</a></li>
        <?php } ?>

        <?php if ($order_extra && $action_name == 'details') { ?>
        <li role="presentation"><a href="#end_client_info" aria-controls="end_client_info" role="tab" data-toggle="tab">终端客户信息</a></li>
        <?php } ?>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <?php if (!empty($order_invoice_info)) { ?>
        <div role="tabpanel" class="tab-pane active" id="order_invoice">             
            <table class="table table-bordered order-express">
                <tr class="caption">
                    <th colspan="8" style="text-align: center; background: #f9f9f9;"> 发票信息
                    <?php 
                        //<!-- 发票状态小于2(已发货)且更改权限存在 显示按钮 -->
                        if (!isset($tags)) {
                            if(in_array($order_info['status'], [1, 2, 3, 4]) && $order_invoice_info['invoice_status'] < 2 && in_array('update_invoice', $userPerms)) {
                                echo '<a href="/changeInvoice/'.$order_info['order_id'].'" class="btn btn-success btn-sm changeBtn">更改发票</a>';
                            }
                        } elseif ($order_info['status'] != -1 && isset($tags) && $tags == 'self' && isset($extend) && !$extend) {
                            if ($order_info['status'] > 3) { // 已付款请求财务接口判断是否能修改发票
                                $isChangeInvoice = App\Http\Controllers\isChangeInvoice($order_info['order_sn']);

                                if ($isChangeInvoice) {
                                    echo '<a href="/changeInvoice/'.$order_info['order_id'].'?tags='.$tags.'" class="btn btn-success btn-sm changeBtn">更改发票</a>';
                                }
                            } else {
                                if ($order_invoice_info['invoice_status'] < 2 && in_array('self_order_update_invoice', $userPerms)) {
                                    echo '<a href="/changeInvoice/'.$order_info['order_id'].'?tags='.$tags.'" class="btn btn-success btn-sm changeBtn">更改发票</a>';
                                }
                            } 
                        }
                    ?>                  
                    </th>
                </tr>

                <tr>
                    <th>发票类型</th>
                    <th>发票抬头</th>
                    <th>公司注册地址</th>
                    <th>公司电话</th>
                    <th>税务登记号</th>
                    <th>开户银行</th>
                    <th>银行卡号</th>
                    <th>开票状态</th>
                </tr>

                <?php if ($order_invoice_info['inv_type'] == 1) { ?>
                    <tr style="text-align: center;">
                        <td colspan="8">不开发票</td>
                    </tr>
                <?php } else { ?>
                    <tr>
                        <td>
                            <?php 
                                switch ($order_invoice_info['inv_type']) {
                                    case 2: echo '普通发票';break;
                                    case 3: echo '增值税专用发票';break;
                                    case 4: echo '增值税普通发票';break;
                                }
                            ?>
                        </td>
                        <td><?= $order_invoice_info['tax_title'] ?></td>
                        <td><?= $order_invoice_info['company_address'] ?></td>
                        <td><?= $order_invoice_info['company_phone'] ?></td>
                        <td><?= $order_invoice_info['tax_no'] ?></td>
                        <td><?= $order_invoice_info['bank_name'] ?></td>
                        <td><?= $order_invoice_info['bank_account'] ?></td>
                        <td><?= $order_invoice_info['invoice_status_val'] ?></td>
                    </tr>
                <?php } ?>
            </table>
        </div>
        <?php } ?>

        <div role="tabpanel" class="tab-pane" id="contract_info">
            <table class="table table-bordered">
                <tr class="caption">
                    <th colspan="4" style="text-align: center; background: #f9f9f9;">合同乙方信息
                        <?php if ($order_info['status'] == 1) { ?>
                            <a href="javascript:;" class="btn btn-success btn-sm changeBtn contract_info_edit">编辑</a>
                        <?php } ?>
                    </th>
                </tr>

                <tr>
                    <th>公司名称</th>
                    <th>公司地址</th>
                    <th>联系人</th>
                    <th>联系电话</th>
                </tr>
                
                <tr>
                    <td><?= $contract_com_name ?></td>
                    <td><?= $contract_com_addr ?></td>
                    <td><?= $contract_link_name ?></td>
                    <td><?= $contract_link_tel ?></td>
                </tr>
            </table>
        </div>  

        <?php if (!empty($order_info['order_source']) && preg_match('/adtag\=/', $order_info['order_source'])) { ?>
        <div role="tabpanel" class="tab-pane" id="adtag_val">
            <table class="table table-bordered table-hover">
                <tr>
                    <th width="10%">Adtag值:</th>
                    <td><?= $order_info['order_source'] ?></td>
                </tr>
            </table>
        </div>
        <?php } ?>
        
        <!-- 订单或发票物流 -->
        <?php if (!empty($order_shipping_info) || !empty($order_invoice_shipping_info)) { ?>
        <div role="tabpanel" class="tab-pane" id="shipping_info">
            <table class="table table-bordered table-hover">
                <tr class="caption">
                    <th colspan="8" style="text-align: center; background: #f9f9f9;">
                        物流信息
                    </th>
                </tr>
                
                <?php if (!empty($order_shipping_info)) { ?>
                <tr> 
                    <th width="5%">订单物流</th>
                    <th width="5%">快递公司:</th>  
                    <td width="10%"><?= $order_shipping_info['shipping_name'] ?></td>
                    <th width="5%">快递单号:</th>
                    <td width="10%"><?= $order_shipping_info['shipping_no'] ?></td>
                    <th width="5%">配送状态:</th>
                    <td width="10%">
                        <?php 
                            switch ($order_shipping_info['status']) {
                                case 0:
                                case 1: echo '已配送'; break;
                                case 2: echo '已签收'; break;
                                default: echo '未配送'; break;
                            }
                        ?>
                    </td>
                    <td width="5%">
                        <a class="btn btn-xs btn-success view-shipping" data-type="1">查看物流轨迹</a>
                    </td>
                </tr>
                <?php } ?>

                <?php if (!empty($order_invoice_shipping_info)) { ?>
                    <tr> 
                        <th width="5%">发票物流</th>  
                        <th width="5%">快递公司:</th>  
                        <td width="10%"><?= $order_invoice_shipping_info['shipping_name'] ?></td>
                        <th width="5%">快递单号:</th>
                        <td width="10%"><?= $order_invoice_shipping_info['shipping_no'] ?></td>
                        <th width="5%">配送状态:</th>
                        <td width="10%">
                            <?php 
                                switch ($order_invoice_shipping_info['status']) {
                                    case 0:
                                    case 1: echo '已配送'; break;
                                    case 2: echo '已签收'; break;
                                    default: echo '未配送'; break;
                                }
                            ?>
                        </td>
                        <td width="5%">
                            <a class="btn btn-xs btn-success view-shipping" data-type="2">查看物流轨迹</a>
                        </td>
                    </tr>
                <?php } ?>
            </table>
        </div>
        <?php } ?>

        <!-- 终端客户信息 -->
        <?php if ($order_extra && $action_name == 'details') { ?>
        <div role="tabpanel" class="tab-pane" id="end_client_info">
            <table class="table table-bordered table-hover">
                <tr class="caption">
                    <th colspan="4" style="text-align: center; background: #f9f9f9;">终端客户信息</th>
                </tr> 
                <tr>
                    <th>客户名称(中文)</th>
                    <th>客户名称(英文)</th>
                    <th>客户类型</th>
                    <th>产品用途</th>
                </tr>
                <tr>
                    <td><?= $order_extra['customer_cn'] ?></td>
                    <td><?= $order_extra['customer_en'] ?></td>
                    <td><?= Config('params.end_user_type')[$order_extra['customer_type']] ?></td>
                    <td><?= $order_extra['product_use'] ?></td>
                </tr>
            </table>   
        </div>
        <?php } ?>
    </div>

</div>