<div class="col card--ui" id="card--dashboard">

    <header id="title--section" style="display:none !important"
        class="d-flex align-items-center justify-content-between">
        <div class="title--section_name d-flex align-items-center justify-content-between">
            <i class="ico--ui title_section utenti me-2"></i>
            <h2 class="primary">Rate</h2>
        </div>
    </header>

    @if ($rate_from == 'course')
    <a class="btn--ui lightGrey" href="/course_member?id={{$mc->course_id}}"><i class="fa-solid fa-arrow-left"></i></a><br>
    @elseif($rate_from == 'subscription')
    <a class="btn--ui lightGrey" href="/subscription_member/{{$ms->subscription_id}}"><i class="fa-solid fa-arrow-left"></i></a><br>
    @endif

    <div class="showFilter" style="display:none" wire:ignore.self>
        <hr size="1">
        <div class="row g-3">
            <div class="col-md-2">
                <div class="row">
                    <div class="col-md-12" style="margin-bottom:10px;">
                        <b>Periodo</b>
                    </div>
                    <div class="col-12 mb-2">
                        <input id="dateFrom" type="date" class="form-control filterFrom" name="txtFrom">
                    </div>
                    <div class="col-12">
                        <input id="dateTo" type="date" class="form-control filterTo" name="txtTo">
                    </div>
                    <div class="col-6 mt-2">
                        <button class="btn--ui lightGrey todayButton" style="width:100%"
                            onclick="setToday('{{date("Y-m-d")}}')">OGGI</button>
                    </div>
                    <div class="col-6 mt-2">
                        <button class="btn--ui lightGrey yesterdayButton" style="width:100%"
                            onclick="setYesterday('{{date("Y-m-d", strtotime("-1 days"))}}')">IERI</button>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="row">
                    <div class="col-md-12" style="margin-bottom:10px;">
                        <b>Stato</b>
                    </div>
                    <div class="col-12">
                        <select class="form-select filterStatus">
                            <option value="">--Seleziona--
                            <option value="1">Attiva
                            <option value="99">Annullata
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="row">
                    <div class="col-md-12" style="margin-bottom:10px;">
                        <b>Cerca Utente</b>
                    </div>
                    <div class="col-12">
                        <select class="form-select filterMember" wire:model="filteredMemberId">
                            <option value="">--Seleziona Utente--</option>
                            @foreach($members as $member)
                                <option value="{{ $member->id }}">{{ $member->last_name }} {{ $member->first_name }}
                                </option>
                            @endforeach
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row g-3">
            <div class="col-md-12" style="text-align:right">
                <button class="btn--ui_outline light" onclick="reset()">RESET</button>
                <button class="btn--ui" onclick="loadDataTable()">FILTRA</button>
            </div>
        </div>
        <hr size="1">
    </div>

    <section id="resume-table">
        <div class="compare--chart_wrapper d-none"></div>

        <div class="row">
            <div class="col-6">
                <h3>{!!$detail!!}</h3>
            </div>
            <div class="col right table-actions" style="text-align: right">
                <button id="btPay" style="display:none;" class="btn" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Crea tutte le entrate"><i class="fa-regular fa-file-text"></i></button>
                <button id="btSuspend" style="display:none;" class="btn" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Sospendi/Riattiva tutto"><i class="fa-solid fa-ban"></i></button>
                <button id="btRemove" style="display:none;" class="btn" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina tutto"><i class="fa-regular fa-trash-can"></i></button>
            </div>
        </div>
        

        <table class="table tablesaw tableHead tablesaw-stack table--lista_ricevute" id="tablesaw-350" width="100%">
            <thead>
                <tr>
                    <th scope="col"><input type="checkbox" name="chkAll" class="chkAll"></th>
                    <th scope="col">Data scadenza</th>
                    <th scope="col">Pagamento</th>
                    <th scope="col">Mesi</th>
                    <th scope="col">Prezzo</th>
                    <th scope="col" style="text-align:center">Stato pagamento</th>
                    <th scope="col">...</th>
                </tr>
            </thead>
            <tbody id="checkall-target">
                @foreach($records as $record)
                    <tr>
                        <td>
                            @if($record->status == 0 || $record->status == 2)
                                <input type="checkbox" name="chk{{$record->id}}" value="{{$record->id}}" class="chkIds">
                            @endif
                        </td>
                        <td>{{date("d/m/Y", strtotime($record->date))}}</td>
                        <td>{{$record->course_subscription ? $record->course_subscription->name : 'Iscrizione'}}</td>
                        <td>
                            @if(sizeof(json_decode($record->months)) > 1)
                                {{getMonthName(json_decode($record->months)[0])}} - {{getMonthName(json_decode($record->months)[sizeof(json_decode($record->months)) - 1])}}
                            @else
                                @if(sizeof(json_decode($record->months)) > 0)
                                    {{getMonthName(json_decode($record->months)[0])}}
                                @endif
                            @endif
                        </td>
                        <td>{{formatPrice($record->price)}}</td>
                        <td  style="text-align:center">
                            <span class="tablesaw-cell-content" >
                                <span class="badge tessera-badge {{$record->status == 0 ? 'due' : ($record->status == 1 ? 'active' : 'suspended')}}">{{$record->status == 0 ? 'Da pagare' : ($record->status == 1 ? 'Pagato' : 'Sospeso')}}</span>
                            </span>
                        </td>
                        <td>
                            @if($record->status == 1)
                                <button type="button" class="btn u"
                                    onclick="document.location.href='/in?id={{$record->record_id}}'" data-bs-toggle="popover"
                                    data-bs-trigger="hover focus" data-bs-placement="bottom"
                                    data-bs-content="Visualizza ricevuta"><i class="fa-regular fa-eye"></i></button>
                            @endif
                            @if($record->status == 0)

                                <input type="hidden" id="memberId_{{$record->id}}" value="{{$record->member_id}}">
                                <input type="hidden" id="createSubscription_{{$record->id}}" value="{{$record->is_subscription ? '1' : ''}}">
                                <input type="hidden" id="months_{{$record->id}}" value="{{implode("|", json_decode($record->months))}}">
                                <input type="hidden" id="price_{{$record->id}}" value="{{!$record->is_subscription ? $record->price : ''}}">
                                <input type="hidden" id="subscription_price_{{$record->id}}" value="{{$record->is_subscription ? $record->price : ''}}">
                                <input type="hidden" id="rateId_{{$record->id}}" value="{{$record->id}}">

                                @if ($rate_from == 'course')
                                <input type="hidden" id="courseId_{{$record->id}}" value="{{$record->member_course_id}}">
                                <input type="hidden" id="subscriptionId_{{$record->id}}" value="0">
                                <input type="hidden" id="causalId_{{$record->id}}" value="{{!$record->is_subscription ? $record->member_course->course->causal_id : ''}}">
                                <input type="hidden" id="subCausalId_{{$record->id}}" value="{{$record->is_subscription ? $record->member_course->course->sub_causal_id : ''}}">

                                <a class="btn  u" href="/in?new=1&memberId={{$record->member_id}}&causalId={{!$record->is_subscription ? $record->member_course->course->causal_id : ''}}&subCausalId={{$record->is_subscription ? $record->member_course->course->sub_causal_id : ''}}&createSubscription={{$record->is_subscription ? '1' : ''}}&months={{implode("|", json_decode($record->months))}}&price={{!$record->is_subscription ? $record->price : ''}}&subscription_price={{$record->is_subscription ? $record->price : ''}}&courseId={{$record->member_course_id}}&subscriptionId=0&rateId={{$record->id}}&backToRates" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Crea entrata"><i class="fa-regular fa-file-lines"></i></a>
                                @elseif($rate_from == 'subscription')
                                <input type="hidden" id="courseId_{{$record->id}}" value="0">
                                <input type="hidden" id="subscriptionId_{{$record->id}}" value="{{$record->member_subscription_id}}">
                                <input type="hidden" id="causalId_{{$record->id}}" value="{{!$record->is_subscription ? $record->member_subscription->subscription->causal_id : ''}}">
                                <input type="hidden" id="subCausalId_{{$record->id}}" value="{{$record->is_subscription ? $record->member_subscription->subscription->sub_causal_id : ''}}">

                                <a class="btn  u" href="/in?new=1&memberId={{$record->member_id}}&causalId={{!$record->is_subscription ? $record->member_subscription->subscription->causal_id : ''}}&subCausalId={{$record->is_subscription ? $record->member_subscription->subscription->sub_causal_id : ''}}&createSubscription={{$record->is_subscription ? '1' : ''}}&months={{implode("|", json_decode($record->months))}}&price={{!$record->is_subscription ? $record->price : ''}}&subscription_price={{$record->is_subscription ? $record->price : ''}}&courseId=0&subscriptionId={{$record->member_subscription_id}}&rateId={{$record->id}}&backToRates" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Crea entrata"><i class="fa-regular fa-file-lines"></i></a>
                                @endif

                                <a class="btn u" onclick="confirmDelete({{$record->id}})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>
                            @endif
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>

    </section>

    <div  wire:ignore.self class="modal" id="rateModal" tabindex="-1" aria-labelledby="rateModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header modal-header-blu">
                    <h5 class="modal-title" id="rateModalLabel">Inserimento nuova rata</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6">
                            <label for="course_subscription_id" class="form-label">Pagamento</label>
                            <select id="course_subscription_id" class="form-select  @error('course_subscription_id') is-invalid @enderror" aria-label="Pagamento" wire:model="course_subscription_id">
                                <option value="">
                                @foreach($course_subscriptions as $t)
                                    <option value="{{$t["id"]}}">{{$t["name"]}}
                                @endforeach
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label for="price" class="form-label">Prezzo</label>
                            <input class="form-control" type="text" id="price" placeholder="Costo" wire:model="price" onkeyup="onlyNumberAmount(this)">
                        </div>
                    </div>
                    <div class="row mt-2">
                        <div class="col-md-6">
                            <label for="date" class="form-label">Scadenza</label>
                            <input class="form-control @error('date') is-invalid @enderror" type="date" id="date" placeholder="Email" wire:model="date">
                        </div>
                        @if($type == '1')
                            <div class="col-md-6">
                                <label for="date" class="form-label">Mese</label>
                                <select class="form-control" id="month"  wire:model="month">
                                    <option value=""></option>
                                    @if(!in_array(9, $disabled))<option value="9">Settembre</option>@endif
                                    @if(!in_array(10, $disabled))<option value="10">Ottobre</option>@endif
                                    @if(!in_array(11, $disabled))<option value="11">Novembre</option>@endif
                                    @if(!in_array(12, $disabled))<option value="12">Dicembre</option>@endif
                                    @if(!in_array(1, $disabled))<option value="1">Gennaio</option>@endif
                                    @if(!in_array(2, $disabled))<option value="2">Febbraio</option>@endif
                                    @if(!in_array(3, $disabled))<option value="3">Marzo</option>@endif
                                    @if(!in_array(4, $disabled))<option value="4">Aprile</option>@endif
                                    @if(!in_array(5, $disabled))<option value="5">Maggio</option>@endif
                                    @if(!in_array(6, $disabled))<option value="6">Giugno</option>@endif
                                    @if(!in_array(7, $disabled))<option value="7">Luglio</option>@endif
                                    @if(!in_array(8, $disabled))<option value="8">Agosto</option>@endif
                                </select>
                            </div>
                        @endif
                    </div>
                    @if($type > 1)
                        <div class="row mt-2">
                            <div class="col-md-12">
                                <label for="months" class="form-label">Seleziona i Mesi</label><br>
                                <div class="row">
                                    @if(!in_array(9, $disabled))<div class="col-3"><input type="checkbox"  value="9" class="chkMonth">&nbsp;Settembre</div>@endif
                                    @if(!in_array(10, $disabled))<div class="col-3"><input type="checkbox"  value="10" class="chkMonth">&nbsp;Ottobre</div>@endif
                                    @if(!in_array(11, $disabled))<div class="col-3"><input type="checkbox"  value="11" class="chkMonth">&nbsp;Novembre</div>@endif
                                    @if(!in_array(12, $disabled))<div class="col-3"><input type="checkbox"  value="12" class="chkMonth">&nbsp;Dicembre</div>@endif
                                    @if(!in_array(1, $disabled))<div class="col-3"><input type="checkbox"  value="1" class="chkMonth">&nbsp;Gennaio</div>@endif
                                    @if(!in_array(2, $disabled))<div class="col-3"><input type="checkbox"  value="2" class="chkMonth">&nbsp;Febbraio</div>@endif
                                    @if(!in_array(3, $disabled))<div class="col-3"><input type="checkbox"  value="3" class="chkMonth">&nbsp;Marzo</div>@endif
                                    @if(!in_array(4, $disabled))<div class="col-3"><input type="checkbox"  value="4" class="chkMonth">&nbsp;Aprile</div>@endif
                                    @if(!in_array(5, $disabled))<div class="col-3"><input type="checkbox"  value="5" class="chkMonth">&nbsp;Maggio</div>@endif
                                    @if(!in_array(6, $disabled))<div class="col-3"><input type="checkbox"  value="6" class="chkMonth">&nbsp;Giugno</div>@endif
                                    @if(!in_array(7, $disabled))<div class="col-3"><input type="checkbox"  value="7" class="chkMonth">&nbsp;Luglio</div>@endif
                                    @if(!in_array(8, $disabled))<div class="col-3"><input type="checkbox"  value="8" class="chkMonth">&nbsp;Agosto </div>@endif                 
                                </div>
                            </div>
                        </div>
                    @endif
                    
                    <span style="color:red">{{$errorMsg}}</span>
                </div>
                <div class="modal-footer mt-2">
                    <button class="btn--ui lightGrey" onclick="annulla()">annulla</a>
                    <button type="button" class="btn--ui btn-primary" wire:click.prevent="add()">Inserisci</button>
                </div>
            </div>
        </div>
    </div>

