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

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

{!! Form::open(['url' => action([\Modules\Manufacturing\Http\Controllers\RecipeController::class, '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) ? @format_quantity($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::select('production_cost_type',['fixed' => __('lang_v1.fixed'), 'percentage' => __('lang_v1.percentage'), 'per_unit' => __('manufacturing::lang.per_unit')], !empty($recipe->production_cost_type) ? $recipe->production_cost_type : 'fixed', ['class' => 'form-control', 'id' => 'production_cost_type']); !!}

{{__('manufacturing::lang.total_production_cost')}}: {{$total_production_cost}}

{!! Form::label('total', __('sale.total').':') !!}
@php $final_price = $ingredient_total; if(!empty($recipe->final_price)) { $final_price = $recipe->final_price; } @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