@extends('layouts.app_operasi')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-12">
            <div class="card">

                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb pb-3">
                        <li class="breadcrumb-item"><a href="{{ url('/') }}">Home</a></li>
                      <li class="breadcrumb-item active" aria-current="page">Perubatan</li>
                    </ol>
                </nav>

                <div class="card-body text-center">
                    <div>
                        <form method="GET" action="{{ route('perubatan.search') }}" class="d-flex w-50 mb-2 float-right">
                            <input type="text" name="search" value="{{ request('search') }}" placeholder="Search..." class="form-control"/>
                            <button class="btn btn-primary ml-2" type="submit">Search</button>
                        </form>
                        
                        <table class="table table-bordered">
                            <thead class="bg-secondary">
                              <tr>
                                <th scope="col">#</th>
                                <th scope="col">Nama</th>
                                <th scope="col">Baki Perubatan</th>
                                <th scope="col" style="width:15%;">Perubatan</th>
                                <th scope="col">Tindakan</th>
                              </tr>
                            </thead>
                            <tbody>
                                @foreach($paginate as $page)
                                <tr>
                                    <td>{{ ($paginate->currentPage() - 1) * $paginate->perPage() + $loop->index + 1 }}</td>
                                    <td scope="col">{{ $page->name }}</td>
                                    <td scope="col">{{ number_format($page->perubatan,2) }}</td>
                                    <td scope="col">
                                        <input name="perubatan" id="input-{{ $page->id }}" class="form-control" value="{{ $page->perubatan_asal }}" disabled/>
                                    </td>
                                    <td>
                                        <div id="divedit-{{ $page->id }}" class="d-block">
                                            <btn class="btn btn-primary" id="editButton-{{ $page->id }}" onclick="editfunc({{ $page->id }})">Edit</btn>
                                        </div>
                                        <div class="d-none" id="div-{{ $page->id }}">
                                            <btn class="btn btn-primary" id="saveButton-{{ $page->id }}" onclick="savefunc({{ $page->id }})">Save</btn>
                                            <btn class="btn btn-danger" id="cancelButton-{{ $page->id }}" onclick="cancelfunc({{ $page->id }})">Cancel</btn>
                                        </div>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                          </table>
                    </div>
                    <!-- Display pagination links -->
                    <div class="pagination float-right">
                        {{ $paginate->links() }}
                    </div>
                
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    let updateurl = "{{ route('perubatan.update') }}";
</script>
<script src="{{ asset('js/perubatan.js') }}"></script>
@endsection
