<?php include_once('../../../config.php') ?>

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Sisplan Web | Cadastro de Representante</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../dist/css/adminlte.min.css?versao=3.258.7.1">
    <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css?versao=3.258.7.1">
    <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,600,700,400italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="../dist/css/dataTables.bootstrap4.min.css?versao=3.258.7.1" />
    <link href='../dist/css/bootstrap.min.css?versao=3.258.7.1'>
    <link rel="stylesheet" href="../dist/css/custom.css?versao=3.258.7.1">
    <link rel="stylesheet" href="../dist/css/sisplan.css?versao=3.258.7.1">
    <link rel="stylesheet" href="../dist/css/PesquisaVariosSelect2.css?versao=3.258.7.1">
    <link rel="stylesheet" href="../plugins/icheck-bootstrap/icheck-bootstrap.min.css?versao=3.258.7.1">
    <link rel="stylesheet" type="text/css" href="../plugins/datatables-keytable/css/keyTable.bootstrap4.min.css?versao=3.258.7.1">
    <link rel="stylesheet" type="text/css" href="../dist/css/responsive.bootstrap.min.css?versao=3.258.7.1">
    <link rel="stylesheet" href="../plugins/select2/css/select2.min.css?versao=3.258.7.1">
    <link rel="stylesheet" href="../plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css?versao=3.258.7.1">
    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" href="../dist/css/cadastro.css?versao=3.258.7.1">
    <link rel="stylesheet" href="../plugins/toastr/toastr.min.css?versao=3.258.7.1">
    <link rel="stylesheet" type="text/css" href="../dist/css/driver.min.css?versao=3.258.7.1" />
    <link rel="stylesheet" href="../dist/css/jquery-ui.css?versao=3.258.7.1">
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">

    <style>
        #progressbar li {
            list-style-type: none;
            font-size: 12px;
            width: 100%;
            float: left;
            position: relative
        }
    </style>
</head>

