@extends('admin/layouts/default')

{{-- Page title --}}
@section('title')
Add Banner
@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_banner->banner_id))<h1>Update Banner</h1>
                @else <h1>Add New Banner</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/banner') }}">Banner List</a></li>
                    <li class="active">@if(isset($selected_banner->banner_id))
                    						Update Banner
                                        @else 
                                        	Add New Banner
                                        @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_banner->banner_id))
                <form name="first" method="post" action="{{ route('banner.update',$selected_banner->banner_id) }}" enctype="multipart/form-data"> @method('PUT')
                  <input type="hidden" name="banner_id" value="{{$selected_banner->banner_id}}">
                @else    
                <form name="first" method="post" action="{{ route('banner.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-3 pd-2">
                        <p class="mar-2">
                            Follow the steps below to add new banner.
                        </p>
                        <ol class="acc-wizard-sidebar">
                            <li class="acc-wizard-todo">
                                <a href="#banner">Banner Detail</a>
                            </li>
                            <li class="acc-wizard-todo">
                                <a href="#journal">Journal</a>
                            </li>
                            <li class="acc-wizard-todo">
                                <a href="#ebook">eBook</a>
                            </li>
                       </ol>
                    </div>
                    <div class="col-md-9 pd-r">
                        <div id="accordion-demo" class="panel-group" ng-app="MAMP.Subapp.Admin">

                            <!-- /.panel.panel-default -->
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a href="#banner" data-parent="#accordion-demo" data-toggle="collapse">Banner Detail</a>
                                    </h4>
                                </div>
                                <div id="banner" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <div class="form-group">
                                            <label for="pic" class="col-sm-4 control-label">Banner Image</label>
                                            <div class="col-sm-4">
                                                <div class="fileinput fileinput-new" data-provides="fileinput">
                                                    <div class="fileinput-new thumbnail" style="width: 150px; height: 150px;" >
                                                        
                                                    @if(!empty($selected_banner->banner_file_name) && (file_exists(config('constants.admin.root_path_banner').$selected_banner->banner_file_name)))

                                                        <img src="{{DisplayImage(config('constants.admin.root_path_banner').$selected_banner->banner_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="banner_file_name" name="banner_file_name" value="{{ old('banner_file_name',isset($selected_banner->banner_file_name) ? $selected_banner->banner_file_name : '') }}">
					                                </span>
                                                        <a href="#" class="btn btn-danger fileinput-exists"
                                                           data-dismiss="fileinput">Remove</a>
                                                    </div>
                                                </div>

                                            </div>
                                            <div class="col-sm-4 text-left">
                                            	<p><b>Horizontal Bannder:</b> Max-width = 728px | height = 90px or any near to it.</p>
                                            	<p><b>Square Banner:</b> Max-width = 350px | height = 280px plus or any near to it.</p>
                                            </div>
                                        </div>

                                        <div class="form-group col-md-12">
                                            <label for="e1" class="control-label">Banner Link:</label>
                                            <textarea class="form-control resize_vertical" id="banner_link" name="banner_link" placeholder="Please enter banner link here..." rows="5">{{ old("banner_link", isset($selected_banner->banner_link) ? $selected_banner->banner_link : '') }}</textarea>
                                        </div>

                                        <div class="form-group col-md-12">
                                            <label for="e1" class="control-label">Banner Placement: *</label>
                                            <select name="banner_placement" class="form-control" required="required">
                                                <option value="" >Select Placement</option>
                                                
                                                <option value="1" @if(old('banner_placement') == 1) {{ 'selected' }}
                                                @elseif(isset($selected_banner->banner_placement) && ($selected_banner->banner_placement == 1))) {{ 'selected' }} @endif>
                                                    Right Menu
                                                </option>
                                                
                                                <option value="2"  @if(old('banner_placement') == 2) {{ 'selected' }}
                                                @elseif(isset($selected_banner->banner_placement) && ($selected_banner->banner_placement == 2))) {{ 'selected' }} @endif>
                                                    Abstract Top
                                                </option>
                                                
                                                <option value="3"  @if(old('banner_placement') == 3) {{ 'selected' }}
                                                @elseif(isset($selected_banner->banner_placement) && ($selected_banner->banner_placement == 3))) {{ 'selected' }} @endif>
                                                    Abstract Bottom
                                                </option>
                                            
                                            </select>
                                        </div>

                                        <div class="form-group col-md-12">
                                            <label for="e1" class="control-label">Banner Name: *</label>
                                            <input type="text" name="banner_name" id="banner_name" class="form-control input-md" required="required" value="{{ old("banner_name", isset($selected_banner->banner_name) ? $selected_banner->banner_name : '') }}">
                                            <div>
                                            </div>
                                        </div>

                                        <div class="form-group col-md-6">
                                            <label for="e1" class="control-label">From:</label>
                                            <input type="date" name="banner_from_date" class="form-control" value="{{ old('banner_from_date', isset($selected_banner->banner_from_date) ? strftime('%Y-%m-%d',$selected_banner->banner_from_date) : '') }}">
                                        </div>

                                        <div class="form-group col-md-6">
                                            <label for="e1" class="control-label">To:</label>
                                            <input type="date" name="banner_to_date" class="form-control" value="{{ old('banner_to_date', isset($selected_banner->banner_to_date) ? strftime('%Y-%m-%d',$selected_banner->banner_to_date) : '') }}">
                                        </div>

                                        <div class="form-group col-md-12">
                                            <label for="e1" class="control-label">Banner Remarks:</label>
                                            <textarea class="form-control resize_vertical" id="banner_remarks" name="banner_remarks" placeholder="Please enter your message here..." rows="5">{{ old("banner_remarks", isset($selected_banner->banner_remarks) ? $selected_banner->banner_remarks : '') }}</textarea>
                                        </div>

                                        <div class="form-group col-md-12">
                                            <label for="e1" class="control-label">Banner Script:</label>
                                            <textarea class="form-control resize_vertical" id="banner_script" name="banner_script" placeholder="Please enter your script here..." rows="5">{{ old("banner_script", isset($selected_banner->banner_script) ? $selected_banner->banner_script : '') }}</textarea>
                                        </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="#journal" data-parent="#accordion-demo" data-toggle="collapse">Journal</a>
                                    </h4>
                                </div>
                                <div id="journal" class="panel-collapse collapse">
	                                <div class="panel-body">
	                                    <div class="form-group">
	                                        <label for="e1" class="control-label">Journal:</label>
	                                        <select id="multiselect11" multiple="multiple" class="form-control" name="journal_id[]">
									        @foreach($journal as $key => $value)
										        <option value="{{$key}}"  

                                                @if (old("journal_id"))
                                                {{ (in_array($key, old("journal_id")) ? "selected":"") }}
                                                @elseif(isset($selected_journal) && in_array($key, $selected_journal)) selected @endif>
                                                
                                                {{$value}}
                                                
                                                </option>
									        @endforeach	
	                                        </select>
	                                    </div>
	                                </div>    
                                </div>
                            </div>

                            <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">
	                                    <div class="form-group">
	                                        <label for="e1" class="control-label">eBook:</label>
	                                        <select id="multiselect12" multiple="multiple" class="form-control" name="ebook_volume_id[]">
									        @foreach($ebook_volume as $value)
												<option value="{{$value->ebook_volume_id}}"

                                                @if (old("ebook_volume_id"))
                                                {{ (in_array($value->ebook_volume_id, old("ebook_volume_id")) ? "selected":"") }}
                                                @elseif(isset($selected_book) && in_array($value->ebook_volume_id, $selected_book)) selected @endif>

                                                    {{$value->ebk_title}}
                                                </option>
									        @endforeach	
	                                        </select>
	                                    </div>
	                                </div>    
                                </div>
                            </div>

  <!-- /#adjusthtml --> </div>
                          <button class="btn btn-primary text-right" type="submit">Save</button>

						</div>

                    </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
