@extends('webprofile.backend.layouts.master')

@section('title')
  {{ $title }}
@stop

@section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.layout')</li>
@stop

@section('content')
<div class="col-md-12">        
    <div class="panel panel-default">
        <div class="panel-body">
            <h3>Header</h3>
        </div>
    </div>
</div>
<div class="col-md-12">
    <div class="col-md-3">        
        <div class="panel panel-default">
            <div class="panel-body">
                <h3>Widget Left</h3>
                <div class="panel-body">
                    <a href="{!! url('webprofile/layouts/widget_left') !!}" class="btn btn-block btn-success"><i class="fa fa-edit"></i> @lang('label.create')</a>
                    @foreach ($layouts->where('name_design', 'widget_left')->sortBy('urutan') as $value)
                    <div class="panel panel-default">
                        <div class="panel-body">
                            {!! $value->title_design !!}    
                            <div class="pull-right">
                                <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                                <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                                {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                {{ csrf_field() }}
                                {{ Form::close() }}
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-6">        
        <div class="panel panel-default">
            <div class="panel-body">
                <h3>Content</h3>
            </div>
        </div>
    </div>
    <div class="col-md-3">        
        <div class="panel panel-default">
            <div class="panel-body">
                <h3>Widget Right</h3>
                <div class="panel-body">
                    <a href="{!! url('webprofile/layouts/widget_right') !!}" class="btn btn-block btn-success"><i class="fa fa-edit"></i> @lang('label.create')</a>
                    @foreach ($layouts->where('name_design', 'widget_right')->sortBy('urutan') as $value)
                    <div class="panel panel-default">
                        <div class="panel-body">
                            {!! $value->title_design !!}
                            <div class="pull-right">
                                <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                                <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                                {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                {{ csrf_field() }}
                                {{ Form::close() }}
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
</div>
<div class="col-md-12">
    <div class="panel panel-default">
        <div class="panel-body">
            <h3>Body <a href="{!! url('webprofile/layouts/body') !!}" class="btn btn-success"><i class="fa fa-edit"></i> @lang('label.create')</a></h3>
            <div class="col-md-12">
                @foreach ($layouts->where('name_design', 'body')->sortBy('urutan') as $value)
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div style="text-align: center;">{!! $value->title_design !!}</div>
                        <div style="text-align: center;">
                            <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                            <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                            {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                            {{ csrf_field() }}
                            {{ Form::close() }}
                        </div>
                        <hr>
                    </div>
                </div>
                @endforeach
            </div>
        </div>
    </div>
</div>
<div class="col-md-12">
    <div class="panel panel-default">
        <div class="panel-body">
            <h3>Quote <a href="{!! url('webprofile/layouts/quote') !!}" class="btn btn-success"><i class="fa fa-edit"></i> @lang('label.create')</a></h3>
            <div class="col-md-12">
                @foreach ($layouts->where('name_design', 'quote')->sortBy('urutan') as $value)
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div style="text-align: center;">{!! $value->value_design !!}</div>
                        <div style="text-align: center;">{!! $value->title_design !!}</div>
                        <div style="text-align: center;">
                            <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                            <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                            {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                            {{ csrf_field() }}
                            {{ Form::close() }}
                        </div>
                    </div>
                </div>
                @endforeach
            </div>
        </div>
    </div>
</div>
<div class="col-md-12">
    <div class="panel panel-default">
        <div class="panel-body">
            <h3>Footer</h3>
            <div class="col-md-3">
                <div class="panel panel-default">
                    <div class="panel-body">
                    <a href="{{ url('webprofile/layouts/footer_row_1') }}" class="btn btn-block btn-success"><i class="fa fa-edit"></i> Footer 1</a>
                    </div>

                    @foreach ($layouts->where('name_design', 'footer_row_1')->sortBy('urutan') as $value)
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div style="text-align: center;">{!! $value->title_design !!}</div>
                            <div style="text-align: center;">
                                <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                                <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                                {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                {{ csrf_field() }}
                                {{ Form::close() }}
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
            <div class="col-md-3">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <a href="{{ url('webprofile/layouts/footer_row_2') }}" class="btn btn-block btn-success"><i class="fa fa-edit"></i> Footer 2</a>
                    </div>

                    @foreach ($layouts->where('name_design', 'footer_row_2')->sortBy('urutan') as $value)
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div style="text-align: center;">{!! $value->title_design !!}</div>
                            <div style="text-align: center;">
                                <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                                <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                                {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                {{ csrf_field() }}
                                {{ Form::close() }}
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
            <div class="col-md-3">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <a href="{{ url('webprofile/layouts/footer_row_3') }}" class="btn btn-block btn-success"><i class="fa fa-edit"></i> Footer 3</a>
                    </div>

                    @foreach ($layouts->where('name_design', 'footer_row_3')->sortBy('urutan') as $value)
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div style="text-align: center;">{!! $value->title_design !!}</div>
                            <div style="text-align: center;">
                                <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                                <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                                {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                {{ csrf_field() }}
                                {{ Form::close() }}
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
            <div class="col-md-3">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <a href="{{ url('webprofile/layouts/footer_row_4') }}" class="btn btn-block btn-success"><i class="fa fa-edit"></i> Footer 4</a>
                    </div>

                    @foreach ($layouts->where('name_design', 'footer_row_4')->sortBy('urutan') as $value)
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div style="text-align: center;">{!! $value->title_design !!}</div>
                            <div style="text-align: center;">
                                <a href="{{ route('layouts.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a>

                                <button class="btn btn-danger btn-xs" id="btn_delete" data-file="{{$value->id}}"><i class="fa fa-trash-o"></i></button>
                                {{ Form::open(['url'=>route('layouts.destroy', ['data'=>Crypt::encrypt($value->id)]), 'method'=>'delete', 'id' => $value->id, 'style' => 'display: none;']) }}
                                {{ csrf_field() }}
                                {{ Form::close() }}
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('script')
<script src="{!!asset('backend/js/datatables.net/js/jquery.dataTables.min.js') !!}"></script>
<script>
  $('button#btn_delete').on('click', function(e){
    e.preventDefault();
    var data = $(this).attr('data-file');

    swal({
      title             : "Apakah Anda Yakin?",
      text              : "Anda akan menghapus widget ini!",
      type              : "warning",
      showCancelButton  : true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText : "Yes",
      cancelButtonText  : "No",
      closeOnConfirm    : false,
      closeOnCancel     : false
    },
    function(isConfirm){
      if(isConfirm){
        swal("Terhapus","Widget berhasil dihapus", "success");
        setTimeout(function() {
          $("#"+data).submit();
        }, 1000); // 1 second delay
      }
      else{
        swal("Dibatalkan","Widget batal dihapus", "error");
      }
    }
  );});
</script>
@stop
