/
cadastro_juros.js
58 lines (48 loc) · 1.75 KB
/
cadastro_juros.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
$("#pedidos").hide();
let montante = $("#total-montante")
let tempo = $("#tempo-dias")
let capital = $("#capital-reais")
let juros = $("#juros")
$("#solicitar").click(function () {
$("#pedidos").show(1000, "swing");
$("#pedidos").css("display", "flex");
});
$("#cancelar").click(function () {
$("#pedidos").hide(1000, "swing");
})
function update() {
console.log(juros.val())
console.log(tempo.val())
console.log(capital.val)
if (juros.val() == "c") {
montante.val(String(Number(capital.val()) * ((1 + 0.05) ^ Number(tempo.val())))).change();
}
else if (juros.val() == "s") {
montante.val(String(Number(capital.val()) * Number(tempo.val()) * 0.09)).change();
}
}
let button = document.getElementById("btn-concluir-cadastro-cliente")
button.addEventListener('click', () => {
let emprestimo = {}
if ( montante.val() == "" ||
tempo.val() == "" ||
capital.val() == "" ||
juros.val() == ""
) {
alert("Por favor preencha todos os campos")
} else {
emprestimo.nome = document.getElementById("nomi").innerHTML.replace(/\n/g, "");
emprestimo.id = document.getElementById("idzinho").innerHTML.replace(/\n/g, "");
emprestimo.montante = montante.val().replace(/^\d/g, "")
emprestimo.tempo = tempo.val().replace(/^\d/g, "")
emprestimo.capital = capital.val().replace(/^\d/g, "")
emprestimo.juros = juros.val()
var data = new FormData();
data.append("data", JSON.stringify(emprestimo));
var xhr = (window.XMLHttpRequest) ? new XMLHttpRequest() : new activeXObject("Microsoft.XMLHTTP");
xhr.open('post', 'banco_de_dividas.php', true);
xhr.send(data);
alert("Empréstimo solicitado")
}
}
)