
<?php $__env->startSection('title'); ?> Client | BDIDEA <?php $__env->stopSection(); ?>
<?php $__env->startSection('lead'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('lead.index'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('main_content_section'); ?>
<div class="row py-3 ps-2">
    <div class="heading d-flex justify-content-start align-items-center">
        <h3 class="mb-0"><span> Client List</span></h3>
    </div>
</div>

<div class="table_wrapper py-1 card">
    <div class="row my-2 aggregate-section-div">
        <div class="px-3 ">
            <div class=" d-flex justify-content-between align-items-center aggregate-section border">
                <div class="d-flex align-items-center">
                    <p class="mb-0"><a href="<?php echo e(route('client.index')); ?>"
                            class="text-primary py-2 px-3 active">All(<?php echo e($customerData->count()); ?>)</a>
                    </p>
                </div>
                <div class="d-none d-sm-block">
                    <?php if(Auth::user()->can('client-create')): ?>
                    <a href="javascript:void(0)"
                        class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0" data-bs-toggle="modal"
                        data-bs-target="#addClient"><span class="">New Client</span></a>
                    <?php endif; ?>
                </div>
            </div>

            <?php if(Auth::user()->can('client-create')): ?>
            <div class="mt-2 btn btn-success d-block rounded-0 d-sm-none" data-bs-toggle="modal"
                data-bs-target="#addClient">
                New Client</div>
            <?php endif; ?>
        </div>
    </div>



    <div class="row px-3">
        <div class="table-container table-responsive">
            <table id="" class="table table-bordered">
                <thead class="text-uppercase">
                    <tr class="me-3">
                        
                        <th class="text-center" scope="col"><span>Name</span></th>
                        <th class="text-center" scope="col"><span>Email</span></th>
                        <th class="text-center" scope="col"><span>Phone</span></th>
                        <th class="text-center" scope="col"><span>Status</span></th>
                    </tr>
                </thead>
                <tbody class="text-center">

                    <?php $__currentLoopData = $customerData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if(isset($item) && $item != null): ?>
                    <tr class="">

                        <td>
                            <div class="row_title">
                                

                                <?php echo e($item->customer_name); ?>

                            </div>
                            <div class="row-actions mt-2">

                                <?php if(Auth::user()->can('client-edit')): ?>
                                <span><button class="edit_class_modal border-0 bg-transparent" value="<?php echo e($item->id); ?>"
                                        onclick="updateClient(<?php echo e($item->id); ?>)"> সম্পাদন </button> | </span>
                                <?php endif; ?>

                                <span><a class="text-primary" href="#">প্রোফাইল</a>
                                    |</span>

                                <?php if($item->status == true): ?>
                                <span><a class="text-warning"
                                        href="<?php echo e(route('client-inactive', $item->id)); ?>">নিস্ক্রিয়</a> | </span>
                                <?php else: ?>
                                <span><a class="text-success"
                                        href="<?php echo e(route('client-active', $item->id)); ?>">সক্রিয়</a> | </span>
                                <?php endif; ?>

                                <span><a class="text-danger" href="<?php echo e(route('client.delete', $item->id)); ?>">ডিলিট</a>
                                    </span>
                            </div>
                        </td>

                        <td><?php echo e($item->customer_email); ?></td>
                        <td><?php echo e($item->customer_mobile); ?></td>

                        <td>
                            <?php if($item->status == true): ?>
                            <span class="badge bg-success">Active</span>
                            <?php else: ?>
                            <span class="badge bg-danger">Inactive</span>
                            <?php endif; ?>
                        </td>

                    </tr>

                    
                    <div class="modal fade" id="updateClient<?php echo e($item->id); ?>" tabindex="-1" aria-labelledby="oneInputModalLabel" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-centered max-width-900px">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h1 class="modal-title fs-5" id="oneInputModalLabel">Update Client</h1>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                </div>
                                <form action="<?php echo e(route('client.update', $item->id)); ?>" method="post" enctype="multipart/form-data">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('put'); ?>
                                    <div class="modal-body p-0">
                                        <div class="row px-4 my-4">
                                            <div class="col-md-6 mb-3">
                                                <div class="form-group">
                                                    <label for="customer_name">Client Name<span class="text-danger">(required)</span>
                                                    </label>
                                                    <input type="text" name="customer_name" required class="form-control form-control-solid"
                                                        value="<?php echo e($item->customer_name); ?>" placeholder="Name">
                                                </div>
                    
                                                <?php $__errorArgs = ['customer_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                <span class=text-danger><?php echo e($message); ?></span>
                                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                            </div>
                    
                                            <div class="col-md-6 mb-3">
                                                <div class="form-group">
                                                    <label for="customer_email">Client Email<span class="text-danger">(required)</span>
                                                    </label>
                                                    <input type="email" name="customer_email" required
                                                        class="form-control form-control-solid" value="<?php echo e($item->customer_email); ?>"
                                                        placeholder="Email">
                                                </div>
                    
                                                <?php $__errorArgs = ['customer_email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                <span class=text-danger><?php echo e($message); ?></span>
                                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                            </div>
                    
                                            <div class="col-md-12 mb-3">
                                                <div class="form-group">
                                                    <label for="customer_mobile">Mobile<span class="text-danger">(required)</span>
                                                    </label>
                                                    <input type="number" name="customer_mobile" id="customer_mobile" required
                                                        class="form-control form-control-solid" value="<?php echo e($item->customer_mobile); ?>"
                                                        placeholder="Mobile Number">
                                                </div>
                    
                                                <?php $__errorArgs = ['customer_mobile'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                <span class=text-danger><?php echo e($message); ?></span>
                                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                            </div>
                    
                                            <div class="col-md-12 mb-3">
                                                <div class="form-group">
                                                    <label for="customer_address">Address<span class="text-danger">(required)</span>
                                                    </label>
                    
                                                    <textarea name="customer_address" id="customer_address" cols="10" rows="2"
                                                        placeholder="Enter Address" class="form-control form-control-solid"
                                                        required><?php echo e($item->customer_address); ?></textarea>
                                                </div>
                    
                                                <?php $__errorArgs = ['customer_address'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                <span class=text-danger><?php echo e($message); ?></span>
                                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                            </div>
                    
                                            
                    
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="submit" class="btn btn-success" onclick="return checkValidate()">সম্পাদন</button>
                                        <button type="button" class="btn btn-danger" data-bs-dismiss="modal">বাতিল</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>

                    <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                </tbody>
            </table>
        </div>

        <?php if(isset($customerCount) && $customerCount > 10): ?>
        <div class="clearfix d-flex">
            <div class="float-left">
                <p class="text-muted">
                    <?php echo e(__('Showing')); ?>

                    <span class="font-weight-bold"><?php echo e($customerData->firstItem()); ?></span>
                    <?php echo e(__('to')); ?>

                    <span class="font-weight-bold"><?php echo e($customerData->lastItem()); ?></span>
                    <?php echo e(__('of')); ?>

                    <span class="font-weight-bold"><?php echo e($customerData->total()); ?></span>
                    <?php echo e(__('results')); ?>

                </p>
            </div>

            <div class="float-right custom-table-pagination">
                <?php echo $customerData->links('pagination::bootstrap-4'); ?>

            </div>
        </div>
        <?php endif; ?>
    </div>
</div>



<div class="modal fade" id="addClient" tabindex="-1" aria-labelledby="oneInputModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered max-width-900px">
        <div class="modal-content">
            <div class="modal-header">
                <h1 class="modal-title fs-5" id="oneInputModalLabel">New Client</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <form action="<?php echo e(route('client.store')); ?>" method="post" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="modal-body p-0">
                    <div class="row px-4 my-4">
                        <div class="col-md-6 mb-3">
                            <div class="form-group">
                                <label for="customer_name">Client Name<span class="text-danger">(required)</span>
                                </label>
                                <input type="text" name="customer_name" required class="form-control form-control-solid"
                                    value="<?php echo e(old('customer_name')); ?>" placeholder="Name">
                            </div>

                            <?php $__errorArgs = ['customer_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class=text-danger><?php echo e($message); ?></span>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <div class="form-group">
                                <label for="customer_email">Client Email<span class="text-danger">(required)</span>
                                </label>
                                <input type="email" name="customer_email" required class="form-control form-control-solid"
                                    value="<?php echo e(old('customer_email')); ?>" placeholder="Email">
                            </div>

                            <?php $__errorArgs = ['customer_email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class=text-danger><?php echo e($message); ?></span>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="col-md-12 mb-3">
                            <div class="form-group">
                                <label for="customer_mobile">Mobile<span class="text-danger">(required)</span>
                                </label>
                                <input type="number" name="customer_mobile" id="customer_mobile" required
                                    class="form-control form-control-solid" value="<?php echo e(old('customer_mobile')); ?>"
                                    placeholder="Mobile Number">
                            </div>

                            <?php $__errorArgs = ['customer_mobile'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class=text-danger><?php echo e($message); ?></span>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="col-md-12 mb-3">
                            <div class="form-group">
                                <label for="customer_address">Address<span class="text-danger">(required)</span>
                                </label>
                        
                                <textarea name="customer_address" id="customer_address" cols="10" rows="2" placeholder="Enter Address"
                                    class="form-control form-control-solid" required></textarea>
                            </div>
                        
                            <?php $__errorArgs = ['customer_address'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class=text-danger><?php echo e($message); ?></span>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-success" onclick="return checkValidate()">সংরক্ষন</button>
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">বাতিল</button>
                </div>
            </form>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>

<script>
    function checkValidate() {
        var mobileNumber = $("#customer_mobile").val();

        if (mobileNumber != '' && mobileNumber.length != 11) { 
            event.preventDefault();
            toastr.error("Mobile number must be 11 digit."); 
        }

        return true;
    }
    
    //For update...
    function checkValidateForUpdate(id) {
        var mobileNumber = $("#customer_mobile"+id).val();

        if (mobileNumber != '' && mobileNumber.length != 11) { 
            event.preventDefault();
            toastr.error("Mobile number must be 11 digit."); 
        }

        return true;
    }

    //To show update modal...
    function updateClient(id) {
        $("#updateClient"+id).modal('show');
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\Project\Personal-Project\Office-Project\update\skin-care\resources\views/admin/customer/index.blade.php ENDPATH**/ ?>