summaryrefslogtreecommitdiff
path: root/includes/member/hierarchy.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/member/hierarchy.php')
-rw-r--r--includes/member/hierarchy.php207
1 files changed, 207 insertions, 0 deletions
diff --git a/includes/member/hierarchy.php b/includes/member/hierarchy.php
new file mode 100644
index 0000000..39045b3
--- /dev/null
+++ b/includes/member/hierarchy.php
@@ -0,0 +1,207 @@
+<?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.php';
+
+$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true);
+
+function timeAgo($time): string
+{
+ if (!is_numeric($time)) {
+ $time = strtotime($time);
+ }
+
+ $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"];
+ $lengths = array("60", "60", "24", "7", "4.35", "12", "100");
+
+ $now = time();
+
+ $difference = $now - $time;
+ if ($difference <= 10 && $difference >= 0) {
+ return $tense = "now";
+ } elseif ($difference > 0) {
+ $tense = "ago";
+ } else {
+ $tense = "later";
+ }
+
+ for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
+ $difference /= $lengths[$j];
+ }
+
+ $difference = round($difference);
+
+ $period = $periods[$j] . ($difference > 1 ? "s" : '');
+ return "{$difference} {$period} {$tense}";
+}
+
+$metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.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.php'; ?> \ No newline at end of file