
<?php $__env->startSection('title'); ?> Common Service | Beauty Parlour <?php $__env->stopSection(); ?>
<?php $__env->startSection('payment-type'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('frontend-common-service.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> Common Service 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('frontend-common-service.index')); ?>"
                            class="text-primary py-2 px-3 active">All(<?php echo e($frontendCSCount); ?>)</a>
                    </p>
                </div>
                <div class="d-none d-sm-block">
                    <?php if(Auth::user()->can('frontend-common-service-access')): ?>
                    <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="#addFCS"><span class="">Add Common Service</span></a>
                    <?php endif; ?>
                </div>
            </div>

            <?php if(Auth::user()->can('frontend-common-service-access')): ?>
            <div class="mt-2 btn btn-success d-block rounded-0 d-sm-none" data-bs-toggle="modal"
                data-bs-target="#addFCS">
                Add Common Service</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>Service Name</span></th>
                        <th class="text-center" scope="col"><span>Created</span></th>
                        <th class="text-center" scope="col"><span>Status</span></th>
                    </tr>
                </thead>
                <tbody class="text-center">

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

                    <?php
                    //To get all the section data with fcsId wise...
                    $getAllServiceData = App\Models\FrontendCommonService::getAllServiceDataWithFrontendCommonServiceIdWise($item->id);
                    // dd($getAllServiceData);
                    ?>

                    <tr class="">

                        <td class="text-start">
                            <div class="row_title">
                                <b>Name: </b>
                                <?php $__currentLoopData = $getAllServiceData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $singleServiceData): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <span class="text-normal"><?php echo e($singleServiceData->service_name); ?></span>, 
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                            <div class="row-actions mt-2">

                                <?php if(Auth::user()->can('frontend-common-service-access')): ?>
                                    <span><button class="text-primary border-0 bg-transparent fw-bolder" value="<?php echo e($item->id); ?>"
                                            onclick="updateFCS(<?php echo e($item->id); ?>)"> Edit </button> </span>
                                    <?php if($item->is_default != true): ?>
                                        <?php if($item->status == true): ?>
                                        <span> | <a class="text-warning fw-bolder"
                                                href="<?php echo e(route('frontend-common-service-inactive', $item->id)); ?>">Inactive</a></span>
                                        <?php else: ?>
                                        <span> | <a class="text-success fw-bolder"
                                                href="<?php echo e(route('frontend-common-service-active', $item->id)); ?>">Active</a></span>
                                        <?php endif; ?>
                                    <?php endif; ?>

                                <?php endif; ?>
                                <?php if($item->is_default != true): ?>
                                    
                                <?php endif; ?>
                            </div>
                        </td>

                        <td class="text-start w-25">
                            <b>Date: </b><?php echo e(Carbon\Carbon::parse($item->created_at->toDateString())->format('d-m-Y')); ?> <br>
                            <b>Time: </b><?php echo e(Carbon\Carbon::create($item->created_at->toTimeString())->format('h:i')); ?>

                        </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="updateFCS<?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 Common Service</h1>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                </div>
                                <form action="<?php echo e(route('frontend-common-service.update', $item->id)); ?>" method="post" enctype="multipart/form-data">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('put'); ?>
                                    <div class="modal-body p-0">
                                        <?php
                                        //To decode service ids...
                                        $arrayServiceIds = json_decode($item->service_id);
                                        ?>

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

                                                    ">
                                                        <label for="service_id">Service <span class=" text-danger">(required)</span>
                                                        </label>
                                                        <select name="service_id[]" id="service_id<?php echo e($item->id); ?>" class="form-select select2" multiple required>
                                                            <option value="" disabled>Select Service</option>
                                                            <?php $__currentLoopData = $serviceData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $singleSND): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($singleSND->id); ?>"
                                                                <?php echo e(in_array($singleSND->id, $arrayServiceIds) ? 'selected' : ''); ?>

                                                                ><?php echo e($singleSND->service_name); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </select>
                                                    </div>
                                                
                                                    <?php $__errorArgs = ['service_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>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="submit" class="btn btn-success">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($frontendCSCount) && $frontendCSCount > 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($frontendCSData->firstItem()); ?></span>
                    <?php echo e(__('to')); ?>

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

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

                </p>
            </div>

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

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



<div class="modal fade" id="addFCS" 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">Add Common Service</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('frontend-common-service.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-12 mb-3">
                            <div class="mb-3">
                                <div class="form-group custom-select2-form 
                                <?php echo e($serviceData->count() > 0 ? '' : 'custom-null-select2-body'); ?>

                                ">
                                    <label for="service_id">Service <span class=" text-danger">(required)</span>
                                    </label>
                                    <select name="service_id[]" id="service_id" class="form-select select2" multiple required>
                                        <option value="" disabled>Select Service</option>
                                        <?php $__currentLoopData = $serviceData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $singleSND): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($singleSND->id); ?>"><?php echo e($singleSND->service_name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            
                                <?php $__errorArgs = ['service_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>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-success">Save</button>
                    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
                </div>
            </form>
        </div>
    </div>
</div>

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

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

<script>

    $(document).ready(function(){
        $("#service_id").select2({
            dropdownParent: $('#addFCS')
        });
    });

    //To show update modal...
    function updateFCS(id) {
        $("#service_id"+id).select2({
            dropdownParent: $('#updateFCS'+id)
        });
        $("#updateFCS"+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/setting/frontend/commonService/index.blade.php ENDPATH**/ ?>