-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalcular.php
80 lines (61 loc) · 1.83 KB
/
calcular.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
if (
isset($_POST['nome']) &&
isset($_POST['consumoQuilowattsHora']) &&
isset($_POST['rua']) &&
isset($_POST['numeroRua'])
) {
$nome = $_POST["nome"];
$consumoQuilowattsHora = $_POST["consumoQuilowattsHora"];
$rua = ucwords(strtolower($_POST["rua"]));
$numeroRua = $_POST["numeroRua"];
if ($rua[0] == 'R' &&
$rua[1] == 'u' &&
$rua[2] == 'a' &&
$rua[3] == ' '
||
$rua[0] == 'R' &&
$rua[1] == '.'
) {
$rua = str_replace('Rua', '', $rua);
$rua = str_replace('R.', '', $rua);
$rua = ucwords($rua);
}
if ($consumoQuilowattsHora > 120) {
$colorClass = 'font-red';
$valor = number_format($consumoQuilowattsHora * 0.42, 2, ',' , '.');
$economizou = false;
} else {
$colorClass = "font-blue";
$valor = number_format($consumoQuilowattsHora * 0.32, 2, ',' , '.');
$economizou = true;
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Resultado</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<div id="circle-result-container">
<h1>Conta de luz de <?= $nome ?>.</h1>
<p> Rua <?= $rua ?>, <?= $numeroRua ?>.</p>
<p class="<?= $colorClass ?>">Consumo: <span class="letra-grande"><?= $consumoQuilowattsHora ?>kWh</span>.</p>
<p>Valor a pagar: R$ <span class="letra-grande-plus"><?= $valor ?></span>.</p>
<?php
if ($economizou) {
echo"Obrigado por economizar!";
}
?>
</div>
</body>
</html>
<?php
} else {
echo "<h1>Você não enviou as informações corretamente</h1>";
exit;
}