
<?php $__env->startSection('title'); ?> Active Client | Beauty Parlour <?php $__env->stopSection(); ?>
<?php $__env->startSection('active-client-list'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('active-client-list'); ?> 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> Active 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">All(<?php echo e($allClientCount); ?>)</a>
                    </p>

                    <p class="mb-0"><a href="<?php echo e(route('active-client-list')); ?>"
                            class="text-primary py-2 px-3 active">Active(<?php echo e($activeClientCount); ?>)</a></p>
                    <p class="mb-0"><a href="<?php echo e(route('inactive-client-list')); ?>"
                            class="text-primary py-2 px-3">Inactive(<?php echo e($inactiveClientCount); ?>)</a></p>
                </div>
                <div class="d-none d-sm-flex">
                    <?php if(Auth::user()->can('client-create')): ?>
                    <a href="javascript:void(0)"
                        class="btn btn-primary rounded-0 d-flex align-items-center px-2 border-0 mx-2"
                        data-bs-toggle="modal" data-bs-target="#filterClient">
                        <span class="material-symbols-outlined custom-project-icon">
                            search
                        </span>
                        <span class="">Client Search</span>
                    </a>

                    <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-primary d-flex rounded-0 d-sm-none custom-justify-content-center"
                data-bs-toggle="modal" data-bs-target="#filterClient">
                <span class="material-symbols-outlined custom-project-icon">
                    search
                </span>
                <span class="">Client Search</span>
            </div>

            <div class="mt-2 btn btn-success d-flex rounded-0 d-sm-none custom-justify-content-center"
                data-bs-toggle="modal" data-bs-target="#addClient">
                <span class="material-symbols-outlined custom-project-icon">
                    add_circle
                </span>
                <span class="">New Client</span>
            </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 = $clientData; $__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->client_name); ?>

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

                                <?php if(Auth::user()->can('client-edit')): ?>
                                <span><button class="text-primary border-0 bg-transparent fw-bolder" value="<?php echo e($item->id); ?>"
                                        onclick="updateClient(<?php echo e($item->id); ?>)"> Edit </button> | </span>
                                <?php endif; ?>

                                <span><a class="text-info fw-bolder" href="<?php echo e(route('client-profile', $item->id)); ?>">Profile</a>
                                </span>

                                <?php if($item->status == true): ?>
                                <span> | <a class="text-warning fw-bolder"
                                        href="<?php echo e(route('client-inactive', $item->id)); ?>">Inactive</a></span>
                                <?php else: ?>
                                <span> | <a class="text-success fw-bolder"
                                        href="<?php echo e(route('client-active', $item->id)); ?>">Active</a></span>
                                <?php endif; ?>
                                <?php if(Auth::user()->can('client-delete')): ?>
                                
                                <?php endif; ?>
                            </div>
                        </td>

                        <td><?php echo e($item->client_email); ?></td>
                        <td><?php echo e($item->client_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" data-bs-backdrop='static'>
                        <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="client_name">Client Name<span
                                                            class="text-danger">(required)</span>
                                                    </label>
                                                    <input type="text" name="client_name" required
                                                        class="form-control form-control-solid"
                                                        value="<?php echo e($item->client_name); ?>" placeholder="Name">
                                                </div>

                                                <?php $__errorArgs = ['client_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="client_email">Client Email<span
                                                            class="text-danger"></span>
                                                    </label>
                                                    <input type="email" name="client_email"
                                                        class="form-control form-control-solid"
                                                        value="<?php echo e($item->client_email); ?>" placeholder="Email">
                                                </div>

                                                <?php $__errorArgs = ['client_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="client_mobile">Mobile<span
                                                            class="text-danger">(required)</span>
                                                    </label>
                                                    <input type="number" name="client_mobile"
                                                        id="client_mobile<?php echo e($item->id); ?>" required
                                                        class="form-control form-control-solid"
                                                        value="<?php echo e($item->client_mobile); ?>" placeholder="Mobile Number">
                                                </div>

                                                <?php $__errorArgs = ['client_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="client_address">Address<span
                                                            class="text-danger">(required)</span>
                                                    </label>

                                                    <textarea name="client_address" id="client_address" cols="10"
                                                        rows="2" placeholder="Enter Address"
                                                        class="form-control form-control-solid"
                                                        required><?php echo e($item->client_address); ?></textarea>
                                                </div>

                                                <?php $__errorArgs = ['client_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 checkValidateForUpdate(<?php echo e($item->id); ?>)">Update</button>
                                        <button type="button" class="btn btn-danger"
                                            data-bs-dismiss="modal">Cancel</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>

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


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

        <?php if(isset($activeClientCount) && $activeClientCount > 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($clientData->firstItem()); ?></span>
                    <?php echo e(__('to')); ?>

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

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

                </p>
            </div>

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

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



<div class="modal fade" id="addClient" tabindex="-1" data-bs-backdrop='static'>
    <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>
            <div class="modal-header">
                <p class="fs-5 text-center mb-0" id="oneInputModalLabel">ক্লায়েন্ট একবার তৈরী হয়ে গেলে Delete করা সম্ভব
                    না
                    , প্রয়োজনে
                    edit বা inactive করতে পারবেন। তাই অপ্রয়োজনীয় ক্লায়েন্ট তৈরী থেকে বিরত
                    থাকুন।</p>
            </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="client_name">Client Name<span class="text-danger">(required)</span>
                                </label>
                                <input type="text" name="client_name" required class="form-control form-control-solid"
                                    value="<?php echo e(old('client_name')); ?>" placeholder="Name">
                            </div>

                            <?php $__errorArgs = ['client_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="client_email">Client Email<span class="text-danger"></span>
                                </label>
                                <input type="email" name="client_email" class="form-control form-control-solid"
                                    value="<?php echo e(old('client_email')); ?>" placeholder="Email">
                            </div>

                            <?php $__errorArgs = ['client_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="client_mobile">Mobile<span class="text-danger">(required)</span>
                                </label>
                                <input type="number" name="client_mobile" id="client_mobile" required
                                    class="form-control form-control-solid" value="<?php echo e(old('client_mobile')); ?>"
                                    placeholder="Mobile Number">
                            </div>

                            <?php $__errorArgs = ['client_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="client_address">Address<span class="text-danger">(required)</span>
                                </label>

                                <textarea name="client_address" id="client_address" cols="10" rows="2"
                                    placeholder="Enter Address" class="form-control form-control-solid"
                                    required></textarea>
                            </div>

                            <?php $__errorArgs = ['client_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()">Save</button>
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
                </div>
            </form>
        </div>
    </div>
</div>


<div class="modal fade" id="filterClient" tabindex="-1" aria-labelledby="oneInputModalLabel" aria-hidden="true"
    data-bs-backdrop='static'>
    <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">Client Search</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body p-0 custom-payment-history-table">
                <form action="#" method="post" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <div class="modal-body p-0">

                        <div class="row px-4 mb-4 my-3">
                            <div class="col-md-12 mb-3">
                                <div class="form-group custom-select2-form 
                                    <?php echo e($clientData->count() > 0 ? '' : 'custom-null-select2-body'); ?>

                                    ">
                                    <label for="client_id">Select Client <span class=" text-danger">(required)</span>
                                    </label>
                                    <select name="client_id" id="client_id" class="form-select select2">
                                        <?php $__currentLoopData = $clientData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $singleClient): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if(isset($singleClient) && $singleClient != null): ?>
                                        <option value="<?php echo e($singleClient->id); ?>"><?php echo e($singleClient->client_name); ?> /
                                            <?php echo e($singleClient->client_mobile); ?></option>
                                        <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>

                                <?php $__errorArgs = ['client_id'];
$__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">
                                <button type="button" class="btn btn-success d-flex custom-float-right-side"
                                    onclick="updateFilterClient()">
                                    <span class="material-symbols-outlined custom-project-icon">
                                        search
                                    </span>
                                    <span> Search</span>
                                </button>
                            </div>
                            <!--begin::Col-->
                        </div>

                        <div class="row mx-3 mb-4" id="updateFilterClientData">

                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
                    </div>
                </form>

            </div>
        </div>
    </div>
</div>

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

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

<script>
    $(document).ready(function(){
        $("#client_id").select2({
            dropdownParent: $('#filterClient')
        });
    });

    function checkValidate() {
        var mobileNumber = $("#client_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 = $("#client_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');
    }

    //To get filter client data...
    function updateFilterClient() {
        let clientId = $("#client_id").val();
        var url = "<?php echo e(route('get-client-details-with-id')); ?>";
        if (clientId != '') {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    client_id: clientId,
                },
                success: function (data) {
                    if(data.error){
                        toastr.error(data.error);
                    }else{
                        $("#updateFilterClient").modal('show');
                        $("#updateFilterClientData").html(data);
                    }
                }
            });
        }
    }
</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/client/activeList.blade.php ENDPATH**/ ?>