

<?php $__env->startSection('title', $page_title); ?>

<?php $__env->startPush('styles'); ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css" crossorigin="anonymous">
    <!-- select2 -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />

    <!-- select2-bootstrap4-theme -->
    <link href="https://raw.githack.com/ttskch/select2-bootstrap4-theme/master/dist/select2-bootstrap4.css" rel="stylesheet"> <!-- for live demo page -->
    <link href="select2-bootstrap4.css" rel="stylesheet"> <!-- for local development env -->


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

<?php $__env->startSection('content'); ?>
    <div class="d-flex flex-column-fluid">
        <div class="container-fluid">
            <!--begin::Notice-->
            <div class="card card-custom gutter-b">
                <div class="card-header flex-wrap py-5">
                    <div class="card-title">
                        <h3 class="card-label"><i class="<?php echo e($page_icon); ?> text-primary"></i> <?php echo e($sub_title); ?></h3>
                    </div>
                    <div class="card-toolbar">
                        <!--begin::Button-->
                        <a href="<?php echo e(route('product')); ?>" class="btn btn-warning btn-sm font-weight-bolder">
                            <i class="fas fa-arrow-left"></i> Back</a>
                        <!--end::Button-->
                    </div>
                </div>
            </div>
            <!--end::Notice-->

            <div class="card card-custom">
                <div class="card-header flex-wrap py-5">
                    <form method="get" action="<?php echo e(route('category.product.search')); ?>" class="col-md-12 px-0">
                        <div class="row">
                            <?php if (isset($component)) { $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4 = $component; } ?>
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'components.form.selectbox','data' => ['labelName' => 'Category','name' => 'category_id','col' => 'col-md-4','class' => 'selectpicker']]); ?>
<?php $component->withName('form.selectbox'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes(['labelName' => 'Category','name' => 'category_id','col' => 'col-md-4','class' => 'selectpicker']); ?>
                                <?php if(!$categories->isEmpty()): ?>
                                    <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($category->id); ?>"><?php echo e($category->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php endif; ?>
                             <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4)): ?>
<?php $component = $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4; ?>
<?php unset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4); ?>
<?php endif; ?>
                            <div class="form-group col-md-4 pt-5 text-center ">
                                <button type="submit" class="btn btn-primary btn-sm rounded" >Search</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <h2>
                <?php
                if (!empty($category_id)){
                    $cat = \App\Models\Category::where('id',$category_id)->first();
                }
                ?>
            </h2>

            <?php if(!empty($category_id)): ?>
                <p style="text-align: center;font-weight:700;font-size:20px;"><?php echo e($cat->name); ?></p>
                <div class="row">
                    <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$prdouct): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            $cat_serial = \Modules\Product\Entities\CategorySerial::where('product_id',$prdouct->id)->where('category_id',$cat->id)->first();
                        ?>
                        <div class="col-sm-2">

                            <form id="store_or_update_form_<?php echo e($key+1); ?>"  method="post" enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                <div class="card" style="height: 300px;">
                                    <div class="card-body">
                                        <p style="text-align: center;"><img src='<?php echo e(asset('storage/'.PRODUCT_IMAGE_PATH.$prdouct->image[0])); ?>' alt='' style='width:100px;height: 133px;'/></p>
                                        <p style="text-align: center;padding-top: 0px;font-size: 10px;color: #034d97;font-weight: 600;"><?php echo e(Str::limit($prdouct->product_name, 15)); ?></p>
                                        <p style="text-align: center;padding-top: 0px;font-size: 12px;font-weight: 600;color: #fa8c15;"><?php echo e($prdouct->sku); ?> <br><span> Qty : <?php echo e($prdouct->total_price_sum); ?></span></p>
                                        <input name="cat_id" type="hidden" value="<?php echo e($cat->id); ?>">
                                        <input name="id" type="hidden" value="<?php echo e($cat_serial->product_id ?? 0); ?>">
                                        <input name="old_product_serial" type="hidden" value="<?php echo e($cat_serial->product_serial ?? 0); ?>">
                                        <div class="row">
                                            <div class="col-sm-8">
                                                <input type="number" class="form-control" name="product_serial" id="product_serial" value="<?php echo e($cat_serial->product_serial ?? 0); ?>" placeholder="Product Serial" required style="margin-bottom: 10px;">

                                            </div>
                                            <div class="col-sm-4">
                                                <button type="button" class="btn btn-danger btn-sm hold_btn" data-form_id = "store_or_update_form_<?php echo e($key+1); ?>"  onclick="getOption()">Go</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            <?php endif; ?>
            <!--end::Card-->
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
    function _(x){
        return document.getElementById(x);
    }

    $(document).on('click', '.hold_btn', function () {
        let form = _($(this).data('form_id'));
        let formData = new FormData(form);
        let url = "<?php echo e(route('product.category.serial.store')); ?>";

        $.ajax({
            url: url,
            type: "POST",
            data: formData,
            dataType: "JSON",
            contentType: false,
            processData: false,
            cache: false,
            beforeSend: function () {
                $('#save-btn').addClass('spinner spinner-white spinner-right');
            },
            complete: function () {
                $('#save-btn').removeClass('spinner spinner-white spinner-right');
            },
            success: function (data) {
                $('#sale_store_form').find('.is-invalid').removeClass('is-invalid');
                $('#sale_store_form').find('.error').remove();
                if (data.status == false){
                    $.each(data.errors, function (key, value){
                        var key = key.split('.').join('_');
                        $('#sale_store_form input#' + key).addClass('is-invalid');
                        $('#sale_store_form textarea#' + key).addClass('is-invalid');
                        $('#sale_store_form select#' + key).parent().addClass('is-invalid');
                        $('#sale_store_form #' + key).parent().append(
                            '<small class="error text-danger">' + value + '</small>');
                    });
                } else {
                    notification(data.status, data.message);
                    if (data.status === 'success') {
                        window.location.reload();
                    }
                }
            },
            error: function (xhr, ajaxOption, thrownError) {
                console.log(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText);
            }
        });
    });

</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/iconshoppercom/iconshopper/Modules/Product/Resources/views/categoryProductSerial.blade.php ENDPATH**/ ?>