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

<?php
    $printSettings = $settings ?? [];
?>

<?php $__env->startPush('css'); ?>
<style>
    .orderTasksWrap {
        overflow-x: auto;
    }

    .orderTasksWrap .table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed !important;
    }

    .orderTasksWrap .table th,
    .orderTasksWrap .table td,
    .dataTables_scrollHeadInner table th,
    .dataTables_scrollBody table td {
        vertical-align: middle !important;
        text-align: center !important;
        box-sizing: border-box !important;
        border: 1px solid #d2d6de !important;
    }

    .orderTasksWrap .table th,
    .dataTables_scrollHeadInner table th {
        white-space: nowrap !important;
        font-weight: 700 !important;
        background: #fff !important;
    }

    .orderTasksWrap .table td,
    .dataTables_scrollBody table td {
        font-weight: 600 !important;
        background: #fff !important;
    }

    .dataTables_scrollHeadInner,
    .dataTables_scrollHeadInner table,
    .dataTables_scrollBody table {
        width: 100% !important;
        min-width: 100% !important;
    }

    .dataTables_scrollBody {
        border-left: 1px solid #d2d6de !important;
        border-right: 1px solid #d2d6de !important;
        border-bottom: 1px solid #d2d6de !important;
    }

    .orderTasksWrap .table th.col-index,
    .orderTasksWrap .table td.col-index,
    .dataTables_scrollHeadInner table th.col-index {
        width: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
    }

    .orderTasksWrap .table th.col-branch,
    .orderTasksWrap .table td.col-branch,
    .dataTables_scrollHeadInner table th.col-branch {
        width: 110px !important;
        min-width: 110px !important;
    }

    .orderTasksWrap .table th.col-date,
    .orderTasksWrap .table td.col-date,
    .dataTables_scrollHeadInner table th.col-date {
        width: 115px !important;
        min-width: 115px !important;
        max-width: 115px !important;
        white-space: nowrap !important;
    }

    .orderTasksWrap .table th.col-task,
    .orderTasksWrap .table td.col-task,
    .dataTables_scrollHeadInner table th.col-task {
        width: 150px !important;
        min-width: 150px !important;
        white-space: normal !important;
        line-height: 1.45 !important;
    }

    .orderTasksWrap .table th.col-client,
    .orderTasksWrap .table td.col-client,
    .dataTables_scrollHeadInner table th.col-client {
        width: 170px !important;
        min-width: 170px !important;
    }

    .orderTasksWrap .table th.col-car,
    .orderTasksWrap .table td.col-car,
    .dataTables_scrollHeadInner table th.col-car {
        width: 165px !important;
        min-width: 165px !important;
        white-space: normal !important;
        line-height: 1.45 !important;
    }

    .orderTasksWrap .table th.col-department,
    .orderTasksWrap .table td.col-department,
    .dataTables_scrollHeadInner table th.col-department {
        width: 115px !important;
        min-width: 115px !important;
    }

    .orderTasksWrap .table th.col-user,
    .orderTasksWrap .table td.col-user,
    .dataTables_scrollHeadInner table th.col-user {
        width: 115px !important;
        min-width: 115px !important;
    }

    .orderTasksWrap .table th.col-invoice,
    .orderTasksWrap .table td.col-invoice,
    .dataTables_scrollHeadInner table th.col-invoice {
        width: 90px !important;
        min-width: 90px !important;
    }

    .orderTasksWrap .table th.col-status,
    .orderTasksWrap .table td.col-status,
    .dataTables_scrollHeadInner table th.col-status {
        width: 150px !important;
        min-width: 150px !important;
    }

    .orderTasksWrap .table th.col-actions,
    .orderTasksWrap .table td.col-actions,
    .dataTables_scrollHeadInner table th.col-actions {
        width: 110px !important;
        min-width: 110px !important;
        max-width: 110px !important;
        border-right: 3px solid #555 !important;
        white-space: normal !important;
    }

    .dataTables_scrollBody table tbody td.col-actions {
        border-right: 3px solid #555 !important;
    }

    .orderTasksWrap .table td.col-actions .btn {
        display: inline-block !important;
        min-width: 0 !important;
        width: auto !important;
        height: auto !important;
        line-height: 1.42857143 !important;
        padding: 2px 5px !important;
        margin: 2px !important;
        font-size: 12px !important;
    }

    .orderTasksWrap .table td.col-actions .btn i {
        margin: 0 !important;
        font-size: inherit !important;
    }

    .orderTasksWrap .table td.col-status form {
        margin: 3px 0 !important;
    }

    .orderTasksWrap .table td.col-status .badge {
        display: inline-block !important;
        margin-bottom: 4px !important;
        padding: 6px 8px !important;
        font-size: 12px !important;
    }

    .dt-buttons .buttons-print {
        display: none !important;
    }

    @media  print {
        .hideprint,
        .box-header,
        .content-header,
        nav, header, footer,
        .sidebar, .main-sidebar, .navbar, .main-header,
        .btn, .pagination, .dataTables_length, .dataTables_filter, .dataTables_info {
            display: none !important;
        }
    }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            المهام
            <span style="float:left; display:flex; gap:5px; align-items:center;">
                <?php if($currentUser->can('Create OrderTasks')): ?>
                    <a class="btn btn-success" href="<?php echo e(route('ordertasks.create')); ?>">
                        <i class="fa fa-plus"></i> إضافة
                    </a>
                <?php endif; ?>

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

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

        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body orderTasksWrap">
                        <table class="table table-bordered table-hover dataTableTT" id="orderTaskTable">
                            <thead>
                                <tr>
                                    <th class="col-index">#</th>
                                    <th class="col-branch">الفرع</th>
                                    <th class="col-date">التاريخ</th>
                                    <th class="col-task">المهمة</th>
                                    <th class="col-client">العميل</th>
                                    <th class="col-car">السيارة</th>
                                    <th class="col-department">القسم</th>
                                    <th class="col-user">المسئول</th>
                                    <th class="col-invoice">الفاتورة</th>
                                    <th class="col-status">الحالة</th>
                                    <th class="col-actions no-sort hideprint">العملية</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php
                                $bg = [
                                    'معلق'=>'#FF9800;',
                                    'مراجعة'=>'#337ab7;',
                                    'قبول'=>'#008d4c;',
                                    'رفض'=>'#d73925;',
                                ];
                            ?>

                            <?php $__currentLoopData = $list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php
                                    $client = optional($t->client);
                                    $userDepartments = $currentUser->dep_id;
                                ?>
                                <tr>
                                    <td class="col-index"><?php echo e($loop->iteration); ?></td>
                                    <td class="col-branch"><?php echo e(optional($t->branche)->name); ?></td>
                                    <td class="col-date"><?php echo e($t->notifcation_date); ?></td>
                                    <td class="col-task"><?php echo e(optional($t->task)->title); ?></td>
                                    <td class="col-client"><?php echo e($client->name); ?></td>
                                    <td class="col-car"><?php echo e($client->model); ?></td>
                                    <td class="col-department"><?php echo e(optional($t->department)->name); ?></td>
                                    <td class="col-user"><?php echo e(optional($t->user)->name); ?></td>
                                    <td class="col-invoice">
                                        <?php if($t->order_id): ?>
                                            <a target="_blank" title="التفاصيل" href="<?php echo e(route('invoice.show',$t->order_id)); ?>">
                                                #<?php echo e($t->order_id); ?>

                                            </a>
                                        <?php endif; ?>
                                    </td>
                                    <td class="col-status">
                                        <span style="color:#fff;background-color: <?php echo e($bg[$t->status] ?? '#777'); ?>" class="badge">
                                            <?php echo e($t->status); ?>

                                        </span>

                                        <?php if($t->status != "قبول" && ($t->user_id == $currentUser->id || ($userDepartments && in_array($t->department_id,$userDepartments)))): ?>
                                            <form action="<?php echo e(route('ordertasks.update',$t->id)); ?>" method="post">
                                                <?php echo e(csrf_field()); ?>

                                                <?php echo e(method_field('PUT')); ?>

                                                <input type="hidden" name="status" value="قبول"/>
                                                <button class="btn btn-success btn-xs" type="submit">
                                                    <i class="fa fa-save"></i> قبول
                                                </button>
                                            </form>
                                        <?php endif; ?>

                                        <?php if(!in_array($t->status,['قبول','رفض']) && ($t->user_id == $currentUser->id || ($userDepartments && in_array($t->department_id,$userDepartments)))): ?>
                                            <form action="<?php echo e(route('ordertasks.update',$t->id)); ?>" method="post">
                                                <?php echo e(csrf_field()); ?>

                                                <?php echo e(method_field('PUT')); ?>

                                                <input type="hidden" name="status" value="رفض"/>
                                                <button class="btn btn-danger btn-xs" type="submit">
                                                    <i class="fa fa-save"></i> رفض
                                                </button>
                                            </form>
                                        <?php endif; ?>
                                    </td>
                                    <td class="col-actions hideprint">
                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Edit OrderTasks')): ?>
                                            <a href="<?php echo e(route('ordertasks.edit',$t->id)); ?>" class="btn btn-xs btn-primary">
                                                <i class="fa fa-edit"></i>
                                            </a>
                                        <?php endif; ?>

                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Delete OrderTasks')): ?>
                                            <a class="btn btn-xs btn-danger remove-record"
                                               data-url="<?php echo e(route('ordertasks.destroy',$t->id)); ?>"
                                               data-id="<?php echo e($t->id); ?>">
                                                <i class="fa fa-trash"></i>
                                            </a>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <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:520px; 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('green')" data-theme="green" style="border:2px solid #ddd; border-radius:8px; padding:12px; cursor:pointer; text-align:center; background:#fff;">
                        <div style="height:34px; background:#1f6b52; border-radius:4px; margin-bottom:10px;"></div>
                        <div style="height:10px; background:#7bd389; border-radius:2px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#e8f5e9; border-radius:2px;"></div>
                        <div style="margin-top:10px; font-size:14px; font-weight:bold; color:#1b5e38;">أخضر</div>
                    </div>

                    <div class="report-theme-card" onclick="selectReportTheme('navy-gold')" data-theme="navy-gold" style="border:2px solid #1a3c5e; border-radius:8px; padding:12px; cursor:pointer; text-align:center; background:#f0f4f8;">
                        <div style="height:34px; background:#1f3a5f; border-radius:4px; margin-bottom:10px;"></div>
                        <div style="height:10px; background:#d4af37; border-radius:2px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#eef2f7; border-radius:2px;"></div>
                        <div style="margin-top:10px; font-size:14px; font-weight:bold; color:#1a3c5e;">كحلي ذهبي</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:34px; background:#6d213c; border-radius:4px; margin-bottom:10px;"></div>
                        <div style="height:10px; background:#d17a92; border-radius:2px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#fdf0f0; border-radius:2px;"></div>
                        <div style="margin-top:10px; font-size:14px; font-weight:bold; color:#6a0f2a;">بردوني</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:34px; background:#3f4a59; border-radius:4px; margin-bottom:10px;"></div>
                        <div style="height:10px; background:#c7ced6; border-radius:2px; margin-bottom:8px;"></div>
                        <div style="height:8px; background:#eceff1; border-radius:2px;"></div>
                        <div style="margin-top:10px; font-size:14px; font-weight:bold; color:#37474f;">رمادي</div>
                    </div>
                </div>

                <div style="display:flex; gap:10px; justify-content:flex-end;">
                    <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>
                    <button type="button" onclick="closeReportThemeModal()" style="padding:8px 20px; border:1px solid #ddd; border-radius:6px; background:#f5f5f5; cursor:pointer; font-size:13px;">إغلاق</button>
                </div>
            </div>
        </div>
    </section>
