<div class="col-md-8 mt-xs-5">
          <h2 class="h4 p-3 bg-dark-light text-primary-light"> Token Report </h2> 

          <div class="card bigbox-hvr-slow mt-4">
            <div class="card-body">
              <div class="row">
			  
			 
                <div class="col-sm-5 lead col-8"><strong>Token Used</strong></div>
				
				
				
                <div class="col-sm-3 col-4 text-xs-right"><span class="badge badge-info font-18">{{$used_token_count}}</span></div>
                <div class="col-md-4 text-xs-right pt-xs-2">
                @if($used_token_count>0)
				<a href="#" class="btn btn-dark btn-sm" data-toggle="modal" data-target="#used_token_detail">View Details</a> 
				@endif
								<!-- Modal -->
				<div id="used_token_detail" class="modal fade" role="dialog">
				  <div class="modal-dialog" style="max-width: 80%;">

					<!-- Modal content-->
					<div class="modal-content">
					  <div class="modal-header">
					  <h4 class="modal-title">Restricted User Access Used Tokens Details</h4>
						<button type="button" class="close" data-dismiss="modal">&times;</button>
						
					  </div>
					  <div class="modal-body" style="height:100%; overflow-y:auto;">
						<table class="table table-striped table-bordered">
							<thead>
								<tr>
									<th>Content Access Key:</th>
									<th >Downloaded From:</th>
									<th >Downloaded Content:</th>
									<th >Download Date:</th>
									
								</tr>
							</thead>
							<tbody>

							@foreach($used_token as $key => $val)
								@if($val->content_type=='article' || $val->content_type=='issue' || $val->content_type=='journal_volume')
									@php $content_type = 'article'; @endphp
								@elseif($val->content_type=='chapter')
									@php $content_type = 'chapter'; @endphp
								@elseif($val->content_type=='ebook_volume')
									@if($val->download_content_type=='e')
										@php $content_type = 'ebook_volume'; @endphp
									@elseif($val->download_content_type=='c')
										@php $content_type = 'chapter'; @endphp
									@endif
								@endif
							<tr>
								<td>{{$val->user_name}}</td>
								<td>{{long2ip($val->download_ip)}}</td>
								<td><a class="btn btn-sm btn-info" href="/{{$content_type}}/{{$val->download_content_id}}">View Content</a></td>
								<td>@if($val->download_time){{strftime("%d-%m-%Y",$val->download_time)}}@endif</td>
							</tr>
						
							@endforeach
							
							</tbody>
						</table>
					
					  </div>
					  <div class="modal-footer">
						<button type="button" class="mt-sm-2 mt-xs-0 mt-xl-0 btn btn-outline-dark btn-sm" data-dismiss="modal">Close</button>
					  </div>
					</div>

				  </div>
				</div>
				<!-- Modal End-->
				@if($used_token_count > 0)
				<a href="/home/exporttokenlist/" class="mt-sm-2 mt-xs-0 mt-xl-0 btn btn-outline-dark btn-sm">Export Files</a>
				@else
				<a href="javascript:void(0);" class="mt-sm-2 mt-xs-0 mt-xl-0 btn btn-outline-dark btn-sm"><font color="red">Export Files</font></a>
				@endif
				</div>
				
              </div>
            </div>
          </div>
          <div class="card bigbox-hvr-slow mt-4">
            <div class="card-body">
              <div class="row">
                <div class="col-sm-5 lead col-8"><strong>Available Token</strong></div>
				
				@if($access_user_data->access_type_id == 555)
					<div class="col-sm-3 col-4 text-xs-right"><span class="badge badge-success font-18">{{ $available_token_count}}</span></div>
				@else
					<div class="col-sm-3 col-4 text-xs-right"><span class="badge badge-success font-18">{{ $available_token_count}}</span></div>
				@endif
				
                <div class="col-md-4 text-xs-right pt-xs-2">
				@if($available_token_count>0)
				<a href="#" class="btn btn-dark btn-sm" data-toggle="modal" data-target="#available_token_detail">View Details</a>
				@endif
				
				<!-- Modal -->
				<div id="available_token_detail" class="modal fade" role="dialog">
				  <div class="modal-dialog" style="max-width:80%;">

					<!-- Modal content-->
					<div class="modal-content">
					  <div class="modal-header">
					  <h4 class="modal-title">Restricted User Access Available Tokens Details</h4>
						<button type="button" class="close" data-dismiss="modal">&times;</button>
						
					  </div>
					  <div class="modal-body" style=" height:400px;margin-top: 20px; overflow-y: scroll; padding:10px;">
						<table class="table table-striped table-bordered">
							<thead>
								<tr>
									<th>Content Access Key:</th>
									<th>Password:</th>
									
									<th >Access Assign Date:</th>
									
								</tr>
							</thead>
							<tbody>
							
								@foreach($available_token as $key => $val)
								
								<tr>
									<td>{{$val->available_user_name}}</td>
									<td>{{$val->password}}</td>
									
									<td>{{strftime("%d-%m-%Y",$val->access_assign_date)}}</td>
								</tr>
								
								@endforeach
							
							</tbody>
						</table>
					
					  </div>
					  <div class="modal-footer">
						<button type="button" class="mt-sm-2 mt-xs-0 mt-xl-0 btn btn-outline-dark btn-sm" data-dismiss="modal">Close</button>
					  </div>
					</div>

				  </div>
				</div>
				<!-- Modal End-->
				
				</div>
				
              </div>
            </div>
          </div>
      
          <h2 class="h4 p-3 bg-dark-light text-primary-light mt-4"> Content Access Key </h2>

          <div class="card bigbox-hvr-slow mt-4">
            <div class="card-body">
              <div class="row">
                <div class="col-md-12">
					{{ Form::open(array('url' => 'home/tokenreport','id'=>'tokensearchfrm')) }}
					<input type="hidden" name="_token" value="<?=csrf_token()?>">
                    <div class="form-group row">
                      <label class="col-sm-3 col-form-label"><strong>Enter Access Key</strong></label>
                      <div class="col-sm-9">
                        <div class="input-group mb-3">
							<input type="hidden" name="search" id="searchtk" value="SearchToken" />
                          <input name="user_name" id="user_name" type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
                          <div class="input-group-append">
                            <button class="btn btn-outline-secondary" type="submit">Search</button>                            
                          </div>                          
                        </div>
                        <span id="resToken"></span>
                      </div>
                    </div>
                 {{ Form::close() }}	
                </div>
              </div>
            </div>
          </div>
		  @if(!empty($SearchToken))
		  <div class="card bigbox-hvr-slow mt-4">
            <div class="card-body">
           
				<div class="form-group col-md-12">
				<h4>Search Result:</h4>
				<hr>
				@if(!empty($SearchToken))
					<div class="form-row col-md-12"><b>Content Access Key&nbsp;:&nbsp;</b> {{$SearchToken[0]}} </div>
					<div class="form-row col-md-12"><b>Status&nbsp;:&nbsp;</b>{{$SearchToken[1]}}</div>
				@endif
				
				</div>
            
            </div>
          </div>
		  @endif
        </div>
<script type="text/javascript">

	    jQuery( document ).ready( function( $ ) {

		    $( '#tokensearchfrm' ).on( 'submit', function(e) {
		        e.preventDefault();

		        var name = $(this).find('input[id=searchtk]').val();
		        var user_name = $(this).find('input[id=user_name]').val();
		        var _token = $(this).find('input[name=_token]').val();
		        
		        $.ajax({
			        type: "POST",
			        url: '/home/tokenreport',
			        data: { search:name, _token:_token,user_name:user_name }, 
			        success: function( msg ) {

			        	if(msg[1]=='Available'){
			        		$('#resToken').addClass('text-success')	;
			        		$('#resToken').removeClass('text-danger')	;
			        	}else{
			        		$('#resToken').removeClass('text-success')	;
			        		$('#resToken').addClass('text-danger')	;
			        	}
			            $('#resToken').html( msg[1] );

			        }
			    });

		    });
		});
  

</script>