
<?php $this->load->view('site/layout'); ?>
<link href="<?php echo base_url() ?>public/css/style.bundle_front.css"
      rel="stylesheet" type="text/css" />
      <?php $this->load->view('site/navbar'); ?>
<style>
    .btn-brand {
        color: #fff;
        background-color: #5d78ff;
        border-color: #5d78ff;
        color: #ffffff;
    }
    .alert.alert-light {
        background: #ffffff;
        border: 1px solid #ffffff;
        color: #282a3c;
    }
    .toggle_fiter_btn{
        text-align: left;
    }
    .rtl .toggle_fiter_btn{
        text-align: right;
    }
</style>

<div
    class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor"
    id="kt_content">

    <!-- begin:: Content Head -->
    <div class="kt-subheader  kt-grid__item" id="kt_subheader">
        <div class="kt-container  kt-container--fluid ">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title">
                    <a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a>
                </h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc"><?php echo $this->lang->line('payment_report'); ?></span>
            </div>

        </div>
    </div>
</div>


<div class="kt-container  kt-container--fluid  kt-grid__item kt-grid__item--fluid">
    <div class="toggle_fiter_btn">
        <button class="btn btn-primary mb-3 " onclick="toggle_filter()"><?= $this->lang->line('show_hide_filter') ?></button>
    </div>
    <div class="alert alert-light alert-elevate" role="alert" id="filter_container">
        <div class="alert-text">

            <form class="kt-form kt-form--label-right" method="post" action=""> 
                <div class="kt-portlet__body">
                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('date') ?></label>
                        <div class="col-9">
                            <input type="text" name="start_expiry" id="start_expiry" class="form-control" value="<?= set_value('start_expiry') ?>"> 
                        </div>
                        <div class="col-1" style="padding-left: 0px">
                            <a onclick="clear_date()" class="btn btn-light btn-text-primary btn-hover-text-primary font-weight-bold"><?= $this->lang->line('clear') ?></a>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('the_type') ?></label>
                        <div class="col-9">
                            <select class="form-control" name="type">
                                <option <?= set_value('type') == -1 ? 'selected' : '' ?> value="-1"><?= $this->lang->line('all') ?></option>
                                <option <?= set_value('type') == 0 ? 'selected' : '' ?> value="0"><?= $this->lang->line('invoice') ?></option>
                                <option <?= set_value('type') == 1 ? 'selected' : '' ?> value="1"><?= $this->lang->line('pay_order') ?></option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('invoice-number') ?></label>
                        <div class="col-9">
                            <input type="text" class="form-control" name="inv_num" value="<?= set_value('inv_num') ?>" />
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('status') ?></label>
                        <div class="col-9">
                            <select class="form-control" name="status">
                                <option <?= set_value('status') == -1 ? 'selected' : '' ?> value="-1"><?= $this->lang->line('all') ?></option>
                                <option <?= set_value('status') == 0 ? 'selected' : '' ?> value="0"><?= $this->lang->line('success') ?></option>
                                <option <?= set_value('status') == 1 ? 'selected' : '' ?> value="1"><?= $this->lang->line('failed') ?></option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label">Transaction Id</label>
                        <div class="col-9">
                            <input type="text" name="trans_id" class="form-control" value="<?= set_value('trans_id') ?>" />
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label">Reference Id</label>
                        <div class="col-9">
                            <input type="text" name="ref_id" class="form-control" value="<?= set_value('ref_id') ?>" />
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label">Tracking Id</label>
                        <div class="col-9">
                            <input type="text" name="track_id" class="form-control" value="<?= set_value('track_id') ?>" />
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="example-text-input" class="col-2 col-form-label">Amount</label>
                        <div class="col-9">
                            <input type="text" name="amount" class="form-control" value="<?= set_value('amount') ?>" />
                        </div>
                    </div>

                    <div class="form-group row">

                        <button  class="btn btn-brand btn-elevate btn-icon-sm mr-5">
                            <?php echo $this->lang->line('submit') ?>
                        </button>

                    </div>
                </div>
            </form>          
        </div>
    </div>
</div>