<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">
        <?php
        ;
        ?>
        <div class="content-wrapper">
            <div class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6 flex">
                        </div>
                        <div class="col-sm-6">
                            <!-- <ol class="breadcrumb float-sm-right">
                                
                                <li class="breadcrumb-item"><a href="../centrocusto">Acesso Centro de Custo</a></li>
                                <li class="breadcrumb-item active">Cadastro de centro de Custo</li>
                            </ol> -->
                        </div>
                    </div>
                </div>
                <div class="row justify-content-center">
                    <div class="col-11 text-center p-0 mt-3">
                        <div class="card px-0 pt-4 pb-4">
                            <div class="card-header text-center flex" style="border: none!important;box-shadow:none!important;">
                                <h2>Cadastro de Centro de Custo
                                    <button type="button" class="btn btn-info btn-sm ml-2" title="Tutorial" style="color: white;" id="tutorial">
                                        <i class="fas fa-question-circle"></i>
                                    </button>
                                </h2>
                            </div>
                            <!-- <div class="col-md-12 col-12 col-sm-12 mx-0" style="padding-right: 0px !important; padding-left: 0px !important -->
                            <div class="row">
                                <div class="col-md-12 mx-0">
                                    <form id="msform">
                                        <ul id="progressbar">
                                            <li class="active" id="account" style="font-size: 100%; width:50%;"><strong>Geral</strong></li>
                                            <li id="payment" style="font-size: 100%; width:50%;"><strong>Empresas</strong></li>
                                        </ul>
                                        <p>Preencha os dados e clique em gravar para realizar o cadastro ou alteração do Centro de Custo.</p>
                                        <fieldset>
                                            <div class="form-card" id="formacard">
                                                <div class="row col-12 col-sm-12 col-md-12">
                                                    <div class="form-group col-sm-12 col-md-12 col-12" style="margin: 0px !important">
                                                        <div class="col-md-3 col-3 col-sm-12 form-group justfy-content" style="margin-bottom: 0px !important">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtCodigo">Código: </label>
                                                            <div class="input-group">
                                                                <input type="text" readonly class="input-default focus form-control" id="txtCodigo" name="txtCodigo" placeholder="Campo preenchido automaticamente">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-3 col-3 col-sm-12 form-group" style="margin-bottom: 0px !important">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtEstrutura">Estrutura: </label>
                                                            <div class="input-group">
                                                                <input type="text" class="input-default focus form-control" id="txtEstrutura" name="txtEstrutura" placeholder="Estrutura">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-3 col-3 col-sm-12 form-group" style="margin-bottom: 0px !important">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="rgTipo">Tipo: </label>
                                                            <div class="input-group">
                                                                <select id="rgTipo" class="input-default focus custom-select">
                                                                    <option value="" selected disabled>Selecione uma opção</option>
                                                                    <option value="T">Título</option>
                                                                    <option value="A">Analítica</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-3 col-3 col-sm-12 form-group" style="margin-bottom: 0px !important">
                                                            <div class="col-md-12 col-12 col-sm-12 form-group">
                                                                <fieldset class="form border-Field p-0" id="tpCusto">
                                                                    <label class="textoBorda pb-0 mb-0">Custo</label>
                                                                    <div class="form-row">
                                                                        <div class="icheck-primary col-12 col-sm-12 col-md-12"><input type="radio" id="cbCustoFixo" checked name="rdTpCusto" value="F"><label class="labelCheck" for="cbCustoFixo">Fixo</label></div>
                                                                        <div class="icheck-primary col-12 col-sm-12 col-md-12"><input type="radio" id="cbCustoVariavel" name="rdTpCusto" value="V"><label class="labelCheck" for="cbCustoVariavel">Variavel</label></div>
                                                                    </div>
                                                                </fieldset>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row col-12 col-sm-12 col-md-12"> 
                                                    <div class="form-group col-sm-12 col-md-12 col-12 pb-0" style="margin: 0px !important">
                                                        <div class="col-md-6 col-6 col-sm-12 form-group">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtDescricao">Descrição: </label>
                                                            <div class="input-group">
                                                                <input type="text" class="input-default focus form-control" id="txtDescricao" name="txtDescricao" placeholder="Descrição">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-3 col-3 col-sm-12 form-group">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtGrupoCC">Grupo: </label>
                                                            <div class="input-group">
                                                                <input type="text" class="input-default focus form-control" id="txtGrupoCC" name="txtGrupoCC" placeholder="Grupo de Centro de Custo">
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-sisp bg-danger" id="btnGrupoCC" name="btnGrupoCC" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn btn-sisp bg-danger" id="btnAGrupoCC" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-3 col-3 col-sm-12">
                                                            <div class="col-md-12 col-12 col-sm-12 form-group">
                                                                <fieldset class="form border-Field-semborda">
                                                                    <div class="icheck-primary col-12 col-sm-12 col-md-12">
                                                                        <input type="checkbox" value="" id="cbAtivo">
                                                                        <label class="labelCheck" for="cbAtivo">Ativo</label>
                                                                    </div>
                                                                    <div class="icheck-primary col-12 col-sm-12 col-md-12">
                                                                        <input type="checkbox" value="" id="cbProdutivo">
                                                                        <label class="labelCheck" for="cbProdutivo"> Produtivo</label>
                                                                    </div>
                                                                </fieldset>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row col-12 col-sm-12 col-md-12">
                                                    <div class="form-group d-flex col-sm-12 col-md-12 col-12">
                                                        <div class="col-md-3 col-3 col-sm-12 form-group">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtResponsavel">Responsável: </label>
                                                            <div class="input-group">
                                                                <input type="text" class="input-default focus form-control" id="txtResponsavel" name="txtResponsavel" placeholder="Responsável">
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-sisp bg-danger" id="btnResponsavel" name="btnResponsavel" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn btn-sisp bg-danger" id="btnAResponsavel" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-3 col-3 col-sm-12 form-group">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtResponsavel2">Responsável Aux.: </label>
                                                            <div class="input-group">
                                                                <input type="text" class="input-default focus form-control" id="txtResponsavel2" name="txtResponsavel2" placeholder="Responsável Aux.">
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-sisp bg-danger" id="btnResponsavel2" name="btnResponsavel2" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn btn-sisp bg-danger" id="btnAResponsavel2" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-3 col-3 col-sm-12 form-group">
                                                            <label data-error="wrong" class="labelGeral" data-success="right" for="txtNegocio">Negócio: </label>
                                                            <div class="input-group">
                                                                <input type="text" class="input-default focus form-control" id="txtNegocio" name="txtNegocio" placeholder="Negócio">
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-sisp bg-danger" id="btnNegocio" name="btnNegocio" data-button="absolute" type="button"><i class="m-0 p-0 fas fa-search"></i></button>
                                                                    <button class="btn btn-sisp bg-danger" id="btnANegocio" type="button"><i class="m-0 p-0 fas fa-trash"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row col-12 col-sm-12 col-md-12 justify-content-start">
                                                    <div class="form-group d-flex col-sm-12 col-md-12 col-12">
                                                        <div class="col-md-12 col-12 col-sm-12 form-group">
                                                            <label>Observação: </label>
                                                            <textarea class="input-default focus form-control validate" id="txtObs" style="resize: none; min-height: 100px;" placeholder="Observação"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <input type="button" name="avancar1" class="btn-sisp btn next action-button" value="Avançar" id="avancar1" />
                                            <!-- <button type="button" id="btnVoltar" style="font-size:15px;" class="btn btn-success btn-sisp action-button-previous" data-dismiss="modal">Voltar</button> -->
                                            <input type="button" name="btnVoltar" class="previous btn-sisp btn action-button-previous" value="Voltar" id="btnVoltar">
                                        </fieldset>

                                        <fieldset>
                                            <div class="form-card">
                                                <div class="row" id="configuracao">
                                                    <div class="col-md-12 col-12 table-responsive">
                                                        <table id="tabelaEmpresa" class="table table-sm table-hover table-select table-condensed">
                                                            <thead>
                                                                <tr>
                                                                    <th>Sel</th>
                                                                    <th>Empresa</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                        </table>
                                                    </div>

                                                </div>
                                            </div>
                                            <input type="button" name="gravar" id="gravar" class="btn-sisp action-button" value="Gravar" />
                                            <input type="button" name="voltar2" class="previous action-button-previous" value="Voltar" id="voltar2">
                                        </fieldset>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php
    include_once('../../../modais.php');
    ?>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->
    </div>

    <!-- jQuery -->
    <script src="../plugins/jquery/jquery.min.js?versao=3.258.7.1"></script>
    <script src="../plugins/jquery-ui/jquery-ui.min.js?versao=3.258.7.1"></script>
    <script type="text/javascript" src="../dist/js/jquery.dataTables.js?versao=3.258.7.1"></script>
    <script type="text/javascript" src="../dist/js/dataTables.bootstrap4.min.js?versao=3.258.7.1"></script>
    <!-- SweetAlert2 -->
    <script src="../plugins/sweetalert2/sweetalert2.min.js?versao=3.258.7.1"></script>
    <script src="../plugins/toastr/toastr.min.js?versao=3.258.7.1"></script>

    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <script>
        $.widget.bridge('uibutton', $.ui.button);
    </script>

    <script src="../plugins/bootstrap/js/bootstrap.bundle.min.js?versao=3.258.7.1"></script>
    <script src="../dist/js/adminlte.min.js?versao=3.258.7.1"></script>
    <script src="../dist/js/requisicoes.js?versao=3.258.7.1"></script>
    <script src="../dist/js/cliente/entidade.js?versao=3.258.7.1"></script>
    <script src="../dist/js/loadingoverlay.min.js?versao=3.258.7.1"></script>
    <script src="../dist/js/valida_cpf_cnpj.js?versao=3.258.7.1"></script>
    <script src="../plugins/jquery-validation/jquery.validate.min.js?versao=3.258.7.1"></script>
    <script src="../dist/js/sisplan.js?versao=3.258.7.1"></script>
    <script src="../utils/funcoes.js?versao=3.258.7.1"></script>
    <script src="../utils/cookies.js?versao=3.258.7.1"></script>
    <script src="../dist/js/driver.min.js?versao=3.258.7.1"></script>
    <script src="../dist/js/jquery.maskMoney.min.js?versao=3.258.7.1"></script>
    <script src="../dist/js/jquery.mask.min.js?versao=3.258.7.1"></script>
    <script src="../dist/js/dataTables.keyTable2.js?versao=3.258.7.1"></script>
    <script type="text/javascript" src="../config.js?versao=3.258.7.1"></script>
    <script src="../plugins/select2/js/select2.full.min.js?versao=3.258.7.1"></script>

    <script>
        $(document).ready(async function() {
            if (getCookie('usuario') == "") {
                window.location.href = `${BASE_URI}/login`;
                return;
            }

            let usuario = getCookie('usuario');
            let empresa = getCookie('empresa');

            ipInterno = IP_INTERNO;
            ipExterno = IP_EXTERNO;
            basicAuth = BASIC_AUTH;

            const temAcesso = await temAcessoTela('CENTROCUSTO');
            if (!temAcesso.resultado) {
                toastrAcesso(temAcesso, BASE_URI);
                return;
            }

            const permissaoUsuarioLogado = await permissaoAcessos("CENTROCUSTO");

            if (permissaoUsuarioLogado.INCLUI == 'N') {
                await criaMensagemErro("Sem permissão para incluir!", () => {
                    window.location.href = `${BASE_URI}/centrocusto`
                });
                return;
            }

            const queryString = window.location.href;
            const parametros = queryString.split("/");
            const centrocusto = parametros[parametros.length - 1];

            $(window).on("beforeunload", function(e) {
                // e.preventDefault();
                e.stopPropagation();
                deletaRegistro("CENTROCUSTO", getCookie("usuario"), centrocusto);
                return undefined;
            });

            sArquivo = `${BASE_URI}/pages/centrocusto/cadcentrocusto/cadcentrocusto.js?versao=3.258.7.1`;
            insereJavaScriptPagina(sArquivo);

            const nomeTela = ('<?php echo basename(__FILE__) ?>').replace('.php', '');
            habilitaCamposObrigatoriosTela(nomeTela);
        });
    </script>
</body>

</html>