<div class="row">
    <div class="col-sm-3">



        <div role="navigation">
            <div class="list-group">
                <a class="list-group-item" ng-href="#/admin/rights"><i class="fa fa-folder-o"></i> <span translate>Rights list</span></a>
                <a class="list-group-item" ng-href="#/admin/rights-sort"><i class="fa fa-sort"></i> <span translate>Sort rights</span></a>
                <a class="list-group-item" ng-href="#/admin/collections"><i class="fa fa-book"></i> <span translate>Rights collections</span></a>
            </div>
        </div>

    </div>

    <div class="col-sm-9">

        <div class="row panel panel-primary">
            <div class="col-xs-8">
                <h2><i class="fa fa-asterisk" style="color:{{right.type.color}}" title="{{right.type.name}}"></i> {{right.name}}</h2>
                <p class="lead">{{right.description}}</p>
                <p><span translate>Type:</span> {{right.type.name}}</p>



                <p>
                    <span class="fa-stack" ng-if="right.specialright">
                        <i class="fa fa-circle fa-stack-2x text-warning"></i>
                        <i class="fa fa-legal fa-stack-1x fa-inverse" title="{{'Special right:'|translate}} {{right.specialright.name}}"></i>
                    </span>

                    <span ng-if="!right.specialright || right.specialright.editQuantity">
                        <span translate>Default quantity on start renewal:</span> {{right.quantity | rightQuantity}} {{right.disp_unit}}
                    </span>
                    <span ng-if="right.specialright && !right.specialright.editQuantity">
                        {{right.specialright.quantityLabel}}
                        <span ng-if="!right.specialright.quantityLabel">
                            <span translate>The start renewal quantity is dynamicaly computed</span>
                        </span>
                    </span>
                </p>

                <p ng-if="!right.activeSpan.useDefault && right.activeSpan.min>0">
                    <span translate>The request must be created at least {{right.activeSpan.min}} days before the leave start date.</span>
                </p>

                <p ng-if="!right.activeSpan.useDefault && right.activeSpan.max>0">
                    <span translate>The leave period must be in the next {{right.activeSpan.max}} days after the request date.</span>
                </p>

                <p ng-if="right.defaultAbsenceLength>0"><span translate>Legal leave duration:</span> {{right.defaultAbsenceLength | rightQuantity}} {{right.disp_unit}}</p>

                <p ng-if="right.addMonthly.quantity>0"><span translate>Monthly additions:</span> {{right.addMonthly.quantity | number}} {{right.disp_unit}}</p>

                <div class="top15 bottom15" ng-if="right.autoAdjustment.quantity"><div translate>An adjustment of {{right.autoAdjustment.quantity | number}} {{right.disp_unit}} is automatically created every {{right.autoAdjustment.step | number}} {{right.disp_unit}} consumed on </div>
                    <div ng-repeat="t in right.autoAdjustment.types"> &nbsp; <a href="#/admin/rights?type={{t._id}}"><i class="fa fa-asterisk" style="color:{{t.color}}"></i> {{t.name}}</a></div>
                </div>

                <p>
                    <span class="label label-default" title="{{'Active for the user'|translate}}" ng-if="right.activeFor.account" bs-tooltip><i class="fa fa-male"></i> User</span>
                    <span class="label label-default" ng-if="right.activeFor.admin" title="{{'Active for the administrator'|translate}}" bs-tooltip><i class="fa fa-star"></i> Admin</span>
                </p>
            </div>

            <div class="col-xs-4 text-right">
                <br />
                <a ng-href="#/admin/right-edit/{{right._id}}" class="btn btn-info hidden-print" role="button">
                    <i class="fa fa-edit"></i> <span class="hidden-xs" translate>Edit</span>
                </a>

                <a ng-click="deleteRight()" class="btn btn-danger hidden-print" role="button">
                    <i class="fa fa-edit"></i> <span class="hidden-xs" translate>Delete</span>
                </a>
            </div>
        </div>

        <div class="row">
            <h3  class="col-xs-10"><i class="fa fa-shield text-muted"></i> <span translate>Rules</span></h3>
            <div class="col-xs-2 text-right">
                <br />
                <a class="hidden-print btn btn-primary" role="button" ng-href="#/admin/rightrule-edit?right={{right._id}}">
                    <i class="fa fa-plus-circle"></i> <span translate>Add</span>
                </a>
            </div>
            <table class="table" ng-if="0!==right.rules.length">
                <thead>
                <tr>
                    <th></th>
                    <th translate>Type</th>
                    <th translate>Title</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="rule in right.rules">
                    <td>
                        <a class="hidden-print btn btn-info btn-xs" role="button" ng-href="#/admin/rightrules/{{rule._id}}?right={{right._id}}">
                            <i class="fa fa-edit"></i> <span class="hidden-xs" translate>Edit</span>
                        </a>
                    </td>
                    <td>{{getRightRuleType(rule.type)}}</td>
                    <td>{{rule.title}}</td>
                </tr>
                </tbody>

            </table>

            <div class="col-xs-12 alert alert-danger" role="alert" ng-if="0===right.rules.length">
                <span translate>This right has no configured rules</span>
            </div>
        </div>


        <div class="row">

            <h3  class="col-xs-10"><i class="fa fa-retweet text-muted"></i> <span translate>Renewals</span></h3>
            <div class="col-xs-2 text-right">
                <br />
                <a class="hidden-print btn btn-primary" role="button" ng-href="#/admin/rightrenewal-edit?right={{right._id}}">
                    <i class="fa fa-plus-circle"></i> <span translate>Add</span>
                </a>
            </div>
            <table class="table">
                <thead>
                <tr>
                    <th></th>
                    <th translate>Start</th>
                    <th translate>Finish</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="renewal in rightRenewals">
                    <td>
                        <a class="hidden-print btn btn-info btn-xs" role="button" ng-href="#/admin/rightrenewals/{{renewal._id}}">
                            <i class="fa fa-edit"></i> <span class="hidden-xs" translate>Edit</span>
                        </a>
                    </td>
                    <td>{{renewal.start|date}}</td>
                    <td>{{renewal.finish|date}}</td>
                </tr>
                </tbody>

            </table>

            <div class="alert alert-danger" role="alert" ng-if="!rightRenewals.length">
                <span translate>This right has no configured renewals</span>
            </div>
        </div>


        <div class="row" ng-if="collections.length>0">

            <h3  class="col-xs-10"><i class="fa fa-folder-o text-muted"></i> <span translate>Right collections</span></h3>

            <table class="table">
                <thead>
                <tr>
                    <th></th>
                    <th translate>Name</th>
                    <th translate>Attendance</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="collection in collections">
                    <td>
                        <a class="hidden-print btn btn-info btn-xs" role="button" ng-href="#/admin/collections/{{collection._id}}">
                            <i class="fa fa-edit"></i> <span class="hidden-xs" translate>Edit</span>
                        </a>
                    </td>
                    <td>{{collection.name}}</td>
                    <td>{{collection.attendance|number}}%</td>
                </tr>
                </tbody>

            </table>

        </div>



        <div class="row" ng-if="users.length>0">

            <h3  class="col-xs-10"><i class="fa fa-folder-o text-muted"></i> <span translate>Users</span></h3>

            <table class="table">
                <thead>
                <tr>
                    <th></th>
                    <th translate>Lastname</th>
                    <th translate>Firstname</th>
                    <th class="hidden-xs" translate>Department</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="user in users">
                    <td>
                        <a class="hidden-print btn btn-info btn-xs" role="button" ng-href="#/admin/users/{{user._id}}">
                            <i class="fa fa-plus"></i> <span class="hidden-xs" translate>View</span>
                        </a>
                    </td>
                    <td>{{user.lastname}}</td>
                    <td>{{user.firstname}}</td>
                    <td class="hidden-xs">{{user.department.name}}</td>
                </tr>
                </tbody>

            </table>

        </div>


        <div class="row" ng-if="!collections.length && !users.length">
            <br />
            <br />
            <div class="alert alert-warning" role="alert">
                <span translate>You must link this right to a collection or users so that it is accessible</span>
            </div>
        </div>

    </div>


</div>
