<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Server <?php echo html_escape($server->sv_nama);?></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/pengaturan');?>">Pengaturan</a></li>
        <li class="active"><span>Server Pulsa</span></li>
      </ul>
      <div class="row">
        <div class="col-sm-4 col-md-3">
          <?php
          $links = array();
          foreach ($servers as $sv) {
            $links[] = array($sv->sv_nama,  site_url('admin/pengaturan/server/edit/'.$sv->sv_id), null, $server->sv_id == $sv->sv_id ? true : false);
          }
          echo sidebar_menu(array(array('title' => 'Server','icon' => 'fa fa-server','links' => $links)));
          ?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3>
                <a class="pull-right" href="<?php echo site_url('admin/pengaturan/server/bantuan');?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-question-circle" data-toggle="tooltip" data-title="Bantuan"></i></a>
                <i class="fa fa-cog"></i> <?php echo html_escape($server->sv_nama);?>
              </h3>
            </div>
            <div class="panel-body">
              <?php echo form_open();?>
                <div class="form-group">
                  <label for="nama">Nama Server</label>
                  <input type="text" class="form-control" name="nama" id="nama" value="<?php echo set_value('nama', $server->sv_nama);?>" maxlength="16" required="required"/>
                  <p class="help-block">Contoh: Server 1</p>
                </div>
                <div class="form-group">
                  <label for="saldo">Saldo</label>
                  <input type="number" class="form-control" name="saldo" id="saldo" value="<?php echo set_value('saldo', $server->sv_saldo);?>" maxlength="12" required="required"/>
                  <p class="help-block">Jika harga pembelian voucher melebihi jumlah saldo maka transaksi tidak akan diproses.<br/>Kamu dapat menyimpan jumlah saldo sebesar mungkin jika ketersedian saldo selalu cukup untuk memproses semua pembelian voucher.</p>
                </div>
                <div class="form-group">
                  <label for="sms_center">SMS Center</label>
                  <input type="text" class="form-control" name="sms_center" id="sms_center" value="<?php echo set_value('sms_center', $server->sv_sms_center);?>" maxlength="13" required="required"/>
                </div>
                <div class="form-group">
                  <label for="jabber_center">Jabber Center</label>
                  <input type="email" class="form-control" name="jabber_center" id="jabber_center" value="<?php echo set_value('jabber_center', $server->sv_jabber_center);?>" maxlength="64"/>
                </div>
                <div class="form-group">
                  <label for="pin">PIN</label>
                  <input type="text" class="form-control" name="pin" id="pin" value="<?php echo set_value('pin', $this->system->decrypt_data($server->sv_pin));?>" maxlength="8" required="required"/>
                </div>
                <div class="alert alert-info">
                  <h4>Format Transaksi</h4>
                  <?php foreach ($this->system->produk as $produk_key=>$produk_val): $format_dobel = $produk_key.'_dobel'; ?>
                  <div class="row">
                    <div class="col-sm-6">
                      <div class="form-group">
                        <label>Transaksi <?php echo $produk_val->nama;?></label>
                        <input class="form-control" type="text" name="<?php echo $produk_key;?>" value="<?php echo set_value($produk_key, property_exists($format_trx,$produk_key) ? $format_trx->$produk_key : '');?>" maxlength="64" required="required"/>
                        <p class="help-block">Kode yang tersedia: {KODE}, {NO_HP}, {ID_PLGN} dan {PIN}.</p>
                      </div>
                    </div>
                    <div class="col-sm-6">
                      <div class="form-group">
                        <label>Transaksi <?php echo $produk_val->nama;?> Dobel</label>
                        <input class="form-control" type="text" name="<?php echo $format_dobel;?>" value="<?php echo set_value($format_dobel, property_exists($format_trx, $format_dobel) ? $format_trx->$format_dobel : '');?>" maxlength="64"/>
                        <p class="help-block">Jika dikosongkan maka transaksi dengan nomor dan voucher sama dalam 1 hari akan ditolak. Kode yang tersedia: {KODE}, {NUM}, {NO_HP}, {ID_PLGN} dan {PIN}.</p>
                      </div>
                    </div>
                  </div>
                  <?php endforeach;?>
                </div>
                <div class="alert alert-warning">
                  <h4>Balasan Server</h4>
                  <div class="form-group">
                    <label for="regex_sukses">Balasan Sukses</label>
                    <input type="text" class="form-control" name="regex_sukses" id="regex_sukses" value="<?php echo set_value('regex_sukses', $server->sv_regex_sukses);?>" maxlength="255"/>
                    <p class="help-block">Masukan teks yang biasa terdapat ketika transaksi sukses.</p>
                  </div>
                  <div class="form-group">
                    <label for="regex_gagal">Balasan Gagal</label>
                    <input type="text" class="form-control" name="regex_gagal" id="regex_gagal" value="<?php echo set_value('regex_gagal', $server->sv_regex_gagal);?>" maxlength="255"/>
                    <p class="help-block">Masukan teks yang biasa terdapat ketika transaksi gagal.</p>
                  </div>
                </div>
                <div class="form-group">
                  <label for="regex_sn">Regex SN</label>
                  <div class="input-group">
                    <input type="text" class="form-control" name="regex_sn" id="regex_sn" value="<?php echo set_value('regex_sn', $server->sv_regex_sn);?>" maxlength="255"/>
                    <span class="input-group-addon"><a href="#" onclick="document.getElementById('regex_sn').value = '/(SN|Ref|Voucher|Token)( :|:|=| =)(?P<sn>(.*?))(Sal\.|Sal |Sal:|Sal=|Saldo|Trx)/i';return false;" data-toggle="tooltip" data-title="Default"><i class="fa fa-refresh"></i></a></span>
                  </div>
                  <p class="help-block">Regex untuk mengambil kode / SN pada transaksi sukses.</p>
                </div>
                <div class="form-group">
                  <label for="gateway" style="margin-bottom: 0;">Jalur Transaksi</label>
                  <?php foreach ($this->server_model->gateway_label() as $g_key=>$g_name):?>
                  <div class="radio">
                    <label><input type="radio" name="gateway" value="<?php echo $g_key;?>" <?php echo set_radio('gateway', $g_key, $server->sv_gateway == $g_key ? true : false); ?>/> <?php echo html_escape($g_name);?></label>
                  </div>
                  <?php endforeach;?>
                </div>
                <div>
                  <button type="submit" class="btn btn-primary"><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>