@extends("admin.admin_app")

@section("content")

<style type="text/css">
  .iframe-container {
  overflow: hidden;
  padding-top: 56.25% !important;
  position: relative;
}
 
.iframe-container iframe {
   border: 0;
   height: 100%;
   left: 0;
   position: absolute;
   top: 0;
   width: 100%;
}
</style>
 
  <div class="content-page">
      <div class="content">
        <div class="container-fluid">
          <div class="row">
            <div class="col-lg-12">
              <div class="card-box">
                 
                @if (count($errors) > 0)
                <div class="alert alert-danger">
                     <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
                @endif
                @if(Session::has('flash_message'))
                      <div class="alert alert-success">
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                          {{ Session::get('flash_message') }}
                      </div>
                @endif
                @if(Session::has('flash_error_message'))
                      <div class="alert alert-danger">
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                          {{ Session::get('flash_error_message') }}
                      </div>
                @endif
                

                 {!! Form::open(array('url' => array('admin/notification_send'),'class'=>'form-horizontal','name'=>'settings_form','id'=>'settings_form','role'=>'form','enctype' => 'multipart/form-data')) !!}  
                   
 
                  <div class="form-group row">
                    <label class="col-sm-3 col-form-label">{{trans('words.title')}}*</label>
                    <div class="col-sm-8">
                      <input type="text" name="notification_title" value="" class="form-control">
                    </div>
                  </div>
  
                   
                  <div class="form-group row">
                    <label class="col-sm-3 col-form-label">{{trans('words.android_notification_message')}}*</label>
                    <div class="col-sm-8">
                       
                      <textarea id="notification_msg" name="notification_msg" class="form-control"></textarea>
                     
                    </div>
                  </div>
                  
                  <div class="form-group row">
                    <label class="col-sm-3 col-form-label">{{trans('words.image')}} <small id="emailHelp" class="form-text text-muted">({{trans('words.optional')}})</small></label>
                    <div class="col-sm-8">
                      <div class="input-group">
                        <input type="text" name="notification_image" id="notification_image" value="" class="form-control" readonly>                         
                        <div class="input-group-append">                           
                          <button type="button" class="btn btn-dark waves-effect waves-light popup_selector" data-input="notification_image" data-preview="holder_thumb" data-inputid="notification_image">Select</button>                        
                        </div>
                      </div>
                      <small id="emailHelp" class="form-text text-muted">( {{trans('words.recommended_resolution')}}: 600x293 or 650x317 or 700x342 or 750x366)</small>
                      <div id="image_holder" class="send_notification_img"></div>                     
                    </div>
                  </div>       
                  <h4 class="m-t-0 m-b-30 header-title" style="font-size: 18px;">{{trans('words.or')}}</h4>

                  <div class="form-group row">
                    <label class="col-sm-3 col-form-label">{{trans('words.post_type')}}</label>
                      <div class="col-sm-8">
                            <select class="form-control" name="section_type" id="home_section_type">     

                                 <option value="" >Select Type</option>                           
                                 <option value="category" @if(isset($info->section_type) AND $info->section_type=="category") selected @endif>Categories</option>
                                <option value="artist" @if(isset($info->section_type) AND $info->section_type=="artist") selected @endif>Artists</option>
                                <option value="album" @if(isset($info->section_type) AND $info->section_type=="album") selected @endif>Album</option>
                                <option value="song" @if(isset($info->section_type) AND $info->section_type=="song") selected @endif>Song</option>
                                <option value="playlist" @if(isset($info->section_type) AND $info->section_type=="playlist") selected @endif>Playlist</option>                            
                            </select>
                      </div>
                  </div>    

                  <div class="form-group row" id="category_list_sec" style="display:none;">
                    <label class="col-sm-3 col-form-label">{{trans('words.categories_text')}} <small id="emailHelp" class="form-text text-muted">({{trans('words.optional')}})</small></label> 
                      <div class="col-sm-8">
                            <select name="category_id" class="select2" id="cat_id1" data-placeholder="{{trans('words.select_category')}}...">   
                                 <option value="" >{{trans('words.select_category')}}</option>

                                 @foreach($category_list as $category_data)
                                  <option value="{{$category_data->id}}" @if(isset($info->id) && in_array($category_data->id, explode(",",$info->post_ids))) selected @endif>{{stripslashes($category_data->category_name)}}</option>
                                @endforeach
                            </select>
                            <small id="emailHelp" class="form-text text-muted">(To directly open single post when click on notification)</small>
                      </div>
                  </div>

                  <div class="form-group row" id="artist_list_sec" style="display:none;">
                    <label class="col-sm-3 col-form-label">{{trans('words.artists_text')}} <small id="emailHelp" class="form-text text-muted">({{trans('words.optional')}})</small></label> 
                      <div class="col-sm-8">
                            <select name="artist_id" class="select2" id="artist_id1" data-placeholder="{{trans('words.select_artist')}}...">

                                 <option value="" >{{trans('words.select_artist')}}</option>

                                 @foreach($artist_list as $artist_data)
                                  <option value="{{$artist_data->id}}" @if(isset($info->id) && in_array($artist_data->id, explode(",",$info->post_ids))) selected @endif>{{stripslashes($artist_data->artist_name)}}</option>
                                @endforeach
                            </select>
                            <small id="emailHelp" class="form-text text-muted">(To directly open single post when click on notification)</small>
                      </div>
                  </div>

                  <div class="form-group row" id="album_list_sec" style="display:none;">
                    <label class="col-sm-3 col-form-label">{{trans('words.album_text')}} <small id="emailHelp" class="form-text text-muted">({{trans('words.optional')}})</small></label> 
                      <div class="col-sm-8">
                            <select name="album_id" class="select2" id="album_id1" data-placeholder="{{trans('words.select_album')}}...">
                                 
                                 <option value="" >{{trans('words.select_album')}}</option>

                                 @foreach($album_list as $album_data)
                                  <option value="{{$album_data->id}}" @if(isset($info->id) && in_array($album_data->id, explode(",",$info->post_ids))) selected @endif>{{stripslashes($album_data->album_name)}}</option>
                                @endforeach
                            </select>
                            <small id="emailHelp" class="form-text text-muted">(To directly open single post when click on notification)</small>
                      </div>
                  </div>


                  <div class="form-group row" id="songs_list_sec" style="display:none;">
                    <label class="col-sm-3 col-form-label">{{trans('words.songs_text')}} <small id="emailHelp" class="form-text text-muted">({{trans('words.optional')}})</small></label> 
                      <div class="col-sm-8">
                            <select name="song_id" class="select2" id="song_id1" data-placeholder="{{trans('words.select_song')}}...">

                                 <option value="" >{{trans('words.select_song')}}</option>

                                 @foreach($songs_list as $songs_data)
                                  <option value="{{$songs_data->id}}" @if(isset($info->id) && in_array($songs_data->id, explode(",",$info->post_ids))) selected @endif>{{stripslashes($songs_data->song_title)}}</option>
                                @endforeach
                            </select>
                            <small id="emailHelp" class="form-text text-muted">(To directly open single post when click on notification)</small>
                      </div>
                  </div>

                  <div class="form-group row" id="playlist_list_sec" style="display:none;">
                    <label class="col-sm-3 col-form-label">{{trans('words.playlist_text')}} <small id="emailHelp" class="form-text text-muted">({{trans('words.optional')}})</small></label> 
                      <div class="col-sm-8">
                            <select name="playlist_id" class="select2" id="playlist_id1" data-placeholder="Select Playlist...">

                                 <option value="" >{{trans('words.select_playlist')}}</option>

                                 @foreach($playlist_list as $playlist_data)
                                  <option value="{{$playlist_data->id}}" @if(isset($info->id) && in_array($playlist_data->id, explode(",",$info->post_ids))) selected @endif>{{stripslashes($playlist_data->playlist_name)}}</option>
                                @endforeach
                            </select>
                            <small id="emailHelp" class="form-text text-muted">(To directly open single post when click on notification)</small>
                      </div>
                  </div>      
  

                  <h4 class="m-t-0 m-b-30 header-title" style="font-size: 18px;">{{trans('words.or')}}</h4>

                  <div class="form-group row">
                    <label class="col-sm-3 col-form-label">{{trans('words.android_external_link')}} <small id="emailHelp" class="form-text text-muted">({{trans('words.optional')}})</small></label>
                    <div class="col-sm-8">
                      <input type="text" name="external_link" value="" class="form-control">
                    </div>
                  </div>

                  <div class="form-group">
                    <div class="offset-sm-3 col-sm-9 pl-1">
                      <button type="submit" class="btn btn-primary waves-effect waves-light"><i class="fa fa-send"></i> {{trans('words.send')}} </button>                      
                    </div>
                   </div>

                
                   
                {!! Form::close() !!} 
              </div>
            </div>            
          </div>              
        </div>
      </div>
      @include("admin.copyright") 
    </div> 
 
<script type="text/javascript">
     
     
// function to update the file selected by elfinder
function processSelectedFile(filePath, requestingField) {

    //alert(requestingField);

    var elfinderUrl = "{{ URL::to('/') }}/";

    if(requestingField=="notification_image")
    {
      var target_preview = $('#image_holder');
      target_preview.html('');
      target_preview.append(
              $('<img class="noti_preview_img">').attr('src', elfinderUrl + filePath.replace(/\\/g,"/"))
            );
      target_preview.trigger('change');
    }
 
    //$('#' + requestingField).val(filePath.split('\\').pop()).trigger('change'); //For only filename
    $('#' + requestingField).val(filePath.replace(/\\/g,"/")).trigger('change');
 
}
 
 </script>

@endsection