@extends('layouts.app')

@section('title','Tambah Staff')

@section('content')

<div class="container-fluid">

    {{-- Header --}}
    <div class="d-flex justify-content-between align-items-center mb-4">

        <div>

            <h3 class="font-weight-bold mb-1">
                Tambah Data Staff
            </h3>

            <p class="text-muted mb-0">
                Tambahkan data tenaga kependidikan baru.
            </p>

        </div>

        <a href="{{ route('staff.index') }}"
           class="btn btn-secondary btn-modern">

            <i class="bi bi-arrow-left-circle"></i>

            Kembali

        </a>

    </div>

    <form action="{{ route('staff.store') }}" method="POST">

        @csrf

        <div class="card card-modern">

            <div class="card-header bg-white border-0">

                <h5 class="mb-0">

                    <i class="bi bi-person-plus-fill text-primary mr-2"></i>

                    Form Data Staff

                </h5>

            </div>

            <div class="card-body">

                <div class="row">

                    {{-- NIP --}}
                    <div class="col-md-6 mb-3">

                        <label>NIP</label>

                        <div class="input-group">

                            <div class="input-group-prepend">

                                <span class="input-group-text">

                                    <i class="bi bi-credit-card-2-front"></i>

                                </span>

                            </div>

                            <input
                                type="text"
                                name="nip"
                                class="form-control @error('nip') is-invalid @enderror"
                                value="{{ old('nip') }}"
                                placeholder="Masukkan NIP">

                            @error('nip')
                                <div class="invalid-feedback">
                                    {{ $message }}
                                </div>
                            @enderror

                        </div>

                    </div>

                    {{-- Nama --}}
                    <div class="col-md-6 mb-3">

                        <label>Nama Staff</label>

                        <div class="input-group">

                            <div class="input-group-prepend">

                                <span class="input-group-text">

                                    <i class="bi bi-person"></i>

                                </span>

                            </div>

                            <input
                                type="text"
                                name="nama"
                                class="form-control @error('nama') is-invalid @enderror"
                                value="{{ old('nama') }}"
                                placeholder="Masukkan Nama Staff">

                            @error('nama')
                                <div class="invalid-feedback">
                                    {{ $message }}
                                </div>
                            @enderror

                        </div>

                    </div>

                    {{-- Guru --}}
                    <div class="col-md-6 mb-3">

                        <label>Terhubung dengan Guru</label>

                        <select
                            name="guru_id"
                            class="form-control modern-select">

                            <option value="">
                                -- Staff Murni --
                            </option>

                            @foreach($guru as $g)

                                <option
                                    value="{{ $g->id }}"
                                    {{ old('guru_id')==$g->id?'selected':'' }}>

                                    {{ $g->nama }}

                                </option>

                            @endforeach

                        </select>

                        <small class="text-muted">

                            Pilih jika staff juga berstatus sebagai guru.

                        </small>

                    </div>

                    {{-- Jabatan --}}
                    <div class="col-md-6 mb-3">

                        <label>Jabatan</label>

                        <div class="input-group">

                            <div class="input-group-prepend">

                                <span class="input-group-text">

                                    <i class="bi bi-briefcase-fill"></i>

                                </span>

                            </div>

                            <input
                                type="text"
                                name="jabatan"
                                class="form-control"
                                value="{{ old('jabatan') }}"
                                placeholder="Contoh: Bendahara">

                        </div>

                    </div>

                    {{-- Gaji --}}
                    <div class="col-md-6 mb-3">

                        <label>Gaji Pokok</label>

                        <div class="input-group">

                            <div class="input-group-prepend">

                                <span class="input-group-text">

                                    Rp

                                </span>

                            </div>

                            <input
                                type="number"
                                name="gaji_pokok"
                                class="form-control"
                                value="{{ old('gaji_pokok') }}"
                                placeholder="0">

                        </div>

                    </div>

                </div>

            </div>

            <div class="card-footer bg-white">

                <button
                    class="btn btn-primary btn-modern">

                    <i class="bi bi-save-fill mr-1"></i>

                    Simpan Data

                </button>

                <a href="{{ route('staff.index') }}"
                   class="btn btn-light btn-modern">

                    Batal

                </a>

            </div>

        </div>

    </form>

</div>

@endsection