<!-- Hover Rows -->
<div class="row clearfix fBTitrBold">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center" dir="rtl">
        <div class="card">
            <div class="header">
                <div class="row">
                    <div class="col-md-2">
                        <div class="form-group">
                            <button class="btn-default btn-block btn waves-effect btn-get-report">گزارش</button>
                        </div>
                    </div>
                    <div class="col-md-2 text-center">
                        <div class="form-group">
                            <button type="button" data-toggle="tooltip" data-placement="bottom"
                                    title="تا تاریخ"
                                    class="btn btn-warning btn-lg waves-effect sEnd"
                                    id="sEnd"
                                    name="sEnd">
                                <i class="material-icons">perm_contact_calendar</i>
                                <span>پایان تاریخ</span>
                            </button>
                        </div>
                    </div>

                    <div class="col-md-2 text-center">
                        <div class="form-group">
                            <button type="button" data-toggle="tooltip" data-placement="bottom"
                                    title="از تاریخ"
                                    class="btn btn-warning btn-lg waves-effect sStart"
                                    id="sStart"
                                    name="sStart">
                                <i class="material-icons">perm_contact_calendar</i>
                                <span>شروع تاریخ</span>
                            </button>
                        </div>
                    </div>

                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="text" id="MerchantCode" class="form-control" placeholder="کد پذیرنده">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="text" id="RefFrom" class="form-control" placeholder="کد مرجع از">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="text" id="RefTo" class="form-control" placeholder="کد مرجع تا">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="body text-center">
                <div class="table-responsive text-center no-overflow-y">
                    <table class="table table-hover js-exportable text-center full_width">
                        <thead>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">کد وضعیت تراکنش</td>
                            <td class="table-bordered ">شرح وضعیت تراکنش</td>
                            <td class="table-bordered ">شماره پیگیری</td>
                            <td class="table-bordered ">شماره ارجاع</td>
                            <td class="table-bordered ">کد پذیرنده</td>
                            <td class="table-bordered ">کد ترمینال</td>
                            <td class="table-bordered ">تاریخ تراکنش</td>
                            <td class="table-bordered ">زمان تراکنش</td>
                            <td class="table-bordered ">شماره کارت</td>
                            <td class="table-bordered "> هش شماره کارت</td>
                            <td class="table-bordered ">نوع سرویس</td>
                            <td class="table-bordered ">مبلغ کل</td>
                            <td class="table-bordered ">مبلغ کارمزد پذیرنده</td>
                            <td class="table-bordered ">مبلغ کارمزد دارنده</td>
                            <td class="table-bordered ">مبلغ تسهیم</td>
                            <td class="table-bordered ">مبلغ قابل پرداخت</td>
                        </tr>
                        </thead>
                        <tbody class="bordered"></tbody>
                        <tfoot>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">کد وضعیت تراکنش</td>
                            <td class="table-bordered ">شرح وضعیت تراکنش</td>
                            <td class="table-bordered ">شماره پیگیری</td>
                            <td class="table-bordered ">شماره ارجاع</td>
                            <td class="table-bordered ">کد پذیرنده</td>
                            <td class="table-bordered ">کد ترمینال</td>
                            <td class="table-bordered ">تاریخ تراکنش</td>
                            <td class="table-bordered ">زمان تراکنش</td>
                            <td class="table-bordered ">شماره کارت</td>
                            <td class="table-bordered "> هش شماره کارت</td>
                            <td class="table-bordered ">نوع سرویس</td>
                            <td class="table-bordered ">مبلغ کل</td>
                            <td class="table-bordered ">مبلغ کارمزد پذیرنده</td>
                            <td class="table-bordered ">مبلغ کارمزد دارنده</td>
                            <td class="table-bordered ">مبلغ تسهیم</td>
                            <td class="table-bordered ">مبلغ قابل پرداخت</td>
                        </tr>
                        </tfoot>
                    </table>
                    <div class="clearfix reset-this">
                        <div class="demo-preloader-table hidden">
                            <div class="block-header">لطفا منتظر بمانید</div>
                            <div class="preloader pl-size-xl">
                                <div class="spinner-layer">
                                    <div class="circle-clipper left">
                                        <div class="circle"></div>
                                    </div>
                                    <div class="circle-clipper right">
                                        <div class="circle"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row clearfix fBTitrBold">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center" dir="rtl">
        <div class="card">
            <div class="header">
                <div class="row">
                    <div class="col-md-12">
                        <div class="col-md-3">
                            <div class="form-group">
                                <button class="btn-default btn-block btn waves-effect btn-get-report-2">گزارش</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="body text-center">
                <div class="table-responsive text-center no-overflow-y">
                    <table class="table table-hover js-exportable-2 text-center full_width">
                        <thead>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">شماره بن</td>
                            <td class="table-bordered ">عنوان بن</td>
                            <td class="table-bordered ">کد گروه مشتری</td>
                            <td class="table-bordered ">نام گروه مشتری</td>
                            <td class="table-bordered ">کد وام</td>
                            <td class="table-bordered ">عنوان وام</td>
                        </tr>
                        </thead>
                        <tbody class="bordered"></tbody>
                        <tfoot>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">شماره بن</td>
                            <td class="table-bordered ">عنوان بن</td>
                            <td class="table-bordered ">کد گروه مشتری</td>
                            <td class="table-bordered ">نام گروه مشتری</td>
                            <td class="table-bordered ">کد وام</td>
                            <td class="table-bordered ">عنوان وام</td>
                        </tr>
                        </tfoot>

                    </table>
                    <div class="clearfix reset-this">
                        <div class="demo-preloader-table-2 hidden">
                            <div class="block-header">لطفا منتظر بمانید</div>
                            <div class="preloader pl-size-xl">
                                <div class="spinner-layer">
                                    <div class="circle-clipper left">
                                        <div class="circle"></div>
                                    </div>
                                    <div class="circle-clipper right">
                                        <div class="circle"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row clearfix fBTitrBold">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center" dir="rtl">
        <div class="card">
            <div class="header">
                <div class="row">
                    <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <button class="btn-default btn-block btn waves-effect btn-get-report-3">گزارش</button>
                            </div>
                        </div>
                        <div class="col-md-6" dir="ltr">
                            <b>شماره کارت</b>
                            <div class="input-group">
                                            <span class="input-group-addon">
                                                <i class="material-icons">credit_card</i>
                                            </span>
                                <div class="form-line">
                                    <input type="text" class="card-number card-numberform-control credit-card"
                                           placeholder="Ex: 0000 0000 0000 0000">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="body text-center">
                <div class="table-responsive text-center no-overflow-y">
                    <table class="table table-hover js-exportable-3 text-center full_width">
                        <thead>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">شماره بن</td>
                            <td class="table-bordered ">عنوان بن</td>
                            <td class="table-bordered ">کد گروه مشتری</td>
                            <td class="table-bordered ">نام گروه مشتری</td>
                            <td class="table-bordered ">کد وام</td>
                            <td class="table-bordered ">عنوان وام</td>
                            <td class="table-bordered "> مبلغ بن (ريال)</td>
                            <td class="table-bordered "> مانده (ريال)</td>
                        </tr>
                        </thead>
                        <tbody class="bordered"></tbody>
                        <tfoot>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">شماره بن</td>
                            <td class="table-bordered ">عنوان بن</td>
                            <td class="table-bordered ">کد گروه مشتری</td>
                            <td class="table-bordered ">نام گروه مشتری</td>
                            <td class="table-bordered ">کد وام</td>
                            <td class="table-bordered ">عنوان وام</td>
                            <td class="table-bordered "> مبلغ بن (ريال)</td>
                            <td class="table-bordered "> مانده (ريال)</td>
                        </tr>
                        </tfoot>

                    </table>
                    <div class="clearfix reset-this">
                        <div class="demo-preloader-table-3 hidden">
                            <div class="block-header">لطفا منتظر بمانید</div>
                            <div class="preloader pl-size-xl">
                                <div class="spinner-layer">
                                    <div class="circle-clipper left">
                                        <div class="circle"></div>
                                    </div>
                                    <div class="circle-clipper right">
                                        <div class="circle"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row clearfix fBTitrBold">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center" dir="rtl">
        <div class="card">
            <div class="header">
                <div class="row">
                    <div class="col-md-12">
                        <div class="col-md-6">
                            <div class="form-group">
                                <button class="btn-default btn-block btn waves-effect btn-get-report-4">گزارش</button>
                            </div>
                        </div>
                        <div class="col-md-6" dir="ltr">
                            <b>شماره ارجاع</b>
                            <div class="input-group">
                                <div class="form-line">
                                    <input type="text" class="single-ref-number"
                                           placeholder="Ex: 00000000">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="body text-center">
                <div class="table-responsive text-center no-overflow-y">
                    <table class="table table-hover js-exportable-4 text-center full_width">
                        <thead>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">شرح وضعیت تراکنش</td>
                            <td class="table-bordered ">کد پذیرنده</td>
                            <td class="table-bordered ">کد ترمینال</td>
                            <td class="table-bordered ">تاریخ</td>
                            <td class="table-bordered ">ساعت</td>
                            <td class="table-bordered ">شماره پیگیری</td>
                            <td class="table-bordered ">شماره کارت</td>
                            <td class="table-bordered "> شماره رپ شده</td>
                            <td class="table-bordered ">هش شماره کارت</td>
                            <td class="table-bordered ">مبلغ کل</td>
                            <td class="table-bordered ">مبلغ کارمزد پذیرنده</td>
                            <td class="table-bordered ">مبلغ کارمزد دارنده</td>
                            <td class="table-bordered ">مبلغ تسهیم</td>
                            <td class="table-bordered ">مبلغ قابل پرداخت</td>
                        </tr>
                        </thead>
                        <tbody class="bordered"></tbody>
                        <tfoot>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">شرح وضعیت تراکنش</td>
                            <td class="table-bordered ">کد پذیرنده</td>
                            <td class="table-bordered ">کد ترمینال</td>
                            <td class="table-bordered ">تاریخ</td>
                            <td class="table-bordered ">ساعت</td>
                            <td class="table-bordered ">شماره پیگیری</td>
                            <td class="table-bordered ">شماره کارت</td>
                            <td class="table-bordered "> شماره رپ شده</td>
                            <td class="table-bordered ">هش شماره کارت</td>
                            <td class="table-bordered ">مبلغ کل</td>
                            <td class="table-bordered ">مبلغ کارمزد پذیرنده</td>
                            <td class="table-bordered ">مبلغ کارمزد دارنده</td>
                            <td class="table-bordered ">مبلغ تسهیم</td>
                            <td class="table-bordered ">مبلغ قابل پرداخت</td>
                        </tr>
                        </tfoot>

                    </table>
                    <div class="clearfix reset-this">
                        <div class="demo-preloader-table-4 hidden">
                            <div class="block-header">لطفا منتظر بمانید</div>
                            <div class="preloader pl-size-xl">
                                <div class="spinner-layer">
                                    <div class="circle-clipper left">
                                        <div class="circle"></div>
                                    </div>
                                    <div class="circle-clipper right">
                                        <div class="circle"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- agency report -->
