@extends('admin/layouts/default')
{{-- Page title --}}
@section('title')
Journal Policy List
@parent
@stop
{{-- page level styles --}}
@section('header_styles')
<link href="{{ asset('assets/css/pages/tables.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('assets/vendors/select2/css/select2.min.css') }}" type="text/css" rel="stylesheet">
<link href="{{ asset('assets/vendors/select2/css/select2-bootstrap.css') }}" rel="stylesheet">
<!-- end of page level css-->
@stop
{{-- Page content --}}
@section('content')
<section class="content-header">
    <!--section starts-->
    <h1>Journal Policy</h1>
    <ol class="breadcrumb">
        <li>
            <a href="{{ route('admin.dashboard') }}">
                <i class="livicon" data-name="home" data-size="18" data-loop="true"></i>
                Dashboard
            </a>
        </li>
        <li class="active">Journal Policy List</li>
    </ol>
</section>
<!--section ends-->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN SAMPLE TABLE PORTLET-->
            <div class="portlet box primary">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="livicon" data-name="responsive" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                        Journal Policy List
                    </div>
                    @if($createPermission)
                    <a class="btn btn-sm btn-default button-alignment pull-right mb-1" title="Add New Journal" href="{{ route('journal_policy.create') }}"><span class="glyphicon glyphicon-plus"></span> New</a>
                    @endif
                </div>
                <div class="portlet-body table-responsive">
                    @if ($message = Session::get('success'))
                    <div class="alert alert-success alert-dismissable">
                        <p>{{ $message }}</p>
                    </div>
                    @endif
                    @if ($message = Session::get('error'))
                    <div class="alert alert-danger alert-dismissable">
                        <p>{{ $message }}</p>
                    </div>
                    @endif
                    <form action="{{ route('journal_policy.index') }}" method="Get" enctype="multipart/form-data">
                        @csrf
                        <div class="form-group col-md-10">
                            @include('search.journal_search')
                        </div>
                        <div class="form-group col-md-2" style="margin-top: 25px ">
                            <button class="btn btn-info" type="submit"><span class="glyphicon glyphicon-search"> Go</span></button>
                            <a href="{{route('journal_policy.index')}}" class="btn btn-default">
                                <span class="glyphicon glyphicon-repeat"></span>&nbsp;Reset</a>
                        </div>
                    </form>

                    <table class="table table-striped table-bordered">
                        <thead>
                            <tr>
                                <th>Journal Code</th>
                                <th>Policy</th>
                                <th>Created Date</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if(count($policy_list) > 0)
                            @foreach($policy_list as $policy)
                            <tr>
                                <td>{{$policy->journal_code}}</td>
                                <td>
                                <button type="button" class="btn btn-info btn-md" data-toggle="modal" data-target="#policy{{$policy->policy_id}}"><i class="livicon" data-name="list" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i> View</button>
                                    <!-- Policy Modal Content-->
                                    <div class="modal fade" id="policy{{$policy->policy_id}}" role="dialog">
                                        <div class="modal-dialog modal-lg">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h3 class="modal-title text-danger">Policy!</h3>
                                                </div>
                                                <div class="modal-body">
                                                    {!! $policy->policy !!}
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td>{{gmdate("d-m-Y", $policy->created_on)}}</td>
                                <td>
                                    @if($policy->status == "1")
                                    <span class="label label-success">Active</span>
                                    @else
                                    <span class="label label-danger">Deleted</span>
                                    @endif
                                </td>
                                <td width="180px">
                                    @if($editPermission)
                                    <a href="{{ route('journal_policy.edit',$policy->policy_id) }}" class="btn btn-primary btn-sm pull-left mb-1">
                                        <i class="livicon mt-2" data-name="pen" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i>
                                        Edit
                                    </a>
                                    @endif
                                    @if($deletePermission)
                                    <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#delete{{$policy->policy_id}}"><i class="livicon mt-2" data-name="trash" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i>Delete</button>
                                    <!-- Modal -->
                                    <div class="modal fade" id="delete{{$policy->policy_id}}" role="dialog">
                                        <div class="modal-dialog">

                                            <!-- Modal content-->
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h3 class="modal-title text-danger">Confirmation</h3>
                                                </div>
                                                <div class="modal-body">
                                                    <p><strong>Are you sure you want to delete this record?</strong></p>
                                                </div>
                                                <div class="modal-footer">
                                                    {{ Form::open([ 'method'  => 'delete', 'route' => [ 'journal_policy.destroy', $policy->policy_id] ]) }}
                                                    {{ Form::hidden('id', $policy->policy_id) }}
                                                    {{ Form::submit('Delete', ['class' => 'btn btn-danger']) }}
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                    {{ Form::close() }}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    @endif
                                </td>
                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td colspan="5">
                                    <center>Empty</center>
                                </td>
                            </tr>
                            @endif
                        </tbody>
                    </table>
                    @if (count($policy_list) > 0)
                    <center>{{ $policy_list->appends(request()->input())->links() }}</center>
                    @endif
                </div>
            </div>
            <!-- END SAMPLE TABLE PORTLET-->
        </div>
    </div>
</section>
@stop

{{-- page level scripts --}}
@section('footer_scripts')
<script src="{!! asset('assets/vendors/select2/js/select2.js') !!}"></script>
<script>
    $(document).ready(function() {
        $("#journal_id").select2({
            theme: "bootstrap",
            placeholder: "Select Journal",
            width: '100%',
            height: '50px'
        });
    });
</script>
@stop