<?php
/*
 * @author: CloudZA(云之安) <2922619853@qq.com>
 * @hitokoto: 一场秋雨一场凉，秋心酌满泪为霜。
 * Copyright (c) 2022 by CloudZA, All Rights Reserved.
 */

include_once 'common.php';
if ( !isset($islogin)) header("Location: /");//非法访问
$title = '订单列表';
include_once 'partials/head.php';


?>
<div id="pjax-container">
    <!--导航-->
    <div class="bg-body-light">
        <div class="content content-full">
            <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center py-2">
                <div class="flex-grow-1">
                    <h1 class="h3 fw-bold mb-2">
                        <?php echo $title ?>
                    </h1>
                </div>
                <nav class="flex-shrink-0 mt-3 mt-sm-0 ms-sm-3" aria-label="breadcrumb">
                    <ol class="breadcrumb breadcrumb-alt">
                        <li class="breadcrumb-item">
                            <a class="link-fx" href="javascript:void(0)">首页</a>
                        </li>
                        <li class="breadcrumb-item" aria-current="page">
                            <?php echo $title ?>
                        </li>
                    </ol>
                </nav>
            </div>
        </div>
</div>
    <!--导航结束-->
    <!--内容-->
<div class="content">
    <link rel="stylesheet" id="css-main" href="<?php echo __CSS__ ?>bootstrap-table.css">
    <div class="block block-rounded">
        <div class="block-header block-header-default">
            <h3 class="block-title"> 订单列表 </h3>
        </div>
        <div class="block-content">
            <form  method="" class="form-inline" id="toolbar">
            <div class="dropdown d-inline-block">
<!--                <button type="button" class="btn btn-light btn-alt-secondary btn-xs" style="padding: 0.4375rem 0.925rem" id="page-header-user-dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">-->
<!--                    <span class="d-sm-inline-block fw-semibold">菜单</span>-->
<!--                </button>-->
                <div class="dropdown-menu fs-sm" aria-labelledby="dropdown-content-rich-primary" data-popper-placement="bottom-start" style="min-width: 320px">
                    <div class="me-2 m-2">
                        <div class="form-group mb-2">
                            <label class="form-label" for="batch">订单号</label>
                            <input type="text" class="form-control" name="batch" id="batch" placeholder="订单号">
                        </div>
                         <div class="input-group mb-3 input-daterange">
                             <input type="text" id="starttime" name="starttime" class="form-control " placeholder="开始日期" autocomplete="off" title="留空则不限时间范围">
                             <span onclick="$('#starttime').val('');$('#endtime').val('');" class="input-group-text">></span>
                             <input type="text" id="endtime" name="endtime" class="form-control dates" placeholder="结束日期" autocomplete="off" title="留空则不限时间范围">
                         </div>
                        <div class="dropdown-divider"></div>
                        <button type="submit" class="btn btn-sm btn-alt-primary form-control">搜索</button>
                    </div>
                </div>
            </div>
                <a class="btn btn-light btn-alt-secondary btn-xs" style="padding: 0.4375rem 0.925rem" href="javascript:delChecks()">
                    <span class="d-sm-inline-block fw-semibold">删除选中</span>
                </a>

        </form>
            <table class="text-center fs-sm mb-2" id="table"></table>
        </div>
    </div>

    <script>
        function delChecks ()
        {
            const selected = $('#table').bootstrapTable('getSelections')
            if (selected.length === 0) {
                app.notify('未选择记录', 'warning')
                return;
            }
            const checkbox = []
            $.each(selected, function (key, item) {
                checkbox.push(item.id_custom)
            })
            app.btn('确定要删除选中的内容吗？删除之后不可恢复！', '确定', '取消', () => {
                app.ajax('ajax_table.php?act=delOrder', {
                    id: checkbox
                }, res => {
                    if (res.code === 200) {
                        app.btn(res.msg, '我知道了', null, () => {
                            app.pjax('order.php')
                        })
                    }
                    else {
                        app.btn(res.msg, '我知道了')
                    }
                })
            }, null)
        }

        app.ajax('ajax_table.php?act=pay_order', null, res => {
            if (res.code === 200) {
                let columns = [
                    {
                        field: 'id',
                        checkbox: true,
                    },
                    {
                        field: 'pay_order_custom',
                        title: '系统订单号'
                    }, {
                        field: 'pay_orderno_custom',
                        title: '商户订单号'
                    },
                    {
                        field: 'pay_type_custom',
                        title: '支付方式'
                    },
                    {
                        field: 'pay_name_custom',
                        title: '商品名称'
                    },
                    {
                        field: 'pay_money_custom',
                        title: '支付金额'
                    }, {
                        field: 'pay_time_custom',
                        title: '订单时间'
                    },
                    {
                        field: 'pay_region_custom',
                        title: '订单地址'
                    }, {
                        field: 'pay_ip_custom',
                        title: '订单IP'
                    }, {
                        field: 'pay_status_custom',
                        title: '订单状态'
                    }
                ];
                table.initTable('table', columns, res.data.custom, null,res.data.page);
            }
        })

    </script>
</div>
</div>
    <!--内容结束-->
    <?php include_once 'partials/foot.php'; ?>
