@extends('layouts.admin')

@section('styles')
<link href="{{asset('assets/admin/css/tabbar.css')}}" rel="stylesheet" />
@endsection

@section('content')

<!-- [ breadcrumb ] start -->
<div class="page-header">
    <div class="page-block">
        <div class="row align-items-center">
            <div class="col-md-12">
                <ul class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">হোম</a></li>
                    <li class="breadcrumb-item"><a href="javascript: void(0)">মিডিয়া</a></li>
                    <li class="breadcrumb-item" aria-current="page">ভিডিও / সম্পাদনা</li>
                </ul>
            </div>
            <div class="col-md-12">
                <div class="page-header-title">
                    <h2 class="mb-0">ভিডিও / সম্পাদনা</h2>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- [ breadcrumb ] end -->

@include('includes.admin.form-both')
<div class="gocover" style="background: url({{asset('assets/images/'.$gs->admin_loader)}}) no-repeat scroll center center rgba(45, 45, 45, 0.5);"></div>
<form id="geniusformdata2" action="{{ route('video.update',$data->id)}}" method="POST" enctype="multipart/form-data">
    {{csrf_field()}}
    <input type="hidden" name="is_pending" value="{{ $data->is_pending}}">
    <input type="hidden" name="post_type" value="{{ $data->post_type}}">
    <input type="hidden" id="id" value="{{ $data->id}}">
    <div class="row">
        {{-- ========== LEFT COLUMN — Content ========== --}}
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header"><h5>{{ __('কন্টেন্ট তথ্য') }}</h5></div>
                <div class="card-body">
                    <div class="mb-3">
                        <label class="form-label">{{ __('Language') }} <span class="text-danger">*</span></label>
                        <select name="language_id" id="video_language_id" class="form-select">
                            <option value="">Please Select a Language</option>
                            @foreach ($languages as $language)
                                <option value="{{$language->id}}" {{ $language->id == $data->language_id ? 'selected' : ''}}>{{$language->language}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ __('Title') }} <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" name="title" placeholder="{{ __('Title') }}" autocomplete="off" id="title" value="{{ $data->title }}">
                        <small class="text-muted">{{ __('(In Any Language)') }}</small>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ __('Slug') }} <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" name="slug" placeholder="{{ __('Slug') }}" autocomplete="off" id="slug" value="{{ $data->slug }}">
                        <small class="text-muted">{{ __('In English') }}</small>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ __('Keyword meta tag') }} <span class="text-danger">*</span></label>
                        <textarea class="form-control" name="meta_tag" rows="2" placeholder="{{ __('Keyword meta tag') }}">{{ $data->meta_tag }}</textarea>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ __('Images Caption') }} <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" name="images_caption" placeholder="{{ __('Images Caption') }}" id="images_caption" autocomplete="off" value="{{ $data->images_caption }}">
                        <small class="text-muted">{{ __('(In Any Language)') }}</small>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ __('Short Description') }} <span class="text-danger">*</span></label>
                        <textarea class="form-control" name="short_description" rows="3" placeholder="{{__('Short Details')}}">{{ $data->short_description }}</textarea>
                    </div>
                    <div class="mb-3 description">
                        <label class="form-label">{{ __('Description') }} <span class="text-danger">*</span></label>
                        <textarea class="nic-edit" name="description" placeholder="{{__('Description')}}" id="description">{{ $data->description }}</textarea>
                    </div>
                </div>
            </div>
        </div>

        {{-- ========== RIGHT COLUMN — Sidebar ========== --}}
        <div class="col-lg-4">
            {{-- Video Upload --}}
            <div class="card">
                <div class="card-header"><h5>{{ __('ভিডিও ও ইমেজ') }}</h5></div>
                <div class="card-body">
                    <div class="mb-3">
                        <select id="videoEdit" class="form-select">
                            <option value="local_video" {{$data->video != NULL ? 'selected':'' }}>Local Video</option>
                            <option value="embed_video" {{$data->embed_video != NULL ? 'selected':''}}>Embed Video</option>
                        </select>
                    </div>
                    <div class="mb-3 localVideo">
                        <label class="form-label">{{ __('Video') }} <span class="text-danger">*</span></label>
                        <input class="upload-video-file form-control" type='file' name="video" value="{{ $data->video }}" id="databaseVideo"/>
                        @if ($data->video)
                        <div class='video-prev mt-2'>
                            <video height="200" width="100%" src="{{asset('assets/videos/'.$data->video)}}" class="video-preview" controls="controls"/>
                        </div>
                        @else
                        <div style="display: none;" class='video-prev mt-2'>
                            <video height="200" width="100%" class="video-preview" controls="controls"/>
                        </div>
                        @endif
                    </div>
                    <div class="mb-3 embedVideo">
                        <label class="form-label">{{ __('Embed Video') }}</label>
                        <textarea class="form-control" name="embed_video" placeholder="{{ __('Embed Video') }}" autocomplete="off" id="embed_video" rows="3">{{$data->embed_video}}</textarea>
                    </div>
                    <hr>
                    <label class="form-label">{{__('Featured Image')}} <span class="text-danger">*</span></label>
                    <div class="img-upload custom-image-upload">
                        <div id="image-preview" class="img-preview" style="background: url({{ $data->image_big ? asset('assets/images/post/'.$data->image_big) : asset('assets/admin/images/upload.png') }});">
                            <label for="image-upload" class="img-label" id="image-label"><i class="icofont-upload-alt"></i>{{__('Upload')}}</label>
                            <input type="file" name="image_big" class="img-upload" id="image-upload">
                        </div>
                        <p class="text-muted small mt-1">{{__('Prefered Size: (600x600) or Square Sized Image')}}</p>
                    </div>
                </div>
            </div>

            {{-- Category --}}
            <div class="card categoryDiv" style="display:none;">
                <div class="card-header"><h5>{{ __('ক্যাটাগরি') }}</h5></div>
                <div class="card-body">
                    <div class="mb-3">
                        <label class="form-label">{{ __('Category') }} <span class="text-danger">*</span></label>
                        <select name="category_id" id="video_parent_id" class="form-select">
                            @foreach ($categories as $category)
                                <option value="{{$category->id}}">{{$category->title}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">{{ __('Sub Category') }}</label>
                        <select name="subcategories_id" id="subcategory_id" class="form-select"></select>
                    </div>
                </div>
            </div>

            {{-- Options --}}
            <div class="card">
                <div class="card-header"><h5>{{ __('পোস্ট অপশন') }}</h5></div>
                <div class="card-body">
                    @php
                        $radioOptions = [
                            ['name' => 'is_feature', 'label' => __('Add to Feature'), 'id' => 'is_feature', 'val' => $data->is_feature],
                            ['name' => 'is_slider', 'label' => __('Add to Slider'), 'id' => 'is_slider', 'val' => $data->is_slider],
                            ['name' => 'slider_right', 'label' => __('Slider Right Post'), 'id' => 'slider_right', 'val' => $data->slider_right],
                            ['name' => 'is_trending', 'label' => __('Add to Trending News'), 'id' => 'is_trending', 'val' => $data->is_trending],
                            ['name' => 'is_videoGallery', 'label' => __('Add to Video Gallery'), 'id' => 'is_videoGallery', 'val' => $data->is_videoGallery],
                        ];
                    @endphp
                    @foreach($radioOptions as $opt)
                    <div class="mb-3">
                        <label class="form-label">{{ $opt['label'] }}</label>
                        <div>
                            <div class="form-check form-check-inline">
                                <input type="radio" class="form-check-input" name="{{ $opt['name'] }}" value="1" id="{{ $opt['id'] }}1" {{ $opt['val'] == 1 ? 'checked' : '' }}>
                                <label class="form-check-label" for="{{ $opt['id'] }}1">{{__('Yes')}}</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input type="radio" class="form-check-input" name="{{ $opt['name'] }}" value="0" id="{{ $opt['id'] }}2" {{ $opt['val'] == 0 ? 'checked' : '' }}>
                                <label class="form-check-label" for="{{ $opt['id'] }}2">{{__('No')}}</label>
                            </div>
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>

            {{-- Schedule & Submit --}}
            <div class="card">
                <div class="card-header"><h5>{{ __('প্রকাশ') }}</h5></div>
                <div class="card-body">
                    <div class="mb-3" @if($data->schedule_post == 0) style="display:none;" @endif>
                        <div class="form-check">
                            <input type="checkbox" class="form-check-input schedule" name="schedule_post" value="{{ $data->schedule_post}}" {{$data->schedule_post == 1 ? 'checked':''}} disabled id="schedule_post">
                            <label class="form-check-label" for="schedule_post">{{ __('Schedule Post') }}</label>
                        </div>
                    </div>
                    <div class="mb-3 datepick" style="display:none;">
                        <label class="form-label">{{ __('Start Date') }}</label>
                        <input id="from" class="form-control" type="text" name="schedule_post_date" autocomplete="off" placeholder="{{__('Start Date')}}" required="" value="{{ $data->schedule_post_date}}">
                    </div>
                    <div class="d-grid gap-2">
                        <input type="submit" data-draft="0" class="btn btn-primary submit-btn1" value="Update Post">
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

@endsection

@section('scripts')
<script src="{{asset('assets/admin/js/videoEdit.js')}}"></script>
<script src="{{asset('assets/admin/js/tagify.js')}}"></script>
<script>
    $('.tags').tagify();
</script>
@endsection
