@extends('layouts.master')

@section('content')
<!-- DataTables -->
<link rel="stylesheet" href="{{ asset('/assets/') }}/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" href="{{ asset('/assets/') }}/switch/rcswitcher.css">
<link rel="stylesheet" href="{{ asset('/assets/') }}/alert/pnotify.css">
<link rel="stylesheet" href="{{ asset('/assets/') }}/alert/sweetalert.css">
<link rel="stylesheet" href="{{ asset('/assets/') }}/alert/sweet-alert-animations.css">
<div class="row">
    <div class="col-md-7">
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading"></div>
                <header class="panel-heading" style="height:50px;">
                    <div class="pull-left">
                        {{$title1}}
                    </div>
                </header>
            <div class="panel-body">
                <div class="clearfix"></div>
                <table class="table table-bordered" id="example">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Role Name</th>
                            <th>Display Name</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    @if($all_permissions)
                    <?php $i=1; ?>
                    @foreach($all_permissions as $row)
                        <tr>
                            <td>{{ $i++ }}</td>
                            <td>{{ $row->name }}</td>
                            <td>{{ $row->display_name }}</td>
                            <td>
                                @if(\Auth::user()->utype==1)
                                <a href="{{ url('admin/permissions/edit') }}/{{ $row->id }}" class='btn btn-default btn-sm' data-toggle="tooltip" title="Edit" data-placement="top"><i class="fa fa-edit"></i></a>

                                <a href="{{ url('admin/permissions/delete') }}/{{ $row->id }}" class='btn btn-default btn-sm' onclick="return confirm('Are you sure to delete this item ?')" data-toggle="tooltip" title="Delete" data-placement="top"><i class="fa fa-trash-o"></i></a>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                    @endif
                    </tbody>
                </table>
            </div>

        </div>
    </div>
    <div class="col-md-5">
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading"></div>
                <header class="panel-heading" style="height:50px;">
                    <div class="pull-left">
                        {{$title2}}
                    </div>
                </header>
            <div class="panel-body">
                <div class="clearfix"></div>
                <form action="{{ url('admin/permissions/store') }}" enctype="multipart/form-data" method="POST" role="form">
                {{ csrf_field() }}
                    <div class="form-group {{ $errors->has('name') ? 'has-error' : '' }}">
                        <label for="name">Permission Name <i class="text-danger">*</i></label>
                        <input type='text' name="name" id="name" class="form-control" value="{{ old('name') }}" placeholder="Name">
                        <lebel class="text-danger"> {{ $errors->first('name') }}</lebel>
                    </div>
                    <div class="form-group {{ $errors->has('display_name') ? 'has-error' : '' }}">
                        <label for="display_name">Permission Name <i class="text-danger">*</i></label>
                        <input type='text' name="display_name" id="display_name" class="form-control" value="{{ old('display_name') }}" placeholder="Display Name">
                        <lebel class="text-danger"> {{ $errors->first('display_name') }}</lebel>
                    </div>

                    <div class="form-group pull-right">
                        <label></label>
                       <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Save Permission</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>
@stop

@section('script')
<script src="{{ asset('/assets/') }}/js/jquery.dataTables.min.js"></script>
<script src="{{ asset('/assets/') }}/js/dataTables.bootstrap.min.js"></script>
<script src="{{ asset('/assets/') }}/switch/rcswitcher.js"></script>
<script src="{{ asset('/assets/') }}/alert/sweetalert.min.js"></script>
<script src="{{ asset('/assets/') }}/alert/pnotify-init.js"></script>
<script src="{{ asset('/assets/') }}/alert/notify.js"></script>
<script type="text/javascript">

$(document).ready(function() {
    
    var table=$("#example").DataTable({
         "searching": true,
         "lengthChange": true,
         "ordering": true,
         stateSave: true       
    });

});
</script>
@if(Session::has('msg'))
    <div class="alert alert-success center-block msg_alt" >
        <a class="close" data-dismiss="alert" href="#">&times;</a>
        <strong><i class="fa fa-check"></i></strong>&nbsp;
    {{Session::get('msg')}}
    </div>
@endif
@stop