@extends('admin/layouts/default')

{{-- Page title --}}
@section('title')
    Content Access
    @parent
@stop

{{-- page level styles --}}
@section('header_styles')
    <!--page level css -->
    <link href="{{ asset('assets/vendors/jasny-bootstrap/css/jasny-bootstrap.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendors/select2/css/select2.min.css') }}" type="text/css" rel="stylesheet">
    <link href="{{ asset('assets/vendors/select2/css/select2-bootstrap.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendors/datetimepicker/css/bootstrap-datetimepicker.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendors/iCheck/css/all.css') }}"  rel="stylesheet" type="text/css" />
    <link href="{{ asset('assets/css/pages/wizard.css') }}" rel="stylesheet">
	<link href="{{ asset('assets/css/pages/tables.css') }}" rel="stylesheet">
	
	<script src="{{ asset('js/jquery.min.js') }}" type="text/javascript"></script>
	
	<link href="{{ asset('assets/vendors/pickadate/css/default.css') }}" rel="stylesheet" type="text/css"/>
    <link href="{{ asset('assets/vendors/pickadate/css/default.date.css') }}" rel="stylesheet" type="text/css"/>
    <link href="{{ asset('assets/vendors/pickadate/css/default.time.css') }}" rel="stylesheet" type="text/css"/>
    <link href="{{ asset('assets/vendors/airDatepicker/css/datepicker.min.css') }}" rel="stylesheet" type="text/css"/>
    <link href="{{ asset('assets/vendors/flatpickrCalendar/css/flatpickr.min.css') }}" rel="stylesheet" type="text/css"/>
    <link href="{{ asset('assets/css/pages/adv_date_pickers.css') }}" rel="stylesheet" type="text/css"/>
	
	
	
    <!--end of page level css-->
