<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>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 class="active"><span>OtomaX API</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><i class="fa fa-server"></i> Server</h3>
            </div>
            <?php if (!$daftar_server):?>
            <div class="alert alert-warning" style="margin: 15px;">
              Belum ada daftar server, silakan <a class="alert-link" href="<?php echo site_url('admin/pengaturan/server/add');?>">Tambah Server</a> terlebih dahulu.
            </div>
            <?php else:?>
              <div class="table-responsive">
                <table class="table table-bordered table-hover" style="margin-bottom: 0;">
                  <thead>
                    <tr>
                      <th>Nama Server</th>
                      <th>Jalur Transaksi</th>
                      <th>ID Agen</th>
                      <th>Nomor HP</th>
                      <th>Status</th>
                      <th class="text-center" style="width: 100px;">Tindakan</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php
                    foreach ($daftar_server as $server):
                    $sv_data = json_decode($server->sv_data, true);
                    ?>
                    <tr>
                      <td><a href="<?php echo site_url('admin/pengaturan/server/edit/'.$server->sv_id);?>"><?php echo html_escape($server->sv_nama)?></a></td>
                      <td><?php echo $this->server_model->gateway_label($server->sv_gateway);?></td>
                      <td><?php echo html_escape(isset($sv_data['otomax_api']) ? $this->otomax_api->decrypt($sv_data['otomax_api']['data']['F1001']) : '')?></td>
                      <td><?php echo html_escape(isset($sv_data['otomax_api']) ? $this->otomax_api->decrypt($sv_data['otomax_api']['data']['F1011']) : '')?></td>
                      <td><?php echo (isset($sv_data['otomax_api']) ? ($sv_data['otomax_api']['status'] == 1 ? 'Aktif' : 'Tidak aktif') : '');?></td>
                      <td style="width: 100px;"><a class="btn btn-default btn-xs btn-block" href="<?php echo site_url('admin/modules/otomax/login/'.$server->sv_id);?>"><i class="fa fa-sign-in"></i> Masuk</a></td>
                    </tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
            <?php endif;?>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
  </body>
</html>