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

  <app-btn-navigate navigate="/sam/GEAD" nameButton="Gestión de adquisición" />

  <mat-card class="override-card override-elevation-z8">
    <section class="override-section">
      
      <nav class="override-nav">
        <mat-card-title class="mat-card-title align-center">Gestión de costos y presupuestos</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="orange_primary_background white_font override_no_shadow ml-8" (click)="getBudgetManagement()">
              <mat-icon>refresh</mat-icon>
            </button>
          </div>
        </div>
      </nav>

      <app-loading-card [isLoading]="isLoading" [isLoadingForm]="isLoadingForm" txtLoading="Cargando la información de las facturas" />

      <div class="override-table">
        <table mat-table [dataSource]="dataSource" matSort [style.display]="isLoading ? 'none' : 'revert'">
          <ng-container matColumnDef="FALS_IDFA">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>ID Factura</th>
            <td mat-cell *matCellDef="let element">#{{ element.FALS_IDFA }}</td>
          </ng-container>
          <ng-container matColumnDef="LINE_OTPR">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>ID Orden de trabajo</th>
            <td mat-cell *matCellDef="let element"> <span [matTooltip]="selectedTooltip(element)">{{ selectedOrder(element) }}</span> </td>
          </ng-container>
          <ng-container matColumnDef="FALS_IDLI">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Linea de solicitud</th>
            <td mat-cell *matCellDef="let element">#{{ element.FALS_IDLI }}</td>
          </ng-container>
          <ng-container matColumnDef="LINE_NUPR">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Proveedor</th>
            <td mat-cell *matCellDef="let element">{{ element.LINE_NUPR }}</td>
          </ng-container>
          <ng-container matColumnDef="FALS_USMO">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Usuario modificación</th>
            <td mat-cell *matCellDef="let element">{{ this.resourcesService.selectUser(element.FALS_USRE, element.FALS_USMO) }}</td>
          </ng-container>
          <ng-container matColumnDef="FALS_FEMO">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Fecha de actualización</th>
            <td mat-cell *matCellDef="let element">{{ this.resourcesService.formatDate(element.FALS_FERE, element.FALS_FEMO) }}</td>
          </ng-container>
          <ng-container matColumnDef="FALS_ESTA">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Estado</th>
            <td mat-cell *matCellDef="let element">
              <mat-chip [class]="resourcesService.setChipList(element.FALS_ESTA)" selected> {{ element.FALS_ESTA }} </mat-chip>
            </td>
          </ng-container>
          <ng-container matColumnDef="ACCIONES">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> Acciones </th>
            <td mat-cell *matCellDef="let element">
                <button mat-mini-fab color="primary" class="override_no_shadow transparent_background gray_dark_font" matTooltip="Descargar factura" [disabled]="isLoading || isLoadingForm" (click)="downloadInvoice(element)">
                  <mat-icon>file_download</mat-icon>
                </button>
            </td>
          </ng-container>
          <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
          <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
          <tr class="mat-row" *matNoDataRow>
            <td class="mat-cell p-20 align-center" 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>