<?php $__env->startSection('body_class', 'depositpage'); ?>

<?php $__env->startSection('content'); ?>
<div class="master-main mainContent maincontent-design2 middlebackground background-design5">
    <div class="container">
        <div class="row multi">
            <div class="col-sm-3 main-sidebar">
                <div class="main-sidebar-container sidebar-design1">
                    <ul>
                        <li><a href="/desktop/account/profile"><span class="glyphicon glyphicon-list-alt"></span>Profil</a></li>
                        <li><a href="/desktop/account/deposit"><span class="glyphicon glyphicon-transfer"></span>Depo/Withdraw</a></li>
                        <li><a href="/desktop/account/walletsummary"><span class="glyphicon glyphicon-stats"></span>Transaksi</a></li>
                        <li><a href="/desktop/account/memo"><span class="glyphicon glyphicon-bell"></span>Memo</a></li>
                        <li><a href="/desktop/account/referral"><span class="glyphicon glyphicon-tags"></span>Referral</a></li>
                        <li><a href="/desktop/account/promo"><span class="glyphicon glyphicon-thumbs-up"></span>Promosi</a></li>
                        <li><a href="https://cutt.ly/rtpsuster1" target="_blank"><span class="glyphicon glyphicon-flash"></span>RTP</a></li>
                        <li><a href="/download/apk"><span class="glyphicon glyphicon-cloud-download"></span>APK</a></li>
                        <li><a href="javascript:;" onclick="showLiveChat();"><span class="glyphicon glyphicon-user"></span>Livechat</a></li>
                    </ul>
                </div>
            </div>

            <div class="col-xs-12 col-sm-9 tabbed main-content">
                <div class="content-inner-container bet-summary-content">
                    <div id="MainContent_PanelNav">
                        <div class="nav-container">
                            <button type="button" id="Account_WalletSummary" class="btn btn-tab" style="order: 10" onclick="gotoView('/desktop/account/walletsummary')">
                                <span>Wallet Summary</span>
                            </button>
                            <button type="button" id="Account_BetSummary" class="btn btn-tab" style="order: 10" onclick="gotoView('/desktop/account/betsummary')">
                                <span>Bet Summary</span>
                            </button>
                        </div>
                    </div>

                    <div id="MainContent_PanelPageSummary">
                        <form action="<?php echo e(route('account.betsummary')); ?>" method="GET">
                            <div class="value-container">
                                <input type="hidden" name="ctl00$MainContent$InputDateStart" id="MainContent_InputDateStart" value="<?php echo e(request('ctl00$MainContent$InputDateStart', '2026-01-01')); ?>" />
                                <input type="hidden" name="ctl00$MainContent$InputDateEnd" id="MainContent_InputDateEnd" value="<?php echo e(request('ctl00$MainContent$InputDateEnd', date('Y-m-d'))); ?>" />
                                <input type="hidden" name="ctl00$MainContent$InputReportType" id="MainContent_InputReportType" value="1" />
                            </div>
                    
                            <div class="summary-container betsummary">
                                <div class="filter">
                                    <div class="container input-group">
                                        <div class="row">
                                            <div class="col-xs-12 col-sm-12">
                                                <div class="input-container datetime-range">
                                                    <label for="filter-datetime-range" class="input-label">Tanggal</label>
                                                    <input id="filter-datetime-range" class="input-filter datetime-range form-control" />
                                                </div>
                                            </div>
                    
                                            <div class="col-xs-12 col-sm-4">
                                                <div class="input-container gamegroup">
                                                    <label for="filter-gamegroup" class="input-label">Tipe</label>
                                                    <select name="ctl00$MainContent$GameGroupDDL" id="MainContent_GameGroupDDL" class="input-filter gamegroup form-control">
                                                        <option value="3" <?php echo e(request('ctl00$MainContent$GameGroupDDL') == '3' ? 'selected' : ''); ?>>Slot</option>
                                                        <option value="2" <?php echo e(request('ctl00$MainContent$GameGroupDDL') == '2' ? 'selected' : ''); ?>>Live Casino</option>
                                                        <option value="1" <?php echo e(request('ctl00$MainContent$GameGroupDDL') == '1' ? 'selected' : ''); ?>>Sports</option>
                                                    </select>
                                                </div>
                                            </div>
                    
                                            <div class="col-xs-12 col-sm-5">
                                                <div class="input-container provider">
                                                    <label for="filter-provider" class="input-label">Providers</label>
                                                    <select id="DDProvider" class="input-filter gamegroup form-control">
                                                        <option value="-1">All Provider</option>
                                                    </select>
                                                </div>
                                            </div>
                    
                                            <div class="col-xs-12 col-sm-3">
                                                <input type="submit" value="Cari" id="MainContent_SearchBtn" class="btn-filter-search btn-theme" />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>

                        <div id="MainContent_PanelResult">
                            <div class="result-container">
                                <div id="SummaryResult" class="summary-result">
                                    <div class="container-fluid hdr details" style="display:block !important;">
                                        <div class="row hdr">
                                            <div class="col-xs-12 hdr-date visible-xs">Summary Details</div>
                                            <div class="col-xs-2 hdr-date hidden-xs">Tanggal (WIB)</div>
                                            <div class="col-xs-4 hdr-game hidden-xs">Game</div>
                                            <div class="col-xs-2 hdr-result hidden-xs">Result</div>
                                            <div class="col-xs-2 hdr-paidamt hidden-xs">Taruhan</div>
                                            <div class="col-xs-2 hdr-winlose hidden-xs">Menang/Kalah</div>
                                        </div>
                                    </div>

                                    <div class="container-fluid content-container"></div>
                                </div>
                            </div>

                            <div class="container ftr details" style="display:block !important;">
                                <div class="container inner">
                                    <div class="row header-total-container">
                                        <div class="col-xs-4"></div>
                                        <div class="col-xs-4 ftr-paidamt-hdr">Turnover</div>
                                        <div class="col-xs-4 ftr-winlose-hdr">Menang/Kalah</div>
                                    </div>
                                    <div class="row grand-total-container">
                                        <div class="col-xs-4 data-title">Grand Total</div>
                                        <div class="col-xs-4 data-gt-paidamt">0</div>
                                        <div class="col-xs-4 data-gt-winlose">0</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />

