<?php
require '../conexao/conexao.php';
//require '../sessao.php';
require '../conexao/acesso.php';
require '../configuacoes.php';

require 'query_orcamento.php';

$formula = $_GET['identificador'];

$dataEntrega = $_GET['data'];
if (isset($_GET['link'])) {
    $sql = '';
    $serieo = substr($formula, 0, 1);
    $filial = substr($formula, 3, 1);
    $n_orcamento = substr($formula, 6, 8);
    $sql .= " and serieo = '{$serieo}' ";
} else {

    $filial = substr($formula, 2, 1);
    $n_orcamento = substr($formula, 5, 8);
}

//echo $n_orcamento;

$sql .= " and tpcmp = 'C' ";

$filialOrcamento = new FilialOrcamento($connection);

$detalhamentoOrcamento = $filialOrcamento->consultaFormulas($filial, $n_orcamento, $dataEntrega, $sql);

//print_r($detalhamentoOrcamento);

$hasResults = false;


?>


<!DOCTYPE html>
<html lang="pt-br">
<?php
$pageTitle = "Orçamentos"; // Definir o título da página aqui
include('../geral/header.php');
?>

<body>


    <!-- ============================================================== -->
    <!-- Start Page Content here -->
    <!-- ============================================================== -->

    <div class="wrapper candidato">
        <div class="container-fluid">

            <div class="card-box mt-3">
                <div class="row">

                    <div class="col-6 text-left">
                        <h4 class="page-title">Ativos </h4>

                    </div>


                    <div class="col-12">
                        <hr>
                    </div>


                    <table width="100%" class="table table-bordered table-hover table-sm dataTable no-footer">
                        <thead class="thead-light">
                            <tr>
                                <th nowrap="nowrap">Produto</th>
                                <th nowrap="nowrap">Quantidade</th>
                                <th nowrap="nowrap">Unidade</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            foreach ($detalhamentoOrcamento as $itens) {

                                $nomesFiliais = $filialOrcamento->consultaFilial($itens['CDFIL'])[0];
                            ?>
                                <tr>
                                    <td><?php echo htmlspecialchars($itens['DESCR']); ?></td>
                                    <td><?php echo htmlspecialchars($itens['QUANT']); ?></td>
                                    <td><?php echo htmlspecialchars($itens['UNIDA']); ?></td>

                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                    <div class="col-sm-12">
                        <button class="btn btn-primary" style="float: right;" onclick="history.back();"><span>Voltar</span></button>
                    </div>

                </div>

            </div> <!-- end container -->
        </div>
    </div>

    <!-- end wrapper -->

    <!-- ============================================================== -->
    <!-- End Page content -->
    <!-- ============================================================== -->
    <!-- Footer Start -->
    <?php
    include('../geral/footer.php');
    ?>
    <!-- end Footer -->

    <?php
    include('../geral/mensagens_modais.php');
    ?>
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

    <!-- Outros scripts -->
    <script src="../../assets/js/vendor.min.js"></script>
    <script src="../../assets/libs/jquery-knob/jquery.knob.min.js"></script>
    <script src="../../assets/js/app.min.js"></script>
    <script src="../geral/javascript.js"></script>

    <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap5.min.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap5.min.css">


</body>

</html>