97 lines
5.0 KiB
PHP
97 lines
5.0 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Family Hub</title>
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<link rel="stylesheet" href="assets/css/style.css">
|
|
</head>
|
|
<body class="family-hub-body" style="--person-accent: <?= htmlspecialchars($favoriteColor ?? '#4a90e2', ENT_QUOTES, 'UTF-8') ?>;">
|
|
<header class="app-header text-white p-3 mb-0">
|
|
<div class="container">
|
|
<div class="d-flex flex-column flex-md-row align-items-start align-items-md-center justify-content-between gap-3">
|
|
<h1 class="h3 mb-0">Family Hub</h1>
|
|
<div class="d-flex flex-column align-items-start align-items-md-end gap-2 ms-md-auto">
|
|
<?php
|
|
$hdrSym = trim((string) ($familySettings['currency_symbol'] ?? '★'));
|
|
$hdrName = trim((string) ($familySettings['currency_name'] ?? ''));
|
|
$hdrBal = 0.0;
|
|
if ($activePerson !== null) {
|
|
$hdrBal = is_numeric($activePerson['currency_balance'] ?? null)
|
|
? (float) $activePerson['currency_balance']
|
|
: 0.0;
|
|
}
|
|
?>
|
|
<?php if ($activePerson !== null && count($people) > 0): ?>
|
|
<div class="user-balance badge rounded-pill bg-light text-dark px-3 py-2 text-wrap text-start" title="Current balance for the selected profile">
|
|
<span class="text-muted small">Balance</span><br>
|
|
<strong class="fs-6"><?= htmlspecialchars(number_format($hdrBal, 2, '.', ''), ENT_QUOTES, 'UTF-8') ?></strong>
|
|
<span class="ms-1"><?= htmlspecialchars($hdrSym, ENT_QUOTES, 'UTF-8') ?><?php if ($hdrName !== ''): ?><span class="text-muted small"> <?= htmlspecialchars($hdrName, ENT_QUOTES, 'UTF-8') ?></span><?php endif; ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="persona-switcher d-flex flex-wrap gap-2 align-items-center" role="toolbar" aria-label="Who is using the hub">
|
|
<?php if (count($people) === 0): ?>
|
|
<span class="small opacity-75">Add people in Family settings.</span>
|
|
<?php else: ?>
|
|
<?php foreach ($people as $p): ?>
|
|
<?php
|
|
$pid = $p['id'] ?? '';
|
|
$pname = $p['name'] ?? 'Unknown';
|
|
$isActive = $activePerson && ($activePerson['id'] ?? '') === $pid;
|
|
$needsPin = personRequiresPinToActivate($p) ? '1' : '0';
|
|
$roleLabel = $p['role'] ?? '';
|
|
?>
|
|
<button
|
|
type="button"
|
|
class="btn btn-sm persona-chip <?= $isActive ? 'btn-light active' : 'btn-outline-light' ?>"
|
|
data-person-id="<?= htmlspecialchars($pid, ENT_QUOTES, 'UTF-8') ?>"
|
|
data-needs-pin="<?= $needsPin ?>"
|
|
data-person-name="<?= htmlspecialchars($pname, ENT_QUOTES, 'UTF-8') ?>"
|
|
>
|
|
<?= sanitizeInput($pname) ?>
|
|
<?php if ($roleLabel === ROLE_HEAD): ?>
|
|
<span class="visually-hidden">(Head of household)</span>
|
|
<i class="fa fa-house-chimney-user ms-1" aria-hidden="true"></i>
|
|
<?php elseif ($roleLabel === ROLE_ADULT): ?>
|
|
<i class="fa fa-person ms-1" aria-hidden="true"></i>
|
|
<?php elseif ($roleLabel === ROLE_CHILD): ?>
|
|
<i class="fa fa-child ms-1" aria-hidden="true"></i>
|
|
<?php endif; ?>
|
|
</button>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="modal fade" id="hohPinModal" tabindex="-1" aria-labelledby="hohPinModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h2 class="modal-title h5" id="hohPinModalLabel">Head of household PIN</h2>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p class="small text-muted mb-2" id="hohPinModalPrompt">Enter PIN to switch to this profile.</p>
|
|
<label for="hohPinInput" class="form-label">PIN</label>
|
|
<input type="password" class="form-control form-control-lg" id="hohPinInput" autocomplete="current-password" minlength="4">
|
|
<div class="invalid-feedback d-block d-none" id="hohPinError"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="button" class="btn btn-primary" id="hohPinSubmit">Continue</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
window.familyHubApiBase = <?= json_encode($familyHubApiBase, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP) ?>;
|
|
</script>
|
|
<main class="container py-4">
|