@extends('layouts.adminapp')

@section('content')

{{-- Support Team --}}


<div class="card mb-4">
    <div class="card-header">
        <div class="d-flex">
            <div class="mr-auto p-2 align-self-center"><h4>Support Tickets</h4></div>
                      
        </div>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <!--th>SLNO.</th-->
                        <th>User</th>
                        <th>Email</th>
                        <th>Department</th>
                        <th>Subject</th>
                        <th>Message</th>  
                        <th>Status</th>
                        <th>Closed</th>                   
                        <th>Actions</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($Bookings as $Booking)
                    <tr>
                        <td>{{$Booking->user->name}}</td>
                        <td>{{$Booking->user->email}}</td>
                        <td>{{$Booking->supportdepartment->title}}</td>
                        <td>{{$Booking->subject}}</td>                       
                        <td>{{$Booking->message}}</td>
                        <td>{{$Booking->status}}</td>
                        <td>
                            @if($Booking->isClosed==0)
                                Not Closed
                            @else
                                Closed 
                            @endif    
                        </td>
                        <td style="width: 150px;">
                            <form method="POST" action="{{route('ticketUpdate',$Booking->id)}}">
                            @csrf
                            @method('post')
                                
                                <button type="submit" class="btn btn-secondary"><i class="fas fa-check"></i> Completed</button>
                            </form>    
                        </td>
                        <td style="width: 150px;"><button class="btn btn-info" data-toggle="modal" onclick="openmail('{{$Booking->user->email}}')"><i class="far fa-comment-dots"></i> Replay</button></td>   
                                          
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
    <div class="card-footer">
        <div class="d-flex justify-content-end font-weight-bold"><h5>Total: {{$Bookings->count()}} </h5></div>        
    </div>
</div>

<script>
    function openmail(Email) {
        document.getElementById("clientemail").value=Email;
      $('#modalEmail').modal('show');
      //JersyView("");
}
</script>


<!-- MODAL POP UP -->
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" id="modalEmail" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title"><i class="far fa-comment-dots"></i> Replay</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button>
        </div>

        <form method="post" action="{{route('sendbasicemail')}}">
        @csrf
        
        <div class="modal-body">
        
            <div class="form-group">
                <label for="clientemail">Email address</label>
                <input type="email" class="form-control" id="clientemail" name="clientemail" placeholder="{{$Booking->user->email}}" value="{{$Booking->user->email}}">
            </div>
            <div class="form-group">
                <label for="subject">Subject</label>
                <input type="text" class="form-control" id="subject" name="txtsubject" placeholder="{{$Booking->subject}}" value="{{$Booking->subject}}">
            </div>
            <div class="form-group">
                <label for="exampleFormControlTextarea1">Message</label>
                <textarea class="form-control" name="emailtxt" id="emailtxt" rows="4"></textarea>
            </div>
       
        </div>

        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            <button type="submit" class="btn btn-primary">Send</button>
        </div>
        
        </form>

    </div>
  </div>
</div>

@endsection