<div class="kt-portlet kt-portlet--mobile">
    <div class="kt-portlet__head kt-portlet__head--lg">
        <div class="kt-portlet__head-label">
            <span class="kt-portlet__head-icon">
                <i class="kt-font-brand flaticon2-line-chart"></i>
            </span>
            <h3 class="kt-portlet__head-title">
                <?php echo $this->lang->line('payment_report'); ?>
            </h3>
        </div> 
    </div>
    <div class="kt-portlet__body">
        <!--<pre style="text-align: left;direction: ltr">-->
        <table class="table table-hover table-responsive table-bordered" id="list_table">
            <thead>
                <tr>
                    <th><?= $this->lang->line('the_type') ?></th>
                    <th>ID</th>
                    <th><?= $this->lang->line('payment_method') ?></th>
                    <th><?= $this->lang->line('date-added') ?></th>
                    <th><?= $this->lang->line('payment_time') ?></th>
                    <th><?= $this->lang->line('status') ?></th>
                    <th><?= $this->lang->line('amount') ?></th>
                    <th>Tracking Id</th>
                    <th>Reference Num.</th>
                    <th>Payment Id</th>
                    <th>Transaction Id</th>
                    <th>Authorization Id</th>
                    <th>Gateway Payment Time</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($payment_details as $pay) {
                    ?>
                    <tr>
                        <td><?= $this->lang->line($pay['type']) ?></td>
                        <td><?= $pay['id'] ?></td>
                        <td><?= $pay['payment_method'] ?></td>
                        <td><?= $pay['order_added'] ?></td>
                        <td><?= $pay['payment_time'] ?></td>
                        <td title="<?= !isset($pay['payment_data']) ? '' : $pay['payment_data']->DESCRIPTION ?>"><?= !isset($pay['payment_data']) ? 'Failed' : $pay['payment_data']->PAYMENT_STATUS ?></td>
                        <td><?= !isset($pay['payment_data']) ? '---' : $pay['payment_data']->AMOUNT ?></td>
                        <td><?= !isset($pay['payment_data']) ? $pay['g_tracking_id'] : $pay['payment_data']->TRACKING_ID ?></td>
                        <td><?= !isset($pay['payment_data']) ? '---' : $pay['payment_data']->REFERENCE_ID ?></td>
                        <td><?= !isset($pay['payment_data']) ? '---' : $pay['payment_data']->PAYMENT_ID ?></td>
                        <td><?= !isset($pay['payment_data']) ? '---' : $pay['payment_data']->TRANSACTION_ID ?></td>
                        <td><?= !isset($pay['payment_data']) ? '---' : $pay['payment_data']->AUTHORIZATION_ID ?></td>
                        <td><?= !isset($pay['payment_data']) ? '---' : $pay['payment_data']->PAYMENT_TIME ?></td>
                    </tr>
                    <?php
                }
                ?>
            </tbody>
        </table>
        <!--</pre>-->
    </div>
</div>


<?php $this->load->view('site/footer_2') ?>
<script>
    $(function () {
        $("#filter_container").hide();
        $("#list_table").DataTable({dom: 'Bfrtip',
            destroy: true,
            aaSorting: [],
            ordering: true,
            buttons: [
                {
                    extend: 'excelHtml5',
                    charset: 'UTF-16LE',
                    fieldSeparator: '\t',
                    bom: true
                },
                {
                    extend: 'csvHtml5',
                    charset: 'UTF-16LE',
                    fieldSeparator: '\t',
                    bom: true
                },
                {
                    extend: 'pdfHtml5',
                    charset: 'UTF-16LE',
                    fieldSeparator: '\t',
                    bom: true
                },
                {
                    extend: 'print',
                    autoPrint: false,
                    footer: true
                }

            ]
        });
//            buttons: [
//                'copyHtml5',
//                'excelHtml5',
//                'csvHtml5',
//                'pdfHtml5'
//            ]
    });

    function toggle_filter() {
        $("#filter_container").toggle();
        $(".select2_plug").select2();
    }
    function clear_date() {
        $("#start_expiry").val('');
    }

</script>