<?php $__env->startSection('title', 'Loaded Inventory Reports'); ?>


<?php $__env->startSection('internal-js'); ?>
    <script>
        $(document).ready(function () {
            $('#insurers1').DataTable( {
                dom: 'lBfrtip',
                buttons: [
                    { extend: 'excel', 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;
                    };

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

                    //Comm Amount
                    totalSalesAmount = api.column( 4 ).data().reduce( function (a, b) { return intVal(a) + intVal(b)}, 0 );
                    currentSalesAmount = 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(numberRenderer(currentSalesAmount) +'<br>('+ numberRenderer(totalSalesAmount) +')').css('color', 'blue');

                },
            } );

            $('#date-from').on('change', function (){
                $('#date-to').attr('required', true);
            });
            $('#date-to').on('change', function (){
                $('#date-from').attr('required', true);
            });
        });

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


<?php $__env->startSection('internal-css'); ?>
    <style>
        #insurers1 tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        #insurers1 th, td {
            text-align: left;
            padding: 5px;
        }
        #insurers1 tr:hover {background-color: #d8d9e1;}
    </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', 'Loaded Inventory Report'); ?>
<?php $__env->startSection('done-by', ''); ?>


<?php $__env->startSection('content'); ?>
    <div class="inputDivider" style="margin-top: 10px; text-align: left; background-color: lightcyan">
        <?php echo Form::open(['action'=>['Modules\InventoryDashboardController@showInventoryReport'], 'method'=>'POST', 'id'=>'filter-inventory-report', 'class'=>'fields-small']); ?>

        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                &nbsp;
            </div>
            <div class="guestDetails_input_right">
                <button type="submit" name="search" style="cursor: pointer"><i class="fa fa-search" aria-hidden="true"></i></button>
            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Date Added To:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <?php echo Form::date('to', $search['to'] ?? date('Y-m-d'), ['id'=>'date-to','style'=>'cursor:pointer', 'class'=>'input-text-height']); ?>

            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Date Added From:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <?php echo Form::date('from',  $search['from'] ?? date('Y-m-d'), ['id'=>'date-from','style'=>'cursor:pointer', 'class'=>'input-text-height']); ?>

            </div>
        </div>
        <div class="guestDetails_inputDividerNone" style="height: 0"></div>
        <?php echo Form::close(); ?>

    </div>
    <div class="guestDetails_inputDivider"></div>
    <!--View and Setup your Insurers-->
    <div>
        <!--Export Links/Buttons-->
        <span onclick="this.parentElement.style.display='none'" class="topright" style="margin-left: 20px">&times</span>
        <table id="insurers1" style="width: 100%; border-collapse: collapse; ">
            <thead>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Item Name.</th>
                <th>Unit Buy Price</th>
                <th>Quantity</th>
                <th>Total Amount Paid</th>
                <th>Comments</th>
                <th>Date Sold</th>
                <th>User</th>
            </tr>
            </thead>
            <tbody>
            <?php $__currentLoopData = $list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if($row->item): ?>
                    <tr>
                        <td class="ar"></td>
                        <td><b class="error"><?php echo strtoupper($row->item->name); ?></b></td>
                        <td><?php echo number_format($row->unit_price_buy,2); ?></td>
                        <td style="font-weight: bold" class="error"><?php echo e(abs($row->quantity)); ?></td>
                        <td style="font-weight: bold"><?php echo number_format($row->total_price_buy,2); ?></td>
                        <td><?php echo $row->comments; ?></td>
                        <td><?php echo date('d/m/Y H:i:s a', strtotime($row->created_at)); ?></td>
                        <td>
                            <?php if($row->user): ?>
                                <?php echo $row->user->firstName." ".$row->user->lastName; ?>

                            <?php endif; ?>
                        </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>Unit Buy Price</th>
                <th>Quantity</th>
                <th>Total Amount Paid</th>
                <th>Comments</th>
                <th>Date Sold</th>
                <th>User</th>
            </tr>
            </tfoot>
        </table>

    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('modal_heading'); ?>
    <h1>Inventory Report</h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('modal_title'); ?>
    <h3><u>Dashboard Functionalities</u></h3>
    <b>
        <ol>
            <li>View Loaded Inventory per a Specified Period</li>
            <li>Filter through available Inventory Reports</li>
            <li>Export Inventory Report</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/loaded-inventory-analysis.blade.php ENDPATH**/ ?>