$sb; } return strcasecmp((string) ($a['name'] ?? ''), (string) ($b['name'] ?? '')); }); $lists = normalizeGroceryLists(readJsonFile('grocery_lists.json')); $catalog = normalizeCatalogList(readJsonFile('grocery_catalog.json')); $selectedStore = isset($_GET['store']) ? trim((string) $_GET['store']) : ''; if ($selectedStore === '' && count($stores) > 0) { $selectedStore = (string) ($stores[0]['id'] ?? ''); } $currentStore = findStoreById($stores, $selectedStore); $filter = isset($_GET['filter']) ? trim((string) $_GET['filter']) : 'active'; if (!in_array($filter, ['active', 'purchased', 'pending', 'all'], true)) { $filter = 'active'; } $allItems = $currentStore ? ($lists['byStore'][$selectedStore] ?? []) : []; $displayItems = []; foreach ($allItems as $it) { if (!is_array($it)) { continue; } $st = (string) ($it['status'] ?? 'active'); if ($filter === 'all') { $displayItems[] = $it; } elseif ($filter === 'pending' && $st === 'pending_review') { $displayItems[] = $it; } elseif ($filter === 'purchased' && $st === 'purchased') { $displayItems[] = $it; } elseif ($filter === 'active' && $st === 'active') { $displayItems[] = $it; } } $pickerOptions = $currentStore ? groceryCatalogPickerOptions($catalog, $selectedStore) : []; $canReviewGroceries = $activePerson !== null && ($activePerson['role'] ?? '') === ROLE_HEAD && isHohVerified(); ?>
No stores yet. Add one under Family settings.
Manage store names under Family settings.
Pick a store from the list.
No items in this view.