
<?php $__env->startSection('title'); ?> Product | Beauty Parlour <?php $__env->stopSection(); ?>
<?php $__env->startSection('product'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('product.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> Product 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('product.index')); ?>"
                            class="text-primary py-2 px-3 active">All(<?php echo e($allProductCount); ?>)</a>
                    </p>

                    <p class="mb-0"><a href="<?php echo e(route('active-product-list')); ?>"
                            class="text-primary py-2 px-3">Active(<?php echo e($activeProductCount); ?>)</a></p>
                    <p class="mb-0"><a href="<?php echo e(route('inactive-product-list')); ?>"
                            class="text-primary py-2 px-3">Inactive(<?php echo e($inactiveProductCount); ?>)</a></p>
                </div>
                <div class="d-sm-block">
                    <?php if(Auth::user()->can('product-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="#addProduct"><span class="">New Product</span></a>
                    <?php endif; ?>
                </div>
            </div>
        </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>Category Name</span></th>
                        <th class="text-center" scope="col"><span>Product Name</span></th>
                        <th class="text-center" scope="col"><span>Product Price</span></th>
                        <th class="text-center" scope="col"><span>Status</span></th>
                    </tr>
                </thead>
                <tbody class="text-center">

                    <?php $__currentLoopData = $productData; $__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->productCategoryData->category_name); ?>

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

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

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

                        <td><?php echo e($item->product_name); ?></td>
                        <td><?php echo e($item->product_price); ?> TK</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="updateProduct<?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 Product</h1>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                </div>
                                <form action="<?php echo e(route('product.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-8">
                                                <div class="mb-3">
                                                    <div class="form-group custom-select2-form">
                                                        <label for="product_category_id">Product Category <span class=" text-danger">(required)</span>
                                                        </label>
                                                        <select name="product_category_id" id="product_category_id<?php echo e($item->id); ?>" class="form-select select2" required>
                                                            <?php $__currentLoopData = $productCategoryData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $singleCategory): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option value="<?php echo e($singleCategory->id); ?>" <?php echo e($singleCategory->id == $item->product_category_id ? "selected":""); ?>><?php echo e($singleCategory->category_name); ?>

                                                            </option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </select>
                                                    </div>
                                                
                                                    <?php $__errorArgs = ['product_category_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="mb-3">
                                                    <div class="form-group">
                                                        <label for="product_name">Product Name<span class="text-danger">(required)</span>
                                                        </label>
                                                        <input type="text" name="product_name" required class="form-control form-control-solid"
                                                            value="<?php echo e($item->product_name); ?>" placeholder="Name">
                                                    </div>
                        
                                                    <?php $__errorArgs = ['product_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="mb-3">
                                                    <div class="form-group">
                                                        <label for="product_price">Prodcut Price<span class="text-danger">(required)</span>
                                                        </label>
                                                        <input type="number" name="product_price" required
                                                            class="form-control form-control-solid" value="<?php echo e($item->product_price); ?>"
                                                            placeholder="Price">
                                                    </div>
                        
                                                    <?php $__errorArgs = ['product_price'];
$__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 class="col-md-4 mb-3">
                                                <div class="form-group">
                                                    <label for="name">Product Image <span class=" text-danger"></span></label> <br>
                                                    <div class=" position-relative custom-soft-setting dropzone">
                                                        <div class="select_imgWith_preview py-2">
                                                            <?php if($item->product_image != null): ?>
                                                            <img id="uploadPreview1<?php echo e($item->id); ?>" src="<?php echo e(asset('uploads/product/'.$item->product_image)); ?>">
                                                            <div id="dropzone-block" class="custom-media-upload-block mt-3">
                                                                <span class="dropzone-label fw-bolder">Upload Photo</span>
                                                            </div>
                                                            <?php else: ?>
                                                            <img id="uploadPreview1<?php echo e($item->id); ?>" src="<?php echo e(asset('backend/template-assets/')); ?>/images/img_preview.png">
                                            
                                                            <div id="dropzone-block" class="custom-media-upload-block mt-3">
                                                                <span class="dropzone-label fw-bolder">Upload Photo</span>
                                                            </div>
                                                            <?php endif; ?>
                                                            <input id="uploadImage1<?php echo e($item->id); ?>" type="file" name="product_image"
                                                                onchange="PreviewImageFP('uploadImage1<?php echo e($item->id); ?>','uploadPreview1<?php echo e($item->id); ?>');" />
                                                        </div>
                                                    </div>
                                            
                                                    <?php $__errorArgs = ['product_image'];
$__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($allProductCount) && $allProductCount > 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($productData->firstItem()); ?></span>
                    <?php echo e(__('to')); ?>

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

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

                </p>
            </div>

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

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



<div class="modal fade" id="addProduct" 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">New Product</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('product.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-8">
                            <div class="mb-3">
                                <div class="form-group custom-select2-form 
                                <?php echo e($productCategoryData->count() > 0 ? '' : 'custom-null-select2-body'); ?>

                                ">
                                    <label for="product_category_id">Product Category <span class=" text-danger">(required)</span>
                                    </label>
                                    <select name="product_category_id" id="product_category_id" class="form-select select2" required>
                                        <option value="" selected disabled>Select Product Category</option>
                                        <?php $__currentLoopData = $productCategoryData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $singleCategory): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($singleCategory->id); ?>"><?php echo e($singleCategory->category_name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            
                                <?php $__errorArgs = ['product_category_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="mb-3">
                                <div class="form-group">
                                    <label for="product_name">Product Name<span class="text-danger">(required)</span>
                                    </label>
                                    <input type="text" name="product_name" required class="form-control form-control-solid"
                                        value="<?php echo e(old('product_name')); ?>" placeholder="Name">
                                </div>

                                <?php $__errorArgs = ['product_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="mb-3">
                                <div class="form-group">
                                    <label for="product_price">Prodcut Price<span class="text-danger">(required)</span>
                                    </label>
                                    <input type="number" name="product_price" required class="form-control form-control-solid"
                                        value="<?php echo e(old('product_price')); ?>" placeholder="Price">
                                </div>

                                <?php $__errorArgs = ['product_price'];
$__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 class="col-md-4 mb-3">
                            <div class="form-group">
                                <label for="name">Product Image <span class=" text-danger"></span></label> <br>
                                <div class=" position-relative custom-soft-setting dropzone">
                                    <div class="select_imgWith_preview py-2">
                                        <img id="uploadPreview1" src="<?php echo e(asset('backend/template-assets/')); ?>/images/img_preview.png">
                            
                                        <div id="dropzone-block" class="custom-media-upload-block mt-3">
                                            <span class="dropzone-label fw-bolder">Upload Photo</span>
                                        </div>
                                        <input id="uploadImage1" type="file" name="product_image"
                                            onchange="PreviewImageFP('uploadImage1','uploadPreview1');" />
                                    </div>
                                </div>
                            
                                <?php $__errorArgs = ['product_image'];
$__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(){
        $("#product_category_id").select2({
            dropdownParent: $('#addProduct')
        });
    });
    
    //To show update modal...
    function updateProduct(id) {
        $("#updateProduct"+id).modal('show');
        $("#product_category_id"+id).select2({
            dropdownParent: $('#updateProduct'+id)
        });
    }

    //For image preview...
    function PreviewImageFP(selectFile, previewImg) {
        var oFReader = new FileReader();
        oFReader.readAsDataURL(document.getElementById(selectFile).files[0]);

        oFReader.onload = function (oFREvent) {
            document.getElementById(previewImg).src = oFREvent.target.result;
        };
    }

    function cancelPreviewFP(selectFile, previewImg) {
        const img = document.getElementById(previewImg);
        img.src = window.location.origin + "/backend/template-assets/images/img_preview.png";
        $("#" + selectFile).val('');
    }
</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/productManage/product/index.blade.php ENDPATH**/ ?>