



<?php $__env->startSection('title', 'Company Inventory Analysis'); ?>


<?php $__env->startSection('internal-js'); ?>
    <script>
        $(document).ready(function () {
            $('#example').DataTable( {
                dom: 'lBfrtip',
                buttons: [
                    { extend: 'excel', className: 'download-buttons' },
                    { extend: 'pdf', className: 'download-buttons' }
                ],
                footerCallback: function ( row, data, start, end, display ) {
                    var api = this.api(), data;
                    var numberRenderer = $.fn.dataTable.render.number(',', '.', 2).display;

                    // Remove the formatting to get integer data for summation
                    var intVal = function ( i ) {
                        return typeof i === 'string' ? i.replace(/[\.]/g, '.').replace(/[\,]/g, '') * 1 : typeof i === 'number' ? i : 0;
                    };
                    //Inventory Number
                    totalItems = api.column( 4 ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    currentItems = api.column( 4, { page: 'current'} ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    // Update Footer - Sale Amount
                    $( api.column( 4 ).footer() ).html(currentItems +'<br>('+ totalItems +')').css('color', 'blue');


                    //Buying Amount
                    totalBuyAmount = api.column( 5 ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    currentBuyAmount = api.column( 5, { page: 'current'} ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    // Update Footer - Sale Amount
                    $( api.column( 5 ).footer() ).html(numberRenderer(currentBuyAmount) +'<br>('+ numberRenderer(totalBuyAmount) +')').css('color', 'blue');

                    //Buying Amount
                    totalSalesAmount = api.column( 6 ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    currentSalesAmount = api.column( 6, { page: 'current'} ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    // Update Footer - Sale Amount
                    $( api.column( 6 ).footer() ).html(numberRenderer(currentSalesAmount) +'<br>('+ numberRenderer(totalSalesAmount) +')').css('color', 'blue');

                    //Buying Amount
                    totalProfitAmount = api.column( 7 ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    currentProfitAmount = api.column( 7, { page: 'current'} ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    // Update Footer - Sale Amount
                    $( api.column( 7 ).footer() ).html(numberRenderer(currentProfitAmount) +'<br>('+ numberRenderer(totalProfitAmount) +')').css('color', 'blue');


                },
            } );
        });
    </script>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('internal-css'); ?>
    <style>
        #example th, td {
            text-align: left;
            padding: 5px;
        }
        #example tr:hover {background-color: #a3aef6;}
    </style>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('headers'); ?>
    <?php echo $__env->make('headers.inventory-header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('heading', 'Company Inventory Analysis'); ?>
<?php $__env->startSection('searches', ''); ?>

<?php $__env->startSection('content'); ?>
    <div class="tab">
        <button class="tablinks" onclick="openCity(event, 'active')" id="defaultOpen">Company Inventory Analysis</button>
    </div>

    <div class="tabcontent" id="active">
        <span onclick="this.parentElement.style.display='none'" class="topright" style="margin-left: 20px">&times</span>
        <h3 class="error">
            Available Inventory Value
        </h3>
        <table id="example" class="display" style="width:100%; border-collapse: collapse">
            <thead>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Item Name</th>
                <th>Buying Price</th>
                <th>Selling Price</th>
                <th>Current Stock</th>
                <th>Stock Total Purchase Value</th>
                <th>Stock Total Sales Value</th>
                <th>Expected Profit</th>
            </tr>
            </thead>
            <tbody>
            <?php $__currentLoopData = $list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if($row->itemInventory->sum('quantity') > 0 && $row->buying_price > 0): ?>
                    <tr>
                        <td class="ar"></td>
                        <td><b class="error"><?php echo e($row->name); ?></b></td>
                        <td><?php echo number_format($row->buying_price, 2); ?></td>
                        <td><b class="error"><?php echo number_format($row->min_selling_price, 2); ?></b></td>
                        <td style="font-weight: bold"><?php echo $row->itemInventory->sum('quantity'); ?></td>
                        <td style="font-weight: bold"><?php echo $row->itemInventory->sum('quantity')*$row->buying_price; ?></td>
                        <td style="font-weight: bold"><?php echo $row->itemInventory->sum('quantity')*$row->max_selling_price; ?></td>
                        <td style="font-weight: bold" class="success"><?php echo $row->itemInventory->sum('quantity')*$row->max_selling_price - $row->itemInventory->sum('quantity')*$row->buying_price; ?></td>
                    </tr>
                <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
            <tfoot>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Item Name</th>
                <th>Buying Price</th>
                <th>Selling Price</th>
                <th>Current Stock</th>
                <th>Stock Total Purchase Value</th>
                <th>Stock Total Sales Value</th>
                <th>Expected Profit</th>
            </tr>
            </tfoot>
        </table>
    </div>
<?php $__env->stopSection(); ?>



<?php $__env->startSection('modal_heading'); ?>
    <h1>Company Inventory Analysis</h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('modal_title'); ?>
    <h3><u>Dashboard Functionalities</u></h3>
    <b>
        <ol>
            <li>View all Available Stock and Balances</li>
            <li>Export Inventory Analysis</li>
        </ol>
    </b>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/zedarroot/public_html/edwulp/resources/views/inventory/inventory-analysis.blade.php ENDPATH**/ ?>