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

if (isset($_GET['id']) && $_GET['id'] == '0') {
    $pageTitle = "Incluir Metas Vendedor"; // Definir o título da página aqui
} else {
    $pageTitle = "Alterar Meta";
}


//Declarado as variáveis que serão usadas para edição.
$meta = array(
    'id_metas' => '0',
    'codigo_filial' => '',
    'ano' => '',
    'mes' => '',
    'valor_manipulado' => '',
    'valor_revenda' => '',
    'valor_marcapropria' => '',
    // ... outros campos que você pode ter ...
);

//Verificando se é alteração

?>

<!DOCTYPE html>
<html lang="pt-br">
<?php

include('../geral/header.php');
?>

<body>

    <!-- Navigation Bar-->
    <?php
    include('../geral/menu.php');
    ?>
    <!-- End Navigation Bar-->

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

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

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

                <div class="row">
                    <div class="col-6 text-left">
                        <h4 class="page-title"><?php echo $pageTitle ?></h4>
                    </div>

                    <div class="col-6 text-right">
                        <button onclick="goBack()" class="btn btn-light"><i class="mdi mdi-keyboard-backspace"></i> Voltar</button>
                    </div>

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

                    <div class="col-12">
                        <form method="post" action="processa_cadastro_alteracao_metas.php" onsubmit="return validarFormulario();">
                            <div class="form-row mb-3">



                                <div class="form-group col-md-3">
                                    <label for="codigo_filial" class="col-form-label">Filial</label>

                                    <p><input type="text" name="codigo_filial" id="codigo_filial" class="form-control" placeholder="Informe a filial" value="<?php echo htmlspecialchars($meta['codigo_filial']); ?>"></p>
                                </div>



                                <div class="form-group col-md-3">
                                    <label for="ano" class="col-form-label">Ano</label>

                                    <p><input type="text" name="ano" id="ano" class="form-control" placeholder="Informe o ano" value="<?php echo htmlspecialchars($meta['ano']); ?>"></p>
                                </div>

                                <div class="form-group col-md-3">
                                    <label for="mes" class="col-form-label">Mês</label>

                                    <p><input type="text" name="mes" id="ano" class="form-control" placeholder="Informe o mes" value="<?php echo htmlspecialchars($meta['mes']); ?>"></p>
                                </div>

                                <div class="form-group col-md-3">
                                    <label for="valor_manipulado" class="col-form-label">Manipulado</label>

                                    <p><input type="text" name="valor_manipulado" id="valor_manipulado" class="form-control" placeholder="Meta Manipulado" value="<?php echo htmlspecialchars($meta['valor_manipulado']); ?>"></p>
                                </div>

                                <div class="form-group col-md-3">
                                    <label for="valor_revenda" class="col-form-label">Revenda</label>

                                    <p><input type="text" name="valor_revenda" id="valor_revenda" class="form-control" placeholder="Meta Revenda" value="<?php echo htmlspecialchars($meta['valor_revenda']); ?>"></p>
                                </div>

                                <div class="form-group col-md-3">
                                    <label for="valor_marcapropria" class="col-form-label">Marca Propria</label>

                                    <p><input type="text" name="valor_marcapropria" id="valor_marcapropria" class="form-control" placeholder="Meta Marca Propria" value="<?php echo htmlspecialchars($meta['valor_marcapropria']); ?>"></p>
                                </div>


                                <input type="hidden" name="id_metas" id="id_metas" value="<?php echo htmlspecialchars($meta['id_meta']); ?>">

                                <div class="col-12 text-right">

                                    <button type="submit" class="btn btn-primary"><i class="mdi mdi-magnify"></i> Salvar</button>
                                </div>
                        </form>
                    </div>
                </div>
            </div>

        </div>

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


    <!-- end wrapper -->

    <!-- ============================================================== -->
    <!-- End Page content -->
    <!-- ============================================================== -->

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

    <?php
    include('../geral/mensagens_modais.php');
    ?>

    <!-- Vendor js -->
    <script src="../../assets/js/vendor.min.js"></script>

    <!-- knob plugin -->
    <script src="../../assets/libs/jquery-knob/jquery.knob.min.js"></script>
    <!-- App js-->
    <script src="../../assets/js/app.min.js"></script>



    <script>
        function validarFormulario() {





            let descricao_dominio = document.getElementById("descricao_dominio").value;


            if (!descricao_dominio) {
                alert("Preencha descricao_dominio");
                return false;
            }


        }

        function goBack() {
            window.history.back();
        }
    </script>
</body>

</html>