@extends('layouts.template')

@section('content')
    @include('components.notification')
    <form action="{{ route('voucher.update',$voucher->id) }}" method="POST">
        @method('put')
        @csrf
        <div class="form-group row">
            <div class="col-md-6">
                <label>Kode Item</label>
                <input type="text" name="item_code" class="form-control @error('item_code') is-invalid @enderror"
                    placeholder="Kode Item" value="{{ old('item_code',$voucher->item_code) }}">
                @error('item_code')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                @enderror
            </div>
            <div class="col-md-6">
            <label>Item</label>
            <input type="text" name="item_name" class="form-control @error('item_name') is-invalid @enderror"
                placeholder="Item" value="{{ old('item_name',$voucher->item_name) }}">
                @error('item_name')
                <div class="invalid-feedback">
                    {{ $message }}
                </div>
                @enderror
            </div>
        </div>
        <div class="form-group row">
            <div class="col-md-6">
                <label>Nominal Voucher</label>
                <input type="number" name="price_item" class="form-control @error('price_item') is-invalid @enderror"
                    placeholder="Nominal Item" value="{{ old('price_item',$voucher->price_item) }}">
                @error('price_item')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                @enderror
            </div>
            <div class="col-md-6">
                <label>Cabang</label>
                <select name="id_branch" id="" class="form-control select2">
                    <option value="0" {{$voucher->id_branch == 0 ? 'selected' : ''}}>Semua Cabang</option>
                    @foreach($branch as $item)
                        <option value="{{$item->id}}" {{$voucher->id_branch == $item->id ? 'selected' : ''}}>{{$item->cabang}}</option>
                    @endforeach
                </select>
            </div>
        </div>
        <div class="form-group row">
            <div class="col-md-6 mt-2">
                <button type="submit" class="btn btn-primary mr-2"><i class="fa fa-save"></i> Simpan</button>
                <button type="reset" class="btn btn-default"><i class="fa fa-times"></i> Reset</button>
            </div>
            </div>
    </form>
    
@endsection
