@extends('backend.layouts.master')
@section('title')
    Bank Management
@endsection
@section('css')

@endsection
<!-- page content -->
@section('content')
    <div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            @if(Session::has('success'))
                <div class="alert alert-success">
                    {{ Session::get('success') }}
                </div>
            @endif
            @if(Session::has('error'))
                <div class="alert alert-danger">
                    {{ Session::get('error') }}
                </div>
            @endif
            <div class="row">
                <div class="col-md-8 col-sm-8 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>Bank Management</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                       aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
						<div class="row search-section">
							<form action="{{route('bank.list')}}" id="searchForm" method="Get">
								<div class="col-sm-2">
									<select class="form-control" name="show" id="show">
										<option value="{{$banks->count()}}">{{$banks->count()}}</option>
										<option value="10">10</option>
										<option value="25">25</option>
										<option value="50">50</option>
										<option value="100">100</option>
										<option value="250">250</option>
										<option value="500">500</option>
									</select>
								</div>
								<div class="col-sm-5"></div>
								<div class="col-sm-5">
									<div class="input-group">
										<input type="text" id="myInput" class="form-control input-s" placeholder="Search">
										<span class="input-group-btn">
											<button type="button" class="btn btn-purple">
											<span class="ace-icon fa fa-search icon-on-right bigger-110"></span></button>
										</span>
									</div>
								</div>
							</form> 
						</div>
						<div class="table-content">
							<table id="" class="table table-bordered condensed" role="grid" aria-describedby="dynamic-table_info">
								<thead>
									<tr>
										<th>SL</th>
										<th>Bank Name</th>
										<th>Branch Name</th>
										<th>Account No</th>
										<th>Bank Location</th>
										<th>Action</th>
									</tr>
								</thead>
								<tbody>
									@foreach($banks as $key=>$bran)
										<tr>
											<td>{{$key + 1}}</td>
											<td><a href="{{route('transaction.show',$bran->id)}}">{{$bran->bank_name}}</a></td>
											<td>{{$bran->branch_name}}</td>
											<td>{{$bran->account_no}}</td>
											<td>{{$bran->bank_location}}</td>
											<td>
											
												<a  href="{{route('bank.edit',$bran->id)}}" title="Edit Bank Information"><i class="ace-icon fa fa-edit bigger-130"></i></a>
											
											@can('bank-name-delete')
												<a  class="red" href="#" data-toggle="tooltip" title="Delete Bank Information!" onclick="deleteCategory({{ $bran->id }})"><i class="fa fa-trash-o bigger-130" ></i></a>
												<form id="delete-form-{{ $bran->id }}" action="{{ route('bank.delete',$bran->id) }}" method="POST" style="display: none;">
													@csrf
													@method('DELETE')
												</form> 
											@endcan
											</td>
										</tr>
									@endforeach
								</tbody>
							</table>
							<div class="text-center">
								{{$banks->links()}}
							</div>
						</div>
                    </div>
                    </div>
                </div>
				<div class="col-xs-4 col-sm-4 col-xs-12">
					<div class="x_panel">
                        <div class="x_title">
                            <h2>Bank Information Edit</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                       aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
							<form action="{{route('bank.update',$bank->id)}}" method="post" class="form-horizontal" role="form" >
									{{ csrf_field()}}
								<div class="form-group">
									<label class="col-sm-4 control-label no-padding-right" for="form-field-1"> Bank Name <span class="red">*</span></label>
									<div class="col-sm-8">
										<input type="text" name="bank_name"  class="form-control input-sm"  value="{{ old('bank_name') ?? $bank->bank_name}}" placeholder=" Bank Name">
										<p class="error-sms">{{ $errors->first('bank_name') }}</p>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label no-padding-right" for="form-field-1-1">Account No <span class="red">*</span></label>
									<div class="col-sm-8">
										<input type="text" id="form-field-1-1" name="account_no" value="{{old('account_no') ?? $bank->account_no}}" placeholder="Bank Account No" class="form-control input-sm">
										<p class="error-sms">{{ $errors->first('account_no') }}</p>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label no-padding-right" for="form-field-1-1">Branch Name <span class="red">*</span></label>
									<div class="col-sm-8">
										<input type="text" id="form-field-1-1" name="branch_name" value="{{old('branch_name') ?? $bank->bank_name}}" placeholder="Branch Name" class="form-control input-sm">
										<p class="error-sms">{{ $errors->first('branch_name') }}</p>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label no-padding-right" for="form-field-1-1">Location </label>
									<div class="col-sm-8">
										<input type="text" id="form-field-1-1" name="bank_location" value="{{old('bank_location') ?? $bank->bank_location}}" placeholder="Branch Location" class="form-control input-sm">
										<p class="error-sms">{{ $errors->first('bank_location') }}</p>
									</div>
								</div>
								<div class="form-group">
									<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-5">
									<button class="btn btn-warning" type="reset">Reset</button>
									<button type="submit" class="btn  btn-success">Update</button>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
@endsection

@push('js')
<script>
	$(document).ready(function(){
		
		 
	})
	
	function deleteCategory(id) {
		var conf = confirm('Do you want to really Delete?');
		  if(conf == true)
		  {
			document.getElementById('delete-form-'+id).submit();
		  }
        }
	</script>
@endpush									