2018-07-14 18:23:41 +02:00
@ extends ( 'layout.default' )
@ if ( $mode == 'edit' )
2020-08-31 20:32:50 +02:00
@ section ( 'title' , $__t ( 'Edit recipe' ))
2018-07-14 18:23:41 +02:00
@ else
2020-08-31 20:32:50 +02:00
@ section ( 'title' , $__t ( 'Create recipe' ))
2018-07-14 18:23:41 +02:00
@ endif
@ section ( 'viewJsName' , 'recipeform' )
@ section ( 'content' )
< div class = "row" >
< div class = "col" >
2020-04-19 08:51:02 -04:00
< h2 class = "title" >@ yield ( 'title' ) </ h2 >
2020-10-31 18:37:10 +01:00
2019-09-16 09:35:20 +02:00
< script >
Grocy . EditMode = '{{ $mode }}' ;
2019-09-21 13:08:42 +02:00
Grocy . QuantityUnits = { !! json_encode ( $quantityunits ) !! };
2019-09-16 09:35:20 +02:00
Grocy . QuantityUnitConversionsResolved = { !! json_encode ( $quantityUnitConversionsResolved ) !! };
</ script >
2018-07-14 18:23:41 +02:00
@ if ( $mode == 'edit' )
2020-08-31 20:32:50 +02:00
< script >
Grocy . EditObjectId = {{ $recipe -> id }};
</ script >
2019-01-26 20:06:01 +01:00
2020-08-31 20:32:50 +02:00
@ if ( ! empty ( $recipe -> picture_file_name ))
< script >
Grocy . RecipePictureFileName = '{{ $recipe->picture_file_name }}' ;
</ script >
@ endif
2018-07-14 18:23:41 +02:00
@ endif
</ div >
</ div >
2020-11-08 15:09:10 +01:00
< hr class = "my-2" >
2020-10-31 18:37:10 +01:00
2018-07-14 18:23:41 +02:00
< div class = "row" >
2018-07-15 09:56:10 +02:00
< div class = "col-xs-12 col-md-7 pb-3" >
2020-08-31 20:32:50 +02:00
< form id = "recipe-form"
novalidate >
2018-07-14 18:23:41 +02:00
< div class = "form-group" >
2019-05-01 20:19:18 +02:00
< label for = "name" > {{ $__t ( 'Name' ) }} </ label >
2020-08-31 20:32:50 +02:00
< input type = "text"
class = "form-control"
required
id = "name"
name = "name"
value = "@if( $mode == 'edit'){{ $recipe->name }}@endif" >
2019-05-01 20:19:18 +02:00
< div class = "invalid-feedback" > {{ $__t ( 'A name is required' ) }} </ div >
2018-07-14 18:23:41 +02:00
</ div >
2020-08-29 16:41:27 +02:00
2019-03-03 13:27:10 +01:00
@ php if ( $mode == 'edit' ) { $value = $recipe -> base_servings ; } else { $value = 1 ; } @ endphp
@ include ( 'components.numberpicker' , array (
2020-08-31 20:32:50 +02:00
'id' => 'base_servings' ,
'label' => 'Servings' ,
2020-12-23 19:56:37 +01:00
'min' => $DEFAULT_MIN_AMOUNT ,
2020-10-20 13:08:54 -05:00
'decimals' => $userSettings [ 'stock_decimal_places_amounts' ],
2020-08-31 20:32:50 +02:00
'value' => $value ,
2020-11-15 14:15:09 +01:00
'hint' => $__t ( 'The ingredients listed here result in this amount of servings' ),
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
2020-08-29 16:41:27 +02:00
))
2020-01-21 13:20:26 -06:00
2019-03-03 15:23:39 +01:00
< div class = "form-group" >
2020-04-21 02:18:09 -04:00
< div class = "custom-control custom-checkbox" >
2020-08-31 20:32:50 +02:00
< input @ if ( $mode == 'edit'
&&
$recipe -> not_check_shoppinglist == 1 ) checked @ endif class = "form-check-input custom-control-input" type = "checkbox" id = "not_check_shoppinglist" name = "not_check_shoppinglist" value = "1" >
< label class = "form-check-label custom-control-label"
for = "not_check_shoppinglist" >
2020-04-21 02:18:09 -04:00
{{ $__t ( 'Do not check against the shopping list when adding missing items to it' ) }} & nbsp ;
2020-11-15 15:23:47 +01:00
< i class = "fas fa-question-circle text-muted"
2020-08-29 16:41:27 +02:00
data - toggle = "tooltip"
2020-11-08 19:00:12 +01:00
title = "{{ $__t ('By default the amount to be added to the shopping list is " needed amount - stock amount - shopping list amount " - when this is enabled, it is only checked against the stock amount, not against what is already on the shopping list') }}" ></ i >
2019-03-03 15:23:39 +01:00
</ label >
</ div >
</ div >
2020-01-21 20:45:34 +01:00
@ include ( 'components.productpicker' , array (
2020-08-31 20:32:50 +02:00
'products' => $products ,
'isRequired' => false ,
'label' => 'Produces product' ,
'prefillById' => $mode == 'edit' ? $recipe -> product_id : '' ,
2020-11-13 15:46:44 +01:00
'hint' => $__t ( 'When a product is selected, one unit (per serving in stock quantity unit) will be added to stock on consuming this recipe' ),
'disallowAllProductWorkflows' => true ,
2020-01-21 20:45:34 +01:00
))
2019-04-23 09:06:18 +02:00
@ include ( 'components.userfieldsform' , array (
2020-08-31 20:32:50 +02:00
'userfields' => $userfields ,
'entity' => 'recipes'
2019-04-23 09:06:18 +02:00
))
2020-04-21 02:18:09 -04:00
< div class = "form-group" >
< label for = "description" > {{ $__t ( 'Preparation' ) }} </ label >
2020-08-31 20:32:50 +02:00
< textarea id = "description"
class = "form-control wysiwyg-editor"
name = "description" >@ if ( $mode == 'edit' ){{ $recipe -> description }} @ endif </ textarea >
2020-04-21 02:18:09 -04:00
</ div >
2020-04-24 18:06:57 +02:00
< small class = "my-2 form-text text-muted @if( $mode == 'edit') d-none @endif" > {{ $__t ( 'Save & continue to add ingredients and included recipes' ) }} </ small >
2020-04-24 11:41:57 -04:00
2020-08-31 20:32:50 +02:00
< button class = "save-recipe btn btn-success mb-2"
data - location = "continue" > {{ $__t ( 'Save & continue' ) }} </ button >
< button class = "save-recipe btn btn-info mb-2"
data - location = "return" > {{ $__t ( 'Save & return to recipes' ) }} </ button >
2018-07-14 18:23:41 +02:00
</ form >
</ div >
2020-04-24 11:41:57 -04:00
< div class = "col-xs-12 col-md-5 pb-3 @if( $mode == 'create') d-none @endif" >
2020-04-21 02:18:09 -04:00
< div class = "row" >
< div class = "col" >
< div class = "title-related-links" >
< h4 >
{{ $__t ( 'Ingredients list' ) }}
</ h4 >
2020-11-07 14:53:45 +01:00
< button class = "btn btn-outline-dark d-md-none mt-2 float-right order-1 order-md-3"
type = "button"
data - toggle = "collapse"
data - target = "#related-links" >
< i class = "fas fa-ellipsis-v" ></ i >
</ button >
< div class = "related-links collapse d-md-flex order-2 width-xs-sm-100"
id = "related-links" >
2020-08-31 20:32:50 +02:00
< a id = "recipe-pos-add-button"
2020-11-07 14:53:45 +01:00
class = "btn btn-outline-primary btn-sm recipe-pos-add-button m-1 mt-md-0 mb-md-0 float-right"
2020-08-31 20:32:50 +02:00
type = "button"
href = "#" >
2020-04-21 02:18:09 -04:00
{{ $__t ( 'Add' ) }}
</ a >
</ div >
</ div >
2020-08-29 16:41:27 +02:00
2020-08-31 20:32:50 +02:00
< table id = "recipes-pos-table"
2020-11-07 14:53:45 +01:00
class = "table table-sm table-striped nowrap w-100" >
2018-10-23 19:36:39 +02:00
< thead >
< tr >
2020-11-11 22:28:05 +01:00
< th class = "border-right" >< a class = "text-muted change-table-columns-visibility-button"
data - toggle = "tooltip"
2020-11-11 21:11:17 +01:00
data - toggle = "tooltip"
2020-12-16 18:18:03 +01:00
title = "{{ $__t ('Table options') }}"
2020-11-11 21:11:17 +01:00
data - table - selector = "#recipes-pos-table"
href = "#" >< i class = "fas fa-eye" ></ i ></ a >
</ th >
2019-05-01 20:19:18 +02:00
< th > {{ $__t ( 'Product' ) }} </ th >
< th > {{ $__t ( 'Amount' ) }} </ th >
< th class = "fit-content" > {{ $__t ( 'Note' ) }} </ th >
2020-12-16 18:18:03 +01:00
< th > {{ $__t ( 'Ingredient group' ) }} </ th >
2018-10-23 19:36:39 +02:00
</ tr >
</ thead >
2019-01-05 20:06:35 +01:00
< tbody class = "d-none" >
2018-10-23 19:36:39 +02:00
@ if ( $mode == "edit" )
@ foreach ( $recipePositions as $recipePosition )
2019-03-03 13:27:10 +01:00
< tr >
2019-03-09 10:49:26 +01:00
< td class = "fit-content border-right" >
2020-08-31 20:32:50 +02:00
< a class = "btn btn-sm btn-info recipe-pos-edit-button"
type = "button"
href = "#"
data - recipe - pos - id = "{{ $recipePosition->id }}"
data - product - id = "{{ $recipePosition->product_id }}" >
2018-10-23 19:36:39 +02:00
< i class = "fas fa-edit" ></ i >
</ a >
2020-08-31 20:32:50 +02:00
< a class = "btn btn-sm btn-danger recipe-pos-delete-button"
href = "#"
data - recipe - pos - id = "{{ $recipePosition->id }}"
data - recipe - pos - name = "{{ FindObjectInArrayByPropertyValue( $products , 'id', $recipePosition->product_id )->name }}" >
2018-10-23 19:36:39 +02:00
< i class = "fas fa-trash" ></ i >
</ a >
</ td >
< td >
{{ FindObjectInArrayByPropertyValue ( $products , 'id' , $recipePosition -> product_id ) -> name }}
</ td >
< td >
2019-09-16 09:35:20 +02:00
@ php
2020-08-31 20:32:50 +02:00
$product = FindObjectInArrayByPropertyValue ( $products , 'id' , $recipePosition -> product_id );
$productQuConversions = FindAllObjectsInArrayByPropertyValue ( $quantityUnitConversionsResolved , 'product_id' , $product -> id );
$productQuConversions = FindAllObjectsInArrayByPropertyValue ( $productQuConversions , 'from_qu_id' , $product -> qu_id_stock );
$productQuConversion = FindObjectInArrayByPropertyValue ( $productQuConversions , 'to_qu_id' , $recipePosition -> qu_id );
2020-11-17 19:11:02 +01:00
if ( $productQuConversion && $recipePosition -> only_check_single_unit_in_stock == 0 )
2020-08-31 20:32:50 +02:00
{
$recipePosition -> amount = $recipePosition -> amount * $productQuConversion -> factor ;
}
2019-09-16 09:35:20 +02:00
@ endphp
2019-05-04 14:50:15 +02:00
@ if ( ! empty ( $recipePosition -> variable_amount ))
2020-08-31 20:32:50 +02:00
{{ $recipePosition -> variable_amount }}
2019-05-04 14:50:15 +02:00
@ else
2020-08-31 20:32:50 +02:00
< span class = "locale-number locale-number-quantity-amount" >@ if ( $recipePosition -> amount == round ( $recipePosition -> amount )){{ round ( $recipePosition -> amount ) }} @ else {{ $recipePosition -> amount }} @ endif </ span >
2019-05-04 14:50:15 +02:00
@ endif
{{ $__n ( $recipePosition -> amount , FindObjectInArrayByPropertyValue ( $quantityunits , 'id' , $recipePosition -> qu_id ) -> name , FindObjectInArrayByPropertyValue ( $quantityunits , 'id' , $recipePosition -> qu_id ) -> name_plural ) }}
2020-02-02 17:26:32 +01:00
@ if ( ! empty ( $recipePosition -> variable_amount ))
2020-08-31 20:32:50 +02:00
< div class = "small text-muted font-italic" > {{ $__t ( 'Variable amount' ) }} </ div >
2020-02-02 17:26:32 +01:00
@ endif
2018-10-23 19:36:39 +02:00
</ td >
< td class = "fit-content" >
2020-08-31 20:32:50 +02:00
< a class = "btn btn-sm btn-info recipe-pos-show-note-button @if(empty( $recipePosition->note )) disabled @endif"
href = "#"
data - toggle = "tooltip"
data - placement = "top"
title = "{{ $__t ('Show notes') }}"
data - recipe - pos - note = "{{ $recipePosition->note }}" >
2018-10-23 19:36:39 +02:00
< i class = "fas fa-eye" ></ i >
</ a >
</ td >
2018-10-27 10:37:31 +02:00
< td >
{{ $recipePosition -> ingredient_group }}
</ td >
2018-10-23 19:36:39 +02:00
</ tr >
@ endforeach
@ endif
</ tbody >
</ table >
</ div >
</ div >
< div class = "row mt-5" >
< div class = "col" >
2020-04-21 02:18:09 -04:00
< div class = "title-related-links" >
< h4 >
{{ $__t ( 'Included recipes' ) }}
</ h4 >
2020-11-07 14:53:45 +01:00
< button class = "btn btn-outline-dark d-md-none mt-2 float-right order-1 order-md-3"
type = "button"
data - toggle = "collapse"
data - target = "#related-links" >
< i class = "fas fa-ellipsis-v" ></ i >
</ button >
< div class = "related-links collapse d-md-flex order-2 width-xs-sm-100"
id = "related-links" >
2020-08-31 20:32:50 +02:00
< a id = "recipe-include-add-button"
2020-11-07 14:53:45 +01:00
class = "btn btn-outline-primary btn-sm m-1 mt-md-0 mb-md-0 float-right"
2020-08-31 20:32:50 +02:00
href = "#" >
2020-04-21 02:18:09 -04:00
{{ $__t ( 'Add' ) }}
</ a >
</ div >
</ div >
2020-08-31 20:32:50 +02:00
< table id = "recipes-includes-table"
2020-11-07 14:53:45 +01:00
class = "table table-sm table-striped nowrap w-100" >
2018-10-23 19:36:39 +02:00
< thead >
< tr >
2020-11-11 22:28:05 +01:00
< th class = "border-right" >< a class = "text-muted change-table-columns-visibility-button"
data - toggle = "tooltip"
2020-11-11 21:11:17 +01:00
data - toggle = "tooltip"
2020-12-16 18:18:03 +01:00
title = "{{ $__t ('Table options') }}"
2020-11-11 21:11:17 +01:00
data - table - selector = "#recipes-includes-table"
href = "#" >< i class = "fas fa-eye" ></ i ></ a >
</ th >
2019-05-01 20:19:18 +02:00
< th > {{ $__t ( 'Recipe' ) }} </ th >
< th > {{ $__t ( 'Servings' ) }} </ th >
2018-10-23 19:36:39 +02:00
</ tr >
</ thead >
2019-01-05 20:06:35 +01:00
< tbody class = "d-none" >
2018-10-23 19:36:39 +02:00
@ if ( $mode == "edit" )
@ foreach ( $recipeNestings as $recipeNesting )
< tr >
2019-03-09 10:49:26 +01:00
< td class = "fit-content border-right" >
2020-08-31 20:32:50 +02:00
< a class = "btn btn-sm btn-info recipe-include-edit-button"
href = "#"
data - recipe - include - id = "{{ $recipeNesting->id }}"
data - recipe - included - recipe - id = "{{ $recipeNesting->includes_recipe_id }}"
data - recipe - included - recipe - servings = "{{ $recipeNesting->servings }}" >
2018-10-23 19:36:39 +02:00
< i class = "fas fa-edit" ></ i >
</ a >
2020-08-31 20:32:50 +02:00
< a class = "btn btn-sm btn-danger recipe-include-delete-button"
href = "#"
data - recipe - include - id = "{{ $recipeNesting->id }}"
data - recipe - include - name = "{{ FindObjectInArrayByPropertyValue( $recipes , 'id', $recipeNesting->includes_recipe_id )->name }}" >
2018-10-23 19:36:39 +02:00
< i class = "fas fa-trash" ></ i >
</ a >
</ td >
< td >
2018-10-25 20:36:29 +02:00
{{ FindObjectInArrayByPropertyValue ( $recipes , 'id' , $recipeNesting -> includes_recipe_id ) -> name }}
2018-10-23 19:36:39 +02:00
</ td >
2019-03-05 23:45:04 +01:00
< td >
{{ $recipeNesting -> servings }}
</ td >
2018-10-23 19:36:39 +02:00
</ tr >
@ endforeach
@ endif
</ tbody >
</ table >
</ div >
2020-01-21 13:20:26 -06:00
</ div >
2020-11-08 19:00:12 +01:00
< div class = "row mt-5" >
< div class = "col" >
< div class = "title-related-links" >
< h4 >
{{ $__t ( 'Picture' ) }}
</ h4 >
< div class = "form-group w-75 m-0" >
< div class = "input-group" >
< div class = "custom-file" >
< input type = "file"
class = "custom-file-input"
id = "recipe-picture"
accept = "image/*" >
< label id = "recipe-picture-label"
class = "custom-file-label @if(empty( $recipe->picture_file_name )) d-none @endif"
for = "recipe-picture" >
{{ $recipe -> picture_file_name }}
</ label >
< label id = "recipe-picture-label-none"
class = "custom-file-label @if(!empty( $recipe->picture_file_name )) d-none @endif"
for = "recipe-picture" >
{{ $__t ( 'No file selected' ) }}
</ label >
</ div >
< div class = "input-group-append" >
< span class = "input-group-text" >< i class = "fas fa-trash"
id = "delete-current-recipe-picture-button" ></ i ></ span >
</ div >
</ div >
</ div >
</ div >
@ if ( ! empty ( $recipe -> picture_file_name ))
< img id = "current-recipe-picture"
data - src = "{{ $U ('/api/files/recipepictures/' . base64_encode( $recipe->picture_file_name ) . '?force_serve_as=picture&best_fit_width=400') }}"
class = "img-fluid img-thumbnail mt-2 lazy mb-5" >
< p id = "delete-current-recipe-picture-on-save-hint"
2020-12-20 22:08:50 +01:00
class = "form-text text-muted font-italic d-none mb-5" > {{ $__t ( 'The current picture will be deleted on save' ) }} </ p >
2020-11-08 19:00:12 +01:00
@ else
< p id = "no-current-recipe-picture-hint"
class = "form-text text-muted font-italic mb-5" > {{ $__t ( 'No picture available' ) }} </ p >
@ endif
</ div >
</ div >
2018-07-14 18:23:41 +02:00
</ div >
2020-01-21 13:20:26 -06:00
2018-07-14 18:23:41 +02:00
</ div >
2018-10-25 20:36:29 +02:00
2020-08-31 20:32:50 +02:00
< div class = "modal fade"
id = "recipe-include-editform-modal"
tabindex = "-1" >
2018-10-25 20:36:29 +02:00
< div class = "modal-dialog" >
< div class = "modal-content text-center" >
< div class = "modal-header" >
2020-08-31 20:32:50 +02:00
< h4 id = "recipe-include-editform-title"
class = "modal-title w-100" ></ h4 >
2018-10-25 20:36:29 +02:00
</ div >
< div class = "modal-body" >
2020-08-31 20:32:50 +02:00
< form id = "recipe-include-form"
novalidate >
2019-03-05 23:45:04 +01:00
@ include ( 'components.recipepicker' , array (
2020-08-31 20:32:50 +02:00
'recipes' => $recipes ,
'isRequired' => true
2019-03-05 23:45:04 +01:00
))
@ include ( 'components.numberpicker' , array (
2020-08-31 20:32:50 +02:00
'id' => 'includes_servings' ,
'label' => 'Servings' ,
2020-12-23 19:56:37 +01:00
'min' => $DEFAULT_MIN_AMOUNT ,
2020-10-20 13:08:54 -05:00
'decimals' => $userSettings [ 'stock_decimal_places_amounts' ],
2020-08-31 20:32:50 +02:00
'value' => '1' ,
2020-11-15 14:15:09 +01:00
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
2019-03-05 23:45:04 +01:00
))
2018-10-25 20:36:29 +02:00
</ form >
</ div >
< div class = "modal-footer" >
2020-08-31 20:32:50 +02:00
< button type = "button"
class = "btn btn-secondary"
data - dismiss = "modal" > {{ $__t ( 'Cancel' ) }} </ button >
< button id = "save-recipe-include-button"
data - dismiss = "modal"
class = "btn btn-success" > {{ $__t ( 'Save' ) }} </ button >
2018-10-25 20:36:29 +02:00
</ div >
</ div >
</ div >
</ div >
2018-07-14 18:23:41 +02:00
@ stop