Limit mealplan products dropdown based on include_in_mealplan product variable

This commit is contained in:
Kurt Riddlesperger 2020-01-29 22:55:49 -06:00
parent 15b4f2ede3
commit 405c3efad1
3 changed files with 14 additions and 1 deletions

View File

@ -169,7 +169,7 @@ class RecipesController extends BaseController
'recipes' => $recipes,
'internalRecipes' => $this->Database->recipes()->whereNot('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll(),
'recipesResolved' => $this->RecipesService->GetRecipesResolved(),
'products' => $this->Database->products()->orderBy('name'),
'products' => $this->Database->products()->where('include_in_mealplan', '1')->orderBy('name'),
'quantityUnits' => $this->Database->quantity_units()->orderBy('name'),
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
]);

View File

@ -1,3 +1,6 @@
ALTER TABLE products
ADD include_in_mealplan TINYINT NOT NULL DEFAULT 0;
ALTER TABLE products
ADD default_best_before_days_after_freezing INTEGER NOT NULL DEFAULT 0;

View File

@ -252,6 +252,16 @@
<input type="hidden" name="default_best_before_days_after_thawing" value="0">
@endif
<div class="form-group">
<div class="form-check">
<input type="hidden" name="include_in_mealplan" value="0">
<input @if($mode == 'edit' && $product->include_in_mealplan == 1) checked @endif class="form-check-input" type="checkbox" id="include_in_mealplan" name="include_in_mealplan" value="1">
<label class="form-check-label" for="include_in_mealplan">{{ $__t('Include in Mealplan') }}
<span class="text-muted small">{{ $__t('When checked, this product is available to be added to a mealplan.') }}</span>
</label>
</div>
</div>
<div class="form-group">
<label for="product-picture">{{ $__t('Product picture') }}
<span class="text-muted small">{{ $__t('If you don\'t select a file, the current picture will not be altered') }}</span>