summaryrefslogtreecommitdiff
path: root/index.php
blob: 117795617d791e5090f685ba2bcbd6fd5a0714b6 (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
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Qarz daftarcha</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="jumbotron text-center">
    <h1>Qarz daftarcha</h1>
</div>

<div class="container">
    <form action="" method="get">
        <div class="input-group mb-3">
            <input type="text" class="form-control" placeholder="Jahongir" id="ism" name="ism">
            <div class="input-group-append">
                <button class="btn btn-primary" type="submit">Kidirish</button>
            </div>
        </div>
    </form>

    <a href="add_user.php" class="btn btn-success mb-3">Qoshish</a>

    <p>Qarzdorlar:</p>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Ism</th>
                <th>Telefon nomer</th>
                <th>Vaqt</th>
                <th>Qarz</th>
                <th>Harakatlar</th>
            </tr>
        </thead>
        <tbody>
        <?php
        $ism = null;

        if (isset($_GET["ism"])) {
            $ism = "'" . $_GET["ism"] . "'";
        }

        include "get_users.php";

        if (isset($users)):
        for ($i = 0; $i < sizeof($users); $i++): ?> 
            <tr>
                <td><?= $users[$i]["ism"] ?></td>
                <td>+<?= $users[$i]["telefon_nomer"] ?></td>
                <td><?= $users[$i]["vaqt"] ?></td>
                <td><span class="badge badge-danger badge-pill"><?= $users[$i]["miqdor"] ?> so'm</span></td>
                <td><?php if ($users[$i]["miqdor"] == 0): ?><a href='delete_user.php?id=<?= $users[$i]["id"] ?>' class="btn btn-danger mr-1">Ochirish</a><?php endif; ?><a href='paid.php?id=<?= $users[$i]["id"] ?>' class="btn btn-success">Toladi</a></td>
            </tr>
        <?php
        endfor; 
        endif;
        ?>
        </tbody>
    </table>

    <p class="mt-5">Statistika</p>
    <ul class="list-group">
        <p>Jami: <?= $sum_duty ?> so'm</p>
        <p>Eng kam qarzdor:</p>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>Ism</th>
                    <th>Telefon nomer</th>
                    <th>Vaqt</th>
                    <th>Qarz</th>
                </tr>
            </thead>
            <tbody>
                <?php if (isset($min_user)): ?>
                <tr>
                    <td><?= $min_user["ism"]; ?></td>
                    <td>+<?= $min_user["telefon_nomer"]; ?></td>
                    <td><?= $min_user["vaqt"] ?></td>
                    <td><span class="badge badge-danger badge-pill"><?= $min_user["miqdor"]; ?> so'm</span></td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
        <p>Eng ko'p qarzdor:</p>

        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>Ism</th>
                    <th>Telefon nomer</th>
                    <th>Vaqt</th>
                    <th>Qarz</th>
                </tr>
            </thead>
            <tbody>
                <?php if (isset($max_user)): ?>
                <tr>
                    <td><?= $max_user["ism"]; ?></td>
                    <td>+<?= $max_user["telefon_nomer"]; ?></td>
                    <td><?= $max_user["vaqt"] ?></td>
                    <td><span class="badge badge-danger badge-pill"><?= $max_user["miqdor"]; ?> so'm</span></td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </ul>
</div>

</body>
</html>