<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="purchaseProductCreate(<?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>
                <p class="mb-1 mt-2 text-center">
                    <b class="text-primary"><?php echo e($singlePD->product_name); ?> </b><br>
                    <b class="text-primary">Price: <span class="text-success"><?php echo e($singlePD->product_price); ?></span> </b>
                </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); ?>">
    <input type="hidden" value="<?php echo e($singlePD->product_price); ?>" id="unit_price<?php echo e($singlePD->id); ?>"
        name="unit_price<?php echo e($singlePD->id); ?>">
    <div class="modal fade" id="purchaseProductCreate<?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>

                <div class="modal-body px-3 py-3">
                    <form action="#" method="post" enctype="multipart/form-data"
                        onsubmit="return addProductDetailsFMP(<?php echo e($singlePD->id); ?>)">
                        <div class="row">

                            <div class="col-md-6 mb-2">
                                <div>
                                    <div class="form-group">
                                        <label for="mrp_price_fmp">MRP Price<span class="text-danger">*</span>
                                        </label>
                                        <input type="number" name="mrp_price_fmp" id="mrp_price_fmp<?php echo e($singlePD->id); ?>"
                                            class="form-control form-control-solid custom-readonly-color"
                                            value="<?php echo e($singlePD->product_price); ?>" placeholder="MRP Price" readonly
                                            required>
                                    </div>

                                    <?php $__errorArgs = ['mrp_price_fmp'];
$__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-6 mb-2">
                                <div>
                                    <div class="form-group">
                                        <label for="product_qty_fmp">Qty<span class="text-danger">*</span>
                                        </label>
                                        <input type="number" name="product_qty_fmp"
                                            id="product_qty_fmp<?php echo e($singlePD->id); ?>"
                                            class="form-control form-control-solid" value="1" placeholder="Product Qty"
                                            onblur="productQuantityFMP(<?php echo e($singlePD->id); ?>)" required>
                                    </div>

                                    <?php $__errorArgs = ['product_qty_fmp'];
$__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-6 mb-2">
                                <div>
                                    <div class="form-group">
                                        <label for="selling_price_fmp">Selling
                                            Price<span class="text-danger">*</span>
                                        </label>
                                        <input type="number" name="selling_price_fmp"
                                            id="selling_price_fmp<?php echo e($singlePD->id); ?>"
                                            class="form-control form-control-solid" value="0"
                                            placeholder="Selling Price" required>
                                    </div>

                                    <?php $__errorArgs = ['selling_price_fmp'];
$__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-6 mb-2">
                                <div>
                                    <div class="form-group">
                                        <label for="total_product_price_fmp">Total
                                            Price<span class="text-danger">*</span>
                                        </label>
                                        <input type="number" name="total_product_price_fmp"
                                            id="total_product_price_fmp<?php echo e($singlePD->id); ?>"
                                            class="form-control form-control-solid custom-readonly-color"
                                            value="<?php echo e($singlePD->product_price); ?>" placeholder="Total Price" readonly
                                            required>
                                    </div>

                                    <?php $__errorArgs = ['total_product_price_fmp'];
$__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">Save</button>
                            <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
                        </div>
                    </form>
                </div>
            </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="previousProductData()"
                style="background-color: #eff2f5">Previous</button>
            <button class="btn btn-sm" id="next" onclick="nextProductData()"
                style="margin-left: 10px; background-color: #eff2f5; ">Next</button>
        </div>
    </div>
</div>

<?php $__env->startSection('scripts'); ?>
<script>
    //To fetch next page product...
    function nextProductData() {
        event.preventDefault();
        var lastProductId = $("#lastProductIdFF").val();
        var url = "<?php echo e(route('purchase.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 {
                        $("#filterProductList").html(data);
                    }
                }
            });
        }
    }

    //To fetch previous page product...
    function previousProductData() {
        event.preventDefault();
        var lastProductId = $("#firstProductIdFF").val();
        var url = "<?php echo e(route('purchase.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 {
                        $("#filterProductList").html(data);
                    }
                }
            });
        }
    }
</script>
<?php $__env->stopSection(); ?><?php /**PATH E:\Project\Personal-Project\Office-Project\update\skin-care\resources\views/admin/productManage/purchaseProduct/filterProductList.blade.php ENDPATH**/ ?>