<link rel="stylesheet" href="<?php echo base_url(); ?>public/js/vendor/smalot_bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>public/plugins/datatables/jquery.dataTables.min.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>public/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css">
<script src="<?php echo base_url(); ?>public/js/vendor/smalot_bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script src="<?php echo base_url(); ?>public/js/vendor/smalot_bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#" id="orderForm">
                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>用户ID:</label>
                                            <input type="text" class="form-control" placeholder="用户UID" name="userid" value="<?php echo $uid ?? ''; ?>">
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>订单ID:</label>
                                            <input type="text" class="form-control" placeholder="订单ID" name="orderid" value="<?php echo $orderid ?? ''; ?>">
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>Google流水号:</label>
                                            <input type="text" class="form-control" placeholder="Google流水号" name="sl_platform_serial_num" value="<?php echo $sl_platform_serial_num ?? ''; ?>">
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>开始时间: </label>
                                            <input type="text" class="form-control datetimepicker" value="<?php echo $stime ?? ''; ?>" placeholder="开始时间" name="payment_stime"/>
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>结束时间: </label>
                                            <input type="text" class="form-control datetimepicker" value="<?php echo $etime ?? ''; ?>" placeholder="结束时间" name="payment_etime"/>
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>渠道:</label>
                                            <select name="channel" id="channel" class="selectpicker show-tick form-control">
                                                <option value="0">--请选择--</option>
                                                <?php foreach ($channelList as $k => $v) { ?>
                                                    <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
                                                <?php } ?>
                                            </select>
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>平台商品ID:</label>
                                            <input type="text" class="form-control" placeholder="平台商品ID" name="sku" value="<?php echo $sku ?? ''; ?>">
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <label>订单状态:</label>
                                            <select name="payment_type" class="form-control">
                                                <?php foreach ($statusMap as $status => $text) { ?>
                                                    <option value="<?= $status ?>" <?php if ($status == $payment_type) { ?> selected<?php } ?> ><?= $text ?></option>
                                                <?php } ?>
                                            </select>
                                            <span class="gap"></span>
                                        </div>

                                        <div class="form-group" style="margin-bottom: 5px">
                                            <button type="button" class="btn btn-primary" id="searchBtn">查询</button>
                                            <a href="javascript:void(0)" onclick="exportRefundOrder()" class="btn btn-warning">退款订单导出</a>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>订单查询</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="table-responsive">
                                        <table id="orderTable" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>序号</th>
                                                <th>订单ID</th>
                                                <th>用户ID</th>
                                                <th>用户等级</th>
                                                <th>游戏内商品ID</th>
                                                <th>平台商品ID</th>
                                                <th>商品名称</th>
                                                <th>商品内容</th>
                                                <th>商品价格(美元)</th>
                                                <th>下单时间</th>
                                                <th>发货时间</th>
                                                <th>支付渠道</th>
                                                <th>设备平台</th>
                                                <th>支付状态</th>
                                                <th>发放途径</th>
                                                <th>Google流水号</th>
                                                <th>商品内容</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody></tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>

<div class="modal fade" id="reissueOrder" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">订单补发</h4>
            </div>
            <div id="msg-tip"></div>
            <form class="form-horizontal J_ajaxForm" role="form" method="post" action="#">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">订单ID:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" disabled value="" id="orderId" name="orderId"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">用户ID:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" disabled value="" id="uid" name="uid"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">平台商品ID:</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" disabled value="" id="sku" name="sku"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">支付订单ID:</label>
                        <div class="col-sm-9">
                            <input type="text" placeholder="请手动输入支付订单ID" class="form-control" value="" id="payId" name="payId"/>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="modalCancel">关闭</button>
                    <button type="button" class="btn btn-primary" id="modalSubmitBtn">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    //选择日期
    $('.datetimepicker').datetimepicker({
        language: 'zh-CN',
        format: 'yyyy-mm-dd hh:ii:ss',
        zIndexOffset: 906  //控制z-index
    });

    function exportRefundOrder() {
        var url = "<?php echo site_url() . '/payment/exportRefundOrder'?>";
        url = url + "?orderid=" + $('input[name="orderid"]').val() + "&userid=" + $('input[name="userid"]').val() + "&sl_platform_serial_num=" + $('input[name="sl_platform_serial_num"]').val() + "&payment_stime=" + $('input[name="payment_stime"]').val() + '&payment_etime=' + $('input[name="payment_etime"]').val() + "&channel=" + $('#channel').val();
        window.open(url, "_blank");
    }

</script>
<script src="<?php echo base_url(); ?>public/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url(); ?>public/plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="<?php echo base_url(); ?>public/js/common.js"></script>
<script src="<?php echo base_url(); ?>static/order/index.js?version=<?php echo time(); ?>"></script>
