@extends('Admin.master_page')
@section('small_title')
Sub Menu
@endsection

@section('content')



                <div class="page-content">
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                    <h4 class="mb-sm-0 font-size-18">   Edit </h4>

                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="{{route('dashboard.index')}}"> {{__("dashboard.submenu.dashboard")}} </a></li>
                                            <li class="breadcrumb-item active">  Sub Menu
                                            </li>
                                        </ol>
                                    </div>

                                </div>
                            </div>
                            @if(Session::has('message'))
                      <div class="alert alert-info">{{ Session::get('message') }}</div>

@endif

                        </div>
                        <!-- end page title -->
                        <div>



                            @if ($submenu->sub_resource_type==='page')
                            {{-- New Page --}}
                            <div>
                                <hr>

                                <form method="post" action="{{ route('submenus.update',['submenu'=>$submenu->id]) }}" enctype="multipart/form-data">
                                    @method('put')
                                    @csrf
                                    <input type="hidden" value="{{$submenu->sub_resource_id}}" name="sub_resource_id">
                                    <input type="hidden" value="{{$submenu->sub_resource_type}}" name="sub_resource_type">
                                    <input type="hidden" value="{{$submenu->sub_route_name}}" name="sub_route_name">
                                    <input type="hidden" value="{{$submenu->menu_id}}" name="menu_id">
                                    <div class="col-lg-12">
                                        <input type="text" required value="{{$submenu->sub_menu_name}}" name="sub_menu_name" class="form-control" >

                                    <div class="row">

                                            <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (English) </h6>
		<hr>

		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->sub_menu_name}}" name="sub_menu_name" class="form-control" placeholder="">
			@error('sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>

        <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (Dari) </h6>
		<hr>

		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->da_sub_menu_name}}"  name="da_sub_menu_name" class="form-control" placeholder="">
			@error('da_sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>

        <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (Pashto) </h6>
		<hr>
		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->pa_sub_menu_name}}" name="pa_sub_menu_name" class="form-control" placeholder="">
			@error('pa_sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>




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


                                <div class="input-group" style="margin-top: 15px;">
                                    <input type="text" required value="{{$post->title}}" name="title" class="form-control" placeholder="">
                                    @error('title')
                                    <span class="alert-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                                <br>

                                 <h6 class="m-0 font-weight-bold text-primary pull-left" >Title (Dari)</h6>
                                <hr>
                                <div class="input-group" style="margin-top: 15px;">
                                    <input type="text" style="direction: rtl"  value="{{$post->da_title}}" name="da_title" class="form-control" placeholder="">
                                    @error('da_title')
                                    <span class="alert-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                                <br>

                                  <h6 class="m-0 font-weight-bold text-primary pull-left" >Title (Pashto)</h6>
                                <hr>
                                <div class="input-group" style="margin-top: 15px;">
                                    <input type="text" style="direction: rtl"  value="{{$post->pa_title}}" name="pa_title" class="form-control" placeholder="">
                                    @error('pa_title')
                                    <span class="alert-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                                <br>



                                <h6 class="m-0 font-weight-bold text-primary pull-left" >Description (English)</h6>
                                <hr>

                                <div class="input-group" style="margin-top: 15px;">
                                    <textarea name="description" id="summary-ckeditor" cols="30" rows="8" class="form-control">
                                          {!!$post->description!!}
                                    </textarea>
                                    @error('description')
                                    <span class="alert-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                                <br>

                                  <h6 class="m-0 font-weight-bold text-primary pull-left" >Description (Dari)</h6>
                                <hr>

                                <div class="input-group" style="margin-top: 15px;">
                                    <textarea name="da_description" id="summary-ckeditor_da" cols="30" rows="8" class="form-control">
                                          {!!$post->da_description!!}
                                    </textarea>
                                    @error('da_description')
                                    <span class="alert-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                                <br>
                                  <h6 class="m-0 font-weight-bold text-primary pull-left" >Description (Pashto)</h6>
                                <hr>

                                <div class="input-group" style="margin-top: 15px;">
                                    <textarea name="pa_description" id="summary-ckeditor_pa" cols="30" rows="8" class="form-control">
                                          {!!$post->pa_description!!}

                                    </textarea>
                                    @error('pa_description')
                                    <span class="alert-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                                <br>

                                <h6 class="m-0 font-weight-bold text-primary pull-left" >Image</h6>
                                <input type="hidden" name="old_image" value="{{$post->image}}">
                                <hr>
                                <div class="input-group" style="margin-top: 15px;">
                                    <div class="fileinput fileinput-new"data-provides="fileinput">
                                        <div class="fileinput-new img-thumbnail" style="width: 150px; height: 150px;">


                                            <img src="{{ render_image_path($post->image)}}"   alt="...">
                                        </div>
                                        <div class="fileinput-preview fileinput-exists img-thumbnail" style="max-width: 150px; max-height: 150px;"></div>
                                        <div class="mt-2">
                                            <span class="btn btn-outline-secondary btn-file"><span class="fileinput-new"> Select Image </span>

                                            <span class="fileinput-exists">Edit</span><input type="file"  name="image"></span>
                                            <a href="#" class="btn btn-outline-secondary fileinput-exists"  data-dismiss="fileinput">Delete</a>
                                        </div>
                                        @error('image')
                                        <span class="alert-danger">{{ $message }}</span>
                                        @enderror
                                    </div>



                                    @error('image')
                                    <span class="alert-danger">{{ $message }}</span>
                                    @enderror
                                </div>
                                <br>


                                </div>

                                    <input type="submit" value="  Save Changes " class="form-control btn btn-secondary">


                                </form>


                              </div>
                             @elseif ($submenu->sub_route_name ==='#')
                             <div >

                                <hr>
                                <form method="post" action="{{ route('submenus.update',['submenu'=>$submenu->id]) }}" enctype="multipart/form-data">
                                    @method('put')

                                    @csrf
                                    <input type="hidden" name="sub_route_name" value="{{$submenu->sub_route_name}}">
                                    <input type="hidden" name="rousource_type" value="{{$submenu->sub_resource_type}}">
                                    <div class="col-lg-12">
                                    <div class="row">


                                            <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (English) </h6>
		<hr>

		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->sub_menu_name}}" name="sub_menu_name" class="form-control" placeholder="">
			@error('sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>

        <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (Dari) </h6>
		<hr>

		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->da_sub_menu_name}}"  name="da_sub_menu_name" class="form-control" placeholder="">
			@error('da_sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>

        <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (Pashto) </h6>
		<hr>
		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->pa_sub_menu_name}}" name="pa_sub_menu_name" class="form-control" placeholder="">
			@error('pa_sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>
                               </div>
                                   <br>
                                   <br>
                                <br>
                                <br>
                                <br>




                                    <input type="submit" value="  Save Changes" class=" btn btn-secondary">


                                </form>

                              </div>

                            @else
                              {{-- Current Page --}}

                              <div>
                                <hr>
                                <form method="post" action="{{ route('submenus.update',['submenu'=>$submenu->id]) }}" enctype="multipart/form-data">
                                    @csrf
                                    @method('put')
                                    <input type="hidden" value="{{$submenu->menu_id}}" name="menu_id">
                                    <div class="col-lg-12">
                                    <div class="row">


                                            <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (English) </h6>
		<hr>

		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->sub_menu_name}}" name="sub_menu_name" class="form-control" placeholder="">
			@error('sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>

        <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (Dari) </h6>
		<hr>

		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->da_sub_menu_name}}"  name="da_sub_menu_name" class="form-control" placeholder="">
			@error('da_sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>

        <div class="col-md-6">
		<h6 class="m-0 font-weight-bold text-primary pull-left" >Name (Pashto) </h6>
		<hr>
		<div class="input-group" style="margin-top: 15px;">
			<input type="text" required  value="{{$submenu->pa_sub_menu_name}}" name="pa_sub_menu_name" class="form-control" placeholder="">
			@error('pa_sub_menu_name')
			<span class="alert-danger">{{ $message }}</span>
			@enderror
		</div>
       </div>
                               </div>
                                   <br>
                                   <br>

                             <div class="row">

                                   <div class="col-md-6">
                                    <h6 class="m-0 font-weight-bold text-primary pull-left" >Page </h6>
                                    <hr>

                                    <div class="input-group" style="margin-top: 15px;">
                                         <select name="sub_route_name" class="form-control">
                                            <option value="">__انتخاب__</option>
                                            @foreach ($pages as $key=>$value)
                                             <option @if ($submenu->sub_route_name===$value) {{"selected"}} @endif value="{{$value}}">{{$key}}</option>
                                            @endforeach
                                         </select>

                                        @error('sub_route_name')
                                        <span class="alert-danger">{{ $message }}</span>
                                        @enderror
                                    </div>
                                   </div>
                                   <div class="col-md-6">

                                   </div>

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




                                    <input type="submit" value="  Save Changes" class=" btn btn-secondary">


                                </form>

                              </div>

                              @endif




                            </div>





</div>
<!-- container-fluid -->
</div>
<!-- End Page-content -->



@endsection




@section('script')
<script>
       CKEDITOR.replace( 'summary-ckeditor');
    CKEDITOR.replace( 'summary-ckeditor_da', {
    contentsLangDirection: 'rtl'
} );

   CKEDITOR.replace( 'summary-ckeditor_pa', {
    contentsLangDirection: 'rtl'
} );
</script>

<script>
  function openCurrentPage(){

       let newPage = document.getElementById("newPage");
       let currentPage = document.getElementById('currentPage');
      newPage.style.display = 'none';
      currentPage.style.display = 'block';

    }

  function  openNewPage(){
        let newPage = document.getElementById("newPage");
       let currentPage = document.getElementById('currentPage');
      newPage.style.display = 'block';
      currentPage.style.display = 'none';

    }

    </script>

@endsection
