<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php
function tipe_pengirm($kode, $pengirim)
{
    if ($kode == 'S')
        return 'SMS';
    if ($kode == 'Y')
        return 'YM';
    if ($kode == 'G') {
        if (strpos($pengirim, '@gmail.com') !== false)
            return 'GTalk/Hangout';
        return 'Jabber';
    }
    return '-';
}
?>
<!DOCTYPE html>
<html>
  <head>
    <title>Akun <?php echo html_escape($server->sv_nama);?> | OtomaX API</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/modules/otomax');?>">OtomaX</a></li>
        <li class="active"><span><?php echo html_escape($server->sv_nama);?></span></li>
      </ul>
      <div class="row">
        <div class="col-sm-4 col-md-3">
          <?php include_once(dirname(__FILE__).'/_sidebar.php');?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><a class="text-danger pull-right" data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/modules/otomax/logout');?>"><i class="fa fa-sign-out" data-toggle="tooltip" data-placement="left" title="Logout <?php echo html_escape($server->sv_nama);?>"></i></a><i class="fa fa-user"></i> Info Akun</h3>
            </div>
            <div class="table-responsive">
              <table class="table">
                <tbody>
                  <tr><td style="width: 140px;">Server</td><td><a href="<?php echo site_url('admin/pengaturan/server/edit/'.$server->sv_id);?>"><?php echo html_escape($server->sv_nama);?></a></td></tr>
                  <tr><td style="width: 140px;">ID Agen</td><td><?php echo $this->otomax_api->decrypt($info_akun['0011']['0001']);?></td></tr>
                  <tr><td style="width: 140px;">Nama</td><td><?php echo $this->otomax_api->decrypt($info_akun['0011']['0011']);?></td></tr>
                  <tr><td style="width: 140px;">Saldo</td><td><?php echo $this->otomax_api->decrypt($info_akun['0011']['0110']);?>&nbsp;&nbsp;<a class="btn btn-default btn-xs"  data-toggle="tooltip" title="Tambah saldo" href="<?php echo site_url('admin/modules/otomax/deposit');?>"><i class="fa fa-plus"></i> Deposit</a></td></tr>
                  <tr><td style="width: 140px;">Komisi</td><td><?php echo $this->otomax_api->decrypt($info_akun['0011']['1010']);?></td></tr>
                  <tr><td style="width: 140px;">Voucher</td><td><?php echo $total_vouchers ? '<span class="badge" data-toggle="tooltip" title="Jumlah voucher yang tersimpan di database">'.$total_vouchers .'</span> &nbsp;&nbsp;<a class="btn btn-default btn-xs" id="btn-sinkronisasi" data-toggle="tooltip" title="Sinkronisasi harga dan status voucher" href="'.site_url('admin/modules/otomax/sinkronisasi').'"><i class="fa fa-refresh"></i> Sinkronisasi</a>' : $total_vouchers;?></td></tr>
                  <tr><td style="width: 140px;">Jumlah Downline</td><td><?php echo $this->otomax_api->decrypt($info_akun['0011']['0111']);?></td></tr>
                  <tr><td style="width: 140px;">Jumlax Trx Hari Ini</td><td><?php echo $this->otomax_api->decrypt($info_akun['0011']['0100']);?></td></tr>
                  <tr><td style="width: 140px;">Total Trx Hari Ini</td><td><?php echo $this->otomax_api->decrypt($info_akun['0011']['0010']);?></td></tr>
                  <tr><td style="width: 140px;">Pengirim Terdaftar</td><td><ul class="list-unstyled"><?php foreach ($pengirim_terdaftar['0101'] as $pengirim):?><li><?php echo $pengirim['pengirim'];?> <span>(<?php echo tipe_pengirm($pengirim['tipe_pengirim'], $pengirim['pengirim']);?>)</span></li><?php endforeach;?></ul></td></tr>
                  <tr><td style="width: 140px;">Status API</td><td><?php echo ($set['status'] == '1' ? 'Aktif' : 'Tidak aktif');?></td></tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script type="text/javascript">$("#btn-sinkronisasi").click(function(){var btn=$(this);btn.attr("disabled","disabled").html('<i class="fa fa-refresh fa-spin"></i> Menyinkronkan');$.get($(this).attr('href'),function(data){if(data.updated>0){$.notify(data.updated+" produk berhasil diperbarui.","success");}else{$.notify("Tidak ada produk yang diperbarui","info");}}).fail(function(){$.notify("Terjadi kesalahan ketika menyinkronkan produk.","error");}).done(function(data){btn.removeAttr("disabled").html('<i class="fa fa-refresh"></i> Sinkronisasi');$.notify("Sinkronisasi selesai","success");});return false;});</script>
  </body>
</html>