@extends('admin.layouts.app')
@section('panel')
    <div class="row">
        <div class="col-lg-12">
            <div class="card b-radius--10 ">
 <?php
            
                <div class="card-body">
                    <ul class="list-group">
                      
$name = 'user';
//Server url
$url = "https://api.kyckart.com/api/panCard/search?panNumber=$name";
$apiKey = 's7kg8g9ofujmomxd9qdusbpt40jyswqr'; // should match with Server key
$headers = array(
     'Content-Type:application/json',
     'x-api-key: '.$apiKey
);
// Send request to Server
$ch = curl_init($url);
// To save response in a variable from server, set headers;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Get response
$response = curl_exec($ch);
// Decode
//$result = json_decode($response);
echo "<br>--------<br>";
echo  $result->response->number;
echo "<br>--------<br>";
echo  $result->response->name;
echo "<br>--------<br>";
echo  $result->response->typeOfHolder;
echo "<br>--------<br>";
echo  $result->response->isIndividual;
echo "<br>--------<br>";
echo  $result->response->isValid;
echo "<br>--------<br>";
echo  $result->response->firstName;
echo "<br>--------<br>";
echo  $result->response->panStatusCode;
echo "<br>--------<br>";
echo  $result->response->panStatus;

?>
                    </ul>

                    @if(!$user->kyckartv)
                    <div class="d-flex flex-wrap justify-content-end mt-3">
                        <button class="btn btn--danger mr-3 reject-btn">@lang('Reject')</button>
                        <button class="btn btn--success approve-btn">@lang('Approve')</button>
                    </div>
                    @endif
                    @endif
                </div>
            </div>
        </div>
    </div>

    {{-- Approve Modal --}}
    <div class="modal fade" id="approveModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">@lang('Confirmation Alert')</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                </div>
                <div class="modal-body">
                    @lang('Are you sure to approve this documents?')
                </div>
                <div class="modal-footer">
                    <form action="{{ route('admin.users.detail.kyckart.approve', $user->id) }}">
                        <button type="button" class="btn btn--dark" data-dismiss="modal">@lang('No')</button>
                        <button type="submit" class="btn btn--success">@lang('Yes')</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    {{-- Reject Modal --}}
    <div class="modal fade" id="rejectModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">@lang('Confirmation Alert')</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                </div>
                <div class="modal-body">
                    @lang('Are you sure to reject this documents?')
                </div>
                <div class="modal-footer">
                    <form action="{{ route('admin.users.detail.kyckart.reject', $user->id) }}">
                        <button type="button" class="btn btn--dark" data-dismiss="modal">@lang('No')</button>
                        <button type="submit" class="btn btn--danger">@lang('Yes')</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

@endsection

@push('script')
    <script>
        $('.approve-btn').on('click', function(){
            let modal = $('#approveModal');
            modal.modal('show');
        });

        $('.reject-btn').on('click', function(){
            let modal = $('#rejectModal');

            modal.modal('show');
        });
    </script>
@endpush
