
<?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_inventory_balance')); ?></h3>
                            </div>
                            <div class="pull-right">
                                <?php echo $__env->make('administrator.report-stock.sub-menu', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="top-content">
                <div class="row">
                    <div class="col-sm-12 col-xs-12 form-group paddin-0">
                        <div>
                            <div class="col-sm-3 col-md-3">
                                <div class="col-sm-3 col-md-3">
                                    <?php echo e(__('administrator.warehouse')); ?>

                                </div>
                                <div class="form-group col-sm-9 col-md-9">
                                    <?php echo Form::select('warehouse', $warehouses, null, array('class' => 'form-control select2', 'placeholder' =>  __('administrator.please_select_warehouse'))); ?>

                                </div>
                            </div>
                            <div class="col-sm-3 col-md-3">
                                <div class="col-sm-3 col-md-3">
                                    <?php echo e(__('administrator.item')); ?>

                                </div>
                                <div class="form-group col-sm-9 col-md-9">
                                    <?php echo Form::select('product_id', [], null, array('class' => 'form-control select2 search_product', 'placeholder' =>  __('administrator.please_select'))); ?>

                                </div>
                            </div>
                            <div class=" col-sm-offset-6 col-sm-6">
                                <button class=" button_success pull-right print_button" type="button"
                                        data-text="<?php echo e(__('administrator.report_stock_inventory_balance')); ?>"><i
                                            class="fa fa-print "></i> <?php echo e(__('administrator.print')); ?></button>
                                <button class=" button_primary pull-right" id="search"
                                        type="submit"> <?php echo e(__('administrator.search')); ?></button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="wrapper-table">
                <table id="print_table_report" width="100%" class="table table-striped table-hover ">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th><?php echo e(__('administrator.warehouse')); ?></th>
                        <th><?php echo e(__('administrator.month')); ?></th>
                        <th><?php echo e(__('administrator.barcode')); ?></th>
                        <th><?php echo e(__('administrator.products')); ?></th>
                        <th><?php echo e(__('administrator.old_stock')); ?></th>
                        <th><?php echo e(__('administrator.import_qty')); ?></th>
                        <th><?php echo e(__('administrator.transfer')); ?></th>
                        <th><?php echo e(__('administrator.export_qty')); ?></th>
                        <th><?php echo e(__('administrator.balance_qty')); ?></th>
                    </tr>
                    </thead>
                    <tbody class="tbody">

                    </tbody>
                    <tfoot class="tfoot">
                    <tr>
                        <th class="text-right" colspan="5"><?php echo e(__('administrator.total')); ?></th>
                        <th class="green old_stock">Old</th>
                        <th class="green search_stock">In</th>
                        <th class="green tran_stock">tran</th>
                        <th class="green export_stock">Ex</th>
                        <th class="green balance">Bal</th>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
    <script type="text/javascript">
        $(document).ready(function () {
            dataTableFilter();
            $(document).on('click', '#search', function () {
                dataTableFilter();
            });
            $('#print_table').on('click','.show-stock-in',function () {
                let url = $(this).data('url');
                getHtmlFormShow(url,'1000px');
            });
        });

        function dataTableFilter() {
            $('#print_table_report').DataTable().destroy();
            let warehouse = $('select[name="warehouse"]').val();
            let product_id = $('select[name="product_id"]').val();
            $('#print_table_report').DataTable().destroy();
            $('#print_table_report').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('report-stock-item-by-date')); ?>",
                    data: {
                        warehouse: warehouse,
                        product_id: product_id,
                    }
                },
                columns:
                    [
                        {data: 'DT_RowIndex', 'searchable': false},
                        {data: 'warehouse_id', 'searchable': false},
                        {data: 'sale_date','searchable': false},
                        {data: 'barcode',  'name': 'nso007_stocks.barcode'},
                        {data: 'product_id', 'searchable': false},
                        {data: 'old_stock','searchable': false},
                        {data: 'import','searchable': false},
                        {data: 'transfer','searchable': false},
                        { data: 'export', 'searchable': false },
                        { data: 'balance', 'searchable': false },
                    ],
                "fnDrawCallback": function (settings, json) {
                    let tr = $('.tbody tr');
                    let t_old_stock = 0;
                    let t_in_stock = 0;
                    let t_tran_stock = 0;
                    let t_ex_stock = 0;
                    let t_bal_stock = 0;
                    $.each(tr,function (ii,vv) {
                        let old_stock = $(this).find('td:nth-child(6) ').text();
                        let in_stock = $(this).find('td:nth-child(7) ').text();
                        let tran_stock = $(this).find('td:nth-child(8) span').text();
                        let ex_stock = $(this).find('td:nth-child(9) ').text();
                        let bal_stock = $(this).find('td:nth-child(10) ').text();
                        old_stock = old_stock?parseFloat(old_stock):0;
                        t_old_stock+=old_stock;

                        in_stock = in_stock?parseFloat(in_stock):0;
                        t_in_stock+=in_stock;

                        tran_stock = tran_stock?parseFloat(tran_stock):0;
                        t_tran_stock+=tran_stock;

                        ex_stock = ex_stock?parseFloat(ex_stock):0;
                        t_ex_stock+=ex_stock;

                        bal_stock = bal_stock?parseFloat(bal_stock):0;
                        t_bal_stock+=bal_stock;

                    });
                    $('.tfoot tr:first-child ').find('.old_stock').html(t_old_stock);
                    $('.tfoot tr:first-child ').find('.search_stock').html(t_in_stock);
                    $('.tfoot tr:first-child ').find('.tran_stock').html(t_tran_stock);
                    $('.tfoot tr:first-child ').find('.export_stock').html(t_ex_stock);
                    $('.tfoot tr:first-child ').find('.balance').html(t_bal_stock);
                },
            });
        }

    </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/administrator/report-stock/stock-item-by-date.blade.php ENDPATH**/ ?>