</div>
<?php $__env->stopSection(); ?>

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

<?php $__env->startPush('js'); ?>
<script>
    var reportThemes = {
        'navy-gold': { primary:'#1f3a5f', accent:'#d4af37', rowAlt:'#f4f7fc' },
        'green':     { primary:'#1f6b52', accent:'#7bd389', rowAlt:'#f1f8f2' },
        'gray':      { primary:'#3f4a59', accent:'#c7ced6', rowAlt:'#f5f6f7' },
        'burgundy':  { primary:'#6d213c', accent:'#d17a92', rowAlt:'#fdf5f6' }
    };

    var currentReportTheme = localStorage.getItem('ordertasks_report_theme') || 'navy-gold';

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

    var reportTitle = 'تقرير المهام';
    var reportUserName = <?php echo json_encode(optional($currentUser)->name ?? '', 15, 512) ?>;

    function setReportTheme(theme) {
        currentReportTheme = theme;
        localStorage.setItem('ordertasks_report_theme', theme);
    }

    function updateThemeCards() {
        document.querySelectorAll('.report-theme-card').forEach(function(card) {
            var theme = card.getAttribute('data-theme');
            var active = theme === currentReportTheme;
            card.style.border = active ? '2px solid #1a3c5e' : '2px solid #ddd';
            card.style.background = active ? '#f0f4f8' : '#fff';
        });
    }

    function selectReportTheme(theme) {
        setReportTheme(theme);
        updateThemeCards();
    }

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

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

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

    function stripHtmlToText(html) {
        var div = document.createElement('div');
        div.innerHTML = html == null ? '' : html;
        return (div.textContent || div.innerText || '').replace(/\s+/g, ' ').trim();
    }

    function buildReportCSS(theme) {
        return [
            ':root{',
                '--primary:' + theme.primary + ';',
                '--accent:' + theme.accent + ';',
                '--rowAlt:' + theme.rowAlt + ';',
            '}',
            '*{box-sizing:border-box;-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important;color-adjust:exact !important;}',
            'html,body{margin:0;padding:0;}',
            'body{font-family:"Tajawal","Segoe UI",Tahoma,Arial,sans-serif;direction:rtl;padding:10mm 8mm;background:#fff;color:#111;font-size:12px;}',
            '#printReport{width:100%;max-width:280mm;margin:0 auto;}',
            '.report-header{margin-bottom:8px;border-bottom:2px solid var(--primary);padding-bottom:6px;}',
            '.header-table{width:100%;border-collapse:collapse;table-layout:fixed;}',
            '.header-right{width:38%;text-align:right;vertical-align:top;}',
            '.header-center{width:24%;text-align:center;vertical-align:middle;}',
            '.header-left{width:38%;text-align:left;vertical-align:top;direction:ltr;}',
            '.site-logo{max-height:42px;max-width:100%;}',
            '.site-name-ar,.site-name-en{font-size:12px;font-weight:900;color:var(--primary);line-height:1.4;}',
            '.small-line{font-size:9px;font-weight:bold;line-height:1.35;color:#333;}',
            '.report-title-wrap{text-align:center;margin:8px 0;}',
            '.report-title-line{height:2px;background:var(--primary) !important;width:100%;}',
            '.report-title{font-size:16px;font-weight:900;color:var(--primary);padding:6px 0;}',
            '.meta-table{width:100%;table-layout:fixed;margin-bottom:8px;border-collapse:collapse;}',
            '.meta-table td{padding:6px 4px;font-size:9px;text-align:center;vertical-align:middle;background:var(--primary) !important;color:#fff !important;border:1px solid var(--primary) !important;}',
            '.meta-lbl{display:block;color:var(--accent) !important;font-weight:bold;font-size:8px;margin-bottom:2px;}',
            '.items-tbl{width:100%;table-layout:fixed;border-collapse:collapse;border:1px solid #333 !important;outline:1px solid #333 !important;outline-offset:0;}',
            '.items-tbl thead th{background:var(--primary) !important;color:#fff !important;text-align:center;font-size:8px;font-weight:bold;padding:5px 2px;line-height:1.2;word-break:break-word;border:1px solid #333 !important;}',
            '.items-tbl tbody td{padding:5px 2px;font-size:8px;font-weight:bold;vertical-align:middle;text-align:center;word-break:break-word;overflow-wrap:anywhere;white-space:pre-line;border:1px solid #333 !important;background:#fff !important;}',
            '.items-tbl tbody tr:nth-child(even) td{background:var(--rowAlt) !important;}',
            '.items-tbl thead th:first-child,.items-tbl tbody td:first-child{border-left:1px solid #333 !important;box-shadow:inset 1px 0 0 #333 !important;}',
            '.items-tbl thead th:nth-child(1), .items-tbl tbody td:nth-child(1){width:4%;}',
            '.items-tbl thead th:nth-child(5), .items-tbl tbody td:nth-child(5){width:17%;}',
            '@page{size:A4 landscape;margin:8mm;}'
        ].join('');
    }

    function printStyledReport() {
        var theme = reportThemes[currentReportTheme];
        var dt = null;

        try {
            dt = $('#orderTaskTable').DataTable();
        } catch (e) {
            dt = null;
        }

        if (!dt) {
            alert('تعذر تحميل بيانات الجدول للطباعة');
            return;
        }

        var printableColumns = [];
        dt.columns().every(function(idx) {
            var headerText = $(this.header()).text().trim();
            if (headerText === 'العملية') return;
            if (!this.visible()) return;

            printableColumns.push({
                title: headerText,
                index: idx
            });
        });

        if (!printableColumns.length) {
            alert('لا توجد أعمدة ظاهرة للطباعة');
            return;
        }

        var rowsHtml = '';
        var rowIter = 0;
        var apiRows = dt.rows({ search: 'applied' });

        apiRows.every(function() {
            var rowNode = $(this.node());
            if (!rowNode.length) return;

            rowIter++;
            var rowHtml = '<tr>';

            printableColumns.forEach(function(col) {
                var cellHtml = rowNode.find('td').eq(col.index).html();
                var cellText = stripHtmlToText(cellHtml);
                rowHtml += '<td>' + escapeHtml(cellText) + '</td>';
            });

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

        if (!rowIter) {
            alert('لا توجد بيانات للطباعة');
            return;
        }

        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 class="header-table">' +
                    '<tr>' +
                        '<td class="header-right">' +
                            '<div class="site-name-ar">' + escapeHtml(reportSettings.siteName) + '</div>' +
                            (reportSettings.address ? '<div class="small-line">' + escapeHtml(reportSettings.address) + '</div>' : '') +
                            (reportSettings.mobile ? '<div class="small-line">' + escapeHtml(reportSettings.mobile) + '</div>' : '') +
                            (reportSettings.taxNumber ? '<div class="small-line">الرقم الضريبي: ' + escapeHtml(reportSettings.taxNumber) + '</div>' : '') +
                        '</td>' +
                        '<td class="header-center">' +
                            (reportSettings.logo ? '<img class="site-logo" src="' + reportSettings.logo + '">' : '') +
                        '</td>' +
                        '<td class="header-left">' +
                            '<div class="site-name-en">' + escapeHtml(reportSettings.siteNameEn) + '</div>' +
                            (reportSettings.addressEn ? '<div class="small-line">' + escapeHtml(reportSettings.addressEn) + '</div>' : '') +
                            (reportSettings.mobileEn ? '<div class="small-line">' + escapeHtml(reportSettings.mobileEn) + '</div>' : '') +
                            ((reportSettings.taxNumberEn || reportSettings.taxNumber) ? '<div class="small-line">Tax Number: ' + escapeHtml(reportSettings.taxNumberEn || reportSettings.taxNumber) + '</div>' : '') +
                        '</td>' +
                    '</tr>' +
                '</table>' +
            '</div>';

        var titleHtml =
            '<div class="report-title-wrap">' +
                '<div class="report-title-line"></div>' +
                '<div class="report-title">' + escapeHtml(reportTitle) + '</div>' +
                '<div class="report-title-line"></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>' + dateStr + ' - ' + timeStr + '</td>' +
            '</tr></table>';

        var tableHeadHtml = '<tr>';
        printableColumns.forEach(function(col) {
            tableHeadHtml += '<th>' + escapeHtml(col.title) + '</th>';
        });
        tableHeadHtml += '</tr>';

        var html =
            '<!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>' + buildReportCSS(theme) + '</style>' +
            '</head>' +
            '<body>' +
            '<div id="printReport">' +
            headerHtml +
            titleHtml +
            metaHtml +
            '<table class="items-tbl"><thead>' + tableHeadHtml + '</thead><tbody>' + rowsHtml + '</tbody></table>' +
            '</div>' +
            '</body></html>';

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

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

        closeReportThemeModal();

        setTimeout(function () {
            printWin.focus();
            printWin.print();
        }, 700);
    }

    $(document).ready(function () {
        updateThemeCards();
    });

    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/order_task/index.blade.php ENDPATH**/ ?>