@extends('layouts.fixed')
@section('title','Stock Transaction report')
@section('css')
    <style>
        body {
            overflow-y: hidden;
            /*font-family: "Times New Roman";*/
            color: #000000;
        }
        .table-bordered td, .table-bordered th {
            border: 0.1rem solid rgba(8, 8, 8, 0.33) !important;
        !important;
        }

        h5.heading-title {
            text-transform: initial;
            font-weight: bold;
            letter-spacing: 1px;
        }

        tr th, tr td {
            line-height: 1.0;
            font-size: 15px;
            padding: 7px !important;

        }

        tr th, span strong, div span {
            text-transform: initial;
            font-weight: bold;
        }

        @media print {
            @page {
                size: A4 landscape;
                padding: 0 !important;
                margin: 0 !important;
            }
            .table-bordered td, .table-bordered th {
                border: 0.1rem solid rgba(8, 8, 8, 0.50) !important;
            }

            body{
                overflow: hidden !important;
                color: #000000;
            }

            div.card-body{
                margin: auto 20px;
            }

            div.card-body{
                padding-top: 0;
            }
            .table .thead-dark th {
                color: #000 !important;
                background-color: #dadada !important;
                /*border-color: #32383e !important;*/
            }
            /*body {*/
            /*-webkit-print-color-adjust: exact;*/
            /*}*/

        }
    </style>
@stop
@section('content')
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>Stock Transaction</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="#">Report</a></li>
                        <li class="breadcrumb-item active">Stock Transaction</li>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>

    <section class="content no-print">
        <div class="container-fluid">
            {{--start --}}
            <div class="col-lg-12 col-sm-8 col-md-6 col-xs-12">
                <div class="card card-primary card-outline">
                    <div class="card-body " style="padding-bottom:0">
                        {{ Form::open(['route'=>'inventory.stock.issue.report','method'=>'get']) }}

                        <div class="form-row">
                            <div class="form-group col-md-4" >
                                <label>From</label>
                                <input type="" name="from" class="form-control" value="{{date('d-m-Y',strtotime($from)) }}">
                            </div>
                            <div class="form-group col-md-4" >
                                <label>To</label>
                                <input type="" name="to" class="form-control" value="{{date('d-m-Y',strtotime($to)) }}">
                            </div>
                           
                            <div class="form-group col-md-2" style="margin-top: 30px">
                                <button type="submit" class="btn btn-info btn-md btn-block"><i class="fa fa-search"></i>&nbsp;Search</button>
                            </div>
                            <div class="form-group col-md-2" style="margin-top: 30px">
                                <button class="btn btn-success btn-md btn-block" onclick="window.print(); return false;"><i class="fa fa-print"></i>&nbsp;Print</button>
                            </div>

                        </div>
                        {{  Form::close() }}
                    </div>
                </div>
                <!-- /.card -->
            </div>
        </div>{{--end --}}
    </section>

@if($datas != null);
    @php
        $pageNo= 1;
        $i=1;
    @endphp
    @foreach($datas->chunk(17) as $issueproducts)
        <section class="content">
            <div class="col-lg-12">
                <div class="card"><br>
                    <div class="card-body">

                        <div class="row">
                            <div class="col-md-12 text-right" style="margin:2px 30px 0 0">
                                <h6>Page No: {{$pageNo++}}</h6>
                            </div>
                            <div class="col-md-12 text-center">
                                <h3><b>  {{ is_numeric(Auth::user()->active_unit) ? \App\Unit::query()->findOrFail(Auth::user()->active_unit)->name : 'NULL' }}</b></h3>
                                <h5><b>Issue Product List</b></h5>
                                {{-- <h5>Transaction Type : Purchase</h5> --}}
                                <h6>Report From {{ dateFormat($from) }} To {{ dateFormat($to) }}</h6>
                            </div>
                        </div>
                        {{-- view start --}}
                        <table class="table table-hover table-bordered table-condensed text-right" width="100%">
                            <thead>
                            <tr class="text-center">
                                <th  class="text-center">#SL</th>
                                <th >Item Name</th>
                                <th >Issud By</th>
                                <th>Issud Qty</th>
                                <th>Date</th>
                            </tr>
                            </thead>
                            <tbody>
                            
                            @foreach($issueproducts as $issueproduct)
                                <tr>
                                    <td class="text-center">{{ $i++ }}</td>
                                    <td class="text-left">{{ $issueproduct->product->name }}</td>
                                    <td>{{ $issueproduct->user->name }}</td>
                                    <td>{{ $issueproduct->qty }}</td>
                                    <td>{{ $issueproduct->issue_date }}</td>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>
        <div class="page_break"></div>
    @endforeach

@else
    <section class="content no-print">
        <div class="container-fluid">

            <div class="col-lg-12 col-sm-8 col-md-6 col-xs-12">
                <div class="card card-primary card-outline">
                    <div class="card-body box-profile">
                        <h4 class="text-center">No Data Found</h4>
                    </div>
                </div>
                <!-- /.card -->
            </div>
        </div>
    </section>

@endif


@stop

@section('style')

@stop


@section('plugin')
    <!-- DataTables -->
    <script src="{{ asset('plugins/datatables/jquery.dataTables.js') }}"></script>
    <script src="{{ asset('plugins/datatables/dataTables.bootstrap4.js') }}"></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js'></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.4/jquery-confirm.min.js"></script>
@stop

@section('script')
    <!-- page script -->
    <script type="text/javascript">
        $('.select2').select2()
    </script>
@stop