2018-07-14 18:23:41 +02:00
@ extends ( 'layout.default' )
@ section ( 'title' , $L ( 'Recipes' ))
@ section ( 'activeNav' , 'recipes' )
@ section ( 'viewJsName' , 'recipes' )
@ section ( 'content' )
< div class = " row " >
2018-10-06 11:43:46 +02:00
< div class = " col-xs-12 col-md-6 pb-3 " >
2018-07-14 18:23:41 +02:00
< h1 >
@ yield ( 'title' )
< a class = " btn btn-outline-dark " href = " { { $U ('/recipe/new') }} " >
< i class = " fas fa-plus " ></ i > {{ $L ( 'Add' ) }}
</ a >
</ h1 >
< label for = " search " > {{ $L ( 'Search' ) }} </ label > < i class = " fas fa-search " ></ i >
< input type = " text " class = " form-control " id = " search " >
2018-08-11 14:38:17 +02:00
< table id = " recipes-table " class = " table table-striped dt-responsive " >
2018-07-14 18:23:41 +02:00
< thead >
< tr >
< th > {{ $L ( 'Name' ) }} </ th >
2019-03-03 13:27:10 +01:00
< th class = " fit-content text-right " > {{ $L ( 'Servings' ) }} </ th >
2018-07-14 18:23:41 +02:00
< th > {{ $L ( 'Requirements fulfilled' ) }} </ th >
2018-11-24 19:59:24 +01:00
< th class = " d-none " > Hidden status for sorting of " Requirements fulfilled " column </ th >
2018-07-14 18:23:41 +02:00
</ tr >
</ thead >
2019-01-05 20:06:35 +01:00
< tbody class = " d-none " >
2018-07-14 18:23:41 +02:00
@ foreach ( $recipes as $recipe )
2018-07-15 09:56:10 +02:00
< tr data - recipe - id = " { { $recipe->id }} " >
2018-07-14 18:23:41 +02:00
< td >
{{ $recipe -> name }}
</ td >
2019-03-03 13:27:10 +01:00
< td class = " fit-content text-right " >
{{ $recipe -> desired_servings }}
</ td >
2018-07-14 18:23:41 +02:00
< td >
2018-07-15 09:56:10 +02:00
@ if ( FindObjectInArrayByPropertyValue ( $recipesSumFulfillment , 'recipe_id' , $recipe -> id ) -> need_fulfilled == 1 ) < i class = " fas fa-check text-success " ></ i >@ elseif ( FindObjectInArrayByPropertyValue ( $recipesSumFulfillment , 'recipe_id' , $recipe -> id ) -> need_fulfilled_with_shopping_list == 1 ) < i class = " fas fa-exclamation text-warning " ></ i >@ else < i class = " fas fa-times text-danger " ></ i >@ endif
< span class = " timeago-contextual " >@ if ( FindObjectInArrayByPropertyValue ( $recipesSumFulfillment , 'recipe_id' , $recipe -> id ) -> need_fulfilled == 1 ){{ $L ( 'Enough in stock' ) }} @ elseif ( FindObjectInArrayByPropertyValue ( $recipesSumFulfillment , 'recipe_id' , $recipe -> id ) -> need_fulfilled_with_shopping_list == 1 ){{ $L ( 'Not enough in stock, #1 ingredients missing but already on the shopping list' , FindObjectInArrayByPropertyValue ( $recipesSumFulfillment , 'recipe_id' , $recipe -> id ) -> missing_products_count ) }} @ else {{ $L ( 'Not enough in stock, #1 ingredients missing' , FindObjectInArrayByPropertyValue ( $recipesSumFulfillment , 'recipe_id' , $recipe -> id ) -> missing_products_count ) }} @ endif </ span >
2018-07-14 18:23:41 +02:00
</ td >
2018-11-24 19:59:24 +01:00
< td class = " d-none " >
2018-11-26 19:40:29 +01:00
{{ FindObjectInArrayByPropertyValue ( $recipesSumFulfillment , 'recipe_id' , $recipe -> id ) -> missing_products_count }}
2018-11-24 19:59:24 +01:00
</ td >
2018-07-14 18:23:41 +02:00
</ tr >
@ endforeach
</ tbody >
</ table >
</ div >
2018-07-15 09:56:10 +02:00
@ if ( $selectedRecipe !== null )
< div class = " col-xs-12 col-md-6 " >
< div id = " selectedRecipeCard " class = " card " >
< div class = " card-header " >
2018-08-11 11:48:25 +02:00
< i class = " fas fa-cocktail " ></ i > {{ $selectedRecipe -> name }} & nbsp ; & nbsp ;
2018-08-11 14:23:36 +02:00
< a id = " selectedRecipeConsumeButton " class = " btn btn-sm btn-outline-success py-0 " href = " # " data - toggle = " tooltip " title = " { { $L ('Consume all ingredients needed by this recipe') }} " data - recipe - id = " { { $selectedRecipe->id }} " data - recipe - name = " { { $selectedRecipe->name }} " >
2018-08-11 11:48:25 +02:00
< i class = " fas fa-utensils " ></ i >
</ a >
2018-08-11 14:23:36 +02:00
< a class = " btn btn-sm btn-outline-primary py-0 recipe-order-missing-button @if(FindObjectInArrayByPropertyValue( $recipesSumFulfillment , 'recipe_id', $selectedRecipe->id )->need_fulfilled_with_shopping_list == 1) { { disabled }}@endif " href = " # " data - toggle = " tooltip " title = " { { $L ('Put missing products on shopping list') }} " data - recipe - id = " { { $selectedRecipe->id }} " data - recipe - name = " { { $selectedRecipe->name }} " >
2018-08-11 11:48:25 +02:00
< i class = " fas fa-cart-plus " ></ i >
2018-08-11 14:38:17 +02:00
</ a >& nbsp ; & nbsp ;
< a id = " selectedRecipeEditButton " class = " btn btn-sm btn-outline-info py-0 " href = " { { $U ('/recipe/') }} { { $selectedRecipe->id }} " >
< i class = " fas fa-edit " ></ i >
</ a >
< a id = " selectedRecipeDeleteButton " class = " btn btn-sm btn-outline-danger py-0 " href = " # " data - recipe - id = " { { $selectedRecipe->id }} " data - recipe - name = " { { $selectedRecipe->name }} " >
< i class = " fas fa-trash " ></ i >
2018-08-11 11:48:25 +02:00
</ a >
2018-08-11 14:23:36 +02:00
< a id = " selectedRecipeToggleFullscreenButton " class = " btn btn-sm btn-outline-secondary py-0 float-right " href = " # " data - toggle = " tooltip " title = " { { $L ('Expand to fullscreen') }} " >
2018-07-15 09:56:10 +02:00
< i class = " fas fa-expand-arrows-alt " ></ i >
</ a >
</ div >
2018-10-25 20:36:29 +02:00
2019-03-03 13:27:10 +01:00
< div class = " card-body " >
@ include ( 'components.numberpicker' , array (
'id' => 'servings-scale' ,
'label' => 'Servings' ,
'min' => 1 ,
'value' => $selectedRecipe -> desired_servings ,
'invalidFeedback' => $L ( 'This cannot be lower than #1' , '1' ),
'additionalGroupCssClasses' => 'mb-0' ,
'additionalCssClasses' => 'col-2' ,
'additionalAttributes' => 'data-recipe-id="' . $selectedRecipe -> id . '"'
))
</ div >
2018-10-25 20:36:29 +02:00
<!-- Subrecipes first -->
@ foreach ( $selectedRecipeSubRecipes as $selectedRecipeSubRecipe )
< div class = " card-body " >
< h3 class = " mb-0 " > {{ $selectedRecipeSubRecipe -> name }} </ h3 >
</ div >
2019-01-26 20:06:01 +01:00
@ if ( ! empty ( $selectedRecipeSubRecipe -> picture_file_name ))
< p >< img src = " { { $U ('/api/files/recipepictures/' . base64_encode( $selectedRecipeSubRecipe->picture_file_name )) }} " class = " img-fluid " ></ p >
@ endif
2018-10-25 20:36:29 +02:00
@ php $selectedRecipeSubRecipePositionsFiltered = FindAllObjectsInArrayByPropertyValue ( $selectedRecipeSubRecipesPositions , 'recipe_id' , $selectedRecipeSubRecipe -> id ); @ endphp
@ if ( count ( $selectedRecipeSubRecipePositionsFiltered ) > 0 )
< div class = " card-body " >
< h5 class = " mb-0 " > {{ $L ( 'Ingredients' ) }} </ h5 >
</ div >
< ul class = " list-group list-group-flush " >
2018-10-27 10:37:31 +02:00
@ php $lastGroup = 'undefined' ; @ endphp
2018-10-25 20:36:29 +02:00
@ foreach ( $selectedRecipeSubRecipePositionsFiltered as $selectedRecipePosition )
2018-10-27 10:37:31 +02:00
@ if ( $lastGroup != $selectedRecipePosition -> ingredient_group )
< h5 class = " mb-2 mt-2 ml-4 " >< strong > {{ $selectedRecipePosition -> ingredient_group }} </ strong ></ h5 >
@ endif
2018-10-25 20:36:29 +02:00
< li class = " list-group-item " >
2018-11-02 19:53:01 +01:00
@ if ( $selectedRecipePosition -> amount == round ( $selectedRecipePosition -> amount )){{ round ( $selectedRecipePosition -> amount ) }} @ else {{ $selectedRecipePosition -> amount }} @ endif {{ Pluralize ( $selectedRecipePosition -> amount , FindObjectInArrayByPropertyValue ( $quantityunits , 'id' , $selectedRecipePosition -> qu_id ) -> name , FindObjectInArrayByPropertyValue ( $quantityunits , 'id' , $selectedRecipePosition -> qu_id ) -> name_plural ) }} {{ FindObjectInArrayByPropertyValue ( $products , 'id' , $selectedRecipePosition -> product_id ) -> name }}
< span class = " timeago-contextual " >@ if ( FindObjectInArrayByPropertyValue ( $recipesFulfillment , 'recipe_pos_id' , $selectedRecipePosition -> id ) -> need_fulfilled == 1 ) {{ $L ( 'Enough in stock' ) }} @ else {{ $L ( 'Not enough in stock, #1 missing, #2 already on shopping list' , FindObjectInArrayByPropertyValue ( $recipesFulfillment , 'recipe_pos_id' , round ( $selectedRecipePosition -> id ) -> missing_amount ), round ( FindObjectInArrayByPropertyValue ( $recipesFulfillment , 'recipe_pos_id' , $selectedRecipePosition -> id ) -> amount_on_shopping_list )) }} @ endif </ span >
2018-10-25 20:36:29 +02:00
@ if ( ! empty ( $selectedRecipePosition -> note ))
2018-10-27 10:39:52 +02:00
< div class = " text-muted " > { !! nl2br ( $selectedRecipePosition -> note ) !! } </ div >
2018-10-25 20:36:29 +02:00
@ endif
</ li >
2018-10-27 10:37:31 +02:00
@ php $lastGroup = $selectedRecipePosition -> ingredient_group ; @ endphp
2018-10-25 20:36:29 +02:00
@ endforeach
</ ul >
@ endif
@ if ( ! empty ( $selectedRecipeSubRecipe -> description ))
< div class = " card-body " >
< h5 > {{ $L ( 'Preparation' ) }} </ h5 >
{ !! $selectedRecipeSubRecipe -> description !! }
</ div >
@ endif
@ endforeach
<!-- Selected recipe -->
2019-01-26 20:06:01 +01:00
@ if ( ! empty ( $selectedRecipe -> picture_file_name ))
< p >< img src = " { { $U ('/api/files/recipepictures/' . base64_encode( $selectedRecipe->picture_file_name )) }} " class = " img-fluid " ></ p >
@ endif
2018-10-25 20:36:29 +02:00
@ if ( $selectedRecipePositions -> count () > 0 )
2018-07-15 09:56:10 +02:00
< div class = " card-body " >
< h5 class = " mb-0 " > {{ $L ( 'Ingredients' ) }} </ h5 >
</ div >
< ul class = " list-group list-group-flush " >
2018-10-25 22:45:44 +02:00
@ php $lastGroup = 'undefined' ; @ endphp
2018-07-15 09:56:10 +02:00
@ foreach ( $selectedRecipePositions as $selectedRecipePosition )
2018-10-25 22:45:44 +02:00
@ if ( $lastGroup != $selectedRecipePosition -> ingredient_group )
2018-10-27 10:37:31 +02:00
< h5 class = " mb-2 mt-2 ml-4 " >< strong > {{ $selectedRecipePosition -> ingredient_group }} </ strong ></ h5 >
2018-10-25 22:45:44 +02:00
@ endif
2018-07-15 09:56:10 +02:00
< li class = " list-group-item " >
2018-11-02 19:53:01 +01:00
@ if ( $selectedRecipePosition -> amount == round ( $selectedRecipePosition -> amount )){{ round ( $selectedRecipePosition -> amount ) }} @ else {{ $selectedRecipePosition -> amount }} @ endif {{ Pluralize ( $selectedRecipePosition -> amount , FindObjectInArrayByPropertyValue ( $quantityunits , 'id' , $selectedRecipePosition -> qu_id ) -> name , FindObjectInArrayByPropertyValue ( $quantityunits , 'id' , $selectedRecipePosition -> qu_id ) -> name_plural ) }} {{ FindObjectInArrayByPropertyValue ( $products , 'id' , $selectedRecipePosition -> product_id ) -> name }}
< span class = " timeago-contextual " >@ if ( FindObjectInArrayByPropertyValue ( $recipesFulfillment , 'recipe_pos_id' , $selectedRecipePosition -> id ) -> need_fulfilled == 1 ) {{ $L ( 'Enough in stock' ) }} @ else {{ $L ( 'Not enough in stock, #1 missing, #2 already on shopping list' , round ( FindObjectInArrayByPropertyValue ( $recipesFulfillment , 'recipe_pos_id' , $selectedRecipePosition -> id ) -> missing_amount ), round ( FindObjectInArrayByPropertyValue ( $recipesFulfillment , 'recipe_pos_id' , $selectedRecipePosition -> id ) -> amount_on_shopping_list )) }} @ endif </ span >
2018-07-15 13:33:59 +02:00
@ if ( ! empty ( $selectedRecipePosition -> note ))
2018-10-27 10:39:52 +02:00
< div class = " text-muted " > { !! nl2br ( $selectedRecipePosition -> note ) !! } </ div >
2018-07-15 13:33:59 +02:00
@ endif
2018-07-15 09:56:10 +02:00
</ li >
2018-10-25 22:45:44 +02:00
@ php $lastGroup = $selectedRecipePosition -> ingredient_group ; @ endphp
2018-07-15 09:56:10 +02:00
@ endforeach
</ ul >
2018-10-25 20:36:29 +02:00
@ endif
@ if ( ! empty ( $selectedRecipe -> description ))
2018-07-15 09:56:10 +02:00
< div class = " card-body " >
< h5 > {{ $L ( 'Preparation' ) }} </ h5 >
2018-10-03 16:41:21 +02:00
{ !! $selectedRecipe -> description !! }
2018-07-15 09:56:10 +02:00
</ div >
2018-10-25 20:36:29 +02:00
@ endif
2018-07-15 09:56:10 +02:00
</ div >
</ div >
@ endif
2018-07-14 18:23:41 +02:00
</ div >
2019-03-03 14:49:46 +01:00
< div id = " missing-recipe-pos-list " class = " list-group d-none mt-3 " >
@ foreach ( $recipesFulfillment as $recipePos )
2019-03-03 14:57:36 +01:00
@ if ( in_array ( $recipePos -> recipe_id , $includedRecipeIdsAbsolute ) && $recipePos -> missing_amount > 0 )
2019-03-03 14:49:46 +01:00
< a href = " # " class = " list-group-item list-group-item-action list-group-item-primary missing-recipe-pos-select-button " >
< div class = " form-check form-check-inline " >
< input class = " form-check-input missing-recipe-pos-product-checkbox " type = " checkbox " data - product - id = " { { $recipePos->product_id }} " checked >
</ div >
{{ FindObjectInArrayByPropertyValue ( $products , 'id' , $recipePos -> product_id ) -> name }}
</ a >
@ endif
@ endforeach
</ div >
2018-07-14 18:23:41 +02:00
@ stop