<div class="col-md-12" ng-controller="OfficesController">
    <ul class="breadcrumb">
        <li><a href="#/organization">{{'label.anchor.organization' | translate}}</a></li>
        <li class="active">{{'label.anchor.manageoffices' | translate}}</li>
    </ul>

    <div class="pull-right">
        <a ng-show="isTreeView" ng-click="isTreeView=!isTreeView" class="btn btn-primary"><i class="icon-list icon-white"></i>{{'label.button.listview' | translate}}</a>
        <a ng-hide="isTreeView" ng-click="isTreeView=!isTreeView" class="btn btn-primary"><i class="icon-sitemap icon-white"></i>{{'label.button.treeview' | translate}}</a>
        <a href="#/createoffice" class="btn btn-primary" has-permission='CREATE_OFFICE'><i class="icon-plus icon-white"></i>{{'label.button.createoffice' | translate}}</a>
    </div>
    <div class="clear"></div>
    <div ng-hide="isTreeView">
        <input ng-autofocus="true" ng-model="filterText" type="text" ng-keyup="onFilter()" class="form-control span marginbottom0px" placeholder="{{'label.input.filterbynameexternalid' | translate}}">
        <table class="table">
            <thead>
            <tr class="graybg">
                <th>{{'label.heading.officeName' | translate}}</th>
                <th>{{'label.heading.officeexternalid' | translate}}</th>
                <th>{{'label.heading.parentoffice' | translate}}</th>
                <th>{{'label.heading.openedon' | translate}}</th>
            </tr>
            </thead>
            <tbody>
            <tr class="pointer-main" ng-repeat="office in offices| orderBy:'name':reverse  | filter:filterText">
                <td class="pointer" data-ng-click="routeTo(office.id)">{{office.name}}</td>
                <td class="pointer" data-ng-click="routeTo(office.id)">{{office.externalId}}</td>
                <td class="pointer" data-ng-click="routeTo(office.id)">{{office.parentName}}</td>
                <td class="pointer" data-ng-click="routeTo(office.id)">{{office.openingDate | DateFormat}}</td>
            </tr>
            </tbody>
        </table>
    </div>
    <div ng-show="isTreeView">
        <div
                data-angular-treeview="true"
                data-tree-id="treeview"
                data-tree-model="treedata"
                data-node-id="id"
                data-node-label="name"
                data-node-children="children">
        </div>
    </div>
</div>