@extends('adminlte::page')

@section('content')
<?php Fun::lang() ?>
<div class="title-add">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li> <a class="ng-binding" href="#"><i class="fa fa-dashboard"></i> Dashboard</a> </li>
            <li><a href="#">Manage User</a></li>
            <li><a href="#">Branchs Infomation</a></li>
        </ul>
    </div>
</div>
<div class="page">
    <div class="top-content">
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                <div class="title-add">
                    <div class="pull-left">
                        <h3>Branch Infomation</h3>
                        <p><span class="text-danger"><strong>NOTE</strong><sup>*</sup> you have to buyed <strong>{{$buyed}}</strong> Branches</span></p>
                    </div>
                </div>
                @can('Branch-Create')
                    <div class="pull-right">
                        <a href="{{ route('branches.create') }}" class="button_primary button_sm"><span class="fa fa-plus"></span> Create New</a>
                    </div>
                @endcan
            </div>
        </div>
    </div>
    <div class="form-wrapper">
        <table id="datatable" class="table  table-bordered table-hover nowrap">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Branch EN</th>
                    <th>Branch KM</th>
                    <th>Logo</th>
                    <th>Type</th>
                    <th>Phone</th>
                    <th>Email / Website</th>
                    <th>Address</th>

                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach($branches as $key => $value)
                <tr>
                    <td>{{$key+1}}</td>
                    <td>{{$value->branch_en}}</td>
                    <td>{{$value->branch_kh}}</td>
                    <td><img src='{{asset("assets/images/resize")}}/{{$value->branch_img}}' width="80px"></td>
                    <td>@if($value->key_code != '') <strong class="text-success">
                            <i class="fa fa-university" aria-hidden="true"></i>
                            Company</strong> @else <strong class="text-success">
                            <i class="fa fa-home" aria-hidden="true"></i>
                            Branch</strong> @endif</td>
                    <td>{{$value->branch_phone}}</td>
                    <td>{{$value->branch_email}}</td>
                    <td>{{$value->branch_address}}</td>
                    <td>
                        @can('Branch-Edit')
                            <a data-toggle="tooltip" data-placement="top" title="Edit Branch" href="{{route("branches.edit", Crypt::encrypt($value->id))}}"> <span class="button_success fa fa-edit" </span> </a> 
                        @endcan 
                        @can('Branch-View-Info') 
                            <a data-toggle="tooltip" data-placement="top" title="Show Branch" href="{{route("branches.show", Crypt::encrypt($value->id))}}"> <span class="button_info fa fa-eye"></span> </a>
                        @endcan
                        @can('Branch-Assign-Branch')
                            @if($value->status == 1)
                                <a data-toggle="tooltip" data-placement="top" title="Assign Branch" href="{{route("assign.branch", Crypt::encrypt($value->id))}}"> <span class="button_primary btn-sm fa fa-plus"></span> </a>
                            @endif
                        @endcan
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>
@endsection