

<?php $__env->startSection('title', 'Daily Summary Report'); ?>

<?php $__env->startSection('content'); ?>
<div class="content-wrapper">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb mb-1">
                    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard.reports')); ?>">Reports</a></li>
                    <li class="breadcrumb-item active">Daily Summary</li>
                </ol>
            </nav>
            <h4 class="mb-0">Daily Summary Report</h4>
        </div>
        <?php if($canExport): ?>
        <a href="<?php echo e(route('dashboard.reports.daily-summary.export', request()->query())); ?>" class="btn btn-success">
            <i class="bi bi-file-earmark-excel me-1"></i> Export to Excel
        </a>
        <?php endif; ?>
    </div>

    <!-- Filters -->
    <div class="card border-0 shadow-sm mb-4">
        <div class="card-body">
            <form method="GET" action="<?php echo e(route('dashboard.reports.daily-summary')); ?>" class="row g-3">
                <div class="col-md-4">
                    <label class="form-label">Date From</label>
                    <input type="date" name="date_from" class="form-control" value="<?php echo e($dateFrom); ?>">
                </div>
                <div class="col-md-4">
                    <label class="form-label">Date To</label>
                    <input type="date" name="date_to" class="form-control" value="<?php echo e($dateTo); ?>">
                </div>
                <div class="col-md-4 d-flex align-items-end">
                    <button type="submit" class="btn btn-primary">
                        <i class="bi bi-funnel me-1"></i> Filter
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- Summary Stats -->
    <div class="row g-3 mb-4">
        <div class="col-md-2">
            <div class="card border-0 shadow-sm bg-primary bg-opacity-10">
                <div class="card-body text-center">
                    <h4 class="text-primary mb-0"><?php echo e(number_format($summary['total_calls'])); ?></h4>
                    <small class="text-muted">Total Calls</small>
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="card border-0 shadow-sm bg-success bg-opacity-10">
                <div class="card-body text-center">
                    <h4 class="text-success mb-0"><?php echo e(number_format($summary['total_sms'])); ?></h4>
                    <small class="text-muted">Total SMS</small>
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="card border-0 shadow-sm bg-warning bg-opacity-10">
                <div class="card-body text-center">
                    <h4 class="text-warning mb-0"><?php echo e(number_format($summary['total_promotions'])); ?></h4>
                    <small class="text-muted">Promotions</small>
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="card border-0 shadow-sm bg-info bg-opacity-10">
                <div class="card-body text-center">
                    <h4 class="text-info mb-0"><?php echo e(number_format($summary['total_sessions'])); ?></h4>
                    <small class="text-muted">Sessions</small>
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="card border-0 shadow-sm bg-danger bg-opacity-10">
                <div class="card-body text-center">
                    <h4 class="text-danger mb-0"><?php echo e(number_format($summary['total_new_users'])); ?></h4>
                    <small class="text-muted">New Users</small>
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="card border-0 shadow-sm bg-secondary bg-opacity-10">
                <div class="card-body text-center">
                    <h4 class="text-secondary mb-0"><?php echo e($summary['avg_daily_calls']); ?></h4>
                    <small class="text-muted">Avg Daily Calls</small>
                </div>
            </div>
        </div>
    </div>

    <!-- Chart -->
    <div class="card border-0 shadow-sm mb-4">
        <div class="card-header bg-transparent">
            <h6 class="mb-0">Activity Trend</h6>
        </div>
        <div class="card-body">
            <canvas id="activityTrendChart" height="100"></canvas>
        </div>
    </div>

    <!-- Report Table -->
    <div class="card border-0 shadow-sm">
        <div class="card-header bg-transparent">
            <h6 class="mb-0">Daily Breakdown</h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Day</th>
                            <th class="text-center">Calls</th>
                            <th class="text-center">SMS</th>
                            <th class="text-center">Promotions</th>
                            <th class="text-center">Sessions</th>
                            <th class="text-center">New Users</th>
                            <th class="text-center">Total Activity</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $report; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td>
                                <strong><?php echo e($day['date']); ?></strong>
                            </td>
                            <td>
                                <span class="text-muted"><?php echo e($day['day_name']); ?></span>
                            </td>
                            <td class="text-center">
                                <span class="badge bg-primary"><?php echo e(number_format($day['calls'])); ?></span>
                            </td>
                            <td class="text-center">
                                <span class="badge bg-success"><?php echo e(number_format($day['sms'])); ?></span>
                            </td>
                            <td class="text-center">
                                <span class="badge bg-warning text-dark"><?php echo e(number_format($day['promotions'])); ?></span>
                            </td>
                            <td class="text-center">
                                <span class="badge bg-info"><?php echo e(number_format($day['sessions'])); ?></span>
                            </td>
                            <td class="text-center">
                                <span class="badge bg-danger"><?php echo e(number_format($day['new_users'])); ?></span>
                            </td>
                            <td class="text-center">
                                <strong class="text-dark">
                                    <?php echo e(number_format($day['calls'] + $day['sms'] + $day['promotions'] + $day['sessions'])); ?>

                                </strong>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8" class="text-center text-muted py-4">No data found for the selected criteria.</td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                    <tfoot class="table-light">
                        <tr>
                            <th colspan="2">Total</th>
                            <th class="text-center"><?php echo e(number_format($summary['total_calls'])); ?></th>
                            <th class="text-center"><?php echo e(number_format($summary['total_sms'])); ?></th>
                            <th class="text-center"><?php echo e(number_format($summary['total_promotions'])); ?></th>
                            <th class="text-center"><?php echo e(number_format($summary['total_sessions'])); ?></th>
                            <th class="text-center"><?php echo e(number_format($summary['total_new_users'])); ?></th>
                            <th class="text-center">
                                <strong>
                                    <?php echo e(number_format($summary['total_calls'] + $summary['total_sms'] + $summary['total_promotions'] + $summary['total_sessions'])); ?>

                                </strong>
                            </th>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        const report = <?php echo json_encode($report, 15, 512) ?>;
        const labels = report.map(d => d.date).reverse();

        new Chart(document.getElementById('activityTrendChart'), {
            type: 'line',
            data: {
                labels: labels,
                datasets: [{
                        label: 'Calls',
                        data: report.map(d => d.calls).reverse(),
                        borderColor: '#667eea',
                        backgroundColor: 'rgba(102, 126, 234, 0.1)',
                        fill: false,
                        tension: 0.4
                    },
                    {
                        label: 'SMS',
                        data: report.map(d => d.sms).reverse(),
                        borderColor: '#28a745',
                        backgroundColor: 'rgba(40, 167, 69, 0.1)',
                        fill: false,
                        tension: 0.4
                    },
                    {
                        label: 'Promotions',
                        data: report.map(d => d.promotions).reverse(),
                        borderColor: '#ffc107',
                        backgroundColor: 'rgba(255, 193, 7, 0.1)',
                        fill: false,
                        tension: 0.4
                    },
                    {
                        label: 'Sessions',
                        data: report.map(d => d.sessions).reverse(),
                        borderColor: '#17a2b8',
                        backgroundColor: 'rgba(23, 162, 184, 0.1)',
                        fill: false,
                        tension: 0.4
                    }
                ]
            },
            options: {
                responsive: true,
                plugins: {
                    legend: {
                        position: 'top'
                    }
                },
                scales: {
                    y: {
                        beginAtZero: true
                    }
                },
                interaction: {
                    intersect: false,
                    mode: 'index'
                }
            }
        });
    });
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\xampp82\htdocs\AutoPromix\backend\resources\views\dashboard\reports\daily-summary.blade.php ENDPATH**/ ?>