@extends('Admin.master_page')



@section('title') <h5 class="m-0 font-weight-bold text-primary" style="float: left;">Incident List</h5> 

<a href="{{ route('Incident.create') }}" style="float: right;"><i class="fas fa-plus-circle"></i></a>
@endsection

@section('content')

@if(Session::has('success_message'))
<div class="alert alert-success">{{ Session::get('success_message') }}</div>
@endif

<div class="table-responsive"> 

 	<br>
 	<table class="table">
 	 <thead>
 	  <tr>
 	   <th>#</th>
 	    <th>Name</th>
         <th>Impact</th>
 	    <th>Components</th>
 	    <th>History</th>
 	    <th>Status</th>
 	    <th>Action</th>
 	       </tr>
 	        </thead> 
 	        <tbody>
 	        @foreach($ins as $in)
 	         <tr>
 	          <td>{{ $in->id }}</td>
               <td>{{ $in->name }}</td>
 	           <td>{{ $in->impact }}</td>
 	           <td>
 	               @foreach($in->components as $com)
 	               <?php $sub = App\Models\StatusCategory::find($com); ?>
 	               {{ $sub->name }},
 	               @endforeach
 	           </td>
 	            <td><a href="{{ route('Incident.show' , $in->id) }}"><i class="fas fa-list"></i></a></td>
 	            
 	            
 	            <td>
 	               @if($in->show_status == 1)
 	               https://www.aryanict.com/noc-live-status.py/incident-history/{{ $in->id }}
 	               @else
 	               Public
 	               @endif
 	           </td>
 	             <td>
			
				  <form action="{{route('Incident.destroy' , $in->id)}}" method="post" id="form-{{$in->id}}">
                        {{csrf_field()}}
                        {{method_field("DELETE")}}
                    </form>

                    <a href="{{ route('Incident.edit' , $in->id) }}" ><i class="fas fa-edit"></i></a>

                    &nbsp;
                                   <a href=""
                       onclick="if(confirm('Are you sure to delete?')) {
                               event.preventDefault();
                               document.getElementById('form-{{$in->id}}').submit();
                               }else{ event.preventDefault(); }"
                       ><i class="fas fa-trash-alt"></i></a>
   
 	             </td> 
 	            
 	         </tr>
 	         @endforeach


 	                 </tbody> 
 	             </table> 

 	             

 	         </div> 



@endsection