{{-- Ecalate Ticket modal --}}

@if (!empty(session('escalateModal')))
<div class="modal fade " id="escalateTicketModal" tabindex="-1" role="dialog"
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal modal-dialog-centered" role="document">
        <div class="modal-content">
        <div class="modal-header mb-5 bg-secondary">
            <h5 class="modal-title text-dark" id="exampleModalCenterTitle">Escalate Ticket</h5>
            {{-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button> --}}
        </div>
        <form action="{{ route('tickets.escalate') }}" method="POST">
            @csrf
            <input name="escalator_id" value="{{ auth()->user()->id }}" hidden>
            <input name="ticket_id" value="{{ session('escalateModal')['ticket_id'] }}" hidden>
            <div class="form-group row mb-4">
              <label class="col-form-label text-md-right col-12 col-md-3 col-lg-3" for="title">Escalate To:</label>
              <div class="col-sm-12 col-md-7">
                <select name="receiver_id" class="form-control" required>
                    <option value="">--select---</option>
                    @foreach ($users as $user)
                            <option value="{{ $user->id }}">{{  $user->first_name.' - ('. $user->role->title .')' }}</option>
                          @endforeach
                </select>
              </div>
            </div>
            <div class="form-group row mb-4">
              <label class="col-form-label text-md-right col-12 col-md-3 col-lg-3" for="title">Escalation Comment</label>
              <div class="col-sm-12 col-md-7">
                <textarea name="escalator_comment" class="form-control" cols="30" rows="10" placeholder="Leave a comment to the one you're escalating to" required></textarea>
              </div>
            </div>
            <div class="modal-footer bg-whitesmoke br">
                <button type="submit" class="btn btn-primary">Submit</button>
                {{-- <button type="button" class="btn btn-secondary dismiss" data-dismiss="modal">Cancel</button> --}}
            </div>
        </form>
        </div>
    </div>
</div>
    
<script>
    setTimeout(() => {
        $('#escalateTicketModal').modal('show')
    }, 500);
</script>
@endif

{{-- Close Ticked Modal --}}
@if (!empty(session('closeModal')))
    
<div class="modal fade " id="closeTicketModal" tabindex="-1" role="dialog"
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal modal-dialog-centered" role="document">
        <div class="modal-content">
        <div class="modal-header mb-5 bg-secondary">
            <h5 class="modal-title text-dark" id="exampleModalCenterTitle">Close Ticket</h5>
            {{-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button> --}}
        </div>
        <form action="{{ route('tickets.close') }}" method="POST">
            @csrf
            <input name="user_id" value="{{ auth()->user()->id }}" hidden>
            <input name="ticket_id" value="{{ session('closeModal')['ticket_id'] }}" hidden>
            <div class="form-group row mb-4">
              <label class="col-form-label text-md-right col-12 col-md-3 col-lg-3" for="title">Closure Comment</label>
              <div class="col-sm-12 col-md-7">
                <textarea name="closure_comment" class="form-control" cols="30" rows="10" placeholder="Leave a comment on ticket closure" required></textarea>
              </div>
            </div>
            <div class="modal-footer bg-whitesmoke br">
                <button type="submit" class="btn btn-primary">Submit</button>
                {{-- <button type="button" class="btn btn-secondary dismiss" data-dismiss="modal">Cancel</button> --}}
            </div>
        </form>
        </div>
    </div>
</div>

<script>
    setTimeout(() => {
        $('#closeTicketModal').modal('show')
    }, 500);
</script>
@endif

{{-- Validate Ticket Modal --}}
@if (!empty(session('validateModal')))
    
<div class="modal fade " id="validateTicketModal" tabindex="-1" role="dialog"
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal modal-dialog-centered" role="document">
        <div class="modal-content">
        <div class="modal-header mb-5 bg-secondary">
            <h5 class="modal-title text-dark" id="exampleModalCenterTitle">Validate Ticket</h5>
            {{-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button> --}}
        </div>
        <form action="{{ route('tickets.validate') }}" method="POST">
            @csrf
            <input name="user_id" value="{{ auth()->user()->id }}" hidden>
            <input name="ticket_id" value="{{ session('validateModal')['ticket_id'] }}" hidden>
            <div class="form-group row mb-4">
              <label class="col-form-label text-md-right col-12 col-md-3 col-lg-3" for="title">Validation Comment</label>
              <div class="col-sm-12 col-md-7">
                <textarea name="validator_comment" class="form-control" cols="30" rows="10" placeholder="Leave a comment on ticket validation" required></textarea>
              </div>
            </div>
            <div class="modal-footer bg-whitesmoke br">
                <button type="submit" class="btn btn-primary">Submit</button>
                {{-- <button type="button" class="btn btn-secondary dismiss" data-dismiss="modal">Cancel</button> --}}
            </div>
        </form>
        </div>
    </div>
</div>

<script>
    setTimeout(() => {
        $('#validateTicketModal').modal('show')
    }, 500);
    // $('.dismiss').click(()=>{
    //     alert('Click')
    //     $('#validateTicketModal').modal('close')
    // })
</script>
@endif