Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues resolvidas no modulo material e patrimonio #699

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions html/cadastro_destino.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,23 @@ function validarCPF(strCPF) {
}

function FormataCnpj(campo, teclapres) {
var tecla = teclapres.keyCode;
var vr = new String(campo.value);
vr = vr.replace(".", "");
vr = vr.replace("/", "");
vr = vr.replace("-", "");
tam = vr.length + 1;
if (tecla != 14) {
if (tam == 3)
campo.value = vr.substr(0, 2) + '.';
if (tam == 6)
campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 5) + '.';
if (tam == 10)
campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(6, 3) + '/';
if (tam == 15)
campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(6, 3) + '/' + vr.substr(9, 4) + '-' + vr.substr(13, 2);
}
var tecla = teclapres.keyCode;
var vr = campo.value.replace(/\D/g, ''); // Remove todos os caracteres não numéricos
var tam = vr.length;

if (tecla != 8) { // Ignora o backspace
if (tam <= 2) {
campo.value = vr; // Ex: 12
} else if (tam <= 5) {
campo.value = vr.substr(0, 2) + '.' + vr.substr(2); // Ex: 12.345
} else if (tam <= 8) {
campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(5); // Ex: 12.345.678
} else if (tam <= 12) {
campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(5, 3) + '/' + vr.substr(8); // Ex: 12.345.678/9012
} else {
campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(5, 3) + '/' + vr.substr(8, 4) + '-' + vr.substr(12, 2); // Ex: 12.345.678/9012-34
}
}
}

function validarCNPJ(cnpj) {
Expand Down Expand Up @@ -177,6 +178,19 @@ function exibirCNPJ(cnpj) {
document.getElementById("enviar").disabled = false;
}
}
function permitirSomenteCNPJ(e) {
var tecla = e.key;

// Permite números (0-9), "/", "-", ".", e teclas de controle como Backspace, Delete, Tab, etc.
var regex = /^[0-9\/\.\-]$/;

// Se a tecla não for permitida, cancela o evento
if (!regex.test(tecla) && !['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight', 'Delete'].includes(tecla)) {
e.preventDefault();

}
}


</script>
<script type="text/javascript">
Expand Down Expand Up @@ -250,7 +264,7 @@ function validar() {
<div class="form-group">
<label class="col-md-3 control-label" for="profileCompany">Número do CNPJ</label>
<div class="col-md-6">
<input type="text" name="cnpj" id="cnpj" onkeyup="FormataCnpj(this,event)" onblur="validarCNPJ(this.value)" maxlength="18" class="form-control input-md" ng-model="cadastro.cnpj" placeholder="Ex: 77.777.777/7777-77">
<input type="text" name="cnpj" id="cnpj" onkeyup="FormataCnpj(this,event)" onkeydown="permitirSomenteCNPJ(event)" onblur="validarCNPJ(this.value)" maxlength="18" class="form-control input-md" ng-model="cadastro.cnpj" placeholder="Ex: 77.777.777/7777-77">
</div>
</div>

Expand Down Expand Up @@ -286,7 +300,7 @@ function validar() {
<div class="col-md-9 col-md-offset-3">
<button id="enviar" class="btn btn-primary" type="submit">Enviar</button>
<input type="reset" class="btn btn-default">
<a href="cadastro_entrada.php" color: white; text-decoration: none;>
<a href="cadastro_saida.php" color: white; text-decoration: none;>
<button type="button" class="btn btn-info">voltar</button>
</a>
<a href="listar_destino.php" style="color: white; text-decoration:none;"><button class="btn btn-success" type="button">Listar destinos</button></a>
Expand Down
4 changes: 2 additions & 2 deletions html/cadastro_entrada.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
require_once($config_path);
}
$conexao = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$id_pessoa = $_SESSION['id_pessoa'];
$resultado = mysqli_query($conexao, "SELECT * FROM funcionario WHERE id_pessoa=$id_pessoa");
$id_pessoa = mysqli_real_escape_string($conexao, $_SESSION['id_pessoa']);
$resultado = mysqli_query($conexao, "SELECT * FROM funcionario WHERE id_pessoa='$id_pessoa'");
if(!is_null($resultado)){
$id_cargo = mysqli_fetch_array($resultado);
if(!is_null($id_cargo)){
Expand Down