Import Export Grocery List
And misc improvements
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user