<%- include ('../../partials/header.ejs') %>
<%- include ('../../partials/navbar.ejs') %>
<%- include ('../../partials/sidebar.ejs') %>

<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Ubah</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/">Home</a></li>
              <li class="breadcrumb-item"><a href="/category">Jenis Pembayaran</a></li>
              <li class="breadcrumb-item active">Ubah</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            <div class="card card-primary">
                <div class="card-header">
                  <h3 class="card-title">Form Ubah Jenis Pembayaran</h3>
                </div>
                <!-- /.card-header -->
                <!-- form start -->
                <form action="/payment/edit/<%= payment._id %>?_method=PUT" method="POST" enctype="multipart/form-data">
                  <div class="card-body">
                    <div class="form-group">
                      <label for="type">Tipe Pembayaran</label>
                      <input type="text" name="type" value="<%= payment.type %>" class="form-control" id="type" placeholder="Masukan tipe pembayaran" required>
                    </div>
                    <div class="form-group">
                      <label>Bank</label>
                      <div class="select2-purple">
                          <select 
                            class="form-control select2" 
                            multiple="multiple" 
                            data-placeholder="Pilih bank"
                            style="width: 100%;" 
                            name="banks" 
                            required
                          >
                            <% banks.forEach(bank => { %>
                                <option value="<%= bank._id %>"
                                  <% banks.forEach(paymentBank => { %>
                                    <% if(bank._id.toString() === paymentBank._id.toString()) { %>
                                        selected
                                    <% } %>
                                  <% }) %>
                                > 
                                <%= bank.name %>-<%= bank.nameBank %>-<%= bank.noRekening %></option>
                            <% }) %>
                          </select>
                      </div>
                    </div>
                  </div>
                  <div class="card-footer">
                    <button type="submit" class="btn btn-primary">Simpan</button>
                  </div>
                </form>
              </div>
            <!-- /.card -->
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>

  <%- include ('../../partials/footer.ejs') %>
  <%- include ('../../partials/js.ejs') %>