<div class="row mt-2 px-2">
    <?php $__currentLoopData = $productData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$singlePD): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php if(isset($singlePD) && $singlePD != null): ?>
    <?php
    $lastProductId = $singlePD->id;
    if($key == 0){
    $firstProductId = $singlePD->id;
    }
    ?>

    <div class="col-md-3 col-sm-2 p-1">
        <div class="card p-1 custom-pos-lay-product-card h-100">
            <a href="#" onclick="sellProductDetailsModal(<?php echo e($singlePD->id); ?>)">
                <div class="img-block">
                    <?php if(isset($singlePD->product_image)): ?>
                    <img src="<?php echo e(asset('uploads/product/thumbnail/'.$singlePD->product_image)); ?>" class="w-100 h-100" />
                    <?php else: ?>
                    <img src="<?php echo e(asset('backend/template-assets/')); ?>/images/img_preview.png" class="w-100 h-100" />
                    <?php endif; ?>
                </div>
                <?php
                //To get product stock qty...
                $productStockData = App\Models\ProductStock::getProductStockCount($singlePD->id);
                ?>
                <p class="mb-1 mt-2 text-center">
                    <b class="text-primary"><?php echo e($singlePD->product_name); ?> </b><br>
                    <b>Code: </b><?php echo e($singlePD->product_code); ?>

                    <b>Qty: </b><span class="fw-bolder text-success"> <?php echo e($productStockData); ?></span>
                </p>
            </a>
        </div>
    </div>


    
    <input type="hidden" value="<?php echo e($singlePD->id); ?>" id="productId<?php echo e($singlePD->id); ?>" name="productId<?php echo e($singlePD->id); ?>">
    <div class="modal fade" id="sellProductDetailsModal<?php echo e($singlePD->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">New Purchase Create</h1>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <form action="#" method="post" enctype="multipart/form-data"
                    onsubmit="addSellProductDetails(<?php echo e($singlePD->id); ?>)">
                    <div class="modal-body p-0">

                        <div class="row px-4 my-4">
                            <div class="col-12">
                                <div class="row" id="singleProductInformation<?php echo e($singlePD->id); ?>">
                                    <?php
                                    $productStockData = App\Models\ProductStock::getProductStockCount($singlePD->id);
                                    $purchaseProductData =
                                    App\Models\PurchaseProduct::getAllProductIdWise($singlePD->id,
                                    $singlePD->user_id);
                                    ?>
                                    <div class="col-md-4 text-center">
                                        <h6>Product Name: <span
                                                class="text-primary"><?php echo e($singlePD->product_name); ?></span>
                                        </h6>
                                    </div>
                                    <div class="col-md-4 text-center">
                                    </div>
                                    <div class="col-md-4 text-center">
                                        <h6>Product Qty: <span class="text-primary"><?php echo e($productStockData); ?></span>
                                        </h6>
                                    </div>
                                </div>

                                <div class="row my-4">
                                    <div class="col-12">
                                        <div>
                                            <div class="form-group custom-select2-form">
                                                <label for="purchase_serial_batch_id">Batch
                                                    No<span class=" text-danger">*</span>
                                                </label>
                                                <select name="purchase_serial_batch_id"
                                                    id="purchase_serial_batch_id<?php echo e($singlePD->id); ?>"
                                                    class="form-select select2" required>
                                                    <option value="" selected disabled>Select Batch</option>
                                                    <?php $__currentLoopData = $purchaseProductData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $singlePPD): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($singlePPD->product_qty > 0): ?>
                                                    <?php if(isset($singlePPD) && $singlePPD->batch_no != null): ?>
                                                    <option value="<?php echo e($singlePPD->id); ?>">Batch No -
                                                        <?php echo e($singlePPD->batch_no); ?> / Price -
                                                        <?php echo e($singlePPD->selling_price); ?> / Qty -
                                                        <?php echo e($singlePPD->product_qty); ?> </option>
                                                    <?php endif; ?>
                                                    <?php endif; ?>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>

                                            <?php $__errorArgs = ['purchase_serial_batch_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>
                    </div>

                    <div class="modal-footer">
                        <button type="submit" class="btn btn-success">Add Product</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(); ?>

    <?php if(isset($lastProductId) && isset($firstProductId)): ?>
    <input type="hidden" id="firstProductId" value="<?php echo e($firstProductId); ?>">
    <input type="hidden" id="lastProductId" value="<?php echo e($lastProductId); ?>">
    <?php endif; ?>

</div>
<div class="row">
    <div class="col-12 mb-1 mt-3">
        <div class="pagination w-100 justify-content-center">
            <button class="btn btn-sm" id="previous" onclick="previousProductDataFS()"
                style="background-color: #eff2f5">Previous</button>
            <button class="btn btn-sm" id="next" onclick="nextProductDataFS()"
                style="margin-left: 10px; background-color: #eff2f5; ">Next</button>
        </div>
    </div>
</div>

<?php $__env->startSection('scripts'); ?>
<script>
    //To fetch next page product...
    function nextProductDataFS() {
        event.preventDefault();
        var lastProductId = $("#lastProductIdFF").val();
        var url = "<?php echo e(route('sell.next-page-product-data')); ?>";
        if (lastProductId != null) {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    lastProductId: lastProductId,
                },
                success: function (data) {
                    if (data.error) {
                        toastr.error(data.error);
                    } else {
                        $("#filterProductListFS").html(data);
                    }
                }
            });
        }
    }

    //To fetch previous page product...
    function previousProductDataFS() {
        event.preventDefault();
        var lastProductId = $("#firstProductIdFF").val();
        var url = "<?php echo e(route('sell.previous-page-product-data')); ?>";
        if (lastProductId != null) {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    lastProductId: lastProductId,
                },
                success: function (data) {
                    if (data.error) {
                        toastr.error(data.error);
                    } else {
                        $("#filterProductListFS").html(data);
                    }
                }
            });
        }
    }
</script>
<?php $__env->stopSection(); ?><?php /**PATH E:\Project\Personal-Project\Office-Project\update\skin-care\resources\views/admin/productManage/sellProduct/filterProductList.blade.php ENDPATH**/ ?>