<?php
defined('BASEPATH') or exit('No direct script access allowed');
$pkey = 'order_'.$produk;
$order_perm = property_exists($this->system->perm, $pkey) ? $this->system->perm->$pkey : 'all';
?>
<?php echo form_open(current_url(), 'class="form-horizontal"');?>
  <div class="form-group">
    <label class="col-sm-3 control-label">ID</label>
    <div class="col-sm-9">
      <input type="text" class="form-control" name="id" value="<?php echo $produk;?>" readonly="readonly"/>
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-3 control-label">Nama</label>
    <div class="col-sm-9">
      <input type="text" class="form-control" name="nama" value="<?php echo set_value('nama', $this->system->produk->{$produk}->nama);?>" maxlength="64" required="required"/>
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-3 control-label">Ikon</label>
    <div class="col-sm-9">
      <input type="text" class="form-control" name="icon" value="<?php echo set_value('icon', @$this->system->produk->{$produk}->mini_icon);?>" maxlength="255" required="required" placeholder="Kode HTML ikon produk"/>
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-3 control-label">Label</label>
    <div class="col-sm-9">
      <div class="input-group" style="margin-bottom: 15px;">
        <span class="input-group-addon">Provider</span>
        <input type="text" class="form-control" name="label_provider" value="<?php echo set_value('label_provider', $this->system->produk->{$produk}->form->provider->label);?>" maxlength="32" required="required"/>
      </div>
      <div class="input-group" style="<?php echo (property_exists($this->system->produk->{$produk}->form,'id_plgn') ? 'margin-bottom: 15px;' : '');?>">
        <span class="input-group-addon">Nominal</span>
        <input type="text" class="form-control" name="label_voucher" value="<?php echo set_value('label_voucher', $this->system->produk->{$produk}->form->voucher->label);?>" maxlength="32" required="required"/>
      </div>
      <?php if (property_exists($this->system->produk->{$produk}->form,'id_plgn')):?>
      <div class="input-group">
        <span class="input-group-addon">ID Pelanggan</span>
        <input type="text" class="form-control" name="label_id_plgn" value="<?php echo set_value('label_voucher', $this->system->produk->{$produk}->form->id_plgn->label);?>" maxlength="32" required="required"/>
      </div>
      <?php endif;?>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-3 col-sm-9">
      <a data-toggle="collapse" href="#pengaturan-lainnya">Pengaturan lainnya <span class="caret"></span></a>
    </div>
  </div>
  <div id="pengaturan-lainnya" class="collapse">
    <div class="form-group">
      <label class="col-sm-3 control-label">Deskripsi</label>
      <div class="col-sm-9">
        <textarea class="form-control" name="description" maxlength="200" rows="4"><?php echo set_value('description', @$this->system->produk->{$produk}->description);?></textarea>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">Perijinan</label>
      <div class="col-sm-9">
        <div class="radio" style="padding-top: 0;min-height: inherit;"><label><input type="radio" name="order_perm" value="all" <?php echo ($order_perm == 'all' ? 'checked="checked"' : '');?>/> Semua orang boleh melakukan pembelian produk ini</label></div>
        <div class="radio" style="padding-top: 0;min-height: inherit;"><label><input type="radio" name="order_perm" value="user" <?php echo ($order_perm == 'user' ? 'checked="checked"' : '');?>/> Semua member yang boleh melakukan pembelian produk ini</label></div>
        <div class="radio" style="padding-top: 0;min-height: inherit;"><label><input type="radio" name="order_perm" value="user_verified" <?php echo ($order_perm == 'user_verified' ? 'checked="checked"' : '');?>/> Hanya member terverifikasi yang boleh melakukan pembelian produk ini</label></div>
        <div class="radio" style="padding-top: 0;min-height: inherit;"><label><input type="radio" name="order_perm" value="reseller" <?php echo ($order_perm == 'reseller' ? 'checked="checked"' : '');?>/> Hanya reseller yang boleh melakukan pembelian produk ini</label></div>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">Pembayaran</label>
      <div class="col-sm-9">
        <?php foreach ($this->payment->get() as $payment):?>
        <div class="checkbox" style="padding-top: 0;min-height: inherit;"><label style="font-weight: normal;"><input type="checkbox" name="payments[]" value="<?php echo $payment->key;?>" <?php echo (!$this->system->produk->{$produk}->payments ? 'checked="checked"' : (in_array($payment->key, $this->system->produk->{$produk}->payments) ? 'checked="checked"' : '')); ?>/> <?php echo ($payment->status == 'on' ? $payment->nama . ($payment->key == 'balance' ? ' <span class="text-muted">(Hanya member)</span>' : '') : '<span class="text-muted">'.$payment->nama.' (Tidak aktif)</span>');?></label></div>
        <?php endforeach;?>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">Pemberitahuan</label>
      <div class="col-sm-9">
        <div class="radio" style="padding-top: 0;min-height: inherit;"><label><input type="radio" name="sms_notify" value="yes" <?php echo (in_array($produk, $this->system->perm->sms_order) ? 'checked="checked"' : '');?>/> Kirimkan SMS pemberitahuan ke nomor HP pembeli</label></div>
        <div class="radio" style="padding-top: 0;min-height: inherit;"><label><input type="radio" name="sms_notify" value="no" <?php echo (!in_array($produk, $this->system->perm->sms_order) ? 'checked="checked"' : '');?>/> Jangan kirimkan SMS pemberitahuan</label></div>
      </div>
    </div>
  </div>
  <div class="form-group" style="margin-bottom:0">
    <div class="col-sm-offset-3 col-sm-9">
      <button type="submit" class="btn btn-primary" name="submit" value="save"><i class="fa fa-check"></i> Simpan</button>
      &nbsp;
      <a href="<?php echo site_url('admin/produk');?>" class="btn btn-default" data-dismiss="modal"><i class="fa fa-remove"></i> Batal</a>
    </div>
  </div>
<?php echo form_close();?>
