<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Admin &gt; Sistem</title>
    <?php include_once(VIEWPATH.'includes/head.php'); ?>
    <style type="text/css">nav{margin-bottom: 15px; float: right;}</style>
  </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>Sistem</span></li>
      </ul>
      <div class="row">
        <div class="col-sm-4 col-md-3">
        <?php include(dirname(__FILE__).'/_sidebar.php');?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="row">
            <div class="col-sm-4 col-md-3">
              <a class="btn btn-warning btn-block" style="margin-bottom: 15px;" href="<?php echo site_url('admin/sistem/cek-pembaruan');?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-refresh"></i> Periksa Pembaruan</a>
            </div>
            <div class="col-sm-8 col-md-9">
              <?php echo form_open_multipart(site_url('admin/sistem/upload-pembaruan'));?>
                <div class="input-group" style="margin-bottom: 15px;">
                  <label class="input-group-btn">
                    <span class="btn btn-default">Pilih... <input type="file" style="display: none;" name="zip"/></span>
                  </label>
                  <input type="text" class="form-control" value="Tidak ada file" readonly="readonly"/>
                  <span class="input-group-btn">
                    <button type="submit" class="btn btn-primary"><i class="fa fa-upload"></i> Upload</button>
                  </span>
                </div>
              <?php echo form_close();?>
            </div>
          </div>
          <?php if (!$total):?>
          <div class="alert alert-warning">Tidak ada riwayat pembaruan.</div>
          <?php else:?>
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-refresh"></i> Riwayat Pembaruan</h3>
            </div>
              <div class="table-responsive">
                <table class="table table-striped">
                  <thead>
                    <tr>
                      <th>Versi</th>
                      <th>Rilis</th>
                      <th>Changelog</th>
                    </tr>
                    </thead>
                  <tbody>
                    <?php foreach ($results as $update):?>
                    <tr>
                      <td><?php echo $update->versi;?></td>
                      <td><?php echo $update->rilis;?></td>
                      <td><ol style="padding-left: 12px"><li><?php echo implode("</li><li>", explode("\r\n", $update->changelog));?></li></ul></td>
                    </tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
          </div>
          <?php echo pagination(site_url('admin/sistem/main/index'),$start,$total,$this->system->set['list_per_page'],'/%d');?>
          <?php endif;?>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script>
    $(document).on('change', ':file', function() {
        var input = $(this),
        numFiles = input.get(0).files ? input.get(0).files.length : 1,
        label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
        input.trigger('fileselect', [numFiles, label]);
    });
    $(document).ready( function() {
        $(':file').on('fileselect', function(event, numFiles, label) {
            var input = $(this).parents('.input-group').find(':text'),
            log = numFiles > 1 ? numFiles + ' files selected' : label;
            if( input.length ) {
                input.val(log);
            }
        });
    });
    </script>
  </body>
</html>