<div class="container">

  <!--
<ul>
  <li *ngFor="let op of opCommData | async">
    Operation Commerciale: {{op.name}}
  </li>
</ul>
<button (click)="goToCreaOpCom()">Nouvelle opération Commercial</button>
<button (click)="goToProfil()">Back</button>
-->
  <app-nav-admin></app-nav-admin>

  <div class="col-md-12" id="listeOpPart1">
    <h4 class="mb-5 mt-1 font-bold wow fadeInDown text-center" style="padding-top: 5%;">Liste des operations commerciales ({{filteredOpCommercials?.length}})</h4>
    <h5 class="wow fadeInDown"><label class="blue-text font-bold">Vous avez accumulé un total de :</label> {{this.admin.avantageCumule === '' ? '0' : this.admin.avantageCumule}} €</h5>
    <div class="btn-block flex-center align-middle" style="padding-top: 2%;">
      <!--<button class="btn btn-primary btn-rounded waves-light" id="nouvelleOp" (click)="goToCreaOpCom()">Nouvelle opération Commerciale</button>-->
      <!--<button class="btn btn-primary btn-rounded waves-light" (click)="goToCarteEnvoyer()">Historique carte envoyer</button>-->
      <!--<button class="btn btn-default btn-rounded waves-light" (click)="goToProfil()">Profil</button>-->
    </div>
    <div class="list-group wow fadeInLeftBig">

      <div *ngFor="let op of filteredOpCommercials">
        <div class="card mainCard" *ngIf="(op.status != 'Bloqué')">
          <div class="row no-margin" id="testt">
            <div class="col-md-6 d-flex flex-column " id="subCard1">
              <img src="{{op.carteTemplate.downloadURL}}" id="image1" class="img-fluid mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
              <div class="subCard1-row d-flex flex-row">
                <div class="merchant-name d-flex flex-center"><p class="white-text info-text font-bold text-center">{{commercant.commercialName}}</p></div>
                <div class="merchant-logo" [ngStyle]="{ 'background-image': 'url(' + commercant.image.downloadURL + ')'}">

                </div>
              </div>
              <div class="subCard1-row d-flex flex-row">
                <div class="operation-data flex-center"><p class="white-text info-text font-bold">{{op.name}}</p></div>
                <div class="operation-id flex-center"><p class="white-text info-text font-bold"></p></div>
              </div>
            </div>
            <div class="col-md-6 card subCard2">
              <div class="card-block no-margin">
                <div class="col-md-12 col-sm-12" id="subCard2Part1">
                  <div id="opTitle">
                    <label>Tarif XJC: {{op.tarifXJCParrain=== ''? '0' : op.tarifXJCParrain}} €</label>
                    <label>Operation Commerciale: {{op.name}}</label>
                    <label>Commercant: {{op.commercantOpCom.commercialName}}</label>
                  </div>
                  <div id="opAvantages">
                    <label>Avantage parrain: {{op.avantageParrain === ''? '0' : op.avantageParrain}} €</label>
                    <label>Avantage filleul: {{op.avantageFilleul === ''? '0' : op.avantageFilleul}} €</label>
                  </div>
                  <div id="opLogs">
                    <label>Carte(s) envoyée(s): {{op.nbEnvoie === ''? '0' : op.nbEnvoie}}</label>
                    <label>Carte(s) scannée(s): {{op.nbScan === ''? '0' : op.nbScan}}</label>
                    <label>Carte(s) débitée(s): {{op.nbDebiter === ''? '0' : op.nbDebiter}}</label>
                  </div>
                </div>
                <div class="btn-block d-flex flex-lg-row flex-md-column flex-sm-row" id="subCard2Part2">
                  <button class="btn btn-outline-default btn-rounded" (click)="bloquer(op.uid)">Bloquer</button>
                  <button class="btn btn-outline-info btn-rounded" (click)="goToCarteEnvoyer(op.uid)">Cartes</button>
                  <button class="btn btn-outline-info btn-rounded" (click)="goToScanEffectuer(op.uid)">Scans</button>
                </div>
              </div>
            </div>
          </div>
          <!-- Card footer -->
          <div class="card-data" id="footerCard">
            <ul>
              <li class="float-right"><i class="fa fa-check-square-o" aria-hidden="true"></i>Validation:
                <label class="font-bold" *ngIf="op.validationXJC == 'Validé'" style="color:#00C851; margin-bottom: 0">{{op.validationXJC}}</label>
                <label class="font-bold" *ngIf="op.validationXJC == 'En Cours'" style="color:#ffbb33; margin-bottom: 0">{{op.validationXJC}}</label>
                <label class="font-bold" *ngIf="op.validationXJC == 'Rejeté'" style="color:#ff4444; margin-bottom: 0">{{op.validationXJC}}</label>
              </li>
              <li class="float-right" style="padding-right: 2%"><i class="fa fa-info-circle" aria-hidden="true"></i>Statut:
                <label class="font-bold" *ngIf="op.status == 'Active'" style="color:#00C851; margin-bottom: 0">{{op.status}}</label>
                <label class="font-bold" *ngIf="op.status == 'Inactive'" style="color:#ffbb33; margin-bottom: 0">{{op.status}}</label>
                <label class="font-bold" *ngIf="op.status == 'Bloqué'" style="color:#ff4444; margin-bottom: 0">{{op.status}}</label>

              </li>
              <li class="float-left"><i class="fa fa-clock-o"></i>Valable du {{op.dateDebut | date:'dd/MM/yyyy'}} au {{op.dateFin | date:'dd/MM/yyyy'}}</li>
            </ul>
          </div>
          <!-- Card footer -->
        </div>
      </div>
    </div>
  </div>
  <hr>




  <div class="col-md-12" id="listeOpPart2">
    <h4 class="mb-5 mt-1 font-bold wow fadeInDown text-center" style="padding-top: 5%;">Historique des opérations bloquées ({{(opCommDataBloquer | async)?.length}})</h4>
    <div class="btn-block flex-center align-middle" style="padding-top: 2%;">
      <!--<button class="btn btn-primary btn-rounded waves-light" id="nouvelleOp" (click)="goToCreaOpCom()">Nouvelle opération Commerciale</button>-->
      <!--<button class="btn btn-primary btn-rounded waves-light" (click)="goToCarteEnvoyer()">Historique carte envoyer</button>-->
      <!--<button class="btn btn-default btn-rounded waves-light" (click)="goToProfil()">Profil</button>-->
    </div>
    <div class="list-group wow fadeInLeftBig">

      <div class="card mainCard" *ngFor="let op of opCommDataBloquer | async">
        <div class="row no-margin" id="testt">
          <div class="col-md-6 d-flex flex-column " id="subCard1">
            <img src="{{op.carteTemplate.downloadURL}}" id="image1" class="img-fluid mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
            <div class="subCard1-row d-flex flex-row">
              <div class="merchant-name d-flex flex-center"><p class="white-text info-text font-bold text-center">{{commercant.commercialName}}</p></div>
              <div class="merchant-logo" [ngStyle]="{ 'background-image': 'url(' + commercant.image.downloadURL + ')'}">

              </div>
            </div>
            <div class="subCard1-row d-flex flex-row">
              <div class="operation-data flex-center"><p class="white-text info-text font-bold">{{op.name}}</p></div>
              <div class="operation-id flex-center"><p class="white-text info-text font-bold"></p></div>
            </div>
          </div>
          <div class="col-md-6 card subCard2">
            <div class="card-block no-margin">
              <div class="col-md-12" id="subCard2Part1">
                <div id="opTitle">
                  <label>Operation Commerciale: {{op.name}}</label>
                  <label>Commercant: {{op.commercantOpCom.commercialName}}</label>
                </div>
                <div id="opAvantages">
                  <label>Avantage parrain: {{op.avantageParrain === ''? '0' : op.avantageParrain}} €</label>
                  <label>Avantage filleul: {{op.avantageFilleul === ''? '0' : op.avantageFilleul}} €</label>
                </div>
                <div id="opLogs">
                  <label>Carte(s) envoyée(s): {{op.nbEnvoie === ''? '0' : op.nbEnvoie}}</label>
                  <label>Carte(s) scannée(s): {{op.nbScan === ''? '0' : op.nbScan}}</label>
                  <label>Carte(s) débitée(s): {{op.nbDebiter === ''? '0' : op.nbDebiter}}</label>
                </div>
              </div>
              <div class="btn-block d-flex flex-lg-row flex-md-column flex-sm-row" id="subCard2Part2">
                <button class="btn btn-outline-primary btn-rounded" (click)="debloquer(op)">Débloquer</button>
              </div>
            </div>
          </div>
        </div>
        <!-- Card footer -->
        <div class="card-data" id="footerCard">
          <ul>
            <li class="float-right"><i class="fa fa-check-square-o" aria-hidden="true"></i>Validation:
              <label class="font-bold" *ngIf="op.validationXJC == 'Validé'" style="color:#00C851; margin-bottom: 0">{{op.validationXJC}}</label>
              <label class="font-bold" *ngIf="op.validationXJC == 'En Cours'" style="color:#ffbb33; margin-bottom: 0">{{op.validationXJC}}</label>
              <label class="font-bold" *ngIf="op.validationXJC == 'Rejeté'" style="color:#ff4444; margin-bottom: 0">{{op.validationXJC}}</label>
            </li>
            <li class="float-right" style="padding-right: 2%"><i class="fa fa-info-circle" aria-hidden="true"></i>Statut:
              <label class="font-bold" *ngIf="op.status == 'Active'" style="color:#00C851; margin-bottom: 0">{{op.status}}</label>
              <label class="font-bold" *ngIf="op.status == 'Inactive'" style="color:#ffbb33; margin-bottom: 0">{{op.status}}</label>
              <label class="font-bold" *ngIf="op.status == 'Bloqué'" style="color:#ff4444; margin-bottom: 0">{{op.status}}</label>
            </li>
            <li class="float-left"><i class="fa fa-clock-o"></i>Valable du {{op.dateDebut | date:'dd/MM/yyyy'}} au {{op.dateFin | date:'dd/MM/yyyy'}}</li>
          </ul>
        </div>
        <!-- Card footer -->
      </div>
    </div>
  </div>

</div>
