summaryrefslogtreecommitdiff
path: root/kalorien_rechner/ausgabe.php
blob: 5aa63ab77edf0e09aee141c9d4c441506e2ea1a6 (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
session_start();

if (isset($_POST['rechnen'])) {
    $geschlecht = $_POST['geschlecht'];
    $gewicht = $_POST['gewicht'];
    $groesse = $_POST['groesse'];
    $alter = $_POST['alter'];
    $aktivitaet = $_POST['aktivitaet'];
    $sport = $_POST['sport'];
    $ziel = $_POST['ziel'];

    if ($geschlecht == 'maennlich') {
        $grundumsatz = 66.47 + (13.7 * $gewicht) + (5 * $groesse) - (6.8 * $alter);
    } else $grundumsatz = 655.1 + (9.6 * $gewicht) + (1.8 * $groesse) - (4.7 * $alter);

    $leistungsumsatz = ($grundumsatz * $aktivitaet) + ($sport * 100);

    if ($ziel == 'abnehmen') {
        $absolut_kalorien = $leistungsumsatz - 400;
    } elseif ($ziel == 'zunehmen') {
        $absolut_kalorien = $leistungsumsatz + 400;
    } else $absolut_kalorien = $leistungsumsatz;

    if ($ziel == 'abnehmen') {
        $protein = $gewicht * 2.2;
    } else if ($ziel == 'zunehmen') {
        $protein = $gewicht * 1.8;
    } else $protein = $gewicht * 2;

	$protein = $protein > 0 ? round($protein) : 0;
	$absolut_zucker = $absolut_kalorien / 40;
	$zucker = $absolut_zucker > 0 ? round($absolut_zucker) : 0;
    $absolut_kohlenhydrate = ($absolut_kalorien - (4 * $protein) - (9 * $gewicht) - (4 * $zucker)) / 4;
	$kohlenhydrate = $absolut_kohlenhydrate > 0 ? round($absolut_kohlenhydrate) : 0;
    $fett = $gewicht;
    $kalorien = $absolut_kalorien > 0 ? round($absolut_kalorien) : 0;
}
?>

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Kalorien Ausgabe</title>
    <link rel="icon" type="image/x-icon" href="/style/avocado.png">
    <link rel="stylesheet" type="text/css" href="/style/style.css">
</head>
<body>
<nav class="medium_box">
    <ul class="hor_spacing">
        <li class="hor_spacing_item">
            <a class="small_box color_inverse_on_hover" href="/login">Login</a>
        </li>
        <li class="hor_spacing_item">
            <a class="small_box tertiary_color_style" href="/kalorien_rechner">Kalorien-rechner</a>
        </li>
        <li class=hor_spacing_item>
            <a class="small_box color_inverse_on_hover" href="/kalorien_zaehler">Kalorien-zähler</a>
        </li>
        <li class="hor_spacing_item">
            <a class="small_box color_inverse_on_hover" href="/rezepte">Rezepte</a>
        </li>
        <li class="hor_spacing_item">
            <a class="small_box color_inverse_on_hover" href="/workouts">Workouts</a>
        </li>
    </ul>
</nav>
<main class="big_box hor_spacing">
    <h1>Täglicher Bedarf</h1>

    <?php if (isset($_POST['rechnen'])) { ?>
        <div class="flexbox hor_spacing_item">
            <div class="medium_box" style="flex: 1">
                <h2 style="margin: 0">Proteine:</h2>
                <div style="font-size: 100px"><?= $protein ?></div>
                <h2 style="margin: 0">gramm</h2>
            </div>
            <div class="medium_box" style="flex: 1">
                <h2 style="margin: 0">Kohlenhydrate:</h2>
                <div style="font-size: 100px"><?= $kohlenhydrate ?></div>
                <h2 style="margin: 0">gramm</h2>
            </div>
            <div class="medium_box" style="flex: 1">
                <h2 style="margin: 0">Fette:</h2>
                <div style="font-size: 100px"><?= $fett ?></div>
                <h2 style="margin: 0">gramm</h2>
            </div>
        </div>
        <div class="flexbox hor_spacing_item">
            <div class="medium_box" style="flex: 1">
                <h2 style="margin: 0">Zucker:</h2>
                <div style="font-size: 100px"><?= $zucker ?></div>
                <h2 style="margin: 0">gramm</h2>
            </div>
            <div class="medium_box" style="flex: 2">
                <h2 style="margin: 0">Um ihr Ziel zu erreichen müssen Sie am Tag</h2>
                <div style="font-size: 100px"><?= $kalorien ?></div>
                <h2 style="margin: 0">Kalorien zu sich nehmen</h2>
            </div>
            <form action="/kalorien_zaehler/index.php" method="POST" style="flex: 1">
                <input style="display: none" name="gesamt_kalorien" value="<?= $zielkalorien ?>" />
                <input style="display: none" name="gesamt_kohlenhydrate" value="<?= $kohlenhydrate ?>" />
                <input style="display: none" name="gesamt_fett" value="<?= $fett ?>" />
                <input style="display: none" name="gesamt_protein" value="<?= $protein ?>" />
                <input style="display: none" name="gesamt_zucker" value="<?= $zucker ?>" />
                <button class="medium_box color_inverse_on_hover" style="height: 100%; width: 100%" type="submit" name="werte_uebernehmen">
                    <h2 style="font-size: 50px; margin: 0">Werte<br>Speichern</h2>
                </button>
            </form>
        </div>
    <?php } else { ?>
        <h2>Fülle erst das <a class="small_box color_inverse_on_hover" href="/kalorien_rechner">Formular</a> aus!</h2>
    <?php } ?>
</main>
</body>
</html>