

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

    
    <form action="">
        <div class="row">
            <div class="col-md-3">
                <label for="">Dari Tanggal</label>
                <input type="date" name="dari" id="" class="form-control"
                    value="<?php echo e(isset($_GET['dari']) ? $_GET['dari'] : date('Y-m-d')); ?>">
            </div>
            <div class="col-md-3">
                <label for="">Sampai Tanggal</label>
                <input type="date" name="sampai" id="" class="form-control"
                    value="<?php echo e(isset($_GET['sampai']) ? $_GET['sampai'] : date('Y-m-d')); ?>">
            </div>
            <div class="col-md-3">
                <label for="">Cabang</label>
                <select class='form-control select2' name='branch'>
                    <option value=''>Semua Cabang</option>
                    <?php $__currentLoopData = $branch; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value='<?php echo e($item->id); ?>'
                            <?php echo e(isset($_GET['branch']) && $_GET['branch'] == $item->id ? 'selected' : ''); ?>>
                            <?php echo e($item->cabang); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="col-md-3">
                <label for="">Tipe Member</label>
                
                <select class='form-control select2' name='kategori_member' id="kategori_member_select">
                    
                    <option value=''>Semua Kategori</option>
                    <option value="komunitas"
                        <?php echo e(isset($_GET['kategori_member']) && $_GET['kategori_member'] == 'komunitas' ? 'selected' : ''); ?>>
                        Komunitas</option>
                    <option value="universitas"
                        <?php echo e(isset($_GET['kategori_member']) && $_GET['kategori_member'] == 'universitas' ? 'selected' : ''); ?>>
                        Universitas</option>
                    <option value="corporate"
                        <?php echo e(isset($_GET['kategori_member']) && $_GET['kategori_member'] == 'corporate' ? 'selected' : ''); ?>>
                        Corporate</option>
                    <option value="sekolah"
                        <?php echo e(isset($_GET['kategori_member']) && $_GET['kategori_member'] == 'sekolah' ? 'selected' : ''); ?>>
                        Sekolah</option>
                </select>
            </div>
            <div class="col">
                <br>
                <button type="submit" class="btn btn-primary"><span class="fa fa-filter"></span> Filter</button>
                <?php if(isset($_GET['dari'])): ?>
                    <a href='<?php echo e(url("list-member?dari=$_GET[dari]&sampai=$_GET[sampai]&branch=$_GET[branch]&kategori_member=$_GET[kategori_member]&export=true")); ?>'
                        class="btn btn-success"><span class="fa fa-file-excel"></span> Export</a>
                <?php endif; ?>
            </div>
        </div>
    </form>
    <?php if(isset($_GET['dari'])): ?>
        <br>
        <?php echo $__env->make('customer._table-list', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php endif; ?>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('custom-script'); ?>
    <?php if(isset($_GET['dari'])): ?>
        <script type="text/javascript">
            $(function() {
                var table = $('.myTable').DataTable({
                    processing: true,
                    serverSide: true,
                    orderable: false,
                    ajax: "<?= url('list-member?dari=' . $_GET['dari'] . '&sampai=' . $_GET['sampai']) . '&branch=' . $_GET['branch'] . '&kategori_member=' . $_GET['kategori_member'] ?>",
                    columns: [{
                            data: 'DT_RowIndex',
                            name: 'DT_RowIndex',
                        },
                        {
                            data: 'nama',
                            name: 'nama'
                        },
                        {
                            data: 'email',
                            name: 'email'
                        },
                        {
                            data: 'phone',
                            name: 'phone'
                        },
                        {
                            data: 'tgl_lahir',
                            name: 'tgl_lahir'
                        },
                        {
                            data: 'poin',
                            name: 'poin'
                        },
                        {
                            data: 'cabang',
                            name: 'cabang'
                        },
                        {
                            data: 'kategori_member',
                            name: 'kategori_member',
                        },
                        {
                            data: 'specific_member_data', // This is the new column
                            name: 'specific_member_data',
                            orderable: false, // Make it not sortable if preferred
                            searchable: false // Make it not searchable if preferred
                        },
                        // {
                        //     data: 'action',
                        //     name: 'action',
                        //     orderable: false,
                        //     searchable: false
                        // },
                    ],
                    order: [
                        [0, 'asc']
                    ],
                });
            });

            function indoDate(newDate) {
                const today = new Date(newDate);
                const yyyy = today.getFullYear();
                let mm = today.getMonth() + 1; // Months start at 0!
                let dd = today.getDate();
                let hh = newDate.substr(11, 2);
                let ii = newDate.substr(14, 2);

                if (dd < 10) dd = '0' + dd;
                if (mm < 10) mm = '0' + mm;

                const formattedToday = dd + '-' + mm + '-' + yyyy + ' ' + hh + ':' + ii;
                return formattedToday
            }
        </script>
    <?php endif; ?>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.template', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\member_new\resources\views/customer/index-list.blade.php ENDPATH**/ ?>