Calendar v2 - Combined Calendar Feature

This commit is contained in:
2026-03-30 16:12:05 -05:00
parent 6353f9c9b4
commit 7eb6160b5a
9 changed files with 672 additions and 34 deletions
+75 -7
View File
@@ -3,6 +3,13 @@ require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/utils.php';
require_once __DIR__ . '/../includes/persona.php';
require_once __DIR__ . '/../includes/grocery_helpers.php';
require_once __DIR__ . '/../includes/family_settings.php';
$usTimezones = familyHubUsTimezoneIdentifiers();
$billDays = $familySettings['calendar_bill_days'] ?? [];
if (!is_array($billDays) || $billDays === []) {
$billDays = [['dayOfMonth' => 1, 'title' => '']];
}
$canManage = count($people) === 0
|| (
@@ -54,6 +61,73 @@ $permanenceOptions = [
</div>
<?php endif; ?>
<div class="card mb-4">
<div class="card-header">Calendar and dates</div>
<div class="card-body">
<p class="text-muted small">Used for the <strong>Calendar</strong> tab agenda (today, due dates, and bill reminders). US timezones only.</p>
<?php if (!$canManage && count($people) > 0): ?>
<p class="text-muted">Switch to a verified Head of household to edit these settings.</p>
<?php endif; ?>
<form id="calendarSettingsForm" class="row g-3">
<div class="col-md-6">
<label class="form-label" for="family_timezone">Family timezone</label>
<select class="form-select" id="family_timezone" name="timezone" <?= !$canManage ? 'disabled' : '' ?>>
<?php
$curTz = (string) ($familySettings['timezone'] ?? 'America/New_York');
foreach ($usTimezones as $zid):
?>
<option value="<?= htmlspecialchars($zid, ENT_QUOTES, 'UTF-8') ?>" <?= $curTz === $zid ? 'selected' : '' ?>>
<?= htmlspecialchars(str_replace('_', ' ', $zid), ENT_QUOTES, 'UTF-8') ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6 d-flex align-items-end">
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="calendar_two_way_google" name="calendar_two_way_google" value="1"
<?= !empty($familySettings['calendar_two_way_google']) ? 'checked' : '' ?>
<?= !$canManage ? 'disabled' : '' ?>>
<label class="form-check-label" for="calendar_two_way_google">Enable two-way Google Calendar sync</label>
</div>
</div>
<div class="col-12">
<label class="form-label">Monthly bill reminders</label>
<p class="small text-muted mb-2">Shown on the family agenda on the same day each month (e.g. rent). Leave a row blank or clear the title to skip.</p>
<div id="billDaysRows" class="d-flex flex-column gap-2">
<?php foreach ($billDays as $i => $bd): ?>
<?php
$dom = (int) ($bd['dayOfMonth'] ?? 1);
$bt = (string) ($bd['title'] ?? '');
?>
<div class="bill-day-row row g-2 align-items-end">
<div class="col-4 col-md-3">
<label class="form-label small text-muted">Day of month</label>
<select class="form-select bill-day-dom" aria-label="Bill day of month">
<?php for ($d = 1; $d <= 31; $d++): ?>
<option value="<?= $d ?>" <?= $dom === $d ? 'selected' : '' ?>><?= $d ?></option>
<?php endfor; ?>
</select>
</div>
<div class="col">
<label class="form-label small text-muted">Reminder title</label>
<input type="text" class="form-control bill-day-title" maxlength="120" placeholder="e.g. Rent" value="<?= htmlspecialchars($bt, ENT_QUOTES, 'UTF-8') ?>">
</div>
</div>
<?php endforeach; ?>
</div>
<?php if ($canManage): ?>
<button type="button" class="btn btn-outline-secondary btn-sm mt-2" id="btnAddBillDayRow">Add reminder row</button>
<div class="col-12 mt-3">
<button type="submit" class="btn btn-primary">Save calendar settings</button>
</div>
<?php endif; ?>
<div class="col-12">
<div class="alert d-none" id="calendarSettingsFeedback" role="status"></div>
</div>
</form>
</div>
</div>
<div class="card mb-4">
<div class="card-header">Chore economy</div>
<div class="card-body">
@@ -83,12 +157,6 @@ $permanenceOptions = [
<?php endforeach; ?>
</select>
</div>
<div class="col-md-6">
<label class="form-label" for="timezone">Timezone</label>
<input class="form-control" id="timezone" name="timezone"
value="<?= sanitizeInput($familySettings['timezone'] ?? 'UTC') ?>"
<?= !$canManage ? 'disabled' : '' ?>>
</div>
<div class="col-md-6">
<label class="form-label" for="week_starts_on">Week starts on (0 = Sunday)</label>
<input type="number" class="form-control" id="week_starts_on" name="week_starts_on" min="0" max="6"
@@ -97,7 +165,7 @@ $permanenceOptions = [
</div>
<?php if ($canManage): ?>
<div class="col-12">
<button type="submit" class="btn btn-primary">Save settings</button>
<button type="submit" class="btn btn-primary">Save chore economy</button>
</div>
<?php endif; ?>
<div class="col-12">