<main class="main-container animated fadeIn">

  <app-btn-navigate [navigate]="'/sam/GEAD'" [nameButton]="'Menú de Despacho'" />

  <!-- CARD -->
  <mat-card class="override-card override-elevation-z8">
    <section class="override-section">
      <nav class="override-nav">
        <mat-card-title class="mat-card-title centre">Gestión de Entregas Parciales</mat-card-title>
        <div class="override-actions">
          <app-search-card
            [dataSource]="dataSource"
            [disabled]="isLoading || isLoadingForm"
            (dataValue)="dataSource = $event"/>
          <div class="override-buttons">
            <button
              mat-mini-fab
              matTooltip="Actualizar Datos"
              class="cyan_dark_background white_font override_no_shadow mr-10"
              (click)="getPartialDeliveries()"
            >
              <mat-icon>refresh</mat-icon>
            </button>
          </div>
        </div>
      </nav>

      <app-loading-card
        [isLoading]="isLoading"
        [isLoadingForm]="isLoadingForm"
        [txtLoading]="'Cargando las entregas parciales'"
      />

      <div class="override-table">
        <table mat-table [dataSource]="dataSource" matSort class="animated fadeIn" [style.display]="isLoading ? 'none' : 'revert'">

          <ng-container matColumnDef="HIOR_NUOR">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> Número de Pedido </th>
            <td mat-cell *matCellDef="let element"> {{ element.HIOR_NUOR }} </td>
          </ng-container>

          <ng-container matColumnDef="HIOR_FEMO">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> Fecha de Entrega </th>
            <td mat-cell *matCellDef="let element"> {{ resourcesService.formatDate(element.HIOR_FERE, element.HIOR_FEMO) }} </td>
          </ng-container>

          <ng-container matColumnDef="HIOR_USMO">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> Usuario de Entrega </th>
            <td mat-cell *matCellDef="let element"> {{ resourcesService.selectUser(element.HIOR_USRE, element.HIOR_USMO) }} </td>
          </ng-container>

          <ng-container matColumnDef="HIOR_POEN">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> Porcentaje de Entrega </th>
            <td mat-cell *matCellDef="let element" [matTooltip]="element.HIOR_POEN + '%'">
              <mat-progress-bar mode="determinate" [value]="element.HIOR_POEN"></mat-progress-bar>
            </td>
          </ng-container>

          <ng-container matColumnDef="ACCIONES">
            <th mat-header-cell *matHeaderCellDef>Acciones</th>
            <td mat-cell *matCellDef="let element">
              <button
                mat-mini-fab
                color="primary"
                class="override_no_shadow mr-4"
                matTooltip="Ver Información"
                (click)="openDialog('DETAILS', element)">
                <mat-icon>info</mat-icon>
              </button>
            </td>
          </ng-container>
          <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
          <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
          <tr class="mat-row" *matNoDataRow>
            <td class="p-80 centre" colspan="12"><object data="assets/img/empty_data.svg" width="150"></object> <h2>Sin datos</h2></td>
          </tr>
        </table>
      </div>
    </section>

    <mat-paginator [pageSizeOptions]="[10, 50, 100]" class="override-paginator"></mat-paginator>
  </mat-card>
</main>
