
<?php $__env->startSection('title', 'المالية'); ?>

<?php $__env->startSection('content'); ?>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                سند القبض والصرف

                <?php if($currentUser->can('Create Transactions')): ?>
                    <a data-toggle="modal" data-target="#myModal" class="btn btn-warning pull-right"
                        href="<?php echo e(route('transactions.create')); ?>?trans_type=صرف">
                        <i class="fa fa-plus"></i> سند صرف
                    </a>

                    <a style="margin-left: 10px" data-toggle="modal" data-target="#myModal" class="btn btn-success pull-right"
                        href="<?php echo e(route('transactions.create')); ?>?trans_type=قبض">
                        <i class="fa fa-plus"></i> سند قبض
                    </a>
                <?php endif; ?>

                <a class="btn btn-primary pull-right" style="margin-left:10px;" href="javascript:void(0)" onclick="openReportThemeModal();">
                    <i class="fa fa-print"></i> طباعة منسقة
                </a>
            </h1>
        </section>

        <section class="content">
            <?php echo $__env->make('_partial.transactions_filter', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

            <div class="row">
                <div class="col-lg-4 col-xs-4">
                    <div class="small-box bg-green transaction-summary-card">
                        <div class="inner">
                            <h3 id="totalOrder">0</h3>
                            <p>إجمالى القبض</p>
                        </div>
                        <div class="icon">
                            <i class="fa fa-money"></i>
                        </div>
                    </div>
                </div>

                <div class="col-lg-4 col-xs-4">
                    <div class="small-box bg-yellow transaction-summary-card">
                        <div class="inner">
                            <h3 id="totalProfit">0</h3>
                            <p>إجمالى الصرف</p>
                        </div>
                        <div class="icon">
                            <i class="fa fa-money"></i>
                        </div>
                    </div>
                </div>

                <div class="col-lg-4 col-xs-4">
                    <div class="small-box bg-primary transaction-summary-card">
                        <div class="inner">
                            <h3 id="countInvoices">0</h3>
                            <p>الصافي</p>
                        </div>
                        <div class="icon">
                            <i class="fa fa-money"></i>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-body">
                            <table id="serverSideTable" class="table table-bordered table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th class="col-index">#</th>
                                        <th class="col-note">البيان</th>
                                        <th class="col-type">نوع</th>
                                        <th class="col-date">التاريخ</th>
                                        <th class="col-time">الوقت</th>
                                        <th class="col-user">المستخدم</th>
                                        <th class="col-value">المبلغ</th>
                                        <th class="col-actions no-sort">الإجراءات</th>
                                    </tr>
                                </thead>
                                <tbody></tbody>
                            </table>

                            <div id="transactions-screen-total-bar" class="transactions-screen-total-bar">
                                <div class="transactions-total-label">المجموع</div>
                                <div class="transactions-total-value" id="screenTransactionsAmountTotal">0.00</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <div id="myModal" class="modal fade" style="overflow:hidden;" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title"></h4>
                    </div>
                    <div class="modal-body">
                        <p class="text-center">
                        <div class="fa-3x text-center">
                            <i class="fa fa-cog fa-spin"></i>
                            << جارى التحميل>>
                        </div>
                        </p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">إغلاق</button>
                    </div>
                </div>
            </div>
        </div>

        <div id="report-theme-modal" style="display:none; position:fixed; inset:0; background:rgba(0,0,0,0.55); z-index:9999; align-items:center; justify-content:center;">
            <div style="background:#fff; border-radius:12px; padding:28px 32px; width:480px; max-width:95vw; box-shadow:0 8px 40px rgba(0,0,0,0.25); direction:rtl;">
                <h4 style="margin:0 0 6px 0; font-size:17px; color:#1a3c5e;">اختر تصميم التقرير</h4>
                <p style="margin:0 0 20px 0; font-size:12px; color:#777;">اتجاه الصفحة يتم اختياره من نافذة الطباعة نفسها</p>

                <div style="display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:24px;">
                    <div class="report-theme-card" onclick="selectReportTheme('navy')" data-theme="navy"
                         style="border:2px solid #1a3c5e; border-radius:8px; padding:12px; cursor:pointer; text-align:center; background:#f0f4f8;">
                        <div style="height:28px; background:#1a3c5e; border-radius:4px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#c8960a; border-radius:2px; margin-bottom:6px;"></div>
                        <div style="height:6px; background:#eef2f7; border-radius:2px;"></div>
                        <div style="margin-top:8px; font-size:12px; font-weight:bold; color:#1a3c5e;">كحلي ذهبي</div>
                    </div>

                    <div class="report-theme-card" onclick="selectReportTheme('green')" data-theme="green"
                         style="border:2px solid #ddd; border-radius:8px; padding:12px; cursor:pointer; text-align:center; background:#fff;">
                        <div style="height:28px; background:#1b5e38; border-radius:4px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#4caf50; border-radius:2px; margin-bottom:6px;"></div>
                        <div style="height:6px; background:#e8f5e9; border-radius:2px;"></div>
                        <div style="margin-top:8px; font-size:12px; font-weight:bold; color:#1b5e38;">أخضر</div>
                    </div>

                    <div class="report-theme-card" onclick="selectReportTheme('gray')" data-theme="gray"
                         style="border:2px solid #ddd; border-radius:8px; padding:12px; cursor:pointer; text-align:center; background:#fff;">
                        <div style="height:28px; background:#37474f; border-radius:4px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#90a4ae; border-radius:2px; margin-bottom:6px;"></div>
                        <div style="height:6px; background:#eceff1; border-radius:2px;"></div>
                        <div style="margin-top:8px; font-size:12px; font-weight:bold; color:#37474f;">رمادي</div>
                    </div>

                    <div class="report-theme-card" onclick="selectReportTheme('burgundy')" data-theme="burgundy"
                         style="border:2px solid #ddd; border-radius:8px; padding:12px; cursor:pointer; text-align:center; background:#fff;">
                        <div style="height:28px; background:#6a0f2a; border-radius:4px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#c0392b; border-radius:2px; margin-bottom:6px;"></div>
                        <div style="height:6px; background:#fdf0f0; border-radius:2px;"></div>
                        <div style="margin-top:8px; font-size:12px; font-weight:bold; color:#6a0f2a;">بردوني</div>
                    </div>
                </div>

                <div style="display:flex; gap:10px; justify-content:flex-end;">
                    <button type="button" onclick="closeReportThemeModal()" style="padding:8px 20px; border:1px solid #ddd; border-radius:6px; background:#f5f5f5; cursor:pointer; font-size:13px;">إغلاق</button>
                    <button type="button" onclick="printStyledReport();" style="padding:8px 20px; border:none; border-radius:6px; background:#1a3c5e; color:#fff; cursor:pointer; font-size:13px;">
                        <i class="fa fa-print"></i> طباعة الآن
                    </button>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('css'); ?>
<style>
    .dt-buttons .buttons-print {
        display: none !important;
    }

    #serverSideTable {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: auto !important;
    }

    #serverSideTable th,
    #serverSideTable td {
        vertical-align: middle !important;
    }

    #serverSideTable th.col-index,
    #serverSideTable td.col-index {
        width: 40px !important;
        min-width: 40px !important;
        text-align: center !important;
        white-space: nowrap !important;
    }

    #serverSideTable th.col-note,
    #serverSideTable td.col-note {
        width: 38% !important;
        min-width: 320px !important;
        text-align: right !important;
        word-break: break-word !important;
        line-height: 1.6 !important;
    }

    #serverSideTable th.col-type,
    #serverSideTable td.col-type {
        width: 8% !important;
        min-width: 75px !important;
        text-align: center !important;
        white-space: nowrap !important;
        font-weight: bold !important;
    }

    #serverSideTable th.col-date,
    #serverSideTable td.col-date {
        width: 13% !important;
        min-width: 110px !important;
        text-align: center !important;
        white-space: nowrap !important;
    }

    #serverSideTable th.col-time,
    #serverSideTable td.col-time {
        width: 11% !important;
        min-width: 95px !important;
        text-align: center !important;
        white-space: nowrap !important;
    }

    #serverSideTable th.col-user,
    #serverSideTable td.col-user {
        width: 9% !important;
        min-width: 75px !important;
        text-align: center !important;
        white-space: nowrap !important;
    }

    #serverSideTable th.col-value,
    #serverSideTable td.col-value {
        width: 13% !important;
        min-width: 120px !important;
        text-align: center !important;
        white-space: nowrap !important;
        font-weight: bold !important;
        border-left: 2px solid #888 !important;
    }

    #serverSideTable th.col-actions,
    #serverSideTable td.col-actions {
        width: 10% !important;
        min-width: 105px !important;
        text-align: center !important;
        white-space: nowrap !important;
    }

    #serverSideTable.table-bordered > thead > tr > th.col-value,
    #serverSideTable.table-bordered > tbody > tr > td.col-value {
        border-left: 2px solid #888 !important;
    }

    .transactions-screen-total-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #1a3c5e;
        color: #fff;
        border: 1px solid #0d2a45;
        margin-top: 8px;
        padding: 10px 14px;
        font-weight: bold;
        font-size: 15px;
    }

    .transactions-screen-total-bar .transactions-total-value {
        color: #f0b429;
        font-size: 18px;
        font-weight: bold;
        direction: ltr;
    }

    .transaction-summary-card {
        border-radius: 6px;
        overflow: hidden;
        box-shadow: 0 2px 6px rgba(0,0,0,.08);
    }
