<?php
session_start();
require_once "gerador/SqlServer.php";
require_once "script_php/conexaoSQL.php";

$lojasec = $_GET['loja'];
$data = $_GET['data'];


if ($lojasec == 'matriz'){
    $lojasec = 'MATRIZ';
}else if($lojasec == 'loja02'){
    $lojasec = 'LOJA 02';
}else if($lojasec == 'loja03') {
    $lojasec = 'LOJA 03';
}else if($lojasec == 'loja04'){
    $lojasec = 'LOJA 04';
}else if($lojasec == 'loja05'){
    $lojasec = 'LOJA 05';
} 

?>

<!DOCTYPE html>
<html>
<head>

<?php include_once 'head.html' ?>

<title></title>
</head>

<body>

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

<h4> <img src="IMG/vendasdia.jpg" height="40px">  LISTAGEM DE NOTAS DE ENTRADA </h4>

<?php

        $hoje = date("Y-d-m");
        //INSTANCIANDO SQL
        $sql = new Sqlserver;
        //BUSCANDO AS VENDAS
        $Compras = $sql-> ComprasProFornecedor($lojasec,$data,$data);
        $total = 0;
?>
<table  class="table tabelaindex">
<tr class='pedidoscbc'>
<th>Emissão</th>
<th>Entrada</th>
<th>Numero</th>
<th>Fornecedor</th>
<th>Valor</th>
<th>CFOP</th>
</tr>

<?php
        //PERCORRENDO DADOS
        foreach ($Compras as $Compra){
            $total += $Compra[5];
?>

<tr>

<td><?php echo date("d/m/Y", strtotime($Compra[0])); ?></td>
<td><?php echo date("d/m/Y", strtotime($Compra[1])); ?></td>
<td align="center"><?php echo $Compra[2]; ?></td>
<td><?php echo $Compra[4]; ?></td>
<td><?php echo round($Compra[5],2); ?></td>
<td><?php echo $Compra[6]; ?></td>

</tr>

<?php } ?>

<tr  class='pedidoscbc'>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td><?php echo "R$" . $total; ?></td>
    <td></td>

</tr>

</table>


<?php include_once 'footer.php' ?>