<div class="col-md-12" ng-controller="VillageController">
    <ul class="breadcrumb">
        <li class="active">{{'label.anchor.villages' | translate}}</li>
    </ul>

    <a href="#/createvillage" class="btn btn-primary pull-right" has-permission='CREATE_VILLAGE'><i class="icon-plus icon-white"></i>{{'label.button.createvillage' | translate}}</a>
    <div class="clearfix"></div>
    <form ng-submit="search()" class="form-horizontal">
        <div class="form-group">
            <div class="col-lg-6">
                <div class="input-group">
                    <input  data-ng-model="searchText" type="text" placeholder="{{'label.input.searchByNameExternalId' | translate}}" class="form-control"/>
                    <span class="input-group-btn">
                        <button class="btn btn-primary form-control">
                            <span class="icon-search"></span>
                        </button>
                    </span>
                </div>
            </div>
            <div class="col-md-4">
                <input ng-autofocus="true" ng-model="filterText" type="text" ng-keyup="onFilter()" class="span form-control" placeholder="{{'label.input.filterbynameorstatusoroffice' | translate}}">
            </div>
        </div>
    </form>

    <table class="table">
        <thead>
        <tr class="graybg">
            <th>{{'label.heading.name' | translate}}</th>
            <th> {{'label.heading.id' | translate}}</th>
            <th> {{'label.heading.villageexternalid' | translate}}</th>
            <th>{{'label.heading.status' | translate}}</th>
            <th>{{'label.heading.office' | translate}}</th>
        </tr>
        </thead>

        <tbody>
        <tr class="pointer-main" dir-paginate="village in villages | orderBy:'name':reverse  | filter:filterText |  itemsPerPage: villagesPerPage" total-items="totalVillages" pagination-id="villages">
            <td class="pointer" data-ng-click="routeTo(village.villageId)">{{village.villageName}}</td>
            <td class="pointer" data-ng-click="routeTo(village.villageId)">{{village.villageId}}</td>
            <td class="pointer" data-ng-click="routeTo(village.villageId)">{{village.externalId}}</td>
            <td class="pointer" data-ng-click="routeTo(village.villageId)">
                <i class="icon-stop {{village.status.code | StatusLookup}}"></i>&nbsp;&nbsp;{{village.status.value}}
            </td>
            <td class="pointer" data-ng-click="routeTo(village.villageId)">{{village.officeName}}</td>
        </tr>
        </tbody>
    </table>
    <dir-pagination-controls boundary-links="true" pagination-id="villages" template-url="bower_components/angular-utils-pagination/dirPagination.tpl.html" on-page-change="getResultsPage(newPageNumber)"></dir-pagination-controls>
</div>