<?php
session_start();
require_once 'script_php/ConexaoSQL.php';
require_once 'gerador/SqlServer.php';
require_once 'gerador/MysqlConsulta.php';

$sql = new SqlServer();
$mysql = new MysqlConsulta;

$loja = $_GET['loja'];
$lojaRecebida = $_GET['loja'];


$negativos = $sql->listarNegativos($lojaRecebida);



?>

<!DOCTYPE html>
<html>
<head>

<?php include_once 'head.html' ?>

<title></title>
</head>

<body>

<?php include_once 'header.php'; ?>


<table class="table table-striped  ">

  <thead class="table-dark">

      <th scope="col" title="Dias pendente">Cód</th>
      <th scope="col" title="Dias pendente">Barras</th>
      <th scope="col" title="Dias pendente">Mercadorias</th>
      <th scope="col" title="Dias pendente">Quantidade</th>  
      <th scope="col" title ="contagem" width="300px"> Contar </th>
      <th scope="col" title ="contagem">limpar</th>

</thead>

<?php foreach($negativos as $dado){
    
   

   $encontrado =  $mysql->buscarContageneNegativo($conexao, $lojaRecebida, $dado[0]);
?>
<tr>
    <td>
        <?php echo $dado[0];?>
    </td>

    <td>
        <?php echo $dado[3];?>
    </td>


    <td>
        <?php echo $dado[1];?>
    </td>

    <td  align='center'>

    <?php echo $dado[2] ;?>

    </td>

    <form action="gerador/negativos/contagenegativos.php" method="post">

    <td>


    <?php if (!$encontrado){?>

        <input type="number" class="contagem" name="produto[<?php echo $dado[0];?>]">

    <?php }else { ?>

    <input type="" class="contagem btn disabled" value="<?=$encontrado; ?>">
    <?php } ?>
    </td>

    <td>

    <?php     if ($tipousuario <> 'recebimento'){?> 

        <a href="gerador/negativos/contagenegativosExcluir.php?loja=<?= $lojaRecebida?>&codigo=<?=$dado[0];?>">
        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-counterclockwise text-danger" viewBox="0 0 16 16">
        <path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2z"/>
        <path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466"/>
        </svg>
</a>

        <?php } ?>
        
    </td>



</tr>

<?php } ?>

</table>

<input type="submit" value="Enviar contagem" class="btn btn-warning table-striped">
<input type="hidden" name="loja" value="<?= $lojaRecebida; ?>">



</form>
</tr>




<?php include_once 'footer.php' ?>