<?php $__env->startSection('title', 'Message Logs'); ?>
<?php $__env->startSection('page-title', 'Message Logs (SMS & WhatsApp)'); ?>

<?php $__env->startSection('content'); ?>
<div class="table-container">
    <!-- Filters -->
    <form action="<?php echo e(route('dashboard.sms-logs')); ?>" method="GET" class="row g-3 mb-4">
        <div class="col-md-2">
            <select name="channel" class="form-select">
                <option value="">All Channels</option>
                <option value="sms" <?php echo e(request('channel') == 'sms' ? 'selected' : ''); ?>>SMS</option>
                <option value="whatsapp" <?php echo e(request('channel') == 'whatsapp' ? 'selected' : ''); ?>>WhatsApp</option>
            </select>
        </div>

        <div class="col-md-2">
            <select name="status" class="form-select">
                <option value="">All Status</option>
                <option value="sent" <?php echo e(request('status') == 'sent' ? 'selected' : ''); ?>>Sent</option>
                <option value="failed" <?php echo e(request('status') == 'failed' ? 'selected' : ''); ?>>Failed</option>
                <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
            </select>
        </div>

        <div class="col-md-2">
            <input type="date" name="from_date" class="form-control" placeholder="From" value="<?php echo e(request('from_date')); ?>">
        </div>

        <div class="col-md-2">
            <input type="date" name="to_date" class="form-control" placeholder="To" value="<?php echo e(request('to_date')); ?>">
        </div>

        <div class="col-md-3">
            <button type="submit" class="btn btn-primary me-2">
                <i class="bi bi-filter"></i> Filter
            </button>
            <a href="<?php echo e(route('dashboard.sms-logs')); ?>" class="btn btn-outline-secondary">
                <i class="bi bi-x"></i> Clear
            </a>
        </div>
    </form>

    <!-- Results Info -->
    <div class="d-flex justify-content-between align-items-center mb-3">
        <span class="text-muted">Showing <?php echo e($smsLogs->count()); ?> of <?php echo e($smsLogs->total()); ?> message logs</span>
    </div>

    <!-- Message Logs Table -->
    <div class="table-responsive">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>User</th>
                    <th>Channel</th>
                    <th>Phone / Contact</th>
                    <th>Message</th>
                    <th>Status</th>
                    <th>Sent At</th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $smsLogs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sms): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td><?php echo e($sms->id); ?></td>
                    <td>
                        <?php if($sms->user): ?>
                        <a href="<?php echo e(route('dashboard.user-details', $sms->user_id)); ?>">
                            <?php echo e($sms->user->name); ?>

                        </a>
                        <?php else: ?>
                        <span class="text-muted">N/A</span>
                        <?php endif; ?>
                    </td>
                    <td>
                        <?php if(($sms->channel ?? 'sms') == 'whatsapp'): ?>
                        <span class="badge bg-success"><i class="bi bi-whatsapp"></i> WhatsApp</span>
                        <?php else: ?>
                        <span class="badge bg-primary"><i class="bi bi-chat-text"></i> SMS</span>
                        <?php endif; ?>
                    </td>
                    <td>
                        <div><?php echo e($sms->phone_number); ?></div>
                        <?php if($sms->contact_name): ?>
                        <small class="text-muted"><?php echo e($sms->contact_name); ?></small>
                        <?php endif; ?>
                    </td>
                    <td>
                        <span title="<?php echo e($sms->message); ?>">
                            <?php echo e(Str::limit($sms->message, 50)); ?>

                        </span>
                    </td>
                    <td>
                        <?php
                        $statusClass = match(strtolower($sms->status)) {
                        'sent', 'delivered' => 'bg-success',
                        'pending' => 'bg-warning',
                        'failed' => 'bg-danger',
                        default => 'bg-secondary',
                        };
                        ?>
                        <span class="badge <?php echo e($statusClass); ?>">
                            <?php echo e(ucfirst($sms->status)); ?>

                        </span>
                    </td>
                    <td><?php echo e($sms->sent_at?->format('M d, Y H:i:s') ?? 'N/A'); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="7" class="text-center text-muted py-4">
                        No message logs found
                    </td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>

    <!-- Pagination -->
    <div class="d-flex justify-content-center mt-4">
        <?php echo e($smsLogs->withQueryString()->links()); ?>

    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/zwfgftjb/autopromix.byteengine.in/resources/views/dashboard/sms-logs.blade.php ENDPATH**/ ?>