Import Export Grocery List

And misc improvements
This commit is contained in:
2026-03-30 21:05:12 -05:00
parent 5e0b096082
commit 9a78c4564e
9 changed files with 919 additions and 225 deletions
+1 -36
View File
@@ -251,42 +251,7 @@ function pushMealItemsToGrocery(array $meal, array $stores): int {
}
$mealId = (string) ($meal['id'] ?? '');
$mealTitle = (string) ($meal['title'] ?? '');
$defaultStore = groceryFirstStoreId($stores);
if ($defaultStore === '') {
return 0;
}
$added = 0;
foreach ($items as $row) {
if (!is_array($row)) {
continue;
}
$name = trim((string) ($row['name'] ?? ''));
if ($name === '') {
continue;
}
$sid = trim((string) ($row['storeId'] ?? ''));
if ($sid === '' || findStoreById($stores, $sid) === null) {
$sid = $defaultStore;
}
$res = groceryAppendShoppingLine(
$stores,
$sid,
$name,
trim((string) ($row['description'] ?? '')),
trim((string) ($row['size'] ?? '')),
trim((string) ($row['quantity'] ?? '1')) ?: '1',
trim((string) ($row['price'] ?? '')),
trim((string) ($row['image'] ?? '')),
'meal_plan',
0,
$mealId !== '' ? $mealId : null,
$mealTitle !== '' ? $mealTitle : null
);
if ($res['ok']) {
$added++;
}
}
return $added;
return groceryAppendMealItemRowsBatch($stores, $items, $mealId, $mealTitle);
}
function mealDayShortLabel(string $weekStart, int $offset): string {