
<?php $__env->startSection('section-title', 'Stock'); ?>
<?php $__env->startSection('page-title', 'Product Stock'); ?>
<?php $__env->startSection('action-button'); ?>
    <a href="" class="btn add_list_btn " onclick="window.print()">Print</a>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('css'); ?>
    <style>
        @media print {

            table,
            table th,
            table td {
                color: black !important;
            }

            .h-hide {
                display: none;
            }
        }


        table .table_vari_bg tr{
            background: #000ce2 !important;
            color: rgb(255, 255, 255);
            font-weight: 800;
        }
        th, td {
            /* border: 1px solid black; Border for table cells */
            /* padding: 10px; */
            /* text-align: center; */
        }
    </style>

<style>
    /* Style for the main table rows (striped) */
    .table-striped tbody tr:nth-child(odd) {
        background-color: #dcdcdc; /* Light gray for odd rows */
    }
    .table-striped tbody tr:nth-child(even) {
        background-color: #ffffff; /* White for even rows */
    }

    /* Style for the nested variation table */
    .table-striped tbody tr:nth-child(odd) table tbody tr {
        background-color: #dcdcdc; /* Match odd row color */
    }
    .table-striped tbody tr:nth-child(even) table tbody tr {
        background-color: #ffffff; /* Match even row color */
    }

    /* Optional: Add borders to differentiate nested table */
    .table-striped table {
        width: 100%;
        border: 1px solid #ddd;
    }
    .table-striped table th,
    .table-striped table td {
        padding: 5px;
        text-align: left;
    }
</style>

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

    <div class="row">
        <div class="col-lg-12">
            <div class="card m-b-30 card_style">
                <div class="card-header ">
                    <h4 style="text-align: center; font-weight:bold; margin-top:5px;font-size:30px"><strong>Stock Report</strong></h4>
                    <?php
                        $brands = App\Models\Brand::get();
                        $categories = App\Models\Category::get();
                        $produc = App\Models\Product::get();
                    ?>
                    <form action="<?php echo e(route('report.stock')); ?>" method="GET">
                        <div class="row h-hide">
                            <div class="col-md-3 mt-3">
                                <input type="text" class="form-control" id="search_keyword" name="search_keyword"
                                    value="<?php echo e($keyword); ?>" placeholder="Barcode or Product Name">
                            </div>
                            <div class="col-md-3 mt-3">
                                <select class="select2" name="product_id" id="product_id" data-provide="selectpicker"
                                    data-live-search="true" data-size="10">
                                    <option value="">Select Product</option>
                                    <?php $__currentLoopData = $produc; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($product->id); ?>"
                                            <?php echo e($product_id == $product->id ? 'SELECTED' : ''); ?>>
                                            <?php echo e($product->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-3 mt-3">
                                <select name="category_id" id="category_id" class="select2" data-provide="selectpicker"
                                    data-live-search="true" data-size="10">
                                    <option value="">Select Category</option>
                                    <?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_id == $category->id ? 'SELECTED' : ''); ?>><?php echo e($category->name); ?>

                                        </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-3 mt-3">
                                <select name="brand_id" id="brand_id" class="select2" data-provide="selectpicker"
                                    data-live-search="true" data-size="10">
                                    <option value="">Select Brand</option>
                                    <?php $__currentLoopData = $brands; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $brand): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($brand->id); ?>" <?php echo e($brand_id == $brand->id ? 'SELECTED' : ''); ?>>
                                            <?php echo e($brand->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>
                        <div class="row mt-3 h-hide">
                            <div class="col-md-12 col-12 d-flex justify-content-center">
                                <a href="<?php echo e(route('report.stock')); ?>" class="btn btn-md mx-1 text-white add_list_btn_reset"
                                    id="">Reset</a>
                                <button type="submit" class="btn btn-md add_list_btn mx-1">Filter</button>
                            </div>
                        </div>
                    </form>

                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-striped text-center">
                            <thead class="header_bg">
                                <tr>
                                    <th class="header_style_left">#SL</th>
                                    <th style="width: 25%">Product</th>
                                    <th>Category</th>
                                    <th>Stock In</th>
                                    <th>Stock Out</th>
                                    <th>Return</th>
                                    <th>Damage</th>
                                    <th class="header_style_right">Available Stock</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <?php
                                        $purchased_qty = purchased_qty($data);
                                        $invoiced_qty = invoiced_qty($data);
                                        $stock_qty = product_stock($data);
                                        $returned_qty = returned_qty($data);
                                        $damaged_qty = damaged_qty($data);
                                        
                                    ?>
                                    <tr>
                                        <td class="table_data_style_left"><?php echo e($loop->index + 1); ?></td>
                                        <td><?php echo e($data->name); ?> - <?php echo e($data->barcode); ?></td>
                                        <td><?php echo e($data->category->name); ?></td>
                                        <td><?php echo e($purchased_qty); ?></td>
                                        <td><?php echo e($invoiced_qty); ?></td>
                                        <td><?php echo e($returned_qty); ?></td>
                                        <td><?php echo e($damaged_qty); ?></td>
                                        <td class="table_data_style_right">
                                            
                                            <?php if($data->product_variations->count() > 0): ?>
                                                <table>
                                                    <thead class="table_vari_bg">
                                                        <tr>
                                                            <th class="table_data_style_left">Variation</th>
                                                            <th class="table_data_style_right">Stock</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php $__currentLoopData = $data->product_variations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $variation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        
                                                            <tr>
                                                                <td class="table_data_style_left"><?php echo e($variation->size?->size); ?> - <?php echo e($variation->color?->color); ?></td>
                                                                <td class="table_data_style_right">
                                                                    <?php echo e(variation_stock($variation->id)); ?> Pics
                                                                    
                                                                </td>
                                                            </tr>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </tbody>
                                                </table>
                                            <?php else: ?>
                                                <?php echo e($stock_qty); ?>

                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="100%" class="text-center text-danger no_data_style">No Data Available</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="pagination justify-content-center">
                        <?php echo e($products->onEachSide(1)->links()); ?>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // $(doucment).ready(function(){
        $('#resetBtn').click(function() {
            $("#product_id option:first").prop("selected", true).change();
            $("#category_id option:first").prop("selected", true).change();
            $("#brand_id option:first").prop("selected", true).change();
            $("#search_keyword").val('');
        });
        // });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\www\new demo multi-bank\resources\views/backend/pages/report/sc_stock.blade.php ENDPATH**/ ?>