
<?php $__env->startSection('content'); ?>
    <?php Fun::lang()?>
    <div class="page">
        <div class=container-fluid>
            <div class="top-content">
                <div class="row">
                    <div class="col-sm-12 col-xs-12 form-group">
                        <div class="title-add">
                            <div class="pull-left">
                                <h3><?php echo e(__('administrator.report_stock')); ?></h3>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="top-content">
                <div class="row">
                    <div class="col-sm-12 col-xs-12 form-group padding-0">
                        <div>
                            <div class="col-sm-4 form-group">
                                <?php echo Form::select('warehouse', $warehouses, null, array('class' => 'form-control select2', 'placeholder' => 'Please select warehouse')); ?>

                            </div>
                            <div class="col-sm-4 form-group">
                                <?php echo Form::select('product_id',$product,null, array('class' => 'form-control select2', 'placeholder' => 'Please select Item')); ?>

                            </div>
                            <div class="col-sm-offset-6 col-sm-6">
                                <button class=" button_success pull-right print_button" type="button"><i class="fa fa-print"></i> <?php echo e(__('administrator.print')); ?></button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="wrapper-table">
                <table id="print_table" class="table table-striped table-hover  ">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th><?php echo e(__('administrator.warehouse')); ?></th>
                            <th><?php echo e(__('administrator.barcode')); ?></th>
                            <th><?php echo e(__('administrator.item_name')); ?></th>
                            <th><?php echo e(__('administrator.type')); ?></th>
                            <th><?php echo e(__('administrator.import_qty')); ?></th>
                            <th><?php echo e(__('administrator.transfers_stock')); ?></th>
                            <th><?php echo e(__('administrator.export_qty')); ?></th>
                            
                            <th><?php echo e(__('administrator.balance_qty')); ?></th>
                        </tr>
                    </thead>
                    <tbody class="tbody">
                    </tbody>
                    <tfoot>
                    <tr>
                        <th colspan="5" class="text-right"><?php echo e(__('administrator.total')); ?></th>
                        <th>0</th>
                        <th>0</th>
                        <th>0</th>
                        <th>0</th>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
    <script type="text/javascript">
        function getTable(warehouse='',product_id=''){
            $('#print_table').DataTable({
                "oLanguage": {
                    "sSearch": "<?php echo e(__('administrator.search')); ?>:",
                    "sLengthMenu": "<?php echo e(__('administrator.display')); ?> _MENU_ <?php echo e(__('administrator.record_per_page')); ?>",
                    "sZeroRecords": "<?php echo e(__('administrator.Nothing_foundsorry')); ?>",
                    "sInfo": "<?php echo e(__('administrator.showing')); ?> _START_ <?php echo e(__('administrator.to')); ?> _END_ <?php echo e(__('administrator.of')); ?> _TOTAL_ <?php echo e(__('administrator.record')); ?>",
                    "sInfoEmpty": "<?php echo e(__('administrator.showing')); ?> 0 <?php echo e(__('administrator.to')); ?> 0 <?php echo e(__('administrator.of')); ?> 0 <?php echo e(__('administrator.record')); ?>",
                    "sInfoFiltered": "(<?php echo e(__('administrator.filter_form')); ?> _MAX_ <?php echo e(__('administrator.total_records')); ?>)",
                    "oPaginate": {
                        "sFirst": "<?php echo e(__('administrator.first')); ?>",
                        "sLast": "<?php echo e(__('administrator.last')); ?>",
                        "sNext": "<?php echo e(__('administrator.next')); ?>",
                        "sPrevious": "<?php echo e(__('administrator.previous')); ?>"
                    },
                },
                ordering: false,
                serverSide: true,
                lengthMenu: [[20, 30, 50, 100, 200, 500, 1000], [20, 30, 50, 100, 200, 500, 1000]],
                ajax: {
                    url:'<?php echo e(route("get-report-stock")); ?>',
                    data:{
                        warehouse:warehouse,
                        product_id:product_id,
                    },
                },
                columns:
                    [
                        {data: 'DT_RowIndex','searchable': false},
                        {data: 'warehouse', 'searchable': true},
                        {data: 'barcode', 'name': 'nso007_products.barcode'},
                        {data: 'product_name', 'name': 'nso007_products.product_name'},
                        {data: 'type', 'name': 'nso007_stocks.type'},
                        {data: 'in_qty','searchable': false},
                        {data: 'transfer_stock','searchable': false},
                        {data: 'out_qty','searchable': false},
                        // {data: 'return_qty'},
                        {data: 'stock_qty','searchable': false},
                    ],
                "fnDrawCallback": function () {
                    let tr = $('.tbody tr');
                    let $total_in = 0;
                    let $total_ex = 0;
                    let $total_stock = 0;
                    let $total_tran_in = 0;
                    let $total_tran_out = 0;
                    $.each(tr, function (ii, vv) {
                        let inn = $(this).find('td:nth-child(6)').text();
                        let tra_in = $(this).find('td:nth-child(7) .text-success').data('qty');
                        let tra_out = $(this).find('td:nth-child(7) .text-success').data('qty');
                        let ex = $(this).find('td:nth-child(8)').text();
                        let st = $(this).find('td:nth-child(9)').text();
                        $total_tran_in += parseFloat(tra_in ? tra_in : 0);
                        $total_tran_out += parseFloat(tra_out ? tra_out : 0);
                        $total_in += parseFloat(inn ? inn : 0);
                        $total_ex += parseFloat(ex ? ex : 0);
                        $total_stock += parseFloat(st ? st : 0);
                    });
                    $('#print_table').find('tfoot tr:first-child th:nth-child(2)').text($total_in ? $total_in : 0);
                    $('#print_table').find('tfoot tr:first-child th:nth-child(3)').text('<?php echo e(__('administrator.in')); ?> : ' + $total_tran_in + ' | <?php echo e(__('administrator.out')); ?> : ' + $total_tran_out);
                    $('#print_table').find('tfoot tr:first-child th:nth-child(4)').text($total_ex ? $total_ex : 0);
                    $('#print_table').find('tfoot tr:first-child th:nth-child(5)').text($total_stock ? $total_stock : 0);
                },
            });
        }
        $(document).ready(function () {
            getTable();
            $('select').on('change',function () {
                $('#print_table').DataTable().destroy();
                let product_id = $('select[name=product_id]').val();
                let warehouse = $('select[name=warehouse]').val();
                getTable(warehouse,product_id);
            });
        });
    </script>
<?php $__env->stopSection(); ?>

    


<?php echo $__env->make(branchMenu(), \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/branch/report/stock/index.blade.php ENDPATH**/ ?>