<script>
    const displayDateFormat = "YYYY-MM-DD";
    const dateFormat = "YYYY-MM-DD";
    const groupSummaryRaw = '<?php echo addslashes($groupSummaryJson ?? ""); ?>';

    $(function () {
        // Navigasi Active
        $("#Account_BetSummary").addClass("active").attr('onclick', "");

        const startInput = $("#MainContent_InputDateStart");
        const endInput = $("#MainContent_InputDateEnd");
        const dateRangeInput = $("#filter-datetime-range");
    
        // Set value awal box tanggal agar sinkron
        dateRangeInput.val(startInput.val() + " - " + endInput.val());
    
        dateRangeInput.daterangepicker({
            autoUpdateInput: false,
            maxDate: moment(),
            startDate: startInput.val(),
            endDate: endInput.val(),
            locale: {
                format: "YYYY-MM-DD",
                applyLabel: "Terapkan",
                cancelLabel: "Batal",
                customRangeLabel: "Rentang Kustom"
            },
            ranges: {
                'Hari ini': [moment(), moment()],
                'Kemarin': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                '7 hari terakhir': [moment().subtract(6, 'days'), moment()],
                'Semua': [moment('2026-01-01'), moment()]
            }
        });
    
        dateRangeInput.on('apply.daterangepicker', function(ev, picker) {
            const startStr = picker.startDate.format('YYYY-MM-DD');
            const endStr = picker.endDate.format('YYYY-MM-DD');
            $(this).val(startStr + " - " + endStr);
            startInput.val(startStr);
            endInput.val(endStr);
        });
        
        dateRangeInput.on('keydown', function(e) { e.preventDefault(); });

        // --- PROSES RENDER DATA ---
        if (groupSummaryRaw && groupSummaryRaw !== "") {
            try {
                const res = JSON.parse(groupSummaryRaw);
                const container = $(".content-container");
                container.empty();

                if (res.SummaryDetailsItemList && res.SummaryDetailsItemList.length > 0) {
                    res.SummaryDetailsItemList.forEach(function (item) {
                        // Layout Desktop (CSS Original)
                        const rowD = `
                            <div class="container data hidden-xs">
                                <div class="row data-container">
                                    <div class="col-xs-2 data-date"><span class="text">${item.FmtBetDate}</span></div>
                                    <div class="col-xs-4 data-game">${item.Game}</div>
                                    <div class="col-xs-2 data-result">${item.Result}</div>
                                    <div class="col-xs-2 data-paidamt">${item.FmtPaidAmt}</div>
                                    <div class="col-xs-2 data-winlose">${item.FmtWinLose}</div>
                                </div>
                            </div>`;

                        // Layout Mobile (CSS Original)
                        const rowM = `
                            <div class="container data visible-xs" style="border-bottom: 1px solid #444; padding: 10px 0;">
                                <div class="row"><div class="col-xs-12 data-date">${item.FmtBetDate}</div></div>
                                <div class="row"><div class="col-xs-3">Game</div><div class="col-xs-1">:</div><div class="col-xs-8">${item.Game}</div></div>
                                <div class="row" style="margin-top:5px;">
                                    <div class="col-xs-4 text-center"><small>Result</small><br><b>${item.Result}</b></div>
                                    <div class="col-xs-4 text-center"><small>Taruhan</small><br><b>${item.FmtPaidAmt}</b></div>
                                    <div class="col-xs-4 text-center"><small>W/L</small><br><b>${item.FmtWinLose}</b></div>
                                </div>
                            </div>`;

                        container.append(rowD + rowM);
                    });

                    // Isi Grand Total
                    $(".data-gt-paidamt").html(res.GrandPaidAmt);
                    $(".data-gt-winlose").html(res.GrandWinlose);
                } else {
                    container.html('<div style="text-align:center; padding:30px; color:#fff;">Tidak ada data ditemukan untuk periode ini.</div>');
                }
            } catch (err) {
                console.error("Error parsing JSON:", err);
            }
        }
    });

    function gotoView(page) {
        location.href = page;
    }
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('frontend.desktop.pages.account.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /www/wwwroot/website/sewa/dragon158/resources/views/frontend/desktop/pages/account/pages/betsummary.blade.php ENDPATH**/ ?>