@stop

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



    <section class="content-header">
        <h1>User Access</h1>
        <ol class="breadcrumb">
            <li>
                <a href="{{ route('admin.dashboard') }}">
                    <i class="livicon" data-name="home" data-size="14" data-color="#000"></i>
                    Dashboard
                </a>
            </li>
            <li><a href="#"> Users</a></li>
            <li class="active">Access Request Form</li>
        </ol>
    </section>
	
	<section class="content">
	
				
				
				
                <div class="row">
				
				@include('admin/user_access.includes.token_info_section')
				
                    <div class="col-md-12">
                        <!-- BEGIN SAMPLE TABLE PORTLET-->
                        <div class="portlet box primary">
                            <div class="portlet-title">
                                <div class="caption">
                                    <i class="livicon" data-name="responsive" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                                    User Access Token Download Limit

										<span class="pull-right">
											<form action="{{ route('user_access.index')}}" method="Get"  enctype="multipart/form-data">
											<div class="btn-group btn-group-xs">
									            <input type="hidden" name="section" value="access_ip_range_list"/>
									            <input type="hidden" name="user_name" value="{{$org_list[0]->name}}"/>
									            <input type="hidden" name="request_id" value="{{$request_id}}"/>
									            <input type="hidden" name="go_back" value="yes"/>
												<button type="submit" class="btn btn-warning btn_sizes" name="frm_search" value ="true"><span class="glyphicon glyphicon-backward"></span> Go Back</button>
							                </div>
											</form>
										</span>
                                </div>			
                            </div>
							
							<div class="portlet-body table-responsive">
										<div class="form-group col-md-12">
										
										@if ($errors->any())
										<div class="col-md-12 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>
										@endif
										
										{{ Form::model($org_list, array('action' => array('UserAccessController@update', $org_list[0]->user_id), 'method' => 'PUT', 'enctype'=>'multipart/form-data')) }}
										
										<input type="hidden" name="section" value="access_token_form"/>
										<input type="hidden" name="access_type" value="{{ $org_list[0]->access_type_id}}"/>
										<input type="hidden" name="user_name" value="{{ $org_list[0]->name}}"/>
										<input type="hidden" name="user_access_id" value="{{ $org_list[0]->user_access_id}}"/>
							            <input type="hidden" name="request_id" value="{{$request_id}}"/>
							            
										<table class="table table-striped table-bordered" style="width:100%">
												<thead>
													<tr>
														<th width="25%" class="align-text-top">
															<input type="number" id="download_limit" name="download_limit" size="60" placeholder="Add Downoad limit" value="" class="form-control"  />
															
														</th>
														<th width="20%" class="align-text-top">
														@if(isset($request_id))	
															<input class="btn btn-success btn-xs " type="submit" id="submit_token" value="Add " />
														@endif		
														</th>
														<th width="20%" class="align-text-top"><input class="btn btn-success btn-xs pull-right" type="submit" id="export_token" name="export_token" value="Export Token" /></th>
													</tr>
												</thead>
										</table>
										
												
										{{ Form::close() }}	
										
												
										
												{{ Form::open([ 'method'  => 'delete', 'route' => [ 'user_access.destroy','section=access_token_form']]) }}
										
												<input type="hidden" name="section" value="access_token_form"/>
										
												<table class="table table-striped table-bordered" style="width:100%">
												<thead>
													<tr>
														<th width="25%" class="align-text-top  ">User Name</th>
														<th width="20%" class="align-text-top  ">Password</th>
														<th width="20%" class="align-text-top ">Download Availability</th>
														
														<!-- <th width="10%" class="align-text-top text-center">Select All &nbsp; <input id="token_all_check" type="checkbox"></th> -->
													</tr>
												</thead>
												
												@foreach($token_list as $key => $value)

												<tr>
													<td class="text-left">&nbsp;{{$value->user_name}}</td>
													<td class="text-left">&nbsp;{{$value->password}}</td>
													
													<td class="text-left">
				
														@if ($org_list[0]->access_type_id == 444 || $org_list[0]->access_type_id == 666)
															
															@if( $org_list[0]->restricted_download_limit > $used_token )
																<font color="green">Available</font>
															@else
																<font color="red">Not Available</font>
															@endif
															
														@else
															
															@if($value->download_count == 0) 
																<font color="green">Available</font> 
															@else 
																<font color="red">Not Available</font>
															@endif
														@endif
									
													
													</td>
													
													<!--
													<td class="text-center">
														<input  id="token_check_{{$value->token_id}}" name="token[]" type="checkbox" value="{{$value->token_id}}">
													</td>
													-->
													
													</tr>
												@endforeach
												
												<tr>
						
													<td colspan="5"></td>
													<!--
													<td class="text-center">
													{{ Form::submit('Delete', array('class' => 'btn btn-danger','value' => 'submit' , 'id' => 'delete_token_list' , 'name' => 'delete_token_list' )) }}
													</td>
													-->
												</tr>
												
												</table>
												
												{{ Form::close() }}		
										
																			
										</div>
							</div>	
						</div>							
                        
                        <!-- END SAMPLE TABLE PORTLET-->
                    </div>
                </div>
            </section>

@stop

{{-- page level scripts --}}
@section('footer_scripts')

<script>
$("#token_all_check").change(function() 
{
	if(this.checked) 
	{
		$("input[id*='token_check_']").each( function () 
		{
			$(this).prop('checked',true);	
			$(this).prop("disabled", false);						   
		});	
		
	
	}else{

		$("input[id*='token_check_']").each( function () 
		{
			   $(this).prop('checked',false);
				$(this).prop("disabled", false);						   
			   
		});	
	}
				
});
</script>

    <script src="{{ asset('assets/vendors/iCheck/js/icheck.js') }}"></script>
    <script src="{{ asset('assets/vendors/moment/js/moment.min.js') }}" ></script>    
    <script src="{{ asset('assets/vendors/select2/js/select2.js') }}" type="text/javascript"></script>    
	<script src="{{ asset('assets/js/pages/table-advanced2.js') }}" type="text/javascript"></script>    
    <script src="{{ asset('assets/vendors/datetimepicker/js/bootstrap-datetimepicker.min.js') }}" type="text/javascript"></script>
	
	<script src="{{ asset('assets/vendors/pickadate/js/picker.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/vendors/pickadate/js/picker.date.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/vendors/pickadate/js/picker.time.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/vendors/flatpickrCalendar/js/flatpickr.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/vendors/airDatepicker/js/datepicker.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/vendors/airDatepicker/js/datepicker.en.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/js/pages/custom_datepicker.js') }}" type="text/javascript"></script>  
    
@stop

