<?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 btn-sm" onclick="window.print()">Print</a>
    <a href="<?php echo e(route('report.stock.pdf')); ?>" class="btn add_list_btn btn-sm">pdf</a>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('css'); ?>
<style>
    @media print{
        table,table th,table td {
            color:black !important;
        }

        .h-hide {
            display: none;
        }
    }
</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 ">
                    
                    <?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-light 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">
                        <h4 style="text-align: center; font-weight:bold; margin-top:5px;font-size:30px"><strong>Stock Report</strong></h4>
                        <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>Sale Return</th>
                                    <th>Purchase Return</th>
                                    <th>Damage</th>
                                    <th>Available Stock</th>
                                    <th class="header_style_right">Available Price</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);
                                        $return_pur_qty = return_pur_qty($data); 
                                        $stock = product_stock_balance($data) * $data->purchase_price;
                                    ?>
                                    <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($return_pur_qty); ?></td>
                                        <td><?php echo e($damaged_qty); ?></td>
                                        <td><?php echo e($stock_qty); ?></td>
                                        <td class="table_data_style_right"><?php echo e($stock); ?> Tk</td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="100%" class="text-center no_data_style text-danger">No Data Available</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                            <tfooter>
                                <tr class="header_bg">
                                    <td colspan="8" class="header_style_left text-white"><strong>Total Available Stock Price: </strong></td>
                                    <td colspan="2" class="header_style_right text-white"><strong><?php echo e(number_format($totalPrice,2)); ?> TK</strong></td>
                                </tr>
                            </tfooter>
                        </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 /home/fastitco/organic-station.fastit.com.bd/resources/views/backend/pages/report/stock.blade.php ENDPATH**/ ?>