<?php
  // ini_set('display_errors',1);
  // ini_set('display_startup_erros',1);
  // error_reporting(E_ALL);
  require '../../../inc/conexao.php';
  require '../../../inc/functions.php';
  require '../../../api/api.php';
  require '../../../api/pages/caixa.php';
?>
<div class="page">
  <div class="navbar">
    <div class="navbar-inner sliding">
      <div class="left">
        <a href="#" class="link back">
          <i class="icon icon-back"></i>
          <span class="ios-only">Voltar</span>
        </a>
      </div>
      <div class="title">Bilhetes</div>
      <div class="right">
        <a href="" style=" font-size: 11px; margin-right: 10px; "><?php echo $_SESSION["usuario"]["nome"]; ?></a>
      </div>
    </div>
  </div>
  <div class="page-content">
    <form action="" method="GET">
      <div class="list no-hairlines-md" style=" margin: 5px 0; ">
        <ul>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" name="date" placeholder="Selecione a data de início" id="cashierDate" class="calendario" value="<?php echo $_GET['date']; ?>" readonly="">
                </div>
              </div>
            </div>
          </li>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" name="enddate" placeholder="Selecione a data de fim" id="cashierEnddate" class="calendario2" value="<?php echo $_GET['enddate']; ?>" readonly="">
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <a class="col button button-fill color-orange" onClick="filterCashierCoupons('bilhetes');">Filtrar</a>
    </form>

    <div class="block-title"><?php echo $api['dates']; ?></div>
    <div class="list">
      <?php foreach ($api['coupons'] as $code => $v) { ?>
      <div class="card demo-facebook-card coupons-cards">
        <div class="card-header">
          <div class="demo-facebook-name">#<?php echo $code; ?></div>
          <div class="demo-facebook-date">R$<?php echo $v["price"]; ?> | R$<?php echo $v["return"]; ?></div>
          <div class="coupon-card-status">
            <?php
               switch ($v["status"]) {
                  case '1':
                     echo '<span id="badgeCoupon'.$code.'" class="badge color-blue">Aberto</span>';
                     break;

                  case '2':
                     echo '<span id="badgeCoupon'.$code.'" class="badge color-green">Ganhou</span>';
                     break;

                  case '3':
                     echo '<span id="badgeCoupon'.$code.'" class="badge color-red">Perdeu</span>';
                     break;

                  case '4':
                     echo '<span id="badgeCoupon'.$code.'" class="badge color-black">Cancelado</span>';
                     break;

                  default:
                     echo '';
                     break;
               }
            ?>
        </div>
        </div>
        <div class="card-content card-content-padding">
          <center><b>Data: </b> <?php echo $v["date"]; ?> | <b>Cliente: </b> <?php echo $v["client"]; ?></center>
        </div>
        <div class="card-footer">
          <a href="#" onClick="cancelCoupon('<?php echo $code; ?>');" class="link color-red">Cancelar</a>
          <a href="/visualizar-bilhete/?code=<?php echo $code; ?>" class="link">Ver</a>
          <a href="/imprimir-app-bilhete/?code=<?php echo $code; ?>" class="link">Imprimir</a>
        </div>
      </div>
      <?php } ?>
    </div>
  </div>
</div>
