@extends('backend.layouts.master')
@section('title')Manage User
@endsection
@push('css')
    <style>
        span.st_active {
            color: green;
        }
    </style>
@endpush
<!-- page content -->
@section('content')
    <div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            @if(Session::has('success_message'))
                <div class="alert alert-success">
                    {{ Session::get('success_message') }}
                </div>
            @endif
            @if(Session::has('error_message'))
                <div class="alert alert-danger">
                    {{ Session::get('error_message') }}
                </div>
            @endif
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>Manage User
                                <a href="{{route('user.register')}}" class="btn btn-xs btn-primary">New User</a>
                            </h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content table-responsive">
                            <table class="table table-bordered table-condensed">
                                <thead>
                                <tr class="bg-primary">
                                    <th>SL</th>
                                    <th>Name</th>
                                    <th>UserName</th>
                                    <th>Email</th>
                                    <th>Role</th>
                                    <th>Last Login</th>
                                    <th>Is Online</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($users as $i=>$m)
                                    <tr>
                                        <th> {{$i+1}}</th>
                                        <td> {{$m->name}}</td>
                                        <td> {{$m->username}}</td>
                                        <td> {{$m->email}}</td>
                                        <td> {{$m->ro->role->name}}</td>
                                       <td> {{date('d-M-Y, h:i a',strtotime($m->last_login))}}</td>
                                       <td>
                                            @if($m->isOnline())
                                                <span class="st_active">
                                                    <i class="ace-icon fa fa-green fa-circle bigger-110"></i> Online
                                                </span>
                                            @else
                                                Offline
                                            @endif
                                       </td>
                                        <td> 
                                            <a href="{{route('user.status',$m->id)}}">
                                                @if($m->status == 1)
                                                    <span class="label label-success"> Active </span>
                                                @else
                                                    <span class="label label-warning"> Pending </span>
                                                @endif
                                            </a>
                                        </td>
                                        <td>
                                            <div class="row">
                                                <div class="col-md-5">
                                                    <a href="{{route('user.edit',$m->id)}}" class="btn btn-xs btn-warning "><i class="fa fa-pencil"></i></a>
                                                </div>
                                               <!-- <div class="col-md-5">
                                                    <form action="" method="post">
                                                        <input type="hidden" name="_method" value="DELETE">
                                                        {{ csrf_field()}}
                                                        <button class="btn btn-xs btn-danger" type="submit" onclick= "return confirm('are you sure to delete?')"><i class="fa fa-trash-o"></i> </button>
                                                    </form>
                                                </div>-->
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="text-center">
                                {{$users->links()}}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /page content -->
@endsection

@section('script')

@endsection