

<?php $__env->startSection('title', 'Product Purchase Report (Meter)'); ?>

<?php $__env->startSection('content'); ?>

<section class="content-header">
    <h1>Product Purchase Report (Meter)</h1>
</section>

<section class="content">
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">Filters</h3>
        </div>
        <div class="box-body">
            <div class="row">
                <div class="col-md-12">
                    <form method="GET" action="<?php echo e(route('product-purchase-meter-report'), false); ?>" class="form-inline" id="filter_form">
                        <div class="form-group">
                            <?php echo Form::label('location_id', __('sale.location') . ':'); ?>

                            <?php echo Form::select('location_id', $business_locations, request()->location_id, ['class' => 'form-control select2', 'style' => 'width:200px', 'placeholder' => __('report.all')]); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('supplier_id', __('contact.supplier') . ':'); ?>

                            <?php echo Form::select('supplier_id', $suppliers, request()->supplier_id, ['class' => 'form-control select2', 'style' => 'width:200px', 'placeholder' => __('report.all')]); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('brand_id', __('product.brand') . ':'); ?>

                            <?php echo Form::select('brand_id', $brands, request()->brand_id, ['class' => 'form-control select2', 'style' => 'width:200px', 'placeholder' => __('report.all')]); ?>

                        </div>
                        <div class="form-group">
                            <?php echo Form::label('start_date', __('Start Date') . ':'); ?>

                            <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                                <?php echo Form::text('start_date', request()->start_date, ['class' => 'form-control datepicker', 'placeholder' => __('report.start_date'), 'readonly']); ?>

                            </div>
                        </div>
                        <div class="form-group">
                            <?php echo Form::label('end_date', __('End Date') . ':'); ?>

                            <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                                <?php echo Form::text('end_date', request()->end_date, ['class' => 'form-control datepicker', 'placeholder' => __('report.end_date'), 'readonly']); ?>

                            </div>
                        </div>
                        <button type="submit" class="btn btn-primary">Filter</button>
                        <a href="<?php echo e(route('product-purchase-meter-report'), false); ?>" class="btn btn-default">Clear</a>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div class="box box-primary">
        <div class="box-body">
            <div class="table-responsive">
                <table class="table table-bordered table-striped" id="product_purchase_meter_table">
                    <thead>
                        <tr>
                            <th>Product</th>
                            <th>SKU</th>
                            <th><?php echo app('translator')->get('purchase.ref_no'); ?></th>
                            <th><?php echo app('translator')->get('contact.supplier'); ?></th>
                            <th><?php echo app('translator')->get('purchase.purchase_date'); ?></th>
                            <th>Quantity (KG)</th>
                            <th>Unit Price (KG)</th>
                            <th>Subtotal (KG)</th>
                            <th>Quantity (Meter)</th>
                            <th>Unit Price (Meter)</th>
                            <th>Subtotal (Meter)</th>
                            <th>Meter to KG Factor</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</section>

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

<?php $__env->startSection('javascript'); ?>
<script>
    $(document).ready(function() {
        // Initialize Select2
        $('.select2').select2();

        // Datepicker
        $('.datepicker').datepicker({
            autoclose: true,
            format: 'yyyy-mm-dd'
        });

        // Initialize DataTable
        var product_purchase_meter_table = $('#product_purchase_meter_table').DataTable({
            processing: true,
            serverSide: true,
            ajax: {
                url: '<?php echo e(route("product-purchase-meter-report"), false); ?>',
                data: function(d) {
                    d.location_id = $('#location_id').val();
                    d.supplier_id = $('#supplier_id').val();
                    d.brand_id = $('#brand_id').val();
                    d.start_date = $('#start_date').val();
                    d.end_date = $('#end_date').val();
                }
            },
            columns: [
                { data: 'product_name', name: 'p.name' },
                { data: 'sub_sku', name: 'v.sub_sku' },
                { data: 'ref_no', name: 't.ref_no' },
                { data: 'supplier', name: 'c.name' },
                { data: 'transaction_date', name: 't.transaction_date' },
                { data: 'purchase_qty_kg', name: 'purchase_qty_kg' },
                { data: 'unit_purchase_price_kg', name: 'unit_purchase_price_kg' },
                { data: 'subtotal_kg', name: 'subtotal_kg' },
                { data: 'purchase_qty_meter', name: 'purchase_qty_meter' },
                { data: 'unit_purchase_price_meter', name: 'unit_purchase_price_meter' },
                { data: 'subtotal_meter', name: 'subtotal_meter' },
                { data: 'kg_to_meter_factor', name: 'kg_to_meter_factor' }
            ],
            fnDrawCallback: function(oSettings) {
                __currency_convert_recursively($('#product_purchase_meter_table'));
            }
        });

        // Apply filters on change
        $('#filter_form').on('submit', function(e) {
            e.preventDefault();
            product_purchase_meter_table.ajax.reload();
        });
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\cable\resources\views/report/product_purchase_meter_report.blade.php ENDPATH**/ ?>