<!DOCTYPE html>
<html>

@include('includes.head')

<body class="hold-transition skin-blue fixed sidebar-mini">
    <!-- Site wrapper -->
    <div class="wrapper">

        @include('includes.header')
        <!-- =============================================== -->

        <!-- Left side column. contains the sidebar -->
        @include('includes.side-nav')

        <!-- =============================================== -->

        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    System File Upload
                    <small>Manage Files</small>
                </h1>
                <ol class="breadcrumb">
                    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                    <li><a href="#">Files</a></li>
                    <li class="active">Upload</li>
                </ol>
            </section>

            <!-- Main content -->
            <section class="content">

                <!-- Default box -->
                <div class="box box-primary">

                    <div class="box-header with-border">
                        <h3 class="box-title">Upload File</h3>
                        <form role="form" action="{{ route('file.upload.submit') }}" method="POST"
                            enctype="multipart/form-data">
                            @csrf
                            <div class="box-body">

                                <div class="form-group">
                                    <label>Select File</label>
                                    <input type="file" name="file">
                                    <p class="help-block">Upload File.</p>
                                </div>

                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" name="submit" class="btn btn-primary btn-flat">Submit</button>
                            </div>
                        </form>

                    </div>
                    <div class="row">

                        <div class="col-md-12">
                            <div class="box-body">
                                @include('includes.messages')
                                <table class="table table-bordered table-hover">
                                    <tr>
                                        <th style="width: 150px">SL No</th>
                                        <th>File Reference ID</th>
                                        <th>File Name</th>
                                        <th>File Size</th>
                                        <th style="width: 150px">Upload Status</th>
                                        <th style="width: 150px">Action</th>

                                    </tr>
                                    @foreach ($records as $index => $record)
                                        <tr>
                                            <td>{{ $index + $records->firstItem() }}</td>
                                            <td>{{ $record->ref }}</td>
                                            <td>{{ $record->original_name }}</td>
                                            <td>{{ $record->file_size }}</td>

                                            @if ($record->is_uploaded)
                                                <td><span class="badge bg-green">Success</span></td>
                                                <td>
                                                    <div class="btn-group">
                                                        <a href="#" type="button"
                                                            class="btn btn-info btn-flat">Download</a>
                                                        <button type="button"
                                                            class="btn btn-info btn-flat dropdown-toggle"
                                                            data-toggle="dropdown">
                                                            <span class="caret"></span>
                                                            <span class="sr-only">Toggle Dropdown</span>
                                                        </button>
                                                        <ul class="dropdown-menu" role="menu">
                                                            <li><a href="#">Download</a>
                                                            </li>
                                                            <li class="divider"></li>
                                                            <li><a href="#">Remove</a>
                                                            </li>

                                                        </ul>
                                                    </div>
                                                </td>
                                            @else
                                                <td><span class="badge bg-red">Failed</span></td>
                                                <td></td>
                                            @endif


                                        </tr>
                                    @endforeach

                                </table>

                                {{ $records->appends(request()->input())->links() }}
                            </div>


                        </div>

                    </div>


                </div>
                <!-- /.box -->

            </section>
            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->

        @include('includes.footer')

    </div>
    <!-- ./wrapper -->

    @include('includes.scripts')
</body>

</html>
