@extends('layouts.app-main')


@section('content')

   <style type="text/css">
       .form-control.has-error {
            border: 1px solid #ea8e49;
        }
   </style>
    <!-- row -->
    <div class="row">
        <div class="col-md-12">
            <div class="white-box p-0 min-height-500">
                <!-- .left-right-aside-column-->
                <div class="page-aside">
                    <!-- .left-aside-column-->
                    <div class="left-aside">
                        <div class="scrollable">
                            <ul class="list-style-none">

                                <?php /*
                                <li class="box-label">Choose <select onchange="if (this.value) window.location.href=this.value" >
                                                    <option value="">Pick one:</option>
                                                     @foreach($langs as $lang)
                                                        <option value="{{ url('/admin/trans/eloquent/0/'.$lang.'/'.$langsource.'/'.$show) }}" @if($language == $lang) selected @endif>{{ $lang }}</option>
                                                    @endforeach 
                                                </select>
                                </li>
                                */?>
                                <li class="divider"></li>
                                @foreach($files as $k => $fl)
                                <li <?php if($fl == $edit) echo 'class="font-bold"' ?>><a href="{{ url('/admin/trans/eloquent/'.$k.'/'.$language.'/'.$langsource.'/all') }}">{{ $fl }}</a></li>
                                @endforeach
                               

                            </ul>
                        </div>
                    </div>

                
                    @if($entries)

                        <div class="right-aside">
                        
                            <div class="scrollable">
                                <div class="table-responsive">
                                
                          
                                    <table class="table table-striped">
                                        <thead>
                                        <tr>
                                            <th>Name</th>
                                           
                                        </tr>
                                        </thead>
                                        <tbody>
        
                                            @foreach($entries as $entry)
                                                <tr>
                                                <td>
                                                    <a href="{{ url('/admin/trans/eloquent/'.$edit.'/'.$language.'/'.$langsource.'/detail/'.$entry->id) }} ">
                                                        {{ $entry->name ? $entry->name : $entry->title }}</a>
                                                </td>
                                                </tr>

                                            @endforeach
                                        </tbody>
                                    </table>

                                </div>
                            </div>
                        </div>

    

                    @endif

                    
                    @if($translations)

                        {!! Form::open([ 'url' => route('admin_trans_eloquent_update', [$file, $language, $langsource, $show, $id]), 'method' => 'post', 'class' => 'form-horizontal' ]) !!}

                        <!-- /.left-aside-column-->
                        <div class="right-aside">
                            
                       
                            <div class="clearfix"></div>
                            <div class="scrollable">

                            <div class="row">
                                <div class="col-xs-12">
                                    <button type="submit" class="btn btn-primary">
                                        Save
                                    </button>
                                </div>
                            </div>
                                  <div class="clearfix"><br></div>

                                <div class="table-responsive">
                                
                          
                                    <table class="table table-striped">
                                        <thead>
                                        <tr>
                                            <th width="50%">Source  
                                                <select onchange="if (this.value) window.location.href=this.value" >
                                                    <option value="">Pick one:</option>
                                                     @foreach($langs as $source)
                                                        <option value="{{ url('/admin/trans/eloquent/'.$file.'/'.$language.'/'.$source.'/'.$show.'/'.$id) }}" @if($source == $langsource) selected @endif>{{ $source }}</option>
                                                    @endforeach 
                                                </select>
                                            </th>
                                            <th width="50%">Translation 
                                                <select onchange="if (this.value) window.location.href=this.value" >
                                                    <option value="">Pick one:</option>
                                                     @foreach($langs as $lang)
                                                        @if($lang != "de")
                                                        <option value="{{ url('/admin/trans/eloquent/'.$file.'/'.$lang.'/'.$langsource.'/'.$show.'/'.$id) }}" @if($language == $lang) selected @endif>{{ $lang }}</option>
                                                        @endif
                                                    @endforeach 
                                                </select>

                                               <?php /* <select onchange="if (this.value) window.location.href=this.value" >
                                                        <option value="{{ url('/admin/trans/eloquent/'.$file.'/'.$language.'/'.$langsource.'/all/'.$id) }}" @if($show == 'all') selected @endif>ALL</option>
                                                        <option value="{{ url('/admin/trans/eloquent/'.$file.'/'.$language.'/'.$langsource.'/empty/'.$id) }}" @if($show == 'empty') selected @endif>EMPTY</option>
                                                </select>
                                                */
                                                ?>

                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @foreach($fields as $field)

                                        <?php $bool = false; ?>
                                        <tr <?php if($show == 'empty' && $bool) echo 'style="display:none"'; ?>>
                                                <td>{!! $translations->{$field} !!}</td>
                                                <td>
                                                     <?php
                                                         $old = $field;
                                                         $class = "";
                                                         if($field != 'name' && $field != 'title' && $field != 'direction')
                                                            $class = 'summernote';
                                                        ?>
                                                    {{ $old }}
                                                    <textarea name="trans_{{$field}}"
                                                      class="{{$class}} form-control @if(!$bool) has-error @endif"
                                                      rows="2">{{ old("{$old}", $translations->getTrans($field, $language)) }}</textarea>
                                                </td>
                                            </tr>
                                                                               
                                        @endforeach
                                        </tbody>
                                    </table>
                                            
                                </div>
                            </div>

                            
                            <div class="row">
                                <div class="col-xs-12">
                                    <button type="submit" class="btn btn-primary">
                                        Save
                                    </button>
                                </div>
                            </div>
                        </div>
                      {!! Form::close() !!}
                    @endif

                    <!-- .left-aside-column-->
                </div>
                <!-- /.left-right-aside-column-->
            </div>
        </div>
    </div>
    <!-- /.row -->

@endsection
