<div class="row">
  <div class="page-wrapper chiller-theme toggled">
    <nav id="sidebar" class="sidebar-wrapper">
      <menu-admin name={{name}} dock={{dock}}></menu-admin>
      <link-exit></link-exit>
    </nav>

    <main class="page-content">
      <div class="container justify-content-md-center">

        <h2>Pedidos - Ecom Convicto</h2>
        <div class="row form-login">
          <div class="col-md-9">
            <input type="text" ng-model="procurar" class="form-control" placeholder="Digite sua busca">
          </div>
        </div>


        <div class="row form-login">
          <div class="col-md-3 ml-4">
            <div class="card border-success mb-3" style="width: 12rem;">
              <a href="#/invoiced" class="card-link">
                <div class="card-header text-white bg-success text-center">Faturados</div>
              </a>
            </div>
          </div>

          <div class="col-md-3">
            <div class="card border-primary mb-3" style="width: 12rem;">
              <a href="#/ready" class="card-link">
                <div class="card-header text-white bg-primary text-center">Prontos para faturar</div>
              </a>
            </div>
          </div>

          <div class="col-md-3">
            <div class="card border-danger mb-3" style="width: 12rem;">
              <a href="#/canceled" class="card-link">
                <div class="card-header text-white bg-danger text-center">Cancelados</div>
              </a>
            </div>
          </div>

        </div>

        <form name="datafilter" ng-submit="submeter()">
          <div class="row form-login mb-3">
            <div class="col-md-3">
              <h5 class="align-middle text-center text-monospace">Filtrar por Data</h5>
            </div>

            <div class="col-md-3">
              <input type="date" class="form-control" ng-model="start">
            </div>
            <div class="col-md-3">
              <input type="date" class="form-control" ng-model="final">
            </div>

            <div class="col-md-1">
              <button type="submit" class="btn btn-primary" ng-disabled="datafilter.$invalid">Filtrar</button>
            </div>
            
            <div class="col-md-2">
              <a href="" role="button" ng-click="reload()" class="btn btn-dark">Listar Todos</a>
            </div>

          </div>
        </form>



        <p ng-show="mensagem.length" class="alert alert-info">{{mensagem}}</p>

        <div class="row form-login" ng-init="inicio()">

        <div class="col">
          <table class="table">
            <thead>
              <tr>
                <th scope="col">Compra</th>
                <th scope="col">Pedido</th>
                <th scope="col">Cliente</th>
                <th scope="col">Status</th>
                <th scope="col">Valor</th>
                <th scope="col"></th>
              </tr>
            </thead>
            <tbody dir-paginate="v in order|filter:procurar|itemsPerPage:12|orderBy:'-creationDate'">
              <tr>
                <!--<th scope="row">{{(v.creationDate).split("T")[0].split("-").reverse().join().replace(",","-").replace(",","-")}}</th>-->
                <th scope="row">{{ v.creationDate | date:'dd/MM/yyyy' }}</th>
                <td>{{v.orderId}}</td>
                <td>{{v.clientFirstName}} {{v.clientLastName}}</td>
                <td ng-class="{'text-success':v.status=='invoiced', 'text-danger':v.status=='canceled', 'text-secondary':v.status=='ready-for-handling' || v.status=='handling'}">{{v.statusDescription}}</td>
                <td>{{(v.totalValue / 100).toFixed(2).replace(".", ",")}}</td>
                <td><a href="#/orders/{{v.orderId}}" class="btn btn-primary">Ver Detalhes</a></td>
              </tr>
            </tbody>
          </table>
        </div>

      </div>
      <div class="row justify-content-md-center">

        <nav>
          <dir-pagination-controls max-size="5" boundary-links="false"></dir-pagination-controls>
        </nav>

      </div>

      </div>
    </main>

  </div>

</div>
