summaryrefslogtreecommitdiff
path: root/includes/member/hierarchy.inc
blob: dfb42c9846953efa72a275a676459cef5200da6e (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php global $system;
global $systemCommonName;
global $systemID;
global $member;
global $memberData;
global $memberCommonName;
global $memberID;
$title = "Member hierarchy · " . $memberCommonName . " · " . $systemCommonName;
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';

$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true);

$metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true));

$allMembers = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true), $systemID);
$allMembers2 = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), $systemID === "gdapd" ? "ynmuc" : "gdapd");

$systemCommonData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/general.json"), true);

if ($travelling[$memberID]["travelling"]) {
    $allMembers = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), $systemID === "gdapd" ? "ynmuc" : "gdapd");
    $allMembers2 = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true), $systemID);

    $systemCommonData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "ynmuc" : "gdapd") . "/general.json"), true);

    $system = $systemID === "gdapd" ? "cloudburst" : "raindrops";
    $systemCommonName = $systemID === "gdapd" ? "Cloudburst System" : "Raindrops System";
}

?>

    <br>
    <div class="container">
        <h2><?= getMiniName($memberCommonName) ?>'s hierarchy</h2>
        <br>

        <?php

        $takingCare = [
            ...array_filter($allMembers, function ($i) use ($systemID, $memberData) {
            return in_array($systemID . "/" . $memberData["id"], $i["_metadata"]["caretakers"]) && $i["id"] !== $memberData["id"];
            }),
            ...array_filter($allMembers2, function ($i) use ($systemID, $memberData) {
                return in_array($systemID . "/" . $memberData["id"], $i["_metadata"]["caretakers"]) && $i["id"] !== $memberData["id"];
            })
        ];

        $protected = array_filter($allMembers, function ($i) use ($memberData) {
            return $i["_metadata"]["protector"] && $i["id"] !== $memberData["id"];
        });

        $caretakers = array_map(function ($i) {
            return getSystemMember(explode("/", $i)[0], explode("/", $i)[1]);
        }, $metadata["caretakers"]);

        ?>

        <p class="text-muted" style="text-align: center;"><b>Part of:</b></p>
        <div class="row">
            <div class="cell" style="width:20%;display:inline-block;margin-left:auto;margin-right:auto;">
                <a href="/<?= $system ?>" style="text-decoration:none !important;filter:none !important;">
                    <div class="hpd-item-card"
                         style="background-color:rgba(255, 255, 255, .1);border:1px solid #<?= $systemCommonData["color"] ?? "ffffff" ?>55;outline-color:#<?= $systemCommonData["color"] ?? "ffffff" ?>55;border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;">
                        <div>
                            <img alt=""
                                 src="/assets/uploads/<?= $system ?>.png"
                                 style="height:48px;display:block;margin-left:auto;margin-right:auto;">
                            <div style="text-decoration:none;color:white;margin-top:5px;"><?= $systemCommonName ?></div>
                        </div>
                    </div>
                </a>
            </div>
        </div>

        <hr>

        <?php if (count($protected) > 0): ?>
            <p class="text-muted" style="text-align: center;"><b>Protected by:</b></p>
            <div class="row">
                <?php foreach ($protected as $selectedMember): ?>
                    <div class="cell" style="width:20%;display:inline-block;margin-left:auto;margin-right:auto;">
                        <?php showMembersFromList([$selectedMember]) ?>
                    </div>
                <?php endforeach; ?>
            </div>

            <hr>
        <?php endif; ?>

        <?php if (count($caretakers) > 0): ?>
            <p class="text-muted" style="text-align: center;"><b>Taken care of by:</b></p>
            <div class="row">
                <?php foreach ($caretakers as $selectedMember): ?>
                    <div class="cell" style="width:20%;display:inline-block;margin-left:auto;margin-right:auto;">
                        <?php showMembersFromList([$selectedMember]) ?>
                    </div>
                <?php endforeach; ?>
            </div>

            <hr>
        <?php endif; ?>

        <p class="text-muted" style="text-align: center;"><b>Member:</b></p>
        <div class="row">
            <div class="cell" style="width:20%;display:inline-block;margin-left:auto;margin-right:auto;">
                <?php showMembersFromList([$memberData]) ?>
            </div>
        </div>

        <?php if (count($takingCare) > 0): ?>
            <hr>

            <p class="text-muted" style="text-align: center;"><b>Taking care of:</b></p>
            <div class="row">
                <?php foreach ($takingCare as $selectedMember): ?>
                    <div class="cell" style="width:20%;display:inline-block;margin-left:auto;margin-right:auto;">
                        <?php showMembersFromList([$selectedMember]) ?>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>

    <style>
        .row {
            margin-bottom: 20px;
        }

        @media (max-width: 750px) {
            #hpd-cloudburst > div, #hpd-raindrops > div {
                grid-template-columns: repeat(1, 1fr) !important;
            }

            .hpd-item-card img {
                display: inline-block !important;
                margin-right: 5px !important;
                height: 32px !important;
            }

            #hpd-cloudburst > div, #hpd-raindrops > div {
                grid-gap: 5px !important;
            }

            .hpd-item-card div {
                display: inline-block !important;
            }

            .hpd-item-card div:nth-child(3)::before {
                content: "(";
                padding-left: 5px;
                color: white !important;
            }

            .hpd-item-card div:nth-child(3)::after {
                content: ")";
                color: white !important;
            }

            div.cell {
                grid-row-gap: 5px !important;
                width: 100% !important;
                margin-bottom: 5px;
            }

            div.cell:nth-last-child(1) {
                margin-bottom: 0 !important;
            }
        }

        @media (max-width: 997px) {
            .cell {
                width: 30% !important;
            }
        }
    </style>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>