@extends("admin.admin_app")

@section("content")

  

<div class="content-page">
      <div class="content">
        <div class="container-fluid">
          
          @if(Auth::User()->usertype=="Admin")  
                <div class="row">
                     
                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/category')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-custom" data-plugin="counterup">{{$category}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.categories_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                     <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/artists')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-purple" data-plugin="counterup">{{$artists}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.artists_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/album')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-pink" data-plugin="counterup">{{$album}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.album_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>
 
                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/songs')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-warning" data-plugin="counterup">{{$songs}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.songs_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div> 

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/playlist')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-success" data-plugin="counterup">{{$playlist}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.playlist_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div> 

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/users')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-danger" data-plugin="counterup">{{$users}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.users')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/suggestions')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-info" data-plugin="counterup">{{$suggestions}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.suggestions')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/reports')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-dark" data-plugin="counterup">{{$reports}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.reports')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div> 
 
                </div> 

                  
                <div class="row">
                
                <div class="col-xl-4 col-md-6">
                        <div class="card-box">
                            

                            <h4 class="header-title mt-0 m-b-5">{{trans('words.trending_now')}}</h4>
                            <p class="text-muted m-b-20">{{trans('words.based_on_30_days')}}</p>

                            <div class="inbox-widget nicescroll" style="height: 315px; overflow: hidden; outline: none;" tabindex="5000">

                                @foreach($trending_now as $trending_data)

                                <a href="Javascript::void(0);" class="text-inverse">
                                
                                <p class="font-600 m-b-5 ">  
                                    {{Str::limit(stripslashes(\App\Songs::getSongInfo($trending_data->post_id,'song_title')), 25)}} 
                                     
                                    <span class="badge badge-danger pull-right">{{number_format_short($trending_data->total_views)}} Views  </span>
                                </p>

                                </a>

                                @endforeach
                                 
                            </div>
                        </div>
                    </div>

                <div class="col-xl-4 col-md-6">
                    <div class="card-box">
                        

                        <h4 class="header-title mt-0 m-b-5">{{trans('words.top_country')}}</h4>
                        <p class="text-muted m-b-20">{{trans('words.based_on_30_days')}}</p>
                      
                        <div class="inbox-widget nicescroll" style="height: 315px; overflow: hidden; outline: none;" tabindex="5000">

                            @foreach($top_country as $country_data)

                            <p class="font-600 m-b-5"><img src="{{ URL::asset('admin_assets/country_icons/').'/'.strtolower(countryNameToISO3166($country_data->country,'US')) }}.png" alt="" style="width:20px;"> &nbsp;{{$country_data->country}} <span class="badge badge-success pull-right">{{number_format_short($country_data->count_row)}} <i class="fa fa-eye"></i></span></p>

                            @endforeach
 
                             
                        </div>
                    </div>
                </div>
                    

                <div class="col-xl-4 col-md-6">
                    <div class="card-box">
                         

                        <h4 class="header-title m-t-0 m-b-5">{{trans('words.os')}}</h4>
                        <p class="text-muted m-b-20">{{trans('words.based_on_30_days')}}</p>
                      
                        <div id="morris-donut-example" style="height: 315px;"></div>

                    </div>
                </div><!-- end col-->

                <div class="col-xl-4">
                    <div class="card-box">
                         
                        <h4 class="header-title mt-0 m-b-30">{{trans('words.latest_reports')}}</h4>

                        <div class="inbox-widget nicescroll">
                            @foreach($reports_list as $reports_data)
                            <a href="{{URL::to('admin/reports')}}">
                                <div class="inbox-item">
                                    <div class="inbox-item-img">
                                        @if(\App\User::getUserInfo($reports_data->user_id)->user_image)
                                        <img src="{{URL::to('upload/'.\App\User::getUserInfo($reports_data->user_id)->user_image)}}" class="rounded-circle" alt="">
                                        @else
                                        <img src="{{URL::to('upload/profile.jpg')}}" class="rounded-circle" alt="">
                                        @endif
                                        
                                    </div>
                                    <p class="inbox-item-author" style="color:#fff;">{{\App\User::getUserInfo($reports_data->user_id)->name}}</p>
                                    <p class="inbox-item-text">{{Str::limit($reports_data->message,100)}}</p>
                                    <p class="inbox-item-date">{{ date('m-d-Y h:i a',$reports_data->date) }}</p>
                                </div>
                            </a>
                            @endforeach                            
                                                          
                        </div>
                    </div>
                </div><!-- end col -->

                <div class="col-xl-8">
                    <div class="card-box">
                         
                        <h4 class="header-title mt-0 m-b-30">{{trans('words.latest_suggestions')}}</h4>

                        <div class="table-responsive">
                            <table class="table mb-0">
                                <thead>
                                <tr>
                                    <th>{{trans('words.title')}}</th>
                                    <th>{{trans('words.image')}}</th>
                                    <th>{{trans('words.date')}}</th>
                                    <th>{{trans('words.name')}}</th>
                                    <th>&nbsp;</th>
                                </tr>
                                </thead>
                                <tbody>
                                    @foreach($suggestion_list as $suggestion_data)
                                     
                                    <tr style="color:#fff;">
                                        <td>{{Str::limit(stripslashes($suggestion_data->title),100)}}</td>
                                        <td>
                                            @if($suggestion_data->image)
                                            
                                                <img src="{{URL::to('upload/'.$suggestion_data->image)}}" class="thumb-sm bdr_radius" alt="">
                                            
                                            @endif
                                        </td>
                                        <td>{{ date('m-d-Y h:i a',$suggestion_data->date) }}</td>
                                        <td>{{\App\User::getUserInfo($suggestion_data->user_id)->name}}</td>
                                        <td><a href="{{ url('admin/suggestions') }}" class="btn btn-icon waves-effect waves-light btn-info m-b-5 m-r-5" data-toggle="tooltip" title="View"> <i class="fa fa-eye"></i> </a></td>
                                    </tr>
                                    </a>
                                    @endforeach  

                                </tbody>
                            </table>
 
                    </div>
                </div><!-- end col -->
 
                       
          </div>

          
          @else

                <div class="row">
                     
                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/category')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-custom" data-plugin="counterup">{{$category}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.categories_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                     <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/artists')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-purple" data-plugin="counterup">{{$artists}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.artists_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/album')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-pink" data-plugin="counterup">{{$album}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.album_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>
 
                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/songs')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-warning" data-plugin="counterup">{{$songs}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.songs_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div> 

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/playlist')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-success" data-plugin="counterup">{{$playlist}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.playlist_text')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div> 

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/users')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-danger" data-plugin="counterup">{{$users}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.users')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/suggestions')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-info" data-plugin="counterup">{{$suggestions}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.suggestions')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div>

                    <div class="col-xl-3 col-md-4 col-6">
                        <a href="{{URL::to('admin/reports')}}">
                        <div class="card-box widget-user">
                            <div class="text-center">
                                <h2 class="text-dark" data-plugin="counterup">{{$reports}}</h2>
                                <h5 style="color: #f9f9f9;">{{trans('words.reports')}}</h5>
                            </div>
                        </div>
                        </a>
                    </div> 
 
                </div>    

                <div class="row">
                        <div class="col-xl-4">
                        <div class="card-box">
                             
                            <h4 class="header-title mt-0 m-b-30">{{trans('words.latest_reports')}}</h4>

                            <div class="inbox-widget nicescroll">
                                @foreach($reports_list as $reports_data)
                                <a href="{{URL::to('admin/reports')}}">
                                    <div class="inbox-item">
                                        <div class="inbox-item-img">
                                            @if(\App\User::getUserInfo($reports_data->user_id)->user_image)
                                            <img src="{{URL::to('upload/'.\App\User::getUserInfo($reports_data->user_id)->user_image)}}" class="rounded-circle" alt="">
                                            @else
                                            <img src="{{URL::to('upload/profile.jpg')}}" class="rounded-circle" alt="">
                                            @endif
                                            
                                        </div>
                                        <p class="inbox-item-author" style="color:#fff;">{{\App\User::getUserInfo($reports_data->user_id)->name}}</p>
                                        <p class="inbox-item-text">{{Str::limit($reports_data->message,100)}}</p>
                                        <p class="inbox-item-date">{{ date('m-d-Y h:i a',$reports_data->date) }}</p>
                                    </div>
                                </a>
                                @endforeach                            
                                                              
                            </div>
                        </div>
                    </div><!-- end col -->

                    <div class="col-xl-8">
                        <div class="card-box">
                             
                            <h4 class="header-title mt-0 m-b-30">{{trans('words.latest_suggestions')}}</h4>

                            <div class="table-responsive">
                                <table class="table mb-0">
                                    <thead>
                                    <tr>
                                        <th>{{trans('words.title')}}</th>
                                        <th>{{trans('words.image')}}</th>
                                        <th>{{trans('words.date')}}</th>
                                        <th>{{trans('words.name')}}</th>
                                        <th>&nbsp;</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                        @foreach($suggestion_list as $suggestion_data)
                                         
                                        <tr style="color:#fff;">
                                            <td>{{Str::limit(stripslashes($suggestion_data->title),100)}}</td>
                                            <td>
                                                @if($suggestion_data->image)
                                                
                                                    <img src="{{URL::to('upload/'.$suggestion_data->image)}}" class="thumb-sm bdr_radius" alt="">
                                                
                                                @endif
                                            </td>
                                            <td>{{ date('m-d-Y h:i a',$suggestion_data->date) }}</td>
                                            <td>{{\App\User::getUserInfo($suggestion_data->user_id)->name}}</td>
                                            <td><a href="{{ url('admin/suggestions') }}" class="btn btn-icon waves-effect waves-light btn-info m-b-5 m-r-5" data-toggle="tooltip" title="View"> <i class="fa fa-eye"></i> </a></td>
                                        </tr>
                                        </a>
                                        @endforeach  

                                    </tbody>
                                </table>
     
                        </div>
                    </div><!-- end col -->

                </div>

          @endif 
        
        </div>

        
      </div>
      @include("admin.copyright") 
    </div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<!--Morris Chart-->
    <script src="{{ URL::asset('admin_assets/plugins/morris/morris.min.js') }}"></script>
    <script src="{{ URL::asset('admin_assets/plugins/raphael/raphael-min.js') }}"></script>
<!--     <script src="{{ URL::asset('admin_assets/pages/jquery.morris.init.js') }}"></script>
 -->
    <script type="text/javascript">
    !function($) {
    "use strict";
 
      var MorrisCharts = function() {};
 

    //creates Donut chart
    MorrisCharts.prototype.createDonutChart = function(element, data, colors) {
        Morris.Donut({
            element: element,
            data: data,
            resize: true, //defaulted to true
            colors: colors,
            labelColor:"#ffffff",
        });
    },
    
     MorrisCharts.prototype.init = function(){  
          
        //creating donut chart
        var $donutData = [
                @foreach($top_os as $os_data) 
                {label: "{{$os_data->operating_system}}", value: {{$os_data->count_os}}},

                @endforeach
 
             ];
        this.createDonutChart('morris-donut-example', $donutData, [
            @foreach($top_os as $os_data)
            '{{getRandomColorCode()}}',
            @endforeach]);

        }    


    $.MorrisCharts = new MorrisCharts, $.MorrisCharts.Constructor = MorrisCharts

}(window.jQuery),

//initializing 
function($) {
    "use strict";
    $.MorrisCharts.init();
}(window.jQuery);

    </script>
 
@endsection