<?php defined('BASEPATH') or exit('No direct script access allowed');?>
<?php echo form_open();?>
  <div class="table-responsive">
    <table class="table table-bordered">
      <thead>
        <tr>
          <th style="width: 120px;">Kode Server</th>
          <th style="width: 120px;">Kode Trx</th>
          <th><?php echo html_escape($this->system->produk->{$produk}->form->voucher->label);?></th>
          <th style="width: 120px;">Hrg Beli</th>
          <th style="width: 120px;">Hrg Jual Umum</th>
          <th style="width: 120px;">Hrg Jual Reseller</th>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($vouchers as $voucher):?>
        <tr>
          <td><input type="text" class="form-control input-sm kode-server" name="vouchers[<?php echo $voucher['vo_id'];?>][kode]" value="<?php echo html_escape($voucher['vo_kode']);?>" placeholder="<?php echo html_escape($voucher['vo_kode']);?>" maxlength="32" required="required"/></td>
          <td><input type="text" class="form-control input-sm kode-trx" name="vouchers[<?php echo $voucher['vo_id'];?>][kode_trx]" value="<?php echo html_escape($voucher['vo_kode_trx']);?>" placeholder="<?php echo html_escape($voucher['vo_kode_trx']);?>" maxlength="32" required="required"/></td>
          <td><input type="text" class="form-control input-sm" name="vouchers[<?php echo $voucher['vo_id'];?>][nominal]" value="<?php echo html_escape($voucher['vo_nominal']);?>" placeholder="<?php echo html_escape($voucher['vo_nominal']);?>" maxlength="120" required="required"/></td>
          <td style="width: 120px;"><input type="number" class="form-control input-sm" name="vouchers[<?php echo $voucher['vo_id'];?>][harga_beli]" value="<?php echo $voucher['vo_harga_beli'];?>" placeholder="<?php echo $voucher['vo_harga_beli'];?>"/></td>
          <td style="width: 120px;"><input type="number" class="form-control input-sm" name="vouchers[<?php echo $voucher['vo_id'];?>][harga_umum]" value="<?php echo $voucher['vo_harga'];?>" placeholder="<?php echo $voucher['vo_harga'];?>" required="required"/></td>
          <td style="width: 120px;"><input type="number" class="form-control input-sm" name="vouchers[<?php echo $voucher['vo_id'];?>][harga_reseller]" value="<?php echo $voucher['vo_harga_reseller'] ? $voucher['vo_harga_reseller'] : $voucher['vo_harga'];?>" placeholder="<?php echo $voucher['vo_harga_reseller'] ? $voucher['vo_harga_reseller'] : $voucher['vo_harga'];?>" required="required" /></td>
        </tr>
        <?php endforeach;?>
      </tbody>
    </table>
  </div>
  <div class="form-group" style="margin-bottom:0">
    <div class="pull-right">
      <button type="submit" class="btn btn-primary" name="submit_harga" value="y"><i class="fa fa-check"></i> Simpan</button>
      &nbsp;
      <a href="<?php echo current_url();?>" data-dismiss="modal" class="btn btn-default"><i class="fa fa-remove"></i> Batal</a>
    </div>
    <div class="clearfix"></div>
  </div>
  <script type="text/javascript">
  $('.kode-server').on('change keyup paste',function() {
    var kode = $(this).val();
    $(this).parent().next().find(".kode-trx").val(kode);
  });
  </script>
<?php echo form_close();?>
