@extends('layouts.member')
@section('content')


    @if(count($ad))

        <div class="row">
            <div class="col-md-12">
                <div class="portlet light bordered">
                    <div class="portlet-title">
                        <div class="caption font-dark">
                            <div class="row" style="margin-left: 100px;">
                                <div class="col-md-12">
                                    {!! Form::model($ad,['route'=>['advert-confirm',$ad->id],'method'=>'put','class'=>'form-inline']) !!}
                                    <div class="form-group">
                                        <label for="exampleInputName2">First Number : </label>
                                        <input style="width:35px" name="num1" value="@php echo rand(0,9); @endphp" type="text" class="form-control" id="exampleInputName2" placeholder="" readonly>
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputEmail2">Second Number : </label>
                                        <input style="width:35px" name="num2" value="@php echo rand(0,9); @endphp" type="text" class="form-control" id="exampleInputEmail2" placeholder="" readonly>
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputEmail2">Summation : </label>
                                        <input name="result" type="number" class="form-control" id="exampleInputEmail2" placeholder="First + Second" required>
                                    </div>
                                    <div class="form-group">
                                        <button type="submit" id="btn-submit" class="btn btn-primary"><i class="fa fa-check"></i> Confirm View</button>
                                    </div>

                                    {!! Form::close() !!}
                                </div>
                            </div>
                        </div>
                        <div class="tools"> </div>
                    </div>
                    <div class="portlet-body">

                        <div class="text-center">
                            <h3>{{ $ad->advertisement->title }}</h3>
                        </div>
                        <hr>
                        <div class="text-center">
                            <iframe src="{{ $ad->advertisement->link }}" width="100%" height="500px" seamless></iframe>
                        </div>
                        <br>

                    </div>
                </div>

            </div>
        </div><!-- ROW-->

    @else

        <div class="text-center">
            <h3>No Data available</h3>
        </div>
    @endif


@endsection
@section('scripts')

    <script>

        $('#btn-submit').on('click',function(e){
            e.preventDefault();
            var form = $(this).parents('form');
            swal({
                title: "Are you Sure?",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "Yes. Sure..!",
                cancelButtonText: "No. Cancel..!",
                closeOnConfirm: false,
                closeOnCancel: false
            }, function(isConfirm){
                if (isConfirm){
                    form.submit();
                } else {
                    swal("Cancelled", "Advertisement View Not Confirm.", "error");
                }
            });

        });

    </script>




@endsection


