<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>  
  <head>
    <title>Login <?php echo html_escape($server->sv_nama);?> | Portal Pulsa / Java H2H</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/portalpulsa');?>">Portal Pulsa / Java H2H</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 echo sidebar_menu($sidebar);?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><a class="pull-right text-danger" title="Hapus Data" data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/modules/portalpulsa/delete-data/'.$server->sv_id);?>"><i class="fa fa-times"></i></a><i class="fa fa-sign-in"></i> Login <?php echo html_escape($server->sv_nama);?></h3>
            </div>
            <div class="panel-body">
              <div class="well well-sm">
                Jika kamu sudah terdaftar di <a href="http://portalpulsa.com/?reff=P23369" target="_blank">Portal Pulsa</a> atau <a href="http://javah2h.com" target="_blank">JavaH2H.com</a> silakan masuk ke akun panel dan pada sidebar kiri klik <strong>Data Profile</strong> kemudian klik <strong>Setting API</strong>.<br />
                Berikut adalah pengaturan yang harus kamu isi:<br />
                <div class="form-group">
                <label>IP Statis:</label>
                  <div class="input-group">
                    <input type="text" id="ipstatis" class="form-control" readonly="readonly" value="<?php echo getHostByName(getHostName());?>" />
                    <span class="input-group-addon"><a class="copy" data-id="#ipstatis" data-name="IP Statis" href="#" data-toggle="tooltip" data-placement="left" data-title="Salin IP Statis"><i class="fa fa-copy"></i></a></span>
                  </div>
                </div>
                <div>
                <label>CallBack URL:</label>
                  <div class="input-group">
                    <span class="input-group-addon"><a id="gencb" href="#" data-toggle="tooltip" data-placement="right" data-title="Generate new Callback URL"><i class="fa fa-refresh"></i></a></span>
                    <input type="text" id="callback" class="form-control" readonly="readonly" value="<?php echo site_url('api/portalpulsa-callback/index/'.$api['callback']);?>" />
                    <span class="input-group-addon"><a class="copy" data-id="#callback" data-name="CallBack URL" href="#" data-toggle="tooltip" data-placement="left" data-title="Salin Callback URL"><i class="fa fa-copy"></i></a></span>
                  </div>
                </div>
              </div>
              <?php echo form_open();?>
                <div class="form-group">
                  <label>Server</label>
                  <select class="form-control" name="server">
                    <option value="portalpulsa" <?php echo set_select('server','portalpulsa', $api['server'] == 'portalpulsa' ? true : false);?>>Portal Pulsa (portalpulsa.com)</option>
                    <option value="javah2h" <?php echo set_select('server','javah2h', $api['server'] == 'javah2h' ? true : false);?>>Java H2H (javah2h.com)</option>
                  </select>
                </div>
                <div class="form-group">
                  <label>User ID</label>
                  <input type="text" class="form-control" name="userid" value="<?php echo set_value('userid', $api['userid']);?>" maxlength="32" required="required"/>
                </div>
                <div class="form-group">
                  <label>API Key</label>
                  <input type="text" class="form-control" name="key" value="<?php echo set_value('key', $api['key']);?>" maxlength="255" required="required"/>
                </div>
                <div class="form-group">
                  <label>API Secret</label>
                  <input type="text" class="form-control" name="secret" value="<?php echo set_value('secret', $api['secret']);?>" maxlength="255" required="required"/>
                </div>
                <div>
                  <button type="submit" class="btn btn-primary" name="submit" value="login"><i class="fa fa-sign-in"></i> Login</button>
                </div>
              <?php echo form_close();?>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script>
      function copyText(text) {
        var aux = document.createElement("input");
        aux.setAttribute("value", text);
        document.body.appendChild(aux);
        aux.select();
        document.execCommand("copy");
        document.body.removeChild(aux);
      }
      $('#gencb').click(function() {
        $.get("<?php echo site_url('admin/modules/portalpulsa/login/'.$server->sv_id.'/callback');?>", function(data) {
          $("#callback").val(data);
        });
        return false;
      });
      $('.copy').click(function() {
        copyText($($(this).data('id')).val());
        $.notify($(this).data('name')+" disalin", "success");
        return false;
      });
    </script>
  </body>
</html>