@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">

        <div class="col-md-12">
            <div class="panel panel-default">
             
                <div class="panel-heading">
                    <h1>Generated Letters</h1>
                </div>
                <div class="panel-body">
                    @if (session('status'))
                        <div class="alert alert-success">
                            {{ session('status') }}
                        </div>
                    @endif
                    <div class="row">
                      <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                          <div class="pull-right">
                            <a href='{{ url("/lg/new")  }}' class="btn btn2"><span class="glyphicon glyphicon-plus"></span>Generate New Letter</a>
                          </div>
                          
                          <div class="x_content">
                              <a href='{{ url("/lg")  }}' class="btn btn2 pull-right">Back</a>
                          
                          {{ $letters->links() }}
                            <table id="datatable-responsive" class="table table-striped table-hover table-responsive dt-responsive nowrap" cellspacing="0" width="100%">
                              <thead>
                                <tr>
                                  <th>Client</th>
                                  <th>Created Date</th>
                                  <th>Letter Files</th>
                                  <th>Number of Files</th>
                                  <th>Actions</th>
                                </tr>
                              </thead>
                              <tbody>

                              @foreach ($letters as $key => $obj)
                                <tr>
                                  <td>{{ $obj->client_name }}</td>
                                  <td>{{ date('F-d-Y', strtotime($obj->created_at)) }}</td>
                                  <td><a  style ="font-weight:bold" href="{{ url('/download/'.$obj->zip_file) }}" title="download file" >{{ $obj->zip_file }}</a></td>
                                  <td>{{ $obj->num_of_files }}</td>
                                                                    
                                  <td>
                                    <a href="{{ url('/download/'.$obj->zip_file) }}" class="btn btn-success" style="padding: 1px 6px;"><span class="glyphicon glyphicon-download" title="download"></span></a>
                                    <a href='{{ url("/lg/edit/$obj->id") }}' class="btn btn-success" style="padding: 1px 6px;"><span class="glyphicon glyphicon-pencil" title="edit"></span></a>
                                    <a href='{{ url("/lg/delete/$obj->id") }}' class="btn btn-danger" style="padding: 1px 6px;" onclick="return confirm('Are you sure you want to delete this letter?');"><span class="glyphicon glyphicon-remove" title="delete"></span></a>
                                    
                                  </td>
                                </tr>
                              @endforeach
                              </tbody>
                            </table>
                            {{ $letters->links() }}
                    
                    
                          </div>
                        </div>
                      </div>
                    </div> 

                </div>
            </div>
        </div>
    </div>
</div>
@endsection
