<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>  
  <head>
    <title>Login Okepay</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/okepay');?>">Okepay</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/okepay/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="alert alert-info" style="margin-bottom: 15px"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>Jika kamu sudah terdaftar di Okepay silakan masuk ke <a class="alert-link" href="https://portal.okepay.id" target="_blank">portal.okepay.id</a> untuk melakukan pendaftaran API.</div>
            <div class="well well-sm">
                <div class="form-group">
                  <label>IP Address</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>URL Callback</label>
                  <div class="input-group">
                    <span class="input-group-addon"><a id="gencb" href="#" data-toggle="tooltip" data-placement="right" data-title="Generate URL Callback"><i class="fa fa-refresh"></i></a></span>
                    <input type="text" id="webhook" class="form-control" readonly="readonly" value="<?php echo site_url('api/okepay-webhook/index/'.$api['webhook_key']);?>" />
                    <span class="input-group-addon"><a class="copy" data-id="#webhook" data-name="URL Callback" href="#" data-toggle="tooltip" data-placement="left" data-title="Salin"><i class="fa fa-copy"></i></a></span>
                  </div>
                </div>
              </div>
              <?php echo form_open();?>
                <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="255" 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>Secret Key</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/okepay/login/'.$server->sv_id.'/webhook_key');?>", function(data) {
          $("#webhook").val("<?php echo site_url('api/okepay-webhook/index');?>/"+data);
        });
        return false;
      });
      $('.copy').click(function() {
        copyText($($(this).data('id')).val());
        $.notify($(this).data('name')+" disalin", "success");
        return false;
      });
    </script>
  </body>
</html>