{{-- Extends layout --}}
@extends('layout.default')
{{-- Content --}}
@section('content')

<div class="card card-custom">
    <div class="card-header flex-wrap border-0 pt-6 pb-0">
        <div class="card-title">
            <h3 class="card-label">My Certificates
            </h3>
        </div>
        <div class="card-toolbar">
        </div>
    </div>
    <div class="card-body">
        <table class="table table-bordered table-hover" id="batch1">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Instructor</th>
                    <th>Batch</th>
                    <th>Download</th>

                </tr>
            </thead>
            <tbody>
                @foreach ($batches as $row)
                <tr>
                    <td> <span class="text-dark-75 font-weight-bolder d-block font-size-lg">{{ $row ->participant_name }}</span>
                    </td>
                    <td><span class="text-dark-75 font-weight-bolder d-block font-size-lg">{{ $row ->FirstName }}</span><span class="text-muted font-weight-bold">{{ $row ->subject }}</span></td>
                    <td>{{ $row ->name }}</td>
                    <td>
                        <form method="post" id="frm{{$row->scid }}" action="{{ route('downloadcertificate') }}" class="form-horizontal">
                            @csrf
                            @method('POST')
                            <input type="hidden" name="bid" value="{{$row->scid }}">
                            <input type="hidden" id="participantid{{$row->scid }}" name="participantid{{$row->scid }}" value="{{ $row ->participant_name }}">
                            <input type="hidden" id="subject{{$row->scid }}" name="subject{{$row->scid }}" value="{{ $row ->name }}">
                          
                            <input type="submit" name="submit" value="Certificate" class="btn btn-primary btn-sm btn-block team">                
                           
                           
                        </form>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>
@endsection
{{-- Styles Section --}}
@section('styles')
<link href="{{ asset('plugins/custom/datatables/datatables.bundle.css') }}" rel="stylesheet" type="text/css" />
@endsection
{{-- Scripts Section --}}
@section('scripts')
{{-- vendors --}}
<script type="text/javascript">
    $(document).ready(function() {
        // $.ajaxSetup({
        //     headers: {
        //         'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        //     }
        // });
        // $(".team").click(function(e) {
        //     e.preventDefault();
        //     btnval = $(this).val();
        //     let name = document.getElementById("participantid" + btnval);
        //     let subject = document.getElementById("subject" + btnval);
        //     var y = document.getElementById("dvmsg" + btnval);
        //     y.innerHTML = 'Processing....Please wait.';
        //     document.getElementById("dvbtn" + btnval).style.display = 'none';
        //     //alert(name);
        //     $.ajax({
        //         type: "POST",
        //         url: "{{ url('downloadcertificate') }}",
        //         data: {                   
        //             'participantid': name,
        //             'subject': subject
        //         },
        //         success: function(result) {
                   
        //             if (result != "") {
        //                 document.getElementById("dvimg" + btnval).style.display = 'block';
        //                 document.getElementById('lnk' + btnval).href = result;
        //                 document.getElementById('img' + btnval).src = result;
        //             }
        //         },
        //         error: function(result) {
        //             alert('error');
        //         }
        //     });

        // });
    });
</script>
<script src="{{ asset('plugins/custom/datatables/datatables.bundle.js') }}" type="text/javascript"></script>

{{-- page scripts --}}
<script src="{{ asset('js/app.js') }}" type="text/javascript"></script>
@endsection