<?php $render('header', ['loggedUser'=>$loggedUser, 'title'=>$titlePage]); ?>
<?=$render('sidebar', [
  'loggedUser'=>$loggedUser, 
  'pageActive'=>$pageActive,
  'permissions'=>$permissions
]);?>

<!-- Content System -->
<div class="content-wrapper">
  <div class="pages">
    <h3>Relatório de Produtos por Fornecedor(es)</h3>
    <div class="users rep-prod-prov">

      <div class="filters filter_responsive">

        <form method="POST" action="<?= $base; ?>/reportprovidersproducts">
          <input type="hidden" id="isclear" name="filter[clear]">
          <div class="filter-items">

            <div class="felx-1">
              <label style="display:flex; align-items: center; width:160px; flex-direction: row-reverse; margin: 0 20px 0 0;">
                Apenas com estoque
                <input type="checkbox" name="filter[onlystock]" style="float: left; width:30px; margin: 0;" <?= ($arrayInfo['filter']['onlystock'] == 'on')?'checked':''; ?> >
              </label style="line-height: 22px;">
            </div>

            <div class="felx-2">
              <select class="form-control" name="filter[searchType]">
                <option value="" >Status</option>
                <option value="1" <?= ($arrayInfo['filter']['searchType'] == '1')?'selected':'' ?> >Ativo</option>
                <option value="2" <?= ($arrayInfo['filter']['searchType'] == '2')?'selected':'' ?> >Inativo</option>
              </select>

              <select class="form-control" name="filter[state]">
                <option value="">Estado</option>
                <?php foreach($arrayInfo['stateList'] as $state): ?>
                    <option value="<?= $state['uf'] ?>" <?= ($arrayInfo['filter']['state'] ==  $state['uf'])?'selected':'' ?> ><?= $state['uf'] ?></option>
                <?php endforeach; ?>
              </select>

              <select class="form-control" name="filter[p_group]">
                <option value="">Grupo</option>
                <option value="2" <?= ($arrayInfo['filter']['p_group'] == 2)?'selected':'' ?> >Com Estoque</option>
                <option value="1" <?= ($arrayInfo['filter']['p_group'] == 1)?'selected':'' ?> >Sem Estoque</option>
                <option value="3" <?= ($arrayInfo['filter']['p_group'] == 3)?'selected':'' ?> >Especial</option>
              </select>

              <div style="position: relative;">
                <input type="hidden" name="filter[provider]" value="<?= $arrayInfo['filter']['provider']; ?>">
                <input type="text" name="filter[provider_name]" style="width: 300px; margin-right: 10px;" class="form-control" id="search_provider"  placeholder="Pesquisar por fornecedor..." value="<?= $arrayInfo['filter']['provider_name']; ?>">

                <div class="result-here searchresultprovider"></div>
              </div>

              <select class="form-control" name="filter[print]">
                <option value="">Formato</option>
                <option value="P" <?= ($arrayInfo['filter']['print'] == 'P')?'selected':'' ?> >Retrato</option>
                <option value="L" <?= ($arrayInfo['filter']['print'] == 'L')?'selected':'' ?> >Paisagem</option>
              </select>

              <!-- <input type="text" name="filter[limit]" id="max_result" class="form-control" value="<?= $arrayInfo['filter']['limit']; ?>"> -->

              <button type="submit" class="proccess">PROCESSAR</button>
              <button id="reports_providers" class="proccess">LIMPAR</button>
            </div>            
          </div>
        </form>

        <div class="filter-buttons">
          <a href="<?= $base; ?>/productspdf" target="_blank" class="btn btn-success">PDF</a>
          <a href="<?= $base; ?>/productscsv" target="_blank" class="btn btn-success">Excel</a>
        </div>
      </div>


      <table class="table table-bordered">
        <tbody>
          <tr>
            <th scope="col">Item</th>
            <th scope="col">Status do Fornecedor</th>
            <th scope="col">Fornecedor</th>
            <th scope="col">Cidade-UF</th>
            <th scope="col">Grupo de Produto</th>
            <th scope="col">Status do Produto</th>
            <th scope="col">Produto</th>
            <th scope="col">Estoque</th>
            <th scope="col">Custo R$</th>
          </tr>
          
          <?php foreach($newItems as $key => $provider): ?>
            <tr>
              <td><?= ($key + 1); ?></td>
              <td><?= $provider['provider_status']; ?></td>
              <td><?= $provider['provider_name']; ?></td>
              <td><?= $provider['provider_location']; ?></td>
              <td><?= $provider['group_product']['name']; ?></td>
              <td><?= ($provider['status'] == 1)?'Ativo':'Inativo'; ?></td>
              <td><?= $provider['name']; ?></td>
              <td><?= $provider['amount']; ?></td>
              <td><?= $provider['cost_price']; ?></td>
            </tr>
          <?php endforeach; ?>      

        </tbody>
      </table>
    </div>

    <script src="<?= $base ?>/assets/js/reports.js"></script>
    <script src="<?= $base ?>/assets/js/providers_reports.js"></script>
  </div>  		
</div>
<!-- /.content-system -->

<?=$render('footer');?>