</div>


@push('scripts')
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <style>
        .select2-container--default .select2-selection--single {
            background-color: #E9F0F5;
            border: 0.0625rem solid #DFE5EB;
            font-size: 0.75rem;
        }

        .select2-selection {
            height: 38px !important;
        }

        .select2-selection__rendered {
            padding-top: 3px;
        }

        .select2 {
            width: 100% !important;
        }
    </style>
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"
        integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
@endpush

@push('scripts')
    <link href="/css/datatables.css" rel="stylesheet" />
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"
        integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>


    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <style>
        .select2-container--default .select2-selection--single {
            background-color: #E9F0F5;
            border: 0.0625rem solid #DFE5EB;
            font-size: 0.75rem;
        }

        .select2-selection {
            height: 38px !important;
        }

        .select2-selection__rendered {
            padding-top: 3px;
        }

        .select2 {
            width: 100% !important;
        }

        .select2-selection--multiple {
            overflow: hidden !important;
            height: auto !important;
        }

        .select2-container {
            box-sizing: border-box;
            display: inline-block;
            margin: 0;
            position: relative;
            vertical-align: middle;
        }

        .select2-container .select2-selection--single {
            box-sizing: border-box;
            cursor: pointer;
            display: block;
            height: 38px;
            user-select: none;
            -webkit-user-select: none;
        }

        .select2-container .select2-selection--single .select2-selection__rendered {
            display: block;
            padding-left: 8px;
            padding-right: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .select2-selection__choice__display {
            color: #000000 !important;
        }
    </style>
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"
        integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
    <script src="/assets/js/datatables.js"></script>
    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
@endpush

@push('scripts')
    <script>

        function annulla()
        {
            $('.btn-close').trigger('click') ;
            setTimeout(() => {
                location.reload();    
            }, 200);                
        }

        function confirmDelete(id)
        {
            if (confirm('Confermi di voler eliminare la rata?'))
            {
                @this.delete(id);
                setTimeout(() => {
                    location.reload();    
                }, 200);                
            }
        }

        $(document).ready(function() {
            loadDataTable();

            $(document).on("click", ".chkMonth", function(event){
                let val = ($(this).val());      
                @this.addDeleteMonth(val);
            }); 

            $('.monthsSelect').select2({
                
            });
            $('.monthsSelect').on('change', function (e) {
                var data = $('.monthsSelect').select2("val");
                @this.set('months', data);
                setTimeout(function() { 
                    $('.monthsSelect').select2({                
                    });
                }, 100);                
            });

        } );

        Livewire.on('close-popup', () => {
            annulla();            
        });

        Livewire.on('load-data-table', () => {
            loadDataTable();
        });

        function loadDataTable(){
            let date = new Date();
            let date_export = `${date.getFullYear()}${date.getMonth() + 1}${date.getDate()}_`;

            if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
                $('#tablesaw-350').DataTable().destroy();
            }
            $('#tablesaw-350').DataTable({
                processing: true,
                stateSave: true,
                thead: {
                'th': {'background-color': 'blue'}
                },
                layout: {
                    topStart : null,
                    topEnd : null,
                    top1A: {
                        // buttons: [
                        //     {
                        //         extend: 'collection',
                        //         text: 'ESPORTA',
                                buttons: [
                                    {
                                        extend: 'excelHtml5',
                                        text: '<i class="fa-solid fa-file-excel"></i>',
                                        action: newexportaction,
                                        title: date_export + 'Rate',
                                        filename: date_export + 'Rate',
                                        exportOptions: {
                                            columns: ":not(':last')"
                                        }
                                    },
                                    {
                                        extend: 'pdfHtml5',
                                        text: '<i class="fa-solid fa-file-pdf"></i>',
                                        action: newexportaction,
                                        title: date_export + 'Rate',
                                        filename: date_export + 'Rate',
                                        exportOptions: {
                                            columns: ":not(':last')"
                                        }
                                    },
                                    {
                                        extend: 'print',
                                        action: newexportaction,
                                        text: '<i class="fa-solid fa-print"></i>',
                                        title: date_export + 'Rate',
                                        filename: date_export + 'Rate',
                                        exportOptions: {
                                            columns: ":not(':last')"
                                        }
                                    }
                                ],
                        //         dropup: true
                        //     }
                        // ]
                    },
                    top1B : {
                        pageLength: {
                            menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
                        }
                    },
                    top1C :'search',
                    bottomEnd: {
                        paging: {
                            boundaryNumbers: false
                        }
                    }
                },
                pagingType: 'first_last_numbers',
                language: {
                    "url": "/assets/js/Italian.json",
                    paginate: {
                        first: '<i class="fa-solid fa-angles-left"></i>',
                        last: '<i class="fa-solid fa-angles-right"></i>',
                    }
                },
                "fnInitComplete": function (oSettings, json) {
                    var html = '&nbsp;<a href="#" data-bs-toggle="modal" data-bs-target="#rateModal" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
                    $(".dt-search").append(html);
                }
            });
            $('#tablesaw-350 thead tr th').addClass('col');
            $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");

            var checked = false;

            $(document).ready(function() {
                $(document).on("click",".addData",function() {
                    $(".title--section_addButton").trigger("click")
                });

                $('.chkAll').change(function() {

                    var check = this.checked;
                    var ok = false;
                    $('.chkIds').each(function () {
                        $(this).prop( "checked", check );
                        ok = true;
                    });
                    if (check && ok)
                    {
                        $("#btRemove").show();
                        $("#btSuspend").show();
                        $("#btPay").show();
                    }
                    else
                    {
                        $("#btRemove").hide();
                        $("#btSuspend").hide();
                        $("#btPay").hide();
                    }

                });

                $('.chkIds').change(function() {
                    
                    checked = false;
                    $('.chkIds').each(function () {
                        
                        if (this.checked)
                            checked = true;
                    });
                    
                    if (checked)
                    {
                        $("#btRemove").show();
                        $("#btSuspend").show();
                        $("#btPay").show();
                    }
                    else
                    {
                        $("#btRemove").hide();
                        $("#btSuspend").hide();
                        $("#btPay").hide();
                        $(".chkAll").prop( "checked", false );
                    }

                });

                $('#btRemove').click(function(){
                    var ids = [];
                    $('.chkIds').each(function () {
                        if (this.checked)
                            ids.push($(this).val());
                    });
                    if (confirm('Sei sicuro?'))
                    {
                        @this.deleteMultiple(ids);
                        setTimeout(() => {
                            location.reload();    
                        }, 200);                
                    }
                });

                $('#btSuspend').click(function(){
                    var ids = [];
                    $('.chkIds').each(function () {
                        if (this.checked)
                            ids.push($(this).val());
                    });
                    if (confirm('Sei sicuro?'))
                    {
                        @this.suspendMultiple(ids);
                        setTimeout(() => {
                            location.reload();    
                        }, 200);                
                    }
                });

                $('#btPay').click(function(){
                    var ids = [];

                    var memberId = 0;
                    var causalId = '';
                    var subCausalId = '';
                    var createSubscription = '';
                    var months = '';
                    var price = '0';
                    var subscription_price = '';
                    var courseId = 0;
                    var subscriptionId = 0;
                    var rateId = 0;

                    $('.chkIds').each(function () {
                        if (this.checked)
                        {
                            var id = $(this).val();
                            memberId = $("#memberId_" + id).val();
                            
                            if ($("#subscription_price_" + id).val() != '')
                            {
                                subCausalId = $("#subCausalId_" + id).val();;
                                createSubscription = $("#createSubscription_" + id).val();
                                subscription_price = $("#subscription_price_" + id).val();
                            }
                            else
                            {
                                causalId = $("#causalId_" + id).val();
                                if (months != '') 
                                    months += "|";
                                months += $("#months_" + id).val();;
                                price = parseFloat(price) + parseFloat($("#price_" + id).val());                            
                            }
                            courseId = $("#courseId_" + id).val();;
                            subscriptionId = $("#subscriptionId_" + id).val();;
                            if (rateId != '') 
                                rateId += ",";
                            rateId += $("#rateId_" + id).val();;
                        }
                            //ids.push($(this).val());
                    });

                    document.location.href = "/in?new=1&memberId=" + memberId + "&causalId=" + causalId + "&subCausalId=" + subCausalId + "&createSubscription=" + createSubscription + "&months=" + months + "&price=" + price + "&subscription_price=" + subscription_price + "&courseId=" + courseId + "&subscriptionId=" + subscriptionId + "&rateId=" + rateId;

                    /*if (confirm('Sei sicuro?'))
                    {
                        @this.suspendMultiple(ids);
                        setTimeout(() => {
                            location.reload();    
                        }, 200);                
                    }*/
                });

            } );

            

        }

    </script>
@endpush
