<?php $__env->startSection('title', 'Riwayat Pengiriman WhatsApp'); ?>

<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-12">
        <div class="card card-primary card-outline">
            <div class="card-header">
                <h3 class="card-title">Filter Riwayat</h3>
            </div>
            <div class="card-body">
                <form action="<?php echo e(route('laporan.riwayat-wa')); ?>" method="GET">
                    <div class="row">
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Pencarian</label>
                                <input type="text" name="search" class="form-control" placeholder="Nama / No WA / NIS" value="<?php echo e(request('search')); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Tanggal Mulai</label>
                                <input type="date" name="tanggal_mulai" class="form-control" value="<?php echo e(request('tanggal_mulai')); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Tanggal Sampai</label>
                                <input type="date" name="tanggal_sampai" class="form-control" value="<?php echo e(request('tanggal_sampai')); ?>">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Status</label>
                                <select name="status" class="form-control">
                                    <option value="">-- Semua Status --</option>
                                    <option value="berhasil" <?php echo e(request('status') == 'berhasil' ? 'selected' : ''); ?>>Berhasil</option>
                                    <option value="gagal" <?php echo e(request('status') == 'gagal' ? 'selected' : ''); ?>>Gagal</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label>Jenis Pesan</label>
                                <select name="jenis_pesan" class="form-control">
                                    <option value="">-- Semua Jenis --</option>
                                    <option value="Bukti Transaksi" <?php echo e(request('jenis_pesan') == 'Bukti Transaksi' ? 'selected' : ''); ?>>Bukti Transaksi</option>
                                    <option value="Tagihan Tunggakan" <?php echo e(request('jenis_pesan') == 'Tagihan Tunggakan' ? 'selected' : ''); ?>>Tagihan Tunggakan</option>
                                    <option value="Tagihan Tunggakan massal" <?php echo e(request('jenis_pesan') == 'Tagihan Tunggakan massal' ? 'selected' : ''); ?>>Tagihan Tunggakan massal</option>
                                    <option value="Rekap Pembayaran" <?php echo e(request('jenis_pesan') == 'Rekap Pembayaran' ? 'selected' : ''); ?>>Rekap Pembayaran</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-9 d-flex align-items-end mb-3">
                            <button type="submit" class="btn btn-primary mr-2"><i class="fas fa-search"></i> Cari</button>
                            <a href="<?php echo e(route('laporan.riwayat-wa')); ?>" class="btn btn-default mr-2">Reset</a>
                            
                            <a href="<?php echo e(route('laporan.riwayat-wa.cetak', request()->all())); ?>" target="_blank" class="btn btn-success ml-auto">
                                <i class="fas fa-print"></i> Cetak Riwayat
                            </a>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="card">
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-striped table-hover">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th>Tanggal</th>
                                <th>NIS</th>
                                <th>Nama Siswa</th>
                                <th>Nomor WhatsApp</th>
                                <th>Jenis Pesan</th>
                                <th>Dikirim Oleh</th>
                                <th>Status</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $riwayats; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $riwayat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($riwayats->firstItem() + $index); ?></td>
                                    <td><?php echo e($riwayat->created_at->format('d-m-Y H:i')); ?></td>
                                    <td><?php echo e($riwayat->nis ?? '-'); ?></td>
                                    <td><?php echo e($riwayat->nama_siswa ?? '-'); ?></td>
                                    <td><?php echo e($riwayat->no_wa); ?></td>
                                    <td><?php echo e($riwayat->jenis_pesan); ?></td>
                                    <td><?php echo e($riwayat->dikirimOleh->name ?? '-'); ?></td>
                                    <td>
                                        <?php if($riwayat->status == 'berhasil'): ?>
                                            <span class="badge badge-success">Berhasil</span>
                                        <?php else: ?>
                                            <span class="badge badge-danger" title="<?php echo e($riwayat->keterangan); ?>">Gagal</span>
                                            <?php if($riwayat->keterangan): ?>
                                                <small class="d-block text-muted"><?php echo e($riwayat->keterangan); ?></small>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="7" class="text-center">Tidak ada data riwayat pengiriman WhatsApp.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php if($riwayats->hasPages()): ?>
            <div class="card-footer">
                <?php echo e($riwayats->links('pagination::bootstrap-4')); ?>

            </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Herd\spp_app\resources\views/laporan/riwayat-wa.blade.php ENDPATH**/ ?>