<form action="{{ route('transaction.update', $data->id) }}" method="POST">
    @csrf
    @method('PUT')
    <div class="form-group row">
        <div class="col-md-6">
            <label>No Nota</label>
            <input type="text" name="trx_code" class="form-control @error('trx_code') is-invalid @enderror"
                placeholder="No Nota" value="{{ old('trx_code', $data->trx_code) }}">
            @error('trx_code')
                <div class="invalid-feedback">
                    {{ $message }}
                </div>
            @enderror
        </div>
        <div class="col-md-6">
            <label>Nama Member</label>
            <select type="text" name="id_cust" class="form-control select2 @error('id_cust') is-invalid @enderror">
                <option value="">---Pilih Member---</option>
                @foreach ($user as $item)
                    <option value="{{ $item->id }}" {{ $data->id_cust == $item->id ? 'selected' : '' }}>{{$item->poin}} Poin - {{ $item->phone .' - '. $item->nama }}</option>
                @endforeach
            </select>
            @error('id_cust')
                <div class="invalid-feedback">
                    {{ $message }}
                </div>
            @enderror
        </div>
    </div>
    <div class="form-group row">
        <div class="col-md-4">
            <label>Nominal Transaksi</label>
            <input type="number" id="amount" onkeyup="getPoin()" name="amount" class="form-control @error('amount') is-invalid @enderror"
                placeholder="Nominal Transaksi" value="{{ old('amount',$data->amount) }}">
            @error('poin')
                <div class="invalid-feedback">
                    {{ $message }}
                </div>
            @enderror
        </div>
        <div class="col-md-2">
            <label>Persentase</label>
            <input type="number" id="persentase" onkeyup="getPoin()" name="persentase" class="form-control @error('persentase') is-invalid @enderror"
                placeholder="Persentase" value="{{ old('persentase',$data->poin/$data->amount*100) }}">
            @error('persentase')
                <div class="invalid-feedback">
                    {{ $message }}
                </div>
            @enderror
        </div>        
        <div class="col-md-6">
        <label>Poin Member</label>
        <input type="number" id="poin_member" name="poin" class="form-control @error('poin') is-invalid @enderror"
            placeholder="Poin Member" value="{{ old('poin', $data->poin) }}">
        @error('poin')
            <div class="invalid-feedback">
                {{ $message }}
            </div>
        @enderror
        </div>
        </div>
    <div class="form-group row">
        <div class="col-md-6">
            <label>Tanggal Transaksi</label>
            <input type="date" name="tgl_trx" class="form-control @error('tgl_trx') is-invalid @enderror"
                placeholder="Tanggal Transaksi" value="{{ old('tgl_trx', $data->tgl_trx) }}">
            @error('tgl_trx')
                <div class="invalid-feedback">
                    {{ $message }}
                </div>
            @enderror
        </div>
        <div class="col-md-6">
            <label>Cabang</label>
            <select type="text" name="id_branch" class="form-control select2 @error('id_branch') is-invalid @enderror">
                <option value="">---Pilih Cabang---</option>
                @foreach ($cabang as $item)
                    <option value="{{ $item->id }}" {{ $data->id_branch == $item->id ? 'selected' : '' }}>{{ $item->cabang }}</option>
                @endforeach
            </select>
            @error('id_branch')
                <div class="invalid-feedback">
                    {{ $message }}
                </div>
            @enderror
        </div>
        
    </div>

    <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>
</form>
