@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center mt-3">
        <div class="col-md-12">
            <div class="card">
                
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb pb-3">
                      <li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
                      <li class="breadcrumb-item active" aria-current="page">Kakitangan</li>
                    </ol>
                  </nav>


                <div class="card-body">
                    
                    <div class="row mb-4">
                       
                    </div>
                    <form action="{{ route('kakitangan.harian') }}" method="post">
                        @csrf
                        <div class="col-12 text-center">
                            <div class="row">
                                <div class="row col-6">
                                    <label class="col-6">Pengurus Cawangan:</label>
                                    @if($pc != null)
                                        <input type="text" class="form-control col-6" readonly name="pc" id="pc" value="{{ $pc['name'] }}"/>
                                        <input type="text" class="form-control col-6" hidden name="pc_id" id="pc_id" value="{{ $pc['id'] }}"/>
                                    @else
                                        <input type="text" class="form-control col-6" readonly name="pc" id="pc" value="Tiada Pengurus Cawangan"/>
                                    @endif
                                </div>
                                
                                <div class="row col-6">
                                    <label class="col-6">Khazanah Cawangan:</label>
                                    <select name="khazanah" id="khazanah" class="form-control col-6">
                                        @foreach ($khazanah as $index=>$k)
                                            <option value="{{ $k['id'] }}" {{ $k['role_harian'] == 'khazanah' ? 'selected' : ''}}>{{ $k['name'] }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="col-12 mt-4 text-center">
                            <div class="row">
                                <div class="row col-6">   
                                    <label class="col-6">Pen. Peng. Cawangan:</label>
                                    @if($ppc != null)
                                        <input type="text" class="form-control col-6" readonly name="ppc" id="ppc" value="{{ $ppc['name'] }}"/>
                                        <input type="text" class="form-control col-6" hidden name="ppc_id" id="ppc_id" value="{{ $ppc['id'] }}"/>
                                    @else
                                        <input type="text" class="form-control col-6" readonly name="pc" id="pc" value="Tiada Penolong Pengurus Cawangan"/>
                                    @endif
                                </div>
                                
                                <div class="row col-6">
                                    <label class="col-6">Penilai Cawangan:</label>
                                    <select name="penilai" id="penilai" class="form-control col-6">
                                        @foreach ($teller as $index=>$t)
                                            <option value="{{ $t['id'] }}" {{ $t['role_harian'] == 'penilai' ? 'selected' : ''}}>{{ $t['name'] }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="col-12 row justify-content-end mt-4 mb-4">
                            <!-- <button class="btn btn-info">Sahkan</button> -->
                            <input type="submit" class="btn btn-primary mr-4" value="Sahkan">
                        </div>
                    </form>
                    


                    <table class='table table-hover table-striped' id='table-kakitangan' style="width:100%;">
                        <thead class="thead-dark">
                            <tr>
                                <th>Bil</th>
                                <th>Teller</th>
                                <th>Cawangan</th>
                                <th>Roles</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($teller as $index=>$t)
                            <tr>
                            <td>{{ $loop->iteration }}</td>
                            <td>{{ $t['name'] }}</td>
                            <td>{{ $t['cawangan'] }}</td>
                            <td>{{ $t['role_harian'] }}</td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    var tablekakitangan = $('#table-kakitangan').DataTable({
          "scrollX": true
        });
    
    </script>
@endsection
