@extends('layouts.front.masterapp')

@section('content')
<div class="content-wrapper container"> 
    <div class="page-heading">
        <div class="page-title">
            <div class="row">
                <div class="col-12 col-md-6 order-md-1 order-last">
                    <h3>Data Kartu Pendaftaran</h3>
                    <p class="text-subtitle text-muted">Universitas Negeri Surabaya</p>
                </div>
                <div class="col-12 col-md-6 order-md-2 order-first">
                    <nav aria-label="breadcrumb" class="breadcrumb-header float-start float-lg-end">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="index.html"></a></li>
                          
                        </ol>
                    </nav>
                </div>
            </div>
        </div>

        <!-- // Basic multiple Column Form section start -->
 
    <section id="multiple-column-form">
        <div class="row match-height">
            <div class="col-12">
                <div class="card">
                   
                    <div class="card-content">
                        <div class="card-body">

                        <table class="table table-striped" id="table1">
                            <thead>
                                <tr>	
                                    <th>Periode</th>
                                    <th>Formasi</th>
                                    <th>#</th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                            @foreach($Pendaftaran as $data)

                                <tr>
                                    <td>{{$data->periode->nama}}</td>
                                    <td>{{$data->formasi->nama}}</td>
                                    <td>  <a href="{{ route('kartupendaftaran', ['data' => encrypt($data->id)]) }}"class="btn btn-success me-1 mb-1" target="_blank">Cetak Kartu Pendaftaran</a></td>
                                </tr>

                            @endforeach

                            </tbody>
                           
                        </table>

                     
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

              
    </div>
</div>

@endsection
@push('js')
<script>
       $('.decimal').keyup(function(){
        var val = $(this).val();
        if(isNaN(val)){
        val = val.replace(/[^0-9\.]/g,'');
        if(val.split('.').length>2) 
        val =val.replace(/\.+$/,"");
     }
         $(this).val(val); 
     });

       function memilih(url){
        Swal.fire({
        title: 'Apakah Anda Yakin?',
        text: "Memilih formasi ini!",
        icon: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: 'Ya'
        }).then((result) => {
            if (result.isConfirmed) {
                var token = "{{ csrf_token() }}";
                var request = $.ajax({
                    url : url,
                    type : "GET",
                    dataType : "html",
                    data : {_token: token, _method: 'PUT'},
                    success: function(data){
                        Swal.fire({
                            position: 'top-end',
                            icon: 'success',
                            title: 'Berhasil memilih formasi ini',
                            showConfirmButton: false,
                            timer: 2000
                        });
                        location.reload();
                },
                error: function(data){
                    Swal.fire({
                        position: 'top-end',
                        icon: 'error',
                        title: 'Gagal memilih formasi ini',
                        showConfirmButton: false,
                        timer: 2000
                    })
                }
            })
            }
        })
    }
      
</script>
@endpush