@extends('layouts.admin')

@php
    if($create){
        $title = __('adminforms.companies.title_insert');
        $formpar = array('route' => 'admin.company.store', 'autocomplete' => 'off');
    } else {
        $title = __('adminforms.companies.title_update');
        $formpar = array('route' => array('admin.company.update', $company->com_id), 'method' => 'PUT', 'autocomplete' => 'off');
    }

    $tr = [
       
        'com id'            => __('adminforms.companies.com_id'),
        'com name'          => __('adminforms.companies.com_name'),
        'com address'       => __('adminforms.companies.com_address'),
        'com zip'           => __('adminforms.companies.com_zip'),
        'com city'          => __('adminforms.companies.com_city'),
        'country id'        => __('adminforms.companies.country_id'),
        'country name'      => __('adminforms.companies.country_name'),
        'com phone'         => __('adminforms.companies.com_phone'),
        'com email'         => __('adminforms.companies.com_email'),
        'com bank account'  => __('adminforms.companies.com_bank_account'),
        'com reg number'    => __('adminforms.companies.com_reg_number'),
        'com vat number'    => __('adminforms.companies.com_vat_number'),
        'com disc'          => __('adminforms.companies.com_disc'),
        'com is vendor'     => __('adminforms.companies.com_is_vendor'),
    ];
@endphp

@section('title'){{$title}}@endsection
@section('header'){{$title}}@endsection
@section('header_desc') @endsection
@section('breadcumbs') @endsection

@section('content')
    <!-- Main content -->
    <section class="content">



        <div class="row">

            <div class="col-xs-12">
                @if (session('error'))
                    <div class="alert alert-danger alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <i class="icon fa fa-exclamation-triangle"></i> <strong>Info: </strong> &nbsp;  &nbsp;
                        {{ session('error') }}
                    </div>
                @endif
            </div>

            {!! Form::open($formpar) !!}

            <div class="col-xs-12">



                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-building"></i> {{__('adminforms.companies.general_block')}}</h3>
                    </div><!-- /. panel-heading -->

                    <div class="panel-body">
                        <div class="row">

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_name', ucfirst(__('adminforms.companies.com_name').':'))}}
                                {{Form::text('com_name', old('com_name', $company->com_name ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_name'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_address', ucfirst(__('adminforms.companies.com_address').':'))}}
                                {{Form::text('com_address', old('com_address', $company->com_address ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_address'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_zip', ucfirst(__('adminforms.companies.com_zip').':'))}}
                                {{Form::text('com_zip', old('com_zip', $company->com_zip ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_zip'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_city', ucfirst(__('adminforms.companies.com_city').':'))}}
                                {{Form::text('com_city', old('com_city', $company->com_city ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_city'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                @php $cgId = old('country_id', $company->country_id); @endphp
                                {{Form::label('country_id', ucfirst(__('adminforms.companies.country_id').':'))}}
                                {{Form::select('country_id', $countries, $cgId, ['placeholder' => __('adminforms.companies.select_country'), 'class' => 'form-control', 'id' => 'group-select'])}}
                                <small class="error">{{ strtr($errors->first('country_id'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_phone', ucfirst(__('adminforms.companies.com_phone').':'))}}
                                {{Form::text('com_phone', old('com_phone', $company->com_phone ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_phone'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_email', ucfirst(__('adminforms.companies.com_email').':'))}}
                                {{Form::text('com_email', old('com_email', $company->com_email ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_email'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_bank_account', ucfirst(__('adminforms.companies.com_bank_account').':'))}}
                                {{Form::text('com_bank_account', old('com_bank_account', $company->com_bank_account ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_bank_account'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_reg_number', ucfirst(__('adminforms.companies.com_reg_number').':'))}}
                                {{Form::text('com_reg_number', old('com_reg_number', $company->com_reg_number ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_reg_number'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_vat_number', ucfirst(__('adminforms.companies.com_vat_number').':'))}}
                                {{Form::text('com_vat_number', old('com_vat_number', $company->com_vat_number ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_vat_number'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('com_disc', ucfirst(__('adminforms.companies.com_disc').':'))}}
                                {{Form::text('com_disc', old('com_disc', $company->com_disc ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('com_disc'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-2 pbb">
                                {{Form::label('com_is_vendor', ucfirst(__('adminforms.companies.com_is_vendor').':'))}}<br>
                                @php
                                    $cv = old('com_is_vendor', $company->com_is_vendor);
                                    $actval = !is_null($cv) ? $cv : 0;
                                @endphp
                                <label class="radio-inline"><input type="radio" name="com_is_vendor" value="1" {{ $actval== 1 ? 'checked': ''}} > Da</label>
                                <label class="radio-inline"><input type="radio" name="com_is_vendor" value="0" {{ $actval== 0 ? 'checked': ''}} > Ne</label>
                                <small class="error">{{ strtr($errors->first('com_is_vendor'),$tr) }}</small>
                            </div>


                            

                        </div> <!-- /.row -->
                    </div> <!-- /.panel-body -->
                </div> <!-- /.panel panel-default-->

                <div class="row">
                    <div class="col-xs-12">
                        <hr>
                        @php $btntext = ($create) ? __('adminforms.companies.btn_insert') : __('adminforms.companies.btn_update')@endphp
                        {{Form::submit($btntext, ['class' => 'btn btn-success pull-right'])}}
                    </div>
                </div>

            </div> <!-- /.col -->



            {!! Form::close() !!}

        </div>
        <!-- /.row -->

    </section>
@endsection

@push('css')
@endpush


@push('scripts')
    <script src="{{asset('assets/js/equalpbb.js')}}"></script>
@endpush