<?php $__env->startSection('title', 'Red Envelope'); ?>
<?php $__env->startSection('red-envelope', 'active'); ?>
<?php echo $__env->make('adminDashboard.layout.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<div class="main-content">
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4>Red Envelope</h4>
                        </div>
                        <form action="<?php echo e(url('/admin/red-envelope/save')); ?>" method="post">
                            <?php echo csrf_field(); ?>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>Users Limit</label>
                                            <input type="number" required name="user_limit" class="form-control">
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>Amount</label>
                                            <input type="number" span="0.1" required name="amount" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div class="card-footer text-right p-0">
                                    <input type="submit" class="btn btn-primary mr-1" value="Submit" />
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4>Envelopes</h4>
                        </div>
                        <div class="card-body p-0">
                            <div class="table-responsive">
                                <table class="table table-striped table-md">
                                    <tr>
                                        <th>ID</th>
                                        <th class="text-center">Users Limit</th>
                                        <th class="text-center">Remaining</th>
                                        <th class="text-center">Amount</th>
                                        <th class="text-center">Date</th>
                                        <th class="text-center">Status</th>
                                        <th class="text-center">Link</th>
                                    </tr>
                                    <?php if(count($envelopes) > 0): ?>
                                    <?php $__currentLoopData = $envelopes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $envelope): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e(++$key); ?></td>
                                        <td class="text-center"><?php echo e($envelope->user_limit); ?></td>
                                        <td class="text-center"><?php echo e($envelope->remaining); ?></td>
                                        <td class="text-center"><?php echo e($envelope->amount); ?></td>
                                        <td class="text-center"><?php echo e($envelope->created_at); ?></td>
                                        <?php if($envelope->status == 1): ?>
                                        <td class="text-center">
                                            <a href="<?php echo e(url('/admin/red-envelope/inactive/'.$envelope->id)); ?>" class="badge badge-primary" style="border:none;">Disable</a>
                                        </td>
                                        <?php else: ?>
                                        <td class="text-center">
                                            <a href="<?php echo e(url('/admin/red-envelope/active/'.$envelope->id)); ?>" class="badge badge-warning" style="border:none;">Enable</a>
                                        </td>
                                        <?php endif; ?>
                                        <td class="text-center">
                                            <button type="button" onclick="copyLink('<?php echo e($envelope->link_code); ?>', '<?php echo e($envelope->id); ?>')" class="badge badge-success" style="border:none;">Copy</button>
                                        </td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php else: ?>
                                    <tr>
                                        <td colspan="6" class="text-center">No Data Found.</td>
                                    </tr>
                                    <?php endif; ?>
                                </table>
                            </div>
                        </div>
                        <div class="card-footer text-right">
                            <nav class="d-inline-block">
                                <?php echo e($envelopes->links('adminDashboard.pagination')); ?>

                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
</div>

<script>
    function copyLink(code, id) {
        let domain = window.location.origin;

        var copyText = domain + "/user/envelope/" + code + id;
        console.log(id);
        if (!navigator.clipboard) {
            fallbackCopyTextToClipboard(copyText);
            return;
        }
        navigator.clipboard.writeText(copyText).then(function() {
            // toastShow(title + " copied.");
            iziToast.show({
                message: " Link Copied ",
                position: 'topRight',
                color: 'green'
            });
        });
    }
</script>
<?php echo $__env->make('adminDashboard.layout.footer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/shyambabamatka/public_html/zupitogames.com/resources/views/adminDashboard/red-envelope.blade.php ENDPATH**/ ?>