@extends('layouts.master')

@section('content')
<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title">{{ $title }}</h3>
    </div>
    <div class="panel-body">
        <a href="{{ url('ticket/new') }}" class="btn btn-info"><i class="fa fa-plus"></i> Open New Ticket</a>
        <br> <br>



        @if($tickets)
            @foreach($tickets as $ticket)
            <div class='media'>
               <a class='pull-left' href="{{ url('ticket/show'.'/'.$ticket->id) }}">
                 <img class="media-object" src="{{ asset('assets/img/support.png') }}" alt="...">
               </a>

                 <div class="media-body">
                    <?php 
                    $priority='';
                    switch ($ticket->priority) {
                        case '1':
                            $priority="<span class='label label-default'>Low</span>";
                            break;
                        case '2':
                            $priority="<span class='label label-info'>Medium</span>";
                            break;

                        case '3':
                            $priority="<span class='label label-warning'>High</span>";
                            break;

                        case '4':
                            $priority="<span class='label label-danger'>Urgent</span>";
                            break;
                        
                        default:
                            
                            break;
                    }

                    ?>
                    <span class="label label-info">{{ @$ticket->user->company_data?$ticket->user->company_data->name:'' }}</span>
                    <h4 class="media-heading">{{ $ticket->title }} {!! $priority !!}</h4>
                    <p>
                    {{ $ticket->details }}
                    </p>
                
                     <a href="{{ url('ticket/show'.'/'.$ticket->id) }}" !important;' class='btn btn-xs btn-link'>Details</a>

                    <br>
                    <p style='margin-left: 2px; padding-top:5px;'>
                        <i class="fa fa-user"></i> {{ $ticket->user?$ticket->user->name:'' }} &nbsp;&nbsp;&nbsp;&nbsp;
                        <i class="fa fa-user"></i> {{ $ticket->created_user?$ticket->created_user->name:'' }} &nbsp;
                        <i class="fa fa-clock-o"></i> {{ date('d M, Y',strtotime($ticket->created_at)) }}
                        &nbsp;&nbsp;
                        <?php 
                        $status='';
                        switch ($ticket->status) {
                            case '0':
                                $status='Initiated';
                                break;
                            case '1':
                                $status='In Process';
                                break;
                            case '2':
                                $status='Onhold';
                                break;
                            case '3':
                                $status='Closed';
                                break;
                            
                            default:
                                # code...
                                break;
                        }
                        ?>
                        <i class="fa fa-tags"></i> {{ $status }}
                    </p>
                    <hr>
                 </div>
            </div>
            @endforeach
            <div class="row">
                <div class="col-md-12">
                    <div style="margin-left:42%">
                       {!! $tickets->render() !!}
                    </div>
                    
                </div>
            </div>
        @endif
    </div>
</div>
@stop

@section('style')
<style>
.label{
 padding: 0.2em 0.3em .2em !important;
 font-size: 60% !important;
}
</style>
@stop





