@extends('layouts.app') @section('title', __('manufacturing::lang.add_ingredients')) @section('content')

@lang('manufacturing::lang.add_ingredients')

{!! Form::open(['url' => action('\Modules\Manufacturing\Http\Controllers\RecipeController@store'), 'method' => 'post', 'id' => 'recipe_form' ]) !!}

@lang('sale.product'): {{$variation->product_name}} @if($variation->product_type == 'variable') - {{$variation->product_variation_name}} - {{$variation->name}} @endif

{!! Form::label('search_product', __('manufacturing::lang.select_ingredient').':') !!} {!! Form::text('search_product', null, ['class' => 'form-control', 'id' => 'search_product', 'placeholder' => __('manufacturing::lang.select_ingredient'), 'autofocus' => true ]); !!} {!! Form::hidden('variation_id', $variation->id); !!}
@php $row_index = 0; $ingredient_groups = []; $ingredient_total = 0; @endphp @if(!empty($ingredients)) @foreach($ingredients as $ingredient) @php $ingredient_obj = (object) $ingredient; $price = !empty($ingredient_obj->quantity) ? $ingredient_obj->quantity * $ingredient_obj->dpp_inc_tax : $ingredient_obj->dpp_inc_tax; $price = $price * $ingredient_obj->multiplier; $ingredient_total += $price; @endphp @if(empty($ingredient['mfg_ingredient_group_id'])) @php $row_index = $loop->index; @endphp @include('manufacturing::recipe.ingredient_row', ['ingredient' => (object) $ingredient, 'ig_index' => '']) @php $row_index++; @endphp @else @php $ingredient_groups[$ingredient['mfg_ingredient_group_id']][] = $ingredient; @endphp @endif @endforeach @endif
@lang('manufacturing::lang.ingredient') @lang('manufacturing::lang.waste_percent') @lang('manufacturing::lang.final_quantity') @lang('lang_v1.price')  
@php $ig_index = 0; @endphp @foreach($ingredient_groups as $ingredient_group) @php $ig_name = !empty($ingredient_group[0]['ingredient_group_name']) ? $ingredient_group[0]['ingredient_group_name'] : ''; $ig_description = !empty($ingredient_group[0]['ig_description']) ? $ingredient_group[0]['ig_description'] : ''; @endphp @include('manufacturing::recipe.ingredient_group', ['ingredients' => $ingredient_group, 'ig_index' => $ig_index, 'ig_name' => $ig_name, 'ig_description' => $ig_description]) @php $ig_index++; $row_index += count($ingredient_group); @endphp @endforeach
@lang('manufacturing::lang.ingredients_cost'): {{@num_format($ingredient_total)}}
{!! Form::label('waste_percent', __('manufacturing::lang.wastage').':') !!} @show_tooltip(__('manufacturing::lang.wastage_tooltip'))
{!! Form::text('waste_percent',!empty($recipe->waste_percent) ? @num_format($recipe->waste_percent) : 0, ['class' => 'form-control input_number', 'placeholder' => __('manufacturing::lang.wastage') ]); !!}
{!! Form::label('total_quantity', __('manufacturing::lang.total_output_quantity').':') !!}
{!! Form::text('total_quantity',!empty($recipe->total_quantity) ? @num_format($recipe->total_quantity) : 1, ['class' => 'form-control input_number', 'placeholder' => __('manufacturing::lang.total_output_quantity') ]); !!} @if(is_array($unit_html)) @else {{ $unit_html }} @endif
{!! Form::label('extra_cost', __('manufacturing::lang.production_cost').':') !!} @show_tooltip(__('manufacturing::lang.production_cost_tooltip'))
{!! Form::text('extra_cost',!empty($recipe->extra_cost) ? @num_format($recipe->extra_cost) : 0, ['class' => 'form-control input_number', 'placeholder' => __('manufacturing::lang.extra_cost') ]); !!}
{!! Form::label('total', __('sale.total').':') !!}
@php $final_price = $ingredient_total; if(!empty($recipe->extra_cost)) { $final_price = $final_price + ($final_price * $recipe->extra_cost / 100); } @endphp {!! Form::text('total', @num_format($final_price), ['id' => 'total', 'class' => "form-control", 'readonly']); !!} {{$currency_details->symbol}}
{!! Form::label('instructions', __('manufacturing::lang.recipe_instructions').':') !!} {!! Form::textarea('instructions',!empty($recipe) ? $recipe->instructions : null, ['class' => 'form-control', 'placeholder' => __('manufacturing::lang.recipe_instructions') ]); !!}

{!! Form::close() !!}
@stop @section('javascript') @include('manufacturing::layouts.partials.common_script') @endsection