@extends('layouts.app')

@section('title','Edit Guru')

@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">
                Edit Data Guru
            </h3>

            <p class="text-muted mb-0">
                Perbarui informasi data guru.
            </p>

        </div>

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

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

            Kembali

        </a>

    </div>

    <form action="{{ route('guru.update',$guru->id) }}"
          method="POST">

        @csrf
        @method('PUT')

        <div class="card card-modern">

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

                <h5 class="mb-0">

                    <i class="bi bi-pencil-square text-warning mr-2"></i>

                    Form Edit Guru

                </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"
                                value="{{ old('nip',$guru->nip) }}"
                                class="form-control @error('nip') is-invalid @enderror">

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

                        </div>

                    </div>

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

                        <label>Nama Guru</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"
                                value="{{ old('nama',$guru->nama) }}"
                                class="form-control @error('nama') is-invalid @enderror">

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

                        </div>

                    </div>

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

                        <label>Email</label>

                        <div class="input-group">

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

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

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

                                </span>

                            </div>

                            <input
                                type="email"
                                name="email"
                                value="{{ old('email',$guru->email) }}"
                                class="form-control">

                        </div>

                    </div>

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

                        <label>Password Baru</label>

                        <div class="input-group">

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

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

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

                                </span>

                            </div>

                            <input
                                type="password"
                                name="password"
                                class="form-control"
                                placeholder="Kosongkan jika tidak diganti">

                        </div>

                    </div>

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

                        <label>Jenis Kelamin</label>

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

                            <option value="L"
                                {{ $guru->jk=='L'?'selected':'' }}>
                                Laki-laki
                            </option>

                            <option value="P"
                                {{ $guru->jk=='P'?'selected':'' }}>
                                Perempuan
                            </option>

                        </select>

                    </div>

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

                        <label>Status Guru</label>

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

                            <option value="Tetap"
                                {{ $guru->status=='Tetap'?'selected':'' }}>
                                Guru Tetap
                            </option>

                            <option value="Honorer"
                                {{ $guru->status=='Honorer'?'selected':'' }}>
                                Guru Honorer
                            </option>

                        </select>

                    </div>

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

                        <label>Tarif Per Jam</label>

                        <div class="input-group">

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

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

                                    Rp

                                </span>

                            </div>

                            <input
                                type="number"
                                name="tarif_per_jam"
                                value="{{ old('tarif_per_jam',$guru->tarif_per_jam) }}"
                                class="form-control">

                        </div>

                    </div>

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

                        <label>Tanggal Masuk</label>

                        <input
                            type="date"
                            name="tanggal_masuk"
                            value="{{ old('tanggal_masuk',$guru->tanggal_masuk) }}"
                            class="form-control">

                    </div>

                </div>

            </div>

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

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

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

                    Update Data

                </button>

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

                    Batal

                </a>

            </div>

        </div>

    </form>

</div>

@endsection