</style>
<?php $__env->stopPush(); ?>

<script>
    var pageUrl = "<?php echo e(route('transactions.index')); ?>";
    var columns = [];

    columns.push(
        {
            data: null,
            name: '#',
            orderable: false,
            searchable: false,
            className: 'col-index'
        },
        {
            data: "note",
            name: "note",
            className: 'col-note'
        },
        {
            data: "trans_type",
            name: "trans_type",
            className: 'col-type'
        },
        {
            data: "trans_date",
            name: "trans_date",
            className: 'col-date'
        },
        {
            data: "time",
            name: "time",
            className: 'col-time'
        },
        {
            data: "username",
            name: "username",
            className: 'col-user'
        },
        {
            data: "value",
            name: "value",
            className: 'col-value'
        },
        {
            data: 'actions',
            name: 'actions',
            orderable: false,
            searchable: false,
            className: 'col-actions'
        }
    );
</script>

<?php echo $__env->make('_partial.datatable', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<?php $__env->startPush('js'); ?>
<script>
    var reportThemes = {
        navy:     { primary:'#1a3c5e', primaryDk:'#0d2a45', accent:'#c8960a', accentLt:'#f0b429' },
        green:    { primary:'#1b5e38', primaryDk:'#144d2c', accent:'#4caf50', accentLt:'#81c784' },
        gray:     { primary:'#37474f', primaryDk:'#263238', accent:'#78909c', accentLt:'#b0bec5' },
        burgundy: { primary:'#6a0f2a', primaryDk:'#4a0a1e', accent:'#c0392b', accentLt:'#e57373' }
    };

    var currentReportTheme = localStorage.getItem('transactions_report_theme') || 'navy';

    var reportSettings = {
        siteName:    <?php echo json_encode($settings['SiteName'] ?? '', 15, 512) ?>,
        siteNameEn:  <?php echo json_encode($settings['SiteNameEn'] ?? '', 15, 512) ?>,
        address:     <?php echo json_encode($settings['Address'] ?? '', 15, 512) ?>,
        addressEn:   <?php echo json_encode($settings['AddressEn'] ?? '', 15, 512) ?>,
        mobile:      <?php echo json_encode($settings['mobile'] ?? '', 15, 512) ?>,
        mobileEn:    <?php echo json_encode($settings['mobileEn'] ?? '', 15, 512) ?>,
        taxNumber:   <?php echo json_encode($settings['taxnumber'] ?? '', 15, 512) ?>,
        taxNumberEn: <?php echo json_encode($settings['taxnumberEn'] ?? '', 15, 512) ?>,
        logo:        <?php echo json_encode(!empty($settings['logo']) ? \Illuminate\Support\Facades\Storage::url('logo/' . $settings['logo']) : '', 15, 512) ?>
    };

    var reportTitle = <?php echo json_encode('الحركة اليومية ( سند القبض و الصرف )', 15, 512) ?>;
    var reportUserName = <?php echo json_encode(optional($currentUser)->name ?? '', 15, 512) ?>;

    function openReportThemeModal() {
        document.getElementById('report-theme-modal').style.display = 'flex';
        updateThemeCards();
    }

    function closeReportThemeModal() {
        document.getElementById('report-theme-modal').style.display = 'none';
    }

    function updateThemeCards() {
        document.querySelectorAll('.report-theme-card').forEach(function(card) {
            var name = card.getAttribute('data-theme');
            var active = (name === currentReportTheme);
            var t = reportThemes[name];
            card.style.border = active ? '2px solid ' + t.primary : '2px solid #ddd';
            card.style.background = active ? '#f0f4f8' : '#fff';
        });
    }

    function selectReportTheme(name) {
        currentReportTheme = name;
        localStorage.setItem('transactions_report_theme', name);
        updateThemeCards();
    }

    function setTopBoxes(json) {
        if (!json) return;
        $('#totalOrder').text(json.totalOrder || '0');
        $('#totalProfit').text(json.totalProfit || '0');
        $('#countInvoices').text(json.countInvoices || '0');
    }

    function parseNumber(value) {
        if (!value) return 0;
        var n = parseFloat(String(value).replace(/[^0-9.\-]/g, ''));
        return isNaN(n) ? 0 : n;
    }

    function formatNumber(n) {
        return n.toLocaleString('en-US', {
            minimumFractionDigits: 2,
            maximumFractionDigits: 2
        });
    }

    function updateVisibleAmountTotal() {
        var dt;
        try {
            dt = $('#serverSideTable').DataTable();
        } catch (e) {
            return;
        }

        var sumValue = 0;
        dt.column(6, { search: 'applied' }).data().each(function(value) {
            sumValue += parseNumber(value);
        });

        $('#screenTransactionsAmountTotal').text(formatNumber(sumValue));
    }

    function escapeHtml(str) {
        return String(str == null ? '' : str).replace(/[&<>"']/g, function(c) {
            return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c];
        });
    }

    function printStyledReport() {
        var theme = reportThemes[currentReportTheme];
        var dt = $('#serverSideTable').DataTable();

        var headers = [];
        var visibleIdxs = [];
        var amountColPos = -1;

        dt.columns().every(function() {
            if (!this.visible()) return;

            var colIdx = this.index();
            var txt = $(this.header()).text().trim();

            if (txt === 'الإجراءات') return;

            headers.push(txt);
            visibleIdxs.push(colIdx);

            if (txt === 'المبلغ') amountColPos = headers.length - 1;
        });

        var rowsHtml = '';
        var rowIter = 0;
        var sumValue = 0;

        var allRows = dt.rows({ search: 'applied' }).nodes();

        $(allRows).each(function() {
            var $tr = $(this);
            if ($tr.find('.dataTables_empty').length) return;

            rowIter++;
            var rowClass = (rowIter % 2 === 0) ? 'row-even' : '';
            var rowHtml = '<tr class="' + rowClass + '">';

            visibleIdxs.forEach(function(colIdx, posIdx) {
                var cellNode = null;
                try {
                    cellNode = dt.cell($tr.get(0), colIdx).node();
                } catch (e) {}

                var text = cellNode ? $(cellNode).text().trim() : '';
                rowHtml += '<td>' + escapeHtml(text) + '</td>';

                if (posIdx === amountColPos) {
                    sumValue += parseNumber(text);
                }
            });

            rowHtml += '</tr>';
            rowsHtml += rowHtml;
        });

        var totalsRow = '<tr class="totals-sum-row">';
        headers.forEach(function(h, idx) {
            if (idx === 0) {
                totalsRow += '<td class="totals-label">المجموع</td>';
            } else if (idx === amountColPos) {
                totalsRow += '<td class="totals-value">' + formatNumber(sumValue) + '</td>';
            } else {
                totalsRow += '<td></td>';
            }
        });
        totalsRow += '</tr>';

        var now = new Date();
        var pad = function(n) { return ('0' + n).slice(-2); };
        var dateStr = now.getFullYear() + '-' + pad(now.getMonth() + 1) + '-' + pad(now.getDate());
        var timeStr = pad(now.getHours()) + ':' + pad(now.getMinutes());

        var headerHtml =
            '<div class="report-header">' +
                '<table style="width:100%; table-layout:fixed; direction:rtl; border-collapse:collapse;">' +
                    '<tr>' +
                        '<td style="width:36%; vertical-align:middle; text-align:right; direction:rtl; padding:0 0 0 10px;">' +
                            '<div style="font-size:16px; font-weight:bold; line-height:1.6; color:' + theme.primary + ';">' + escapeHtml(reportSettings.siteName) + '</div>' +
                            (reportSettings.address ? '<div style="font-size:11px; font-weight:bold; line-height:1.5;">' + escapeHtml(reportSettings.address) + '</div>' : '') +
                            (reportSettings.mobile ? '<div style="font-size:11px; font-weight:bold; line-height:1.5;">' + escapeHtml(reportSettings.mobile) + '</div>' : '') +
                            '<div style="font-size:11px; font-weight:bold; line-height:1.5;">الرقم الضريبى: ' + escapeHtml(reportSettings.taxNumber) + '</div>' +
                        '</td>' +
                        '<td style="width:28%; vertical-align:middle; text-align:center; padding:0 8px;">' +
                            (reportSettings.logo ? '<img style="max-height:72px; max-width:100%;" src="' + reportSettings.logo + '">' : '') +
                        '</td>' +
                        '<td style="width:36%; vertical-align:middle; text-align:left; direction:ltr; padding:0 10px 0 0;">' +
                            '<div style="font-size:16px; font-weight:bold; line-height:1.6; color:' + theme.primary + ';">' + escapeHtml(reportSettings.siteNameEn) + '</div>' +
                            (reportSettings.addressEn ? '<div style="font-size:11px; font-weight:bold; line-height:1.5;">' + escapeHtml(reportSettings.addressEn) + '</div>' : '') +
                            (reportSettings.mobileEn ? '<div style="font-size:11px; font-weight:bold; line-height:1.5;">' + escapeHtml(reportSettings.mobileEn) + '</div>' : '') +
                            '<div style="font-size:11px; font-weight:bold; line-height:1.5;">Tax Number: ' + escapeHtml(reportSettings.taxNumberEn) + '</div>' +
                        '</td>' +
                    '</tr>' +
                '</table>' +
            '</div>';

        var titleHtml =
            '<div class="inv-title-block">' +
                '<div class="inv-title-ar">' + escapeHtml(reportTitle) + '</div>' +
                '<div class="inv-number">تاريخ الإصدار | Issued: <strong>' + dateStr + ' — ' + timeStr + '</strong></div>' +
            '</div>';

        var metaHtml =
            '<table class="meta-table"><tr>' +
                '<td><span class="meta-lbl">اسم التقرير</span>' + escapeHtml(reportTitle) + '</td>' +
                '<td><span class="meta-lbl">المستخدم</span>' + escapeHtml(reportUserName) + '</td>' +
                '<td><span class="meta-lbl">عدد السجلات</span>' + rowIter + '</td>' +
                '<td><span class="meta-lbl">نوع الحركة</span>يومية</td>' +
            '</tr></table>';

        var tableHeadHtml = '<tr class="items-head-row">';
        headers.forEach(function(h) {
            tableHeadHtml += '<th>' + escapeHtml(h) + '</th>';
        });
        tableHeadHtml += '</tr>';

        var fullHtml =
            '<!DOCTYPE html>' +
            '<html lang="ar" dir="rtl">' +
            '<head>' +
                '<meta charset="UTF-8">' +
                '<title>' + escapeHtml(reportTitle) + '</title>' +
                '<link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&display=swap" rel="stylesheet">' +
                '<style>' +
                    '@page  { margin: 10mm; }' +
                    ':root{' +
                        '--theme-primary:' + theme.primary + ';' +
                        '--theme-primary-dk:' + theme.primaryDk + ';' +
                        '--theme-accent:' + theme.accent + ';' +
                        '--theme-accent-lt:' + theme.accentLt + ';' +
                    '}' +
                    'html,body{margin:0;padding:0;}' +
                    'body{font-family:"Tajawal",Tahoma,Arial,sans-serif;direction:rtl;color:#111;background:#fff;padding:8px;}' +
                    '*{-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important;color-adjust:exact !important;box-sizing:border-box;}' +
                    '.report-header{margin-bottom:8px;padding-bottom:6px;border-bottom:2px solid var(--theme-primary);}' +
                    '.inv-title-block{text-align:center;border-top:3px solid var(--theme-primary);border-bottom:3px solid var(--theme-primary);padding:7px 0;margin-bottom:10px;}' +
                    '.inv-title-ar{font-size:19px;font-weight:900;color:var(--theme-primary);}' +
                    '.inv-number{font-size:11px;color:#555;margin-top:3px;}' +
                    '.inv-number strong{color:var(--theme-accent);font-size:12px;}' +
                    '.meta-table{width:100%;table-layout:fixed;background:var(--theme-primary);color:#fff;margin-bottom:10px;border-collapse:collapse;border-radius:3px;overflow:hidden;}' +
                    '.meta-table td{padding:6px 8px;font-size:11px;text-align:center;vertical-align:middle;}' +
                    '.meta-lbl{display:block;color:var(--theme-accent-lt);font-weight:bold;font-size:10px;margin-bottom:2px;}' +
                    '.items-tbl{width:100%;border-collapse:collapse;table-layout:fixed;border:2px solid #333;}' +
                    '.items-tbl thead th{background:var(--theme-primary);color:#fff;text-align:center;font-size:11px;font-weight:bold;padding:7px 3px;border:1px solid var(--theme-primary-dk);}' +
                    '.items-tbl tbody td{border:1px solid #333;padding:6px 4px;font-size:11px;font-weight:bold;vertical-align:middle;text-align:center;word-break:break-word;}' +
                    '.items-tbl tbody tr.row-even td{background:#fafafa;}' +
                    '.items-tbl thead th:nth-child(1), .items-tbl tbody td:nth-child(1){width:32px;min-width:32px;max-width:32px;}' +
                    '.items-tbl thead th:nth-child(2), .items-tbl tbody td:nth-child(2){width:40%;}' +
                    '.items-tbl thead th:nth-child(3), .items-tbl tbody td:nth-child(3){width:8%;}' +
                    '.items-tbl thead th:nth-child(4), .items-tbl tbody td:nth-child(4){width:13%;}' +
                    '.items-tbl thead th:nth-child(5), .items-tbl tbody td:nth-child(5){width:11%;}' +
                    '.items-tbl thead th:nth-child(6), .items-tbl tbody td:nth-child(6){width:8%;}' +
                    '.items-tbl thead th:nth-child(7), .items-tbl tbody td:nth-child(7){width:13%;border-left:2px solid #888 !important;}' +
                    '.items-tbl tbody tr.totals-sum-row td{background:var(--theme-primary) !important;color:#fff !important;font-size:12px !important;font-weight:bold !important;padding:8px 4px !important;border:1px solid var(--theme-primary-dk) !important;}' +
                    '.items-tbl tbody tr.totals-sum-row td.totals-value{color:var(--theme-accent-lt) !important;}' +
                '</style>' +
            '</head>' +
            '<body>' +
                headerHtml +
                titleHtml +
                metaHtml +
                '<table class="items-tbl">' +
                    '<thead>' + tableHeadHtml + '</thead>' +
                    '<tbody>' + rowsHtml + totalsRow + '</tbody>' +
                '</table>' +
                '<script>window.addEventListener("load", function(){ setTimeout(function(){ window.focus(); window.print(); }, 300); });<\/script>' +
            '</body>' +
            '</html>';

        var printWin = window.open('', '_blank', 'width=1400,height=900');
        if (!printWin) {
            alert('يرجى السماح بالنوافذ المنبثقة في المتصفح للطباعة');
            return;
        }

        printWin.document.open();
        printWin.document.write(fullHtml);
        printWin.document.close();

        closeReportThemeModal();
    }

    $('.datepicker').datepicker({
        autoclose: true,
        rtl: true,
        format: 'yyyy-mm-dd',
        language: "ar",
    });

    $('.select2List').select2();

    $(document).ready(function() {
        $('.dt-buttons .buttons-print').hide();

        setTimeout(function() {
            var dt;
            try {
                dt = $('#serverSideTable').DataTable();
            } catch (e) {
                return;
            }

            dt.on('xhr.dt', function(e, settings, json) {
                setTopBoxes(json);
            });

            dt.on('draw.dt', function() {
                setTimeout(function() {
                    updateVisibleAmountTotal();
                }, 50);
            });

            var ajaxJson = dt.ajax.json ? dt.ajax.json() : null;
            if (ajaxJson) {
                setTopBoxes(ajaxJson);
            }

            setTimeout(function() {
                updateVisibleAmountTotal();
            }, 300);
        }, 500);
    });

    document.addEventListener('click', function(e) {
        var modal = document.getElementById('report-theme-modal');
        if (e.target === modal) closeReportThemeModal();
    });
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layouts.front', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/mwarsha2023/public_html/test4.mwarsha.com/resources/views/transactions/index.blade.php ENDPATH**/ ?>