@extends('admin.index')
@section('content')

  <title>{{trans('admin.Reviews')}}</title>

    <main id="js-page-content" role="main" class="page-content">
                    <ol class="breadcrumb page-breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0);"> {{trans('admin.Resturant')}}</a></li>
                        <li class="breadcrumb-item active">{{trans('admin.Reviews')}}</li>
                        <li class="position-absolute pos-top pos-right d-none d-sm-block"><span
                                class="js-get-date"></span></li>
                    </ol>

                    <div class="row">
                        <div class="col-xl-12">
                            <div id="panel-1" class="panel">
                                <div class="panel-hdr">
                                    <h2>
                                         <span class="fw-300"><i>{{trans('admin.Reviews')}}</i></span>
                                    </h2>

                                    <div class="panel-toolbar">


                                        <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-lg">{{trans('admin.AddNew')}}</button>


                                        <button class="btn btn-primary btn-sm mx-3" data-toggle="dropdown">Table Style</button>

                                        @include('admin.layouts.toolbar')
                                    </div>

                                </div>
                                <div class="panel-container show">
                                   <span id="ex"> @include('admin.layouts.messages')</span>
                                    <div class="panel-content">
                                        <!-- datatable start -->
                                        <div id="mobile-overflow">
                                        <table id="dt-basic-example"
                                            class="table table-bordered table-hover table-striped w-100 mobile-width">
                                            <thead class="bg-highlight">
                                                <tr>
                                                    <th>{{trans('admin.Image')}}</th>
                                                    <th>{{trans('admin.Arabic_Name')}}</th>
                                                    <th>{{trans('admin.English_Name')}}</th>
                                                    <th>{{trans('admin.Arabic_Desc')}}</th>
                                                    <th>{{trans('admin.English_Desc')}}</th>
                                                    <th>{{trans('admin.Actions')}}</th>

                                                </tr>
                                            </thead>
                                            <tbody>

                                            @foreach($items as $item)
                                                <tr>
                                                    <td>
                                        <img src="{{URL::to($item->Image)}}" class="img-fluid">
                                                    </td>

                                                    <td>{{$item->Arabic_Name}}</td>
                                                    <td>{{$item->English_Name}}</td>


                                            <td>

           <button type="button" class="btn btn-default" data-toggle="modal" data-target="#ArDec{{$item->id}}">
                                    {{trans('admin.Arabic_Desc')}}
                                                </button>
                                           </td>


                                                           <td>

           <button type="button" class="btn btn-default" data-toggle="modal" data-target="#EnDec{{$item->id}}">
                                    {{trans('admin.English_Desc')}}
                                                </button>
                                           </td>


                                                    <td class="text-center">

                                                        <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-center{{$item->id}}"><i class="fal fa-trash"></i></button>


                                                        <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-lg-edit{{$item->id}}"><i class="fal fa-edit"></i></button>

                                                    </td>
                                                </tr>
                                             @endforeach


                                            </tbody>
                                            <tfoot>
                                                <tr>
                                                     <th>{{trans('admin.Image')}}</th>
                                                    <th>{{trans('admin.Arabic_Name')}}</th>
                                                    <th>{{trans('admin.English_Name')}}</th>
                                                    <th>{{trans('admin.Arabic_Desc')}}</th>
                                                    <th>{{trans('admin.English_Desc')}}</th>
                                                    <th>{{trans('admin.Actions')}}</th>
                                                </tr>
                                            </tfoot>
                                        </table>
                                        </div>
                                        <!-- datatable end -->

                                              {{$items->Links()}}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Modal Add-->
         <div class="modal fade" id="default-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-lg" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title">{{trans('admin.AddNew')}}  </h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    <form action="{{url('AddRReviews')}}" method="post" enctype="multipart/form-data">
                                        {!! csrf_field() !!}
                                              @honeypot
                                        <div class="form-row">

                                        <div class="form-group col-lg-12">
                                            <label class="form-label" for="simpleinput">{{trans('admin.Image')}}</label>
                                            <input type="file" name="Image" accept="image/*" required>
                                        </div>

                                        <div class="form-group col-lg-12">
                        <label class="form-label" for="simpleinput">{{trans('admin.Arabic_Name')}}</label>
                    <input type="text" name="Arabic_Name" value="{{old('Arabic_Name')}}"  class="form-control" required>
                                        </div>
                                        <div class="form-group col-lg-12">
                                     <label class="form-label" for="simpleinput"> {{trans('admin.English_Name')}}</label>
                         <input type="text" name="English_Name"  value="{{old('English_Name')}}" class="form-control" >
                                        </div>


                                    <div class="form-group col-md-6" style="display: none">
                                       <label class="form-label" for=""> {{trans('admin.Arabic_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="">

                                       </textarea>
                                    </div>

                                                 <div class="form-group col-md-6">
                                       <label class="form-label" for=""> {{trans('admin.Arabic_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="Arabic_Desc">

                                       </textarea>
                                    </div>




                                                    <div class="form-group col-md-6" style="display: none">
                                       <label class="form-label" for=""> {{trans('admin.English_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="">

                                       </textarea>
                                    </div>

                                                 <div class="form-group col-md-6">
                                       <label class="form-label" for=""> {{trans('admin.English_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="English_Desc">

                                       </textarea>
                                    </div>


                                        </div>
                                    <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">{{trans('admin.Close')}}</button>
                                    <button type="submit" class="btn btn-primary"> {{trans('admin.Save')}}</button>
                                </div>
                                    </form>
                                </div>

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

         @foreach($items as $item)
        <!-- Modal Edit-->
                    <div class="modal fade" id="default-example-modal-lg-edit{{$item->id}}" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-lg" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title">{{trans('admin.Edit')}}  </h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    <form action="{{url('EditRReviews/'.$item->id)}}" method="post" enctype="multipart/form-data">
                                        {!! csrf_field() !!}
                                              @honeypot
                                        <div class="form-row">
                                             <div class="form-group col-lg-12">
                                            <label class="form-label" for="simpleinput">{{trans('admin.Image')}}</label>
                                            <input type="file" name="Image" accept="image/*">
                                            <input type="hidden" name="Images" value="{{$item->Image}}">
                                        </div>


                                        <div class="form-group col-lg-12">
                        <label class="form-label" for="simpleinput">{{trans('admin.Arabic_Name')}}</label>
                    <input type="text" name="Arabic_Name" value="{{$item->Arabic_Name}}"  class="form-control" required>
                                        </div>
                                        <div class="form-group col-lg-12">
                                     <label class="form-label" for="simpleinput"> {{trans('admin.English_Name')}}</label>
                         <input type="text" name="English_Name"  value="{{$item->English_Name}}" class="form-control" >
                                        </div>

                                                 <div class="form-group col-md-6" style="display: none">
                                       <label class="form-label" for=""> {{trans('admin.Arabic_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="">
                                       {{$item->Arabic_Desc}}
                                       </textarea>
                                    </div>

                                                 <div class="form-group col-md-6">
                                       <label class="form-label" for=""> {{trans('admin.Arabic_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="Arabic_Desc">
                                       {{$item->Arabic_Desc}}
                                       </textarea>
                                    </div>




                                                    <div class="form-group col-md-6" style="display: none">
                                       <label class="form-label" for=""> {{trans('admin.English_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="">
                                       {{$item->English_Desc}}
                                       </textarea>
                                    </div>

                                                 <div class="form-group col-md-6">
                                       <label class="form-label" for=""> {{trans('admin.English_Desc')}}   </label>
                                       <textarea class="js-summernote" id="saveToLocal" name="English_Desc">
                                       {{$item->English_Desc}}
                                       </textarea>
                                    </div>



                                        </div>
                                    <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">{{trans('admin.Close')}}</button>
                                    <button type="submit" class="btn btn-primary"> {{trans('admin.Save')}}</button>
                                </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>

                      <!-- Modal Delete -->
<div class="modal fade" id="default-example-modal-center{{$item->id}}" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-centered" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 class="modal-title">
                                          {{trans('admin.RUSWDT')}} <strong>{{$item->Arabic_Title}}</strong>
                                    </h4>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                    </button>
                                </div>

                                <div class="modal-footer">
                  <button type="button" class="btn btn-secondary" data-dismiss="modal"> {{trans('admin.No')}}</button>
                   <a href="{{url('DeleteRReviews/'.$item->id)}}"  class="btn btn-primary"> {{trans('admin.Yes')}}</a>
                                </div>
                            </div>
                        </div>
                    </div>

                              <!-- Modal Arabic Dec -->
<div class="modal fade" id="ArDec{{$item->id}}" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-centered" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 class="modal-title">
                              <strong>
                                    @php
  echo html_entity_decode($item->Arabic_Desc);

                    @endphp
                                        </strong>
                                    </h4>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                    </button>
                                </div>

                                <div class="modal-footer">
                  <button type="button" class="btn btn-secondary" data-dismiss="modal"> {{trans('admin.Close')}}</button>
                                </div>
                            </div>
                        </div>
                    </div>


                                      <!-- Modal English Dec -->
<div class="modal fade" id="EnDec{{$item->id}}" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-centered" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 class="modal-title">
                              <strong>
                                                           @php
  echo html_entity_decode($item->English_Desc);

                    @endphp
                                        </strong>
                                    </h4>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                    </button>
                                </div>

                                <div class="modal-footer">
                  <button type="button" class="btn btn-secondary" data-dismiss="modal"> {{trans('admin.Close')}}</button>
                                </div>
                            </div>
                        </div>
                    </div>

        @endforeach
                </main>

@endsection

@push('js')
    <link rel="stylesheet" media="screen, print" href="{{asset('Admin/css/datagrid/datatables/datatables.bundle.css')}}">
    <link rel="stylesheet" media="screen, print" href="{{asset('Admin/css/formplugins/summernote/summernote.css')}}">
    <link rel="stylesheet" media="screen, print" href="{{asset('Admin/css/formplugins/select2/select2.bundle.css')}}">

 <script src="{{asset('Admin/js/datagrid/datatables/datatables.bundle.js')}}"></script>
    <script src="{{asset('Admin/js/datagrid/datatables/datatables.export.js')}}"></script>
    <script src="{{asset('Admin/js/formplugins/summernote/summernote.js')}}"></script>
    <script src="{{asset('Admin/js/formplugins/select2/select2.bundle.js')}}"></script>
    <script>
        //_fnFeatureHtmlLength();
        $(document).ready(function () {
            // Setup - add a text input to each footer cell
            $('#dt-basic-example thead tr').clone(true).appendTo('#dt-basic-example thead');
            $('#dt-basic-example thead tr:eq(1) th').each(function (i) {
                var title = $(this).text();
                $(this).html('<input type="text" class="form-control form-control-sm" placeholder="Search ' + title + '" />');

                $('input', this).on('keyup change', function () {
                    if (table.column(i).search() !== this.value) {
                        table
                            .column(i)
                            .search(this.value)
                            .draw();
                    }
                });
            });
            var table = $('#dt-basic-example').DataTable(
                {
                    responsive: true,
                    orderCellsTop: true,
                    fixedHeader: true,
                    lengthChange: true,

                    dom: "<'row mb-3'<'col-sm-12 col-md-3 d-flex align-items-center justify-content-start'f><'col-sm-12 col-md-9 d-flex align-items-center justify-content-end'B>>" +
                        "<'row'<'col-sm-12'tr>>" +
                        "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",

                    buttons: [
                        {
                            extend: 'pageLength',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'colvis',
                            text: 'Column Visibility',
                            titleAttr: 'Col visibility',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'pdfHtml5',
                            text: 'PDF',
                            titleAttr: 'Generate PDF',
                            className: 'btn-outline-danger btn-sm mr-1'
                        },
                        {
                            extend: 'excelHtml5',
                            text: 'Excel',
                            titleAttr: 'Generate Excel',
                            className: 'btn-outline-success btn-sm mr-1'
                        },
                        {
                            extend: 'csvHtml5',
                            text: 'CSV',
                            titleAttr: 'Generate CSV',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'copyHtml5',
                            text: 'Copy',
                            titleAttr: 'Copy to clipboard',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'print',
                            text: 'Print',
                            titleAttr: 'Print Table',
                            className: 'btn-outline-primary btn-sm'
                        }
                    ],
                });
            $('.js-thead-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example thead').removeClassPrefix('bg-').addClass(theadColor);
            });

            $('.js-tbody-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example').removeClassPrefix('bg-').addClass(theadColor);
            });

        });

    </script>
<script src="js/formplugins/summernote/summernote.js"></script>
<script>
   var autoSave = $('#autoSave');
   var interval;
   var timer = function()
   {
       interval = setInterval(function()
       {
           //start slide...
           if (autoSave.prop('checked'))
               saveToLocal();

           clearInterval(interval);
       }, 3000);
   };

   //save
   var saveToLocal = function()
   {
       localStorage.setItem('summernoteData', $('#saveToLocal').summernote("code"));
       console.log("saved");
   }

   //delete
   var removeFromLocal = function()
   {
       localStorage.removeItem("summernoteData");
       $('#saveToLocal').summernote('reset');
   }

   $(document).ready(function()
   {
       //init default
       $('.js-summernote').summernote(
       {
           height: 200,
           tabsize: 2,
           placeholder: "Type here...",
           dialogsFade: true,
           toolbar: [
               ['style', ['style']],
               ['font', ['strikethrough', 'superscript', 'subscript']],
               ['font', ['bold', 'italic', 'underline', 'clear']],
               ['fontsize', ['fontsize']],
               ['fontname', ['fontname']],
               ['color', ['color']],
               ['para', ['ul', 'ol', 'paragraph']],
               ['height', ['height']]
               ['table', ['table']],
               ['insert', ['link', 'picture', 'video']],
               ['view', ['fullscreen', 'codeview', 'help']]
           ],
           callbacks:
           {
               //restore from localStorage
               onInit: function(e)
               {
                   $('.js-summernote').summernote("code", localStorage.getItem("summernoteData"));
               },
               onChange: function(contents, $editable)
               {
                   clearInterval(interval);
                   timer();
               }
           }
       });

       //load emojis
       $.ajax(
       {
           url: 'https://api.github.com/emojis',
           async: false
       }).then(function(data)
       {
           window.emojis = Object.keys(data);
           window.emojiUrls = data;
       });

       //init emoji example
       $(".js-hint2emoji").summernote(
       {
           height: 100,
           toolbar: false,
           placeholder: 'type starting with : and any alphabet',
           hint:
           {
               match: /:([\-+\w]+)$/,
               search: function(keyword, callback)
               {
                   callback($.grep(emojis, function(item)
                   {
                       return item.indexOf(keyword) === 0;
                   }));
               },
               template: function(item)
               {
                   var content = emojiUrls[item];
                   return '<img src="' + content + '" width="20" /> :' + item + ':';
               },
               content: function(item)
               {
                   var url = emojiUrls[item];
                   if (url)
                   {
                       return $('<img />').attr('src', url).css('width', 20)[0];
                   }
                   return '';
               }
           }
       });

       //init mentions example
       $(".js-hint2mention").summernote(
       {
           height: 100,
           toolbar: false,
           placeholder: "type starting with @",
           hint:
           {
               mentions: ['jayden', 'sam', 'alvin', 'david'],
               match: /\B@(\w*)$/,
               search: function(keyword, callback)
               {
                   callback($.grep(this.mentions, function(item)
                   {
                       return item.indexOf(keyword) == 0;
                   }));
               },
               content: function(item)
               {
                   return '@' + item;
               }
           }
       });

   });

</script>

@endpush

