@extends('admin/layouts/default')

{{-- Page title --}}
@section('title')
Add New eBook
@parent
@stop

{{-- page level styles --}}
@section('header_styles')
     @include('admin.layouts.css')
<link rel="stylesheet" href="{{ asset('assets/vendors/bootstrap-tagsinput/css/bootstrap-tagsinput.css') }}" />
<link rel="stylesheet" href="{{ asset('assets/vendors/bootstrap-tagsinput/css/app.css') }}" />
@stop

{{-- Page content --}}
@section('content')

<section class="content-header">
                <!--section starts-->
                @if(isset($selected_ebook->ebook_id))<h1>Update eBook</h1>
                @else <h1>Add New eBook</h1>
                @endif
                <ol class="breadcrumb">
                    <li>
                        <a href="{{ route('admin.dashboard') }}">
                            <i class="livicon" data-name="home" data-size="14" data-loop="true"></i>
                            Dashboard
                        </a>
                    </li>
                    <li ><a href="{{ URL::to('admin/ebook') }}">eBook List</a></li>
                    <li class="active">@if(isset($selected_ebook->ebook_id))Update Ebook
                                        @else Add New eBook
                                        @endif
                    </li>
                </ol>
            </section>
            <!--section ends-->
<section class="content paddingleft_right15">
    <!--main content-->
    <div class="row">
        <div class="panel panel-primary ">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <i class="livicon" data-name="gear" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                    Options
                </h3>
                <span class="pull-right clickable">
                    <i class="glyphicon glyphicon-chevron-up"></i>
                </span>
            </div>
            <div class="panel-body">
                @if(isset($selected_ebook->ebook_id))
                <form name="first" method="post" action="{{ route('ebook.update',$selected_ebook->ebook_id) }}" enctype="multipart/form-data"> @method('PUT')
                  <input type="hidden" name="ebook_id" value="{{$selected_ebook->ebook_id}}">
                  <input type="hidden" name="ebook_nid" value="{{$selected_ebook->nid}}">
                @else    
                <form name="first" method="post" action="{{ route('ebook.store') }}" enctype="multipart/form-data">
                @endif
                    <input type="hidden" name="_token" value="<?=csrf_token()?>">
             @if ($errors->any())
                <div class="row">
                    <div class="col-md-9 col-lg-offset-3 col-md-offset-3 pd-r lert alert-danger">
                        <strong>Whoops!</strong> There were some problems with your input.<br>
                        <ul>
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                </div>
                @endif
                <div class="row acc-wizard">
                    <div class="col-md-2 pd-2">
                      
                        <ol class="acc-wizard-sidebar">
                            <li class="acc-wizard-todo">
                                <a href="#ebook">eBook</a>
                            </li>
                            <li class="acc-wizard-todo">
                                <a href="#management">eBook Management</a>
                            </li>
                            <li class="acc-wizard-todo">
                                <a href="#meta">Meta Tags</a>
                            </li>
                       </ol>
                    </div>
                    <div class="col-md-10 pd-r">
                        <div id="accordion-demo" class="panel-group">
                            <!-- /.panel.panel-default -->
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#ebook" data-parent="#accordion-demo" data-toggle="collapse">eBook</a>
                                    </h4>
                                </div>
                                <div id="ebook" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <p>Enter details of an eBook.</p>                                                
                                            <div class="form-group {{ $errors->first('pic_file', 'has-error') }}">                                              
                                            <label for="pic" class="col-sm-4 control-label">Cover Image</label>
                                            <div class="col-sm-8">
                                                <div class="fileinput fileinput-new" data-provides="fileinput">
                                                    <div class="fileinput-new thumbnail" style="width: 150px; height: 150px;">
                                                    @if(isset($selected_ebook->image_file_name) && (file_exists(config('constants.admin.root_path').'E-books/BEN/'.$selected_ebook->image_file_name)))

                                                        <img src="{{DisplayImage(config('constants.admin.root_path').'E-books/BEN/'.$selected_ebook->image_file_name)}}" class="img-responsive"/>
                                                    @else         
                                                        <img src="http://placehold.it/200x200" alt="profile pic">
                                                    @endif    
                                                    </div>
                                                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 150px; max-height: 150px;"></div>
                                                    <div>
                                                <span class="btn btn-default btn-file">
                                                    <span class="fileinput-new">Select image</span>
                                                    <span class="fileinput-exists">Change</span>
                                                    <input type="file" id="image_file_name" name="image_file_name" @if(!isset($selected_ebook->image_file_name)) @endif value="{{ old('image_file_name',isset($selected_ebook->image_file_name) ? $selected_ebook->image_file_name : '') }}">
                                                </span>
                                                                        <a href="#" class="btn btn-danger fileinput-exists"
                                                                           data-dismiss="fileinput">Remove</a>
                                                                    </div>
                                                                </div>
                                                                <span class="help-block">{{ $errors->first('pic_file', ':message') }}</span>


                                     @if(isset($selected_ebook->image_file_name))
                                        @if(file_exists(config('constants.admin.root_path').'E-books/BEN/'.$selected_ebook->image_file_name)) 
                                            <strong><span> {{$selected_ebook->image_file_name}}</span></strong>  
                                            @if($user==1)
                                                <a href="{{ route('DeleteEbookFile', array('id' => $selected_ebook->ebook_id, 'file_type' => 'image_file_name')) }}">[remove]</a> 
                                            @endif  
                                        @endif
                                    @endif


                                                            </div>
                                                        </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Publisher</label>
                                                    <select id="e1" class="form-control select2" name="publisher_id">
                                                         @foreach ($publisher as $publisher)
                                                            <option value="{{$publisher->publisher_id}}" @if(old('publisher_id') == $publisher->publisher_id) {{ 'selected' }}
                                                            @elseif(isset($selected_ebook->publisher_id) and ($selected_ebook->publisher_id == $publisher->publisher_id))) {{ 'selected' }} @endif> {{$publisher->title}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Subject: *</label>
                                                    <select id="multiselect4" multiple="multiple" class="form-control" name="subject_id[]">                                                       @foreach ($subject as $key => $value)
                                                        <option value="{{$key}}" @if (old("subject_id")){{ (in_array($key, old("subject_id")) ? "selected":"") }}
                                                         @elseif(isset($ebooksubject) and in_array($key, $ebooksubject)) selected @endif>{{$value}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                                <!--div class="form-group">
                                                    <label for="e1" class="control-label">Disease:</label>
                                                    <select id="multiselect5" multiple="multiple" class="form-control" name="disease_id[]">
                                                         @foreach ($disease as $disease)
                                                            <option value="{{$disease->disease_id}}" @if (old("disease_id")){{ (in_array($disease->disease_id, old("disease_id")) ? "selected":"") }}
                                                         @elseif(isset($ebookdisease) and in_array($disease->disease_id, $ebookdisease)) selected @endif>{{$disease->disease_name}}</option>
                                                        @endforeach
                                                    </select>
                                                </div-->
                                                <div class="form-group">
                                                    <label for="e1" class="control-label">Title: *</label>
                                                    <input type="text" name="title" id="title" class="form-control input-md" placeholder="Title" value="{{ old("title", isset($selected_ebook->title) ? $selected_ebook->title : '') }}">
                                                </div>
                                    </div>
                                    <!--/.panel-body --> </div>
                                <!-- /#adjusthtml --> </div>
                            <!-- /.panel.panel-default -->
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#management" data-parent="#accordion-demo" data-toggle="collapse">eBook Management</a>
                                    </h4>
                                </div>
                                <div id="management" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <form id="form-management">
                                        <label for="e1" class="control-label">Left Panel:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" placeholder="Place some text here" name="left_panel">{{ old("left_panel", isset($selected_ebook->left_panel) ? $selected_ebook->left_panel : '') }}</textarea>
                                        </div>
                                        <label for="e1" class="control-label">Right Panel:</label>
                                        <div class='box-body box_content'>
                                            <textarea class="textarea editor-cls" name="right_panel" placeholder="Please enter your message here..." rows="5">{{ old("right_panel", isset($selected_ebook->right_panel) ? $selected_ebook->right_panel : '') }}</textarea>
                                        </div>
                                    </div>
                                </div>
      <!-- /#adjusthtml --> </div>
                            @include('admin.meta_tag.meta_tag')
            <!-- /.panel.panel-default --> 
                        </div>
                    <button class="btn btn-primary" type="submit">Save</button>
                    </div>
                           
                </div>
            </form>
            </div>
        </div>

    </div>
    <!--main content ends--> </section>
            <!-- content --> 
    @stop

{{-- page level scripts --}}
@section('footer_scripts')
        
    @include('admin.layouts.js')
<script src="{{ asset('assets/vendors/bootstrap-tagsinput/js/bootstrap-tagsinput.js') }}"  type="text/javascript"></script>
@stop
