<?php
defined('BASEPATH') or exit('No direct script access allowed');
$jumlah  = $this->input->get('jumlah');
if (substr($jumlah, 0, 1) == '-') {
    $jumlah = (int)substr($jumlah, 1);
    $jenis = 'mengurangi';
} else {
    $jumlah =  (int)$jumlah;
    $jenis = 'menambahkan';
}
?>
<?php if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest'):?>
<!DOCTYPE html>
<html>
  <head>
    <title>Edit Saldo <?php echo html_escape($user->us_name);?>
    </title>
    <?php include_once(VIEWPATH. 'includes/head.php'); ?>
  </head>  
  <body>
    <?php include_once(VIEWPATH. 'admin/_navbar.php'); ?>
    <div class="container">
      <ul class="breadcrumb">
        <li><a href="<?php echo site_url();?>"><i class="fa fa-home"></i></a></li>
        <li><a href="<?php echo site_url('admin');?>">Admin Panel</a></li>
        <li><a href="<?php echo site_url('admin/users');?>">Member</a></li>
        <li class="active"><span><?php echo html_escape($user->us_name);?></span></li>
      </ul>
      <div class="row">
        <div class="col-sm-4 col-md-3">
          <?php include dirname(__FILE__).'/_sidebar.php';?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-money"></i> Edit Saldo</h3>
            </div>
            <div class="panel-body">
              <?php echo form_open();?>
              <?php else:?>
              <?php echo form_open();?>
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"> &times;</span></button>
                <h4 class="modal-title"><i class="fa fa-money"></i> Edit Saldo <?php echo html_escape($user->us_name);?></h4>
              </div>
              <div class="modal-body">
              <?php endif;?>
              <div class="well well-sm">
                <strong>Jumlah saldo <?php echo html_escape($user->us_name);?>: Rp <?php echo format_uang($user->us_balance);?></strong>
              </div>
                <div class="form-group">
                  <label for="jenis">Jenis</label>
                  <select class="form-control" name="jenis" id="jenis" required="required">
                    <option>--Piih--</option>
                    <option value="menambahkan" <?php echo set_select('jenis', 'menambahkan', $jenis == 'menambahkan' && $jumlah ? true : false);?>>Menambahkan</option>
                    <option value="mengurangi" <?php echo set_select('jenis', 'mengurangi', $jenis == 'mengurangi' && $jumlah ? true : false);?>>Mengurangi</option>
                  </select>
                </div>
                <div class="form-group">
                  <label for="jumlah">Jumlah</label>
                  <div class="input-group">
                    <span class="input-group-addon">Rp</span>
                    <input class="form-control" type="number" name="jumlah" id="jumlah" value="<?php echo set_value('jumlah', $jumlah ? $jumlah : '');?>" required="required"/>
                  </div>
                </div>
                <div class="form-group">
                  <label for="keterangan">Keterangan</label>
                  <input class="form-control" type="text" name="keterangan" id="keterangan" value="<?php echo set_value('keterangan', $this->input->get('keterangan') ? $this->input->get('keterangan') : '');?>"  maxlength="160" required="required" autocomplete="off"/>
                </div>
                <div class="form-group">
                  <label for="user_password">Admin Password</label>
                  <input class="form-control" type="password" name="user_password" id="user_password" value="" required="required" autocomplete="new-password"/>
                </div>
                <div class="form-group">
                  <div class="checkbox"><label><input type="checkbox" name="send_email" value="1"/> Kirim Email pemberitahuan ke pengguna ini</label></div>
                  <div class="checkbox"><label><input type="checkbox" name="send_sms" value="1"/> Kirim SMS pemberitahuan ke pengguna ini</label></div>
                </div>
              <?php if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'):?>
              </div>
              <div class="modal-footer">
                <button class="btn btn-primary" type="submit" name="submit" value="save"><i class="fa fa-check"></i> Simpan</button>
                &nbsp;
                <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> Batal</button>
              </div>
              <?php echo form_close();?>
              <?php else:?>
              <div>
                <button class="btn btn-primary" type="submit" name="submit" value="save"><i class="fa fa-check"></i> Simpan</button>
              </div>
              <?php echo form_close();?>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
  </body>
</html>
<?php endif;?>