<div class="row clearfix fBTitrBold">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center" dir="rtl">
        <div class="card">
            <div class="header">
                <div class="row">
                    <div class="col-md-12">
                        <div class="col-md-3">
                            <div class="form-group">
                                <button class="btn-default btn-block btn waves-effect btn-get-report-5">گزارش</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="body text-center">
                <div class="table-responsive text-center no-overflow-y">
                    <table class="table table-hover js-exportable-5 text-center full_width">
                        <thead>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">آیدی نماینده</td>
                            <td class="table-bordered ">نام - نام خانوادگی</td>
                            <td class="table-bordered ">ثبت کاربران</td>
                            <td class="table-bordered ">ثبت پزیرندگان</td>
                        </tr>
                        </thead>
                        <tbody class="bordered"></tbody>
                        <tfoot>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">آیدی نماینده</td>
                            <td class="table-bordered ">نام - نام خانوادگی</td>
                            <td class="table-bordered ">ثبت کاربران</td>
                            <td class="table-bordered ">ثبت پزیرندگان</td>
                        </tr>
                        </tfoot>
                    </table>
                    <div class="clearfix reset-this">
                        <div class="demo-preloader-table-5 hidden">
                            <div class="block-header">لطفا منتظر بمانید</div>
                            <div class="preloader pl-size-xl">
                                <div class="spinner-layer">
                                    <div class="circle-clipper left">
                                        <div class="circle"></div>
                                    </div>
                                    <div class="circle-clipper right">
                                        <div class="circle"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row clearfix fBTitrBold">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center" dir="rtl">
        <div class="card">
            <div class="header">
                <div class="row">
                    <div class="col-md-2">
                        <div class="form-group">
                            <button class="btn-default btn-block btn waves-effect btn-get-report-6">گزارش</button>
                        </div>
                    </div>
                    <div class="col-md-3 text-center">
                        <div class="form-group">
                            <button type="button" data-toggle="tooltip" data-placement="bottom"
                                    title="تا تاریخ"
                                    class="btn btn-warning btn-block btn-lg waves-effect sEnd-2"
                                    id="sEnd-2"
                                    name="sEnd-2">
                                <i class="material-icons">perm_contact_calendar</i>
                                <span>پایان تاریخ</span>
                            </button>
                        </div>
                    </div>

                    <div class="col-md-3 text-center">
                        <div class="form-group">
                            <button type="button" data-toggle="tooltip" data-placement="bottom"
                                    title="از تاریخ"
                                    class="btn btn-warning btn-block btn-lg waves-effect sStart-2"
                                    id="sStart-2"
                                    name="sStart-2">
                                <i class="material-icons">perm_contact_calendar</i>
                                <span>شروع تاریخ</span>
                            </button>
                        </div>
                    </div>

                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="text" id="agency-code" class="form-control" placeholder="کد نماینده">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="text" id="agency-name" class="form-control" placeholder="نام نماینده">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="body text-center">
                <div class="table-responsive text-center no-overflow-y">
                    <table class="table table-hover js-exportable-6 text-center full_width">
                        <thead>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">کد کاربری</td>
                            <td class="table-bordered ">نام و نام خانوادگی</td>
                            <td class="table-bordered ">وضعیت کاربر</td>
                            <td class="table-bordered ">وضعیت کارت</td>
                            <td class="table-bordered ">تاریخ ثبت</td>
                            <td class="table-bordered ">روز سپری شده</td>
                        </tr>
                        </thead>
                        <tbody class="bordered table-bordered "></tbody>
                        <tfoot>
                        <tr>
                            <td class="table-bordered ">شماره</td>
                            <td class="table-bordered ">کد کاربری</td>
                            <td class="table-bordered ">نام و نام خانوادگی</td>
                            <td class="table-bordered ">وضعیت کاربر</td>
                            <td class="table-bordered ">وضعیت کارت</td>
                            <td class="table-bordered ">تاریخ ثبت</td>
                            <td class="table-bordered ">روز سپری شده</td>
                        </tr>
                        </tfoot>
                    </table>
                    <div class="clearfix reset-this">
                        <div class="demo-preloader-table-6 hidden">
                            <div class="block-header">لطفا منتظر بمانید</div>
                            <div class="preloader pl-size-xl">
                                <div class="spinner-layer">
                                    <div class="circle-clipper left">
                                        <div class="circle"></div>
                                    </div>
                                    <div class="circle-clipper right">
                                        <div class="circle"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- #END# Hover Rows -->

<script type="text/javascript">
    let table1 = null, table2 = null, table3 = null, table4 = null, table5 = null, table6 = null;
    (function ($) {
        $(document).ready(function () {
            let start = $("#sStart");
            start.persianDatepicker({
                element: start
            });

            let end = $("#sEnd");
            end.persianDatepicker({
                element: end
            });

            $('.credit-card').inputmask('9999 9999 9999 9999', {placeholder: '____ ____ ____ ____'});

            $('.btn-get-report').unbind().bind("tap", function (e) {
                GetReport(
                    start.find('span').text(), end.find('span').text(),
                    $('#MerchantCode').val(),
                    $('#RefFrom').val(),
                    $('#RefTo').val()
                );
            });
            $('.btn-get-report-2').unbind().bind("tap", function (e) {
                GetReport2();
            });
            $('.btn-get-report-3').unbind().bind("tap", function (e) {
                GetReport3(($(".card-number").val()).replace(/ /g, ""));
            });

            $('.btn-get-report-4').unbind().bind("tap", function (e) {
                GetReport4(($(".single-ref-number").val()).replace(/ /g, ""));
            });
            $('.btn-get-report-5').unbind().bind("tap", function (e) {
                GetReport5();
            });


            let start2 = $("#sStart-2");
            start2.persianDatepicker({
                element: start2
            });

            let end2 = $("#sEnd-2");
            end2.persianDatepicker({
                element: end2
            });

            //start.find('span').text(), end.find('span').text(),
            $('.btn-get-report-6').unbind().bind('tap', function () {
                let startTime = start2.find('span').text();
                let endTime = end2.find('span').text();
                GetReport6(
                    (checkForm(startTime) ? startTime : ''),
                    (checkForm(endTime) ? endTime : ''),
                    $('#agency-code').val(),
                    $('#agency-name').val()
                );
            });
        });
    }(jQuery));

    function loader(state = false, div) {
        let loader = $(div);
        if (state)
            loader.removeClass("hidden");
        else
            loader.addClass("hidden");
    }

    function GetReport(FromDate = '', ToDate = '', MerchantCode = '', RefFrom = '', RefTo = '') {
        let dataArray = [];
        CreateTable(dataArray);
        loader(true, '.demo-preloader-table');
        LoadData({
            request: 'proxy',
            action: 'WebServicesController',
            object: {
                FromDate: FromDate,
                ToDate: ToDate,
                MerchantCode: MerchantCode,
                FromRefNo: RefFrom,
                ToRefNo: RefTo
            },
            'data-header': 'TransReportNafis'
        }, null, true, function (data) {
            let conter = 0;
            if (data.length === 1) {
                let o = data[0];
                if (o.response != null) {
                    let response = o.response;
                    if (response.length > 0) {
                        for (let i = 0; i < response.length; i += 1) {
                            let DaysRecord = response[i].result;
                            for (let x = 0; x < DaysRecord.length; x += 1) {
                                let record = DaysRecord[x];

                                if (x === 0)
                                    console.log(record);
                                dataArray.push({
                                    index: (++conter),
                                    ClarifiedStatus: record.ClarifiedStatus,
                                    ClarifiedStatusDesc: record.ClarifiedStatusDesc,
                                    Stan: record.Stan,
                                    RefNo: record.RefNo,
                                    MerchantCode: record.MerchantCode,
                                    TerminalCode: record.TerminalCode,
                                    TransDate: record.TransDate,
                                    TransTime: record.TransTime,
                                    WrappPan: record.WrappPan,
                                    HashPan: record.HashPan,
                                    ServiceName: record.ServiceName,
                                    TotalAmount: record.TotalAmount,
                                    MerchantWageAmount: record.MerchantWageAmount,
                                    CustWageAmount: record.CustWageAmount,
                                    ShareAmount: record.ShareAmount,
                                    PayableAmount: record.PayableAmount
                                });
                            }
                        }
                    } else {
                        swal("خطا", o.error, "error");
                    }
                } else {
                    swal("خطا", o.error, "error");
                }
            } else {
                swal("خطا", "این درخواست انجام نشد", "error");
            }
            CreateTable(dataArray);
        });
    }

    function CreateTable(dataArray) {
        loader(false, '.demo-preloader-table');
        if (table1 !== null)
            table1.destroy();
        table1 = $('.js-exportable').DataTable({
            "data": dataArray,
            'processing': true,
            "columns": [
                {"data": "index"},
                {"data": "ClarifiedStatus"},
                {"data": "ClarifiedStatusDesc"},
                {"data": "Stan"},
                {"data": "RefNo"},
                {"data": "MerchantCode"},
                {"data": "TerminalCode"},
                {"data": "TransDate"},
                {"data": "TransTime"},
                {"data": "WrappPan"},
                {"data": "HashPan"},
                {"data": "ServiceName"},
                {"data": "TotalAmount"},
                {"data": "MerchantWageAmount"},
                {"data": "CustWageAmount"},
                {"data": "ShareAmount"},
                {"data": "PayableAmount"}
            ],
            dom: 'Bfrtip',
            responsive: true,
            buttons: [
                {extend: 'copy', charset: 'windows-1256'},
                {extend: 'csv', charset: 'windows-1256'},
                {extend: 'excel', charset: 'windows-1256'},
                {extend: 'pdf', charset: 'windows-1256'},
                {extend: 'print', charset: 'windows-1256'}
            ],//  to _END_ of _TOTAL_ entries
            "language": {
                "lengthMenu": "Display _MENU_ records per page",
                "zeroRecords": " چیزی یافت نشد",
                "info": "نمایش از _START_ تا _END_ در _TOTAL_ رکورد",
                "infoEmpty": "<center>رکوردی پیدا نشد</center>",
                "infoFiltered": "(filtered from _MAX_ total records)",
                "paginate": {
                    "next": "بعدی",
                    "previous": "قبلی"
                }
            }
        });
    }

    function CreateTable2(dataArray) {
        loader(false, '.demo-preloader-table-2');
        if (table2 !== null)
            table2.destroy();
        table2 = $('.js-exportable-2').DataTable({
            "data": dataArray,
            "columns": [
                {"data": "index"},
                {"data": "BonNo"},
                {"data": "BonTitle"},
                {"data": "CustCategoryCode"},
                {"data": "CustCategoryName"},
                {"data": "LoanCode"},
                {"data": "LoanName"}
            ],
            dom: 'Bfrtip',
            responsive: true,
            buttons: [
                {extend: 'copy', charset: 'windows-1256'},
                {extend: 'csv', charset: 'windows-1256'},
                {extend: 'excel', charset: 'windows-1256'},
                {extend: 'pdf', charset: 'windows-1256'},
                {extend: 'print', charset: 'windows-1256'}
            ],//  to _END_ of _TOTAL_ entries
            "language": {
                "lengthMenu": "Display _MENU_ records per page",
                "zeroRecords": " چیزی یافت نشد",
                "info": "نمایش از _START_ تا _END_ در _TOTAL_ رکورد",
                "infoEmpty": "<center>رکوردی پیدا نشد</center>",
                "infoFiltered": "(filtered from _MAX_ total records)",
                "paginate": {
                    "next": "بعدی",
                    "previous": "قبلی"
                }
            }
        });
    }

    function GetReport2() {
        let dataArray = [];
        CreateTable2(dataArray);
        loader(true, '.demo-preloader-table-2');
        LoadData({
            request: 'proxy',
            action: 'WebServicesController',
            'data-header': 'BonServiceNafis'
        }, null, true, function (data) {
            let conter = 0;
            if (data.length === 1) {
                let o = data[0];
                if (o.response != null) {
                    let response = o.response;
                    if (response.error.ResponseCode === "0000") {
                        let result = response.result;
                        for (let i = 0; i < result.length; i += 1) {
                            let record = result[i];
                            dataArray.push({
                                index: (++conter),
                                BonNo: record.BonNo,
                                BonTitle: record.BonTitle,
                                CustCategoryCode: record.CustCategoryCode,
                                CustCategoryName: record.CustCategoryName,
                                LoanCode: record.LoanCode,
                                LoanName: record.LoanName,
                            });
                        }
                    } else {
                        swal(response.error.ErrorFieldName, response.error.ResponseMessage, "error");
                    }
                } else {
                    swal("خطا", o.error, "error");
                }
            } else {
                swal("خطا", "این درخواست انجام نشد", "error");
            }
            CreateTable2(dataArray);
        });
    }

    function GetReport3(Pan) {
        let dataArray = [];
        CreateTable3(dataArray);
        loader(true, '.demo-preloader-table-3');
        LoadData({
            request: 'proxy',
            action: 'WebServicesController',
            object: {
                Pan: Pan
            },
            'data-header': 'CustBonServiceNafis'
        }, null, true, function (data) {
            let conter = 0;
            if (data.length === 1) {
                let o = data[0];
                if (o.response != null) {//6037 9919 0010 0623
                    let response = o.response;
                    if (response.error.ResponseCode === "0000") {
                        let result = response.result;
                        if (result.length > 0) {
                            for (let i = 0; i < result.length; i += 1) {
                                let record = result[i];
                                dataArray.push({
                                    index: (++conter),
                                    BonNo: record.BonNo,
                                    BonTitle: record.BonTitle,
                                    CustCategoryCode: record.CustCategoryCode,
                                    CustCategoryName: record.CustCategoryName,
                                    LoanCode: record.LoanCode,
                                    LoanName: record.LoanName,
                                    CrAmnt: record.CrAmnt,
                                    RemAmnt: record.RemAmnt,
                                });
                            }
                        } else {
                            swal("خطا", "موردی یافت نشد", "error");
                        }
                    } else {
                        swal(response.error.ErrorFieldName, response.error.ResponseMessage, "error");
                    }
                } else {
                    swal("خطا", o.error, "error");
                }
            } else {
                swal("خطا", "این درخواست انجام نشد", "error");
            }
            CreateTable3(dataArray);
        });
    }

    function CreateTable3(dataArray) {
        loader(false, '.demo-preloader-table-3');
        if (table3 !== null)
            table3.destroy();
        table3 = $('.js-exportable-3').DataTable({
            "data": dataArray,
            "columns": [
                {"data": "index"},
                {"data": "BonNo"},
                {"data": "BonTitle"},
                {"data": "CustCategoryCode"},
                {"data": "CustCategoryName"},
                {"data": "LoanCode"},
                {"data": "LoanName"},
                {"data": "CrAmnt"},
                {"data": "RemAmnt"}
            ],
            dom: 'Bfrtip',
            responsive: true,
            buttons: [
                {extend: 'copy', charset: 'windows-1256'},
                {extend: 'csv', charset: 'windows-1256'},
                {extend: 'excel', charset: 'windows-1256'},
                {extend: 'pdf', charset: 'windows-1256'},
                {extend: 'print', charset: 'windows-1256'}
            ],//  to _END_ of _TOTAL_ entries
            "language": {
                "lengthMenu": "Display _MENU_ records per page",
                "zeroRecords": " چیزی یافت نشد",
                "info": "نمایش از _START_ تا _END_ در _TOTAL_ رکورد",
                "infoEmpty": "<center>رکوردی پیدا نشد</center>",
                "infoFiltered": "(filtered from _MAX_ total records)",
                "paginate": {
                    "next": "بعدی",
                    "previous": "قبلی"
                }
            }
        });
    }

    function GetReport4(RefNo) {
        let dataArray = [];
        CreateTable4(dataArray);
        loader(true, '.demo-preloader-table-4');
        LoadData({
            request: 'proxy',
            action: 'WebServicesController',
            object: {
                RefNo: RefNo
            },
            'data-header': 'RefNoServiceNafis'
        }, null, true, function (data) {
            let conter = 0;
            if (data.length === 1) {
                let o = data[0];
                if (o.response != null) {//6037 9919 0010 0623
                    let response = o.response;
                    if (response.error.ResponseCode === "0000") {
                        let result = response.result;
                        if (result != null) {
                            let record = result;
                            dataArray.push({
                                index: (++conter),
                                ClarifiedStatusDesc: record.ClarifiedStatusDesc,
                                MerchantCode: record.MerchantCode,
                                TerminalCode: record.TerminalCode,
                                TransDate: record.TransDate,
                                TransTime: record.TransTime,
                                Stan: record.Stan,
                                Pan: record.Pan,
                                WrapPan: record.WrapPan,
                                HashPan: record.HashPan,
                                TotalAmount: record.TotalAmount,
                                MerchantWageAmount: record.MerchantWageAmount,
                                CustWageAmount: record.CustWageAmount,
                                ShareAmount: record.ShareAmount,
                                PayableAmount: record.PayableAmount
                            });


                        } else {
                            swal(response.error.ErrorFieldName, response.error.ResponseMessage, "error");
                        }
                    } else {
                        swal("خطا", o.error, "error");
                    }
                } else {
                    swal("خطا", "این درخواست انجام نشد", "error");
                }
                CreateTable4(dataArray);
            }
        });
    }

    function CreateTable4(dataArray) {
        loader(false, '.demo-preloader-table-4');
        if (table4 !== null)
            table4.destroy();
        table4 = $('.js-exportable-4').DataTable({
            "data": dataArray,
            "columns": [
                {"data": "index"},
                {"data": "ClarifiedStatusDesc"},
                {"data": "MerchantCode"},
                {"data": "TerminalCode"},
                {"data": "TransDate"},
                {"data": "TransTime"},
                {"data": "Stan"},
                {"data": "Pan"},
                {"data": "WrapPan"},
                {"data": "HashPan"},
                {"data": "TotalAmount"},
                {"data": "MerchantWageAmount"},
                {"data": "CustWageAmount"},
                {"data": "ShareAmount"},
                {"data": "PayableAmount"}
            ],
            dom: 'Bfrtip',
            responsive: true,
            buttons: [
                {extend: 'copy', charset: 'windows-1256'},
                {extend: 'csv', charset: 'windows-1256'},
                {extend: 'excel', charset: 'windows-1256'},
                {extend: 'pdf', charset: 'windows-1256'},
                {extend: 'print', charset: 'windows-1256'}
            ],//  to _END_ of _TOTAL_ entries
            "language": {
                "lengthMenu": "Display _MENU_ records per page",
                "zeroRecords": " چیزی یافت نشد",
                "info": "نمایش از _START_ تا _END_ در _TOTAL_ رکورد",
                "infoEmpty": "<center>رکوردی پیدا نشد</center>",
                "infoFiltered": "(filtered from _MAX_ total records)",
                "paginate": {
                    "next": "بعدی",
                    "previous": "قبلی"
                }
            }
        });
    }

    function CreateTable5(dataArray) {
        loader(false, '.demo-preloader-table-5');
        if (table5 !== null)
            table5.destroy();
        table5 = $('.js-exportable-5').DataTable({
            "data": dataArray,
            "columns": [
                {"data": "index"},
                {"data": "ID"},
                {"data": "full-name"},
                {"data": "client"},
                {"data": "acceptor"}
            ],
            dom: 'Bfrtip',
            responsive: true,
            buttons: [
                {extend: 'copy', charset: 'windows-1256'},
                {extend: 'csv', charset: 'windows-1256'},
                {extend: 'excel', charset: 'windows-1256'},
                {extend: 'pdf', charset: 'windows-1256'},
                {extend: 'print', charset: 'windows-1256'}
            ],//  to _END_ of _TOTAL_ entries
            "language": {
                "lengthMenu": "Display _MENU_ records per page",
                "zeroRecords": " چیزی یافت نشد",
                "info": "نمایش از _START_ تا _END_ در _TOTAL_ رکورد",
                "infoEmpty": "<center>رکوردی پیدا نشد</center>",
                "infoFiltered": "(filtered from _MAX_ total records)",
                "paginate": {
                    "next": "بعدی",
                    "previous": "قبلی"
                }
            }
        });
    }

    function GetReport5() {
        let dataArray = [];
        CreateTable5(dataArray);
        loader(true, '.demo-preloader-table-5');
        LoadData({
                request: 'proxy',
                action: 'WebServicesController',
                'data-header': 'agent-report'
            }, null, true, function (data) {
                let conter = 0;
                if (data.length > 0) {
                    CreateTable5(data);
                } else {
                    swal("خطا", "این درخواست انجام نشد", "error");
                }
            }
        );
    }


    function CreateTable6(dataArray) {
        loader(false, '.demo-preloader-table-6');
        if (table6 !== null)
            table6.destroy();
        table6 = $('.js-exportable-6').DataTable({
            "data": dataArray,
            "columns": [
                {"data": "index"},
                {"data": "code"},
                {"data": "full-name"},
                {"data": "client-state"},
                {"data": "card-state"},
                {"data": "transaction-time"},
                {"data": "transaction-def"}
            ],
            dom: 'Bfrtip',
            responsive: true,
            buttons: [
                {extend: 'copy', charset: 'windows-1256'},
                {extend: 'csv', charset: 'windows-1256'},
                {extend: 'excel', charset: 'windows-1256'},
                {extend: 'pdf', charset: 'windows-1256'},
                {extend: 'print', charset: 'windows-1256'}
            ],//  to _END_ of _TOTAL_ entries
            "language": {
                "lengthMenu": "Display _MENU_ records per page",
                "zeroRecords": " چیزی یافت نشد",
                "info": "نمایش از _START_ تا _END_ در _TOTAL_ رکورد",
                "infoEmpty": "<center>رکوردی پیدا نشد</center>",
                "infoFiltered": "(filtered from _MAX_ total records)",
                "paginate": {
                    "next": "بعدی",
                    "previous": "قبلی"
                }
            }
        });
    }


    function GetReport6(start, end, code, full_name) {
        let dataArray = [];
        CreateTable6(dataArray);
        loader(true, '.demo-preloader-table-6');
        let request = {
            request: 'proxy',
            object: {
                start: start,
                end: end,
                code: code,
                full_name: full_name
            },
            action: 'agency-report-full',
            'data-header': 'agent-report-2'
        };
        LoadData(request, null, true, function (data) {
                // console.log(data);
                let conter = 0;
                if (data.length > 0) {
                    CreateTable6(data);
                } else {
                    swal("خطا", "این درخواست انجام نشد", "error");
                }
            }
        );
    }


    // Try edit msg

    function checkForm(date) {
        if ((date.length >= 8 && date.length <= 10)) {
            let time = new Date(date);
            if (typeof time === 'object' && ("" + time) !== 'Invalid Date') return true;
        }
        return false;
    }

</script>