@extends('Admin.master_page')



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

<a href="{{ route('ScheduledMain.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>Start Date</th>
 	    <th>To Date</th>
 	    <th>Component</th>
 	    <th>Details</th>
 	    <th>Status</th>
 	    <th>Action</th>
 	       </tr>
 	        </thead> 
 	        <tbody>
 	        @foreach($mains as $main)		
 	         <tr>
 	          <td>{{ $main->id }}</td>
               <td>{{ $main->name }}</td>
 	           <td>{{ $main->start_date }}</td>
 	           <td>{{ $main->to_date }}</td>
 	           <td>
 	               @foreach($main->components as $com)
 	               <?php $sub = App\Models\StatusCategory::find($com); ?>
 	               {{ $sub->name }},
 	               @endforeach
 	           </td>
 	           <td>
 	               <a href="{{ route('ScheduledMain.show' , $main->id) }}" ><i class="fas fa-list"></i></a>
 	           </td>
 	           <td>
 	               @if($main->status == 1)
 	               https://www.aryanict.com/noc-live-status.py/history/{{ $main->id }}
 	               @else
 	               Public
 	               @endif
 	           </td>
 	            
 	             <td>
			
				  <form action="{{route('ScheduledMain.destroy' , $main->id)}}" method="post" id="form-{{$main->id}}">
                        {{csrf_field()}}
                        {{method_field("DELETE")}}
                    </form>

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

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


 	                 </tbody> 
 	             </table> 

 	             

 	         </div> 



@endsection