@extends('layouts.app')
@php
    $labelWidth = 5;
    $inputWidth = 7;
@endphp
@section('content')
    <div class="container">
        <div class="row">
            <div class="{{ $containerSize }}">
                @include('layouts.alerts')

                <div class="panel panel-default">
                    <div class="panel-heading"><strong>@lang($heading) {{ $singular }}</strong></div>
                    <div class="panel-body">
                        {!! Form::open(['route' => [$router . '.store', 'classId' => $classId ], 'files' => true, 'class' => 'form-horizontal', 'role' => 'form' ]) !!}
                        {!! \App\Http\ViewHelpers\HtmlAggregator::entityParametersToHtml($result, $labelWidth, $inputWidth) !!}
                        @if($location !== null)
                            <div class="form-group">
                                {!! Form::label('location', Lang::getFromJson('Location Name'), ['class' => "col-md-$labelWidth control-label"]) !!}
                                <div class="col-md-{{$inputWidth}}">
                                    {!! $location /* viewFeeder->autoComplete */ !!}
                                </div>
                            </div>
                        @endif
                        @if($manufacturer !== null)
                            <div class="form-group">
                                {!! Form::label('manufacturer', Lang::getFromJson('Manufacturer Name'), ['class' => "col-md-$labelWidth control-label"]) !!}
                                <div class="col-md-{{$inputWidth}}">
                                    {!! $manufacturer /* viewFeeder->autoComplete */ !!}
                                </div>
                            </div>
                        @endif
                        @if($supplier !== null)
                            <div class="form-group">
                                {!! Form::label('supplier', Lang::getFromJson('Supplier Name'), ['class' => "col-md-$labelWidth control-label"]) !!}
                                <div class="col-md-{{$inputWidth}}">
                                    {!! $supplier /* viewFeeder->autoComplete */ !!}
                                </div>
                            </div>
                        @endif
                        @if($result->type_id !== null)
                            <div class="form-group">
                                {!! Form::label('type_id', $result->type_name . ' Id', ['class' => "col-md-$labelWidth control-label"]) !!}
                                <div class="col-md-{{$inputWidth}}">
                                    {!! Form::number('type_id', Input::old('type_id'), [
                                        'class' => 'form-control',
                                        'autofocus',
                                        'min' => 1,
                                        'placeholder' => Lang::getFromJson('Insert valid Id of') . ' ' . $result->type_name
                                    ]) !!}
                                </div>
                            </div>
                        @endif
                        @if(count($result->parents) > 0)
                            <div class="form-group">
                                {!! Form::label('parent_entity_class_id', Lang::getFromJson('Entity'), ['class' => "col-md-$labelWidth control-label"]) !!}
                                <div class="col-md-{{$inputWidth}}">
                                    @if(count($result->parents) > 1)
                                        {!! Form::select('parent_entity_class_id', $result->parents, Input::old('parent_entity_class_id'), [
                                            'class' => 'form-control',
                                            'required' => $result->require_parent ? 'required' : null,
                                            'placeholder' => Lang::getFromJson('Entity')
                                        ]) !!}
                                    @else
                                        {!! Form::select('parent_entity_class_id', $result->parents, Input::old('parent_entity_class_id'), [
                                            'class' => 'form-control',
                                            'required' => $result->require_parent ? 'required' : null
                                        ]) !!}
                                    @endif
                                </div>
                            </div>
                            <div class="form-group">
                                {!! Form::label('parent_entity_id', Lang::getFromJson('Parent Entity Id'), ['class' => "col-md-$labelWidth control-label"]) !!}
                                <div class="col-md-{{$inputWidth}}">
                                    {!! Form::number('parent_entity_id', Input::old('parent_entity_id'), [
                                        'class' => 'form-control',
                                        'autofocus',
                                        'required' => $result->require_parent ? 'required' : null,
                                        'min' => 1,
                                        'placeholder' => Lang::getFromJson('Insert valid Entity parent Id')
                                    ]) !!}
                                </div>
                            </div>
                        @endif
                        <div class="col-md-12 text-center">
                            {!! Form::submit(Lang::getFromJson('do.Create'), ['class' => 'btn btn-primary']) !!}
                        </div>
                        {!! Form::close() !!}
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
