<uib-tabset active="active">
  <uib-tab heading="{{ 'CHECK_LIST' | translate }}" index="0">
    <h3>{{ "CHECK_LIST" | translate }} {{alert.id}}</h3>
    <div class="padT-20">
      <table class="table table-hover">
        <thead>
          <tr>
            <th>{{ 'TASK' | translate }}</th>
            <th>{{ 'USER' | translate }}</th>
            <th>{{ 'DATE' | translate }}</th>
            <th>{{ 'COMMENT' | translate }}</th>
            <th>{{ 'VALIDATION' | translate }}</th>
            <th>{{ 'STATUS' | translate }}</th>
            <th>{{ 'ACTION' | translate }}</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="record in item.tasks" 
            ng-class="vm.active_task && vm.active_task !== record.task && !vm.process_is_mine ? 'table-inactive' : ''"
            ng-if="!vm.active_task || vm.active_task === record.task">
            <td>{{record.task | translate}} 
            <!--   <abbr title="Delegate" ng-hide="vm.active_task && vm.active_task !== record.task && !vm.process_is_mine" class="hide-abbr"><a class="no-link-link" ng-click="vm.createInquiry(record.task)"><span class="glyphicon glyphicon-play"></span></a></abbr> -->
            </td>
            <td>{{record.comment.user.username}}</td>
            <td>{{record.comment.date | formatTimestamp}}</td>
            <td><span compile="sanitizeAddrForUi(record.comment.text)"></span>
              <div ng-repeat="inquiry in item.inquires" ng-if="inquiry.linked_process_task == record.id">
                <br/><span compile="sanitizeAddrForUi(inquiry.text)"></span>
              </div>
            </td>
            <td>{{record.validation | translate}}</td>
              <td>
                <b ng-if="record.status === 'Validated'" class="swamp">&#10004;&nbsp;</b><span ng-if="record.status && record.status !== 'Autovalidate'">{{record.status | translate}}</span><span ng-if="!record.status || record.status === 'Autovalidate'">{{ 'OPEN' | translate}}</span>
              </td>
              <td>
                <div ng-hide="(vm.active_task && vm.active_task !== record.task && !vm.process_is_mine)" class="marB-5">
                  <a ng-click="vm.approve(record)"
                   ng-class="vm.validLock ? 'black' : 'no-link-link'">{{ 'DEMAND_APPROVAL' | translate }}</a>
                </div>
                <!-- <div ng-hide="record.status === 'Validated'  || (vm.active_task && vm.active_task !== record.task && !vm.process_is_mine)" class="marB-5">
                  <a ng-click="vm.validate(record)"
                   ng-class="vm.validLock ? 'black' : 'no-link-link'">{{ 'VALIDATE' | translate }}</a
                ></div> -->
                <!-- <div ng-hide="!record.status  || (vm.active_task && vm.active_task !== record.task && !vm.process_is_mine)" class="marB-5">
                  <a ng-click="vm.invalidate(record)"
                   ng-class="vm.validLock ? 'black' : 'no-link-link'">{{ 'RESET_VALIDATION' | translate }}</a>
                </div> -->
              </td>
          </tr>
        </tbody>
      </table>
    </div>
  </uib-tab>
  <uib-tab heading="{{ 'GENERAL_DATA' | translate }}" index="1">
    <div class="row">
      <div class="col-sm-6" ng-if="item.id"><dl class="dl-horizontal"><dt>{{ "ID" | translate }}:</dt><dd>{{item.id}}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.category"><dl class="dl-horizontal"><dt>{{ "CATEGORY" | translate }}:</dt><dd>{{item.category | translate }}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.created"><dl class="dl-horizontal"><dt>{{ "CREATED" | translate }}:</dt><dd>{{item.created | parseDate | formatTimestamp}}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.priority"><dl class="dl-horizontal"><dt>{{ "PRIORITY" | translate }}:</dt><dd>{{item.priority}}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.status"><dl class="dl-horizontal"><dt>{{ "STATUS" | translate }}:</dt><dd>{{item.status | translate }}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.session"><dl class="dl-horizontal"><dt>{{ "SESSION" | translate }}:</dt><dd>{{item.session}}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.orgClient"><dl class="dl-horizontal"><dt>{{ "ORGCLIENT" | translate }}:</dt><dd>{{item.orgClient}}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.configuration"><dl class="dl-horizontal"><dt>{{ "CONFIGURATION" | translate }}:</dt><dd>{{item.configuration}}</dd></dl></div>
      <div class="col-sm-6" ng-if="item.user.username"><dl class="dl-horizontal"><dt>{{ "ASSIGNED_TO" | translate }}:</dt><dd>{{item.user.username}}</dd></dl></div> 
    </div>

    <div ng-repeat="alert in item.alerts">
      <!-- <h2>{{ "ALERT" | translate }} {{alert.id}}</h2> -->
      <div ng-init="item=alert"
           ng-include="config.types.ro_alert.view.detailsAnon"></div>
    </div>
  </uib-tab>
  <uib-tab heading="{{ 'INQUIRIES' | translate }}" index="3">
    <h3>{{ 'INQUIRIES' | translate }}</h3>
    <inquires-list data="item.inquires"
                   open-inquiry="vm.showInquiry($id)"
                   sanitize-addr-for-ui="sanitizeAddrForUi"></inquires-list>
  </uib-tab>
  <uib-tab heading="{{ 'DOCUMENTS' | translate }}" index="4">
    <h3>{{ 'ATTACHED' | translate }}</h3>
    <table class="table table-hover">
      <thead>
        <tr>
          <th>{{ 'DOCUMENT' | translate }}</th>
          <th>{{ 'USER' | translate }}</th>
          <th>{{ 'DATE' | translate }}</th>
          <th>{{ 'ATTACHED_ON' | translate }}</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="record in vm.docs"
            ng-if="record.attachments.length > 0">
          <td>
            <div ng-repeat="att in record.attachments">
              &ndash; <a href="{{att.path}}">{{att.name}}</a>
              <!-- <button class="btn btn-default btn-xs glyphicon glyphicon-eye-open" 
              ng-if="att.name.substring(att.name.length - 4) === '.xml' && vm.showFormTab" 
              ng-click="vm.loadFormByXmlPath(att.path, att.name)"></button> -->
            </div>
          </td>
          <td>{{record.user.username}}</td>
          <td>{{record.date | formatTimestamp}}</td>
          <td>
            <span ng-if="record.category === 'info'">{{ 'GATHERED_INFORMATION' | translate }}</span>
            <span ng-if="record.category === 'comment'">{{ 'OPINION' | translate }}</span>
            <span ng-if="record.category === 'decision'">{{ 'DECISIONS' | translate }}</span>
            <span ng-if="record.category === 'alert'">{{ record.alert_id }}</span>
          </td>
        </tr>
      </tbody>
    </table>
    <button class="btn btn-primary pull-right marL-3" ng-click="vm.downloadAttachments()" ng-if="vm.allpaths.length > 0">{{ 'DOWNLOAD_ALL_ATTACHMENTS' | translate }}</button>
  </uib-tab>
  <uib-tab heading="{{ 'OPINIONS_AND_DECISION' | translate }}" index="5">
    <h3>{{ 'DECISIONS' | translate }}</h3>
    <table class="table table-hover">
      <thead>
        <tr>
          <th>{{ 'SUBMITTED_BY' | translate }}</th>
          <th>{{ 'VALIDATED_BY' | translate }}</th>
          <th>{{ 'DATE' | translate }}</th>
          <th>{{ 'JUSTIFICATION' | translate }}</th>
          <th>{{ 'ATTACHMENTS' | translate }}</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="record in item.comments | filter:{category:'decision'}">
          <td>{{record.user.username}}</td>
          <td>{{record.validatedBy.name}}</td>
          <td>{{record.date | formatTimestamp}}</td>
          <td>{{record.text}}</td>
          <td>
            <div ng-repeat="att in record.attachments">
              &ndash; <a href="{{att.path}}">{{att.name}}</a>
              </div>
          </td>
        </tr>
      </tbody>
    </table>


    <h3>{{ 'OPINIONS' | translate }}</h3>
    <comments-list comments="item.comments"
                   category="'comment'"
                   aux="vm">
    </comments-list>
    <button class="btn btn-primary pull-right"
            ng-click="vm.addOpinion()">{{ 'ADD' | translate }}</button>
  </uib-tab>
</uib-tabset>
  