<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Admin &gt; File Manager</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>
        <?php if ($path_array):?>
        <li><a href="<?php echo site_url('admin/modules/file-manager/browse');?>">File Manager</a></li>
        <?php
        $total = count($path_array) - 1;
        $url = '';
        for ($i = 0; $i <= $total; $i++) {
            if ($i == $total)
              echo '<li class="active"><span>'.$path_array[$i].'</span></li>';
            else
              echo '<li><a href="' . site_url('admin/modules/file-manager/browse/'.str_replace('//', '/', $url.$path_array[$i])) . '">'.$path_array[$i].'</a></li>';
            $url .= ($url == '' ? '' : '/') . $path_array[$i].'/';
        }?>
        <?php else:?>
        <li class="active"><span>File Manager</span></li>
        <?php endif;?>
      </ul>
      <?php echo form_open('admin/modules/file-manager/download_zip/'.$path);?>
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3>File Manager</h3>
        </div>
        <div class="table-responsive">
          <table class="table table-bordered table-hover" style="margin-bottom: 0;">
            <thead>
              <tr>
                <?php if ($set['download']):?>
                <th class="text-center" style="width: 40px;"><input type="checkbox" id="select-all"/></th>
                <?php endif;?>
                <th>Nama</th>
                <th>Ukuran</th>
                <th>Tanggal Diperbarui</th>
                <th>CHMOD</th>
              </tr>
            </thead>
            <tbody>
              <?php foreach ($results['folders'] as $dir):?>
              <tr>
                <?php if ($set['download']):?>
                <td class="text-center" style="vertical-align: middle;"><input type="checkbox" class="checkbox1" name="dir[]" value="<?php echo $dir['name'];?>"/></td>
                <?php endif;?>
                <td><a href="<?php echo site_url('admin/modules/file-manager/browse/'.$path.$dir['name']);?>"><i class="fa fa-folder-o"></i> <?php echo $dir['name'];?></a></td>
                <td></td>
                <td><?php echo format_tanggal($dir['time']);?></td>
                <td><?php echo $dir['perms'];?></td>
              </tr>
              <?php endforeach;?>
              <?php foreach ($results['files'] as $file):?>
              <tr>
                <?php if ($set['download']):?>
                <td class="text-center" style="vertical-align: middle;"><input type="checkbox" class="checkbox1" name="file[]" value="<?php echo $file['name'];?>"/></td>
                <?php endif;?>
                <td><a href="<?php echo site_url('admin/modules/file-manager/edit/'.$path.$file['name']);?>"><i class="fa fa-file"></i> <?php echo $file['name'];?></a></td>
                <td><?php echo format_size($file['size']);?></td>
                <td><?php echo format_tanggal($file['time']);?></td>
                <td><?php echo $file['perms'];?></td>
              </tr>
              <?php endforeach;?>
            </tbody>
          </table>
        </div>
      </div>
      <?php if ($set['download']):?>
      <div style="margin-bottom: 20px;">
        <button class="btn btn-primary btn-sm" type="submit" name="action" value="zip_download"><i class="fa fa-download"></i> Download yang ditandai</button>
      </div>
      <?php endif;?>
      <?php echo form_close();?>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script>$(document).ready(function(){$('#select-all').click(function(event){if(this.checked){$('.checkbox1').each(function(){this.checked=true;});}else{$('.checkbox1').each(function(){this.checked=false;});}});});</script>
  </body>
</html>