Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @extends('layouts.master')
- @section('title')
- Form Transaksi
- @endsection
- @section('content')
- <div class="container-fluid">
- <div class="d-sm-flex align-items-center justify-content-between mb-4">
- <h1 class="h3 mb-0 text-gray-800">Form Transaksi</h1>
- </div>
- <form action="{{ url('/admin/transaksi') }}" method="post" enctype="multipart/form-data">
- @csrf
- <div class="row">
- @if (session('success'))
- <div class="col-md-12">
- <div class="alert alert-success">
- {!! session('success') !!}
- </div>
- </div>
- @endif
- <div class="col-md-6">
- <div class="card border-left-primary shadow h-100 py-2">
- <div class="card-body">
- <div class="form-group">
- <label for="">Tipe Pelanggan</label>
- <select name="tipe_pelanggan" id="tipepelanggan" class="form-control">
- <option value="0">Baru</option>
- <option value="1">Lama</option>
- </select>
- <p class="text-danger">{{ $errors->first('tipe_pelanggan') }}</p>
- </div>
- <div id="existingCustomer" style="display:none">
- <div class="form-group">
- <label for="">Pelanggan</label>
- <select name="pelanggan_id" class="form-control">
- <option value="">Pilih</option>
- @foreach ($pelanggan as $row)
- <option value="{{ $row->id }}">{{ $row->nama }}</option>
- @endforeach
- </select>
- </div>
- </div>
- <div id="newCustomer">
- <div class="form-group">
- <label for="">NIK</label>
- <input type="number" name="nik" class="form-control {{ $errors->has('nik') ? 'is-invalid':'' }}">
- <p class="text-danger">{{ $errors->first('nik') }}</p>
- </div>
- <div class="form-group">
- <label for="">Foto KTP</label>
- <input type="file" name="foto_ktp" class="form-control {{ $errors->has('foto_ktp') ? 'is-invalid':'' }}">
- <p class="text-danger">{{ $errors->first('foto_ktp') }}</p>
- </div>
- <div class="form-group">
- <label for="">Nama Lengkap</label>
- <input type="text" name="nama" class="form-control {{ $errors->has('nama') ? 'is-invalid':'' }}">
- <p class="text-danger">{{ $errors->first('nama') }}</p>
- </div>
- <div class="form-group">
- <label for="">No Telpon/HP</label>
- <input type="text" name="notelp" class="form-control {{ $errors->has('notelp') ? 'is-invalid':'' }}">
- <p class="text-danger">{{ $errors->first('notelp') }}</p>
- </div>
- <div class="form-group">
- <label for="">Alamat</label>
- <input type="text" name="alamat" class="form-control {{ $errors->has('alamat') ? 'is-invalid':'' }}">
- <p class="text-danger">{{ $errors->first('alamat') }}</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="col-md-6">
- <div class="card border-left-primary shadow h-100 py-2">
- <div class="card-body">
- <div class="form-group">
- <label for="">Produk</label>
- <select name="produk_id" id="produk" class="form-control" required>
- <option value="">Pilih</option>
- @foreach ($produk as $row)
- <option value="{{ $row->id }}">{{ $row->varian }} - {{ $row->merk }}</option>
- @endforeach
- </select>
- <p class="text-danger">{{ $errors->first('produk_id') }}</p>
- </div>
- <div class="form-group">
- <label for="">Layanan</label>
- <select name="layanan" id="layanan" class="form-control" required>
- <option value="">Pilih</option>
- {{-- @foreach ($produk as $row)
- <option value="{{ $row->id }}">{{ $row->varian }} - {{ $row->merk }}</option>
- @endforeach --}}
- </select>
- <p class="text-danger">{{ $errors->first('layanan') }}</p>
- </div>
- <div class="form-group">
- <label for="">Jaminan</label>
- <input type="text" name="jaminan" class="form-control {{ $errors->has('jaminan') ? 'is-invalid':'' }}" required>
- <p class="text-danger">{{ $errors->first('jaminan') }}</p>
- </div>
- <div class="form-group">
- <label for="">Foto Jaminan</label>
- <input type="file" name="foto_jaminan" class="form-control {{ $errors->has('foto_jaminan') ? 'is-invalid':'' }}">
- <p class="text-danger">{{ $errors->first('foto_jaminan') }}</p>
- </div>
- <div class="form-group">
- <label for="">Tanggal Pinjam</label>
- <input type="date" name="tgl_pinjam" class="form-control {{ $errors->has('tgl_pinjam') ? 'is-invalid':'' }}" required>
- <p class="text-danger">{{ $errors->first('tgl_pinjam') }}</p>
- </div>
- <div class="form-group">
- <label for="">Lama Pinjam</label>
- <select name="lama_pinjam" class="form-control" required>
- <option value="">Pilih</option>
- <option value="1">1 hari</option>
- <option value="2">2 hari</option>
- <option value="3">3 hari</option>
- <option value="4">4 hari</option>
- <option value="5">5 hari</option>
- </select>
- <p class="text-danger">{{ $errors->first('lama_pinjam') }}</p>
- </div>
- <div class="float-right">
- <input type="reset" class="btn btn-secondary btn-sm">
- <button class="btn btn-primary btn-sm">Kirim</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </form>
- </div>
- @endsection
- @section('js')
- <script>
- $('#tipepelanggan').on('change', function() {
- if ($(this).val() == 0) {
- $('#newCustomer').show()
- $('#existingCustomer').hide()
- } else {
- $('#existingCustomer').show()
- $('#newCustomer').hide()
- }
- })
- $('#produk').on('change', function() {
- let produk_id = $(this).val()
- //console.log(produk_id)
- $.ajax({
- url: "{{ url('/api/produk-harga') }}",
- type: 'GET',
- data: {id: produk_id},
- success: function(item) {
- //console.log(item)
- $('#layanan').empty()
- $('#layanan').append('<option value="">Pilih</option>')
- $.each(item.data, function(key, row) {
- //console.log($row)
- $('#layanan').append('<option value="'+ row.id +'">'+ row.deskripsi + ' - Rp ' + row.harga_format + '</option>')
- })
- }
- })
- })
- </script>
- @endsection
Add Comment
Please, Sign In to add comment