@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.access_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>
                                    Add Organization User & IP 

										<span class="pull-right">
											<form action="{{ route('user_access.index')}}" method="Get"  enctype="multipart/form-data">											@csrf
											<div class="btn-group btn-group-xs">
									            <input type="hidden" name="section" value="access_ip_range_list"/>
									            <input type="hidden" name="user_name" value="{{$user_access->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">
					
										<hr>
									<div class="form-row col-md-12">
										<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
										
						@if(isset($request_id))							<form method="POST" action="{{ action('UserAccessController@update', ['user_access_id' => $user_access->user_access_id]) }}" enctype="multipart/form-data">								@method('PUT')								@csrf
						
			                    <input type="hidden" name="user_id" value="{{$user_access->user_id}}"/>
			                    <input type="hidden" name="access_org_id" value="{{$user_access->access_org_id}}"/>
			                    <input type="hidden" name="request_id" value="{{$request_id}}"/>
			                    <input type="hidden" name="section" value="access_ip_range_form"/>
					
												<table class="table table-striped table-bordered" style="width:100%">
												<thead>
													<tr>
														
														<th width="40%" class="align-text-top text-center ">Ip Range Start From</th>
														<th width="40%" class="align-text-top text-center ">Ip Range End To</th>
														<th width="20%" class="align-text-top text-center ">Action</th>
													</tr>
												</thead>
												
												<tr>
													<td class="text-left">
														<input type="text" id="ip_range_from" name="ip_range_from" size="60" placeholder="From" value="{{old('ip_range_from')}}" class="form-control" required = 'required' onkeyup="validate_ip();"  />
														<label id="lbl_ip_range_from" class="text-danger">
														@if($errors->first('ip_range_from'))
															<label class="text-danger">{{$errors->first('ip_range_from')}}</label>
														@endif
													</td>
														
													<td class="text-center">
														<input type="text" id="ip_range_to" name="ip_range_to" size="60" placeholder="To" value="{{old('ip_range_to')}}" class="form-control" required = 'required' onkeyup="validate_ip();" />
														<label id="lbl_ip_range_to" class="text-danger"></label>
													</td>
													<td class="text-center">
														<input class="btn btn-success btn-xs " type="submit" id="add_ip" value="Add Ip Range" disabled="disabled" />
													</td>
												</tr>
												
												</table>
												
												</form>		
						@endif						
												@if(isset($user_ip_range))
																								<form method="POST" action="{{ route('user_access.destroy', ['section' => 'access_ip_range_form']) }}">								@csrf

							                    <input type="hidden" name="request_id" value="{{$request_id}}"/>
												<input type="hidden" name="section" value="access_ip_range_form"/>
												
												<table class="table table-striped table-bordered" style="width:100%">
												<thead>
													<tr>
														<th width="2%" class="align-text-top text-center ">No</th>
														<th colspan="2" width="38%" class="align-text-top text-center ">IP Range</th>
														<th width="20%" class="align-text-top text-center ">Date</th>
														<th width="20%" class="align-text-top text-center ">Provided By</th>
														@if(isset($request_id))
														<th width="20%" class="align-text-top text-center ">Delete &nbsp; <input id="ip_all_check" type="checkbox"></th>
														@endif
													</tr>
												</thead>
												
												@foreach($user_ip_range as $key => $value)

												<tr>
												<td class="text-center">{{$key+1}}</td>
												<td class="text-left">&nbsp;{{long2ip($value->from_ip)}}</td>
												<td class="text-left">&nbsp;{{long2ip($value->to_ip)}}</td>
												<td class="text-center">{{strftime("%d-%B-%Y (%X)",$value->system_time)}}</td>
												<td class="text-center">{{$value->name}}</td>
												@if(isset($request_id))
												<td class="text-center">
													<input  id="ip_check_{{ $value->ip_range_id }}" name="ip_range[]" type="checkbox" value="{{$value->ip_range_id}}">
												</td>
												@endif
												

												@endforeach
												
												@if(isset($request_id))	
												<tr>
												<td colspan="5" class="text-center"></td>
												<td class="text-center">
													
													<button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#delete_ip"><i class="livicon" data-name="trash" data-loop="true" data-color="#fff" data-hovercolor="white" data-size="14"></i>DELETE</button>
													
														<!-- Modal -->
														<div class="modal fade" id="delete_ip" role="dialog">
														<div class="modal-dialog">

															<!-- Modal content-->
															<div class="modal-content">
															<div class="modal-header">
															<button type="button" class="close" data-dismiss="modal">&times;</button>
															<h4 class="modal-title">Warning</h4>
															</div>
															<div class="modal-body">
															<p>Do you really want to delete Selected Ip Range: <br><br>
															
															</p>
															</div>
																<div class="modal-footer">
																	<button type="submit" class="btn btn-danger">Delete</button>
																<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
															
															</div>
															</div>

														</div>
														</div>
												</td>
												</tr>
												@endif
												</table>
												
												</form>
												
												@endif


										</div>
									</div>		
							</div>	
						</div>							
                        
                        <!-- END SAMPLE TABLE PORTLET-->
                    </div>
                </div>
            </section>

@stop

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


<script>
$(function()
{
$("#ip_all_check").change(function() 
{

	if(this.checked) 
	{
	
		$("input[id*='ip_check']").each( function () 
		{
			$(this).prop('checked',true);	
			$(this).prop("disabled", false);						   
		});	
		
	
	}else{

		$("input[id*='ip_check']").each( function () 
		{
			   $(this).prop('checked',false);
				$(this).prop("disabled", false);						   
			   
		});	
	}
				
});	
});
</script>
	<script src="{!! asset('js/user_access.js') !!}"></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

