<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Admin &gt; Aplikasi Android</title>
    <?php include_once(VIEWPATH.'includes/head.php'); ?>
    <style type="text/css">
    .popover{width: 100%; display: block;left: 0;right: 0;}
    .popover-content>.list-group{margin: -9px -15px;border-radius:0;}
    .popover-content>.list-group>.list-group-item{border-left:0;border-right:0;}
    .popover-content>.list-group>.list-group-item:first-child{border-top:0;}
    .popover-content>.list-group>.list-group-item:last-child{border-bottom:0;}
    </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>Aplikasi Android</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="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-cog"></i> Pengaturan</h3>
            </div>
            <div class="panel-body">
              <?php include(dirname(__file__).'/_tabs.php');?>
              <ul class="nav nav-pills" style="margin-bottom: 15px;" id="tabs">
                <li role="presentation" class="<?php echo $tab != 'navigasi' ? 'active' : '';?>"><a href="#konten" aria-controls="konten" role="tab" data-toggle="tab"><i class="fa fa-th-large"></i> Konten</a></li>
                <li role="presentation" class="<?php echo $tab == 'navigasi' ? 'active' : '';?>"><a href="#navigasi" aria-controls="navigasi" role="tab" data-toggle="tab"><i class="fa fa-bars"></i> Menu Navigasi</a></li>
                <li id="konten-menu" style="<?php echo $tab == 'navigasi' ? 'display:none' : '';?>" role="presentation" class="dropdown pull-right">
                  <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-plus"></i> Tambah Konten <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                    <li><a data-toggle="modal" data-target="#customModal" href="<?php echo site_url('admin/modules/aplikasi-android/add-item/product');?>">Produk Pilihan</a></li>
                    <li><a data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/modules/aplikasi-android/add-item/webview');?>">Webview</a></li>
                  </ul>
                </li>
                <li id="navigasi-menu" style="<?php echo $tab != 'navigasi' ? 'display:none' : '';?>" role="presentation" class="pull-right"><a data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/modules/aplikasi-android/tambah-menu-navigasi');?>"><i class="fa fa-plus"></i> Tambah Menu</a></li>
              </ul>
              <div class="tab-content">
                <div role="tabpanel" class="tab-pane fade <?php echo $tab != 'navigasi' ? 'in active' : '';?>" id="konten">
                  <div class="list-group" id="pages" style="margin-bottom: 0;">
                    <?php for ($i = 0; $i < count($app['main_page']); $i++):?>
                    <?php
                    $menu = '<div class="list-group">';
                    if ($i != 0)
                        $menu .='<a class="list-group-item" href="'.site_url('admin/modules/aplikasi-android/sort/up/'.$i).'"><i class="fa fa-arrow-up"></i> Naikan</a>';
                    $menu .='<a data-toggle="modal" data-target="#customModal" class="list-group-item" href="'.site_url('admin/modules/aplikasi-android/edit-item/'.$app['main_page'][$i]['id'].'/'.$i).'"><i class="fa fa-pencil"></i> Edit</a>';
                    if ($app['main_page'][$i]['id'] != 'category' && $app['main_page'][$i]['id'] != 'banner')
                        $menu .='<a data-toggle="modal" data-target="#myModal" class="list-group-item" href="'.site_url('admin/modules/aplikasi-android/remove-item/'.$i).'"><span class="text-danger"><i class="fa fa-remove"></i> Hapus</span></a>';
                    if ($i != (count($app['main_page']) - 1))
                        $menu .='<a class="list-group-item" href="'.site_url('admin/modules/aplikasi-android/sort/down/'.$i).'"><i class="fa fa-arrow-down"></i> Turunkan</a>';
                    $menu .='</div>';
                    ?>
                    <a href="javascript:;" class="list-group-item" id="item-<?php echo $i;?>" data-container="body" data-toggle="popover" data-placement="top" data-html="true" data-content="<?php echo html_escape($menu);?>" data-trigger="focus">
                      <h5 class="list-group-item-heading"><?php echo isset($app['main_page'][$i]['title']) ? html_escape($app['main_page'][$i]['title']) : ucfirst($app['main_page'][$i]['id']);?></h5>
                      <?php if ($app['main_page'][$i]['id'] == 'webview'):?>
                      <p class="list-group-item-text"><?php echo html_escape($app['main_page'][$i]['data']);?></p>
                      <?php elseif ($app['main_page'][$i]['id'] == 'banner' && count($app['main_page'][$i]['data']) != 0):?>
                      <p class="list-group-item-text"><?php echo count($app['main_page'][$i]['data']);?> banner</p>
                      <?php elseif ($app['main_page'][$i]['id'] == 'product'):?>
                      <p class="list-group-item-text"><?php echo count($app['main_page'][$i]['data']);?> produk</p>
                      <?php elseif ($app['main_page'][$i]['id'] == 'category'):?>
                      <p class="list-group-item-text"><?php echo (is_array($app['main_page'][$i]['data']) ? ($app['main_page'][$i]['data']['max_visible'] == 0 ? 'Menampilkan semua kategori' : $app['main_page'][$i]['data']['max_visible'].' kategori yang terlihat') : 'Menampilkan semua kategori');?></p>
                      <?php endif;?>
                    </a>
                    <?php endfor;?>
                  </div>
                </div>
                <div role="tabpanel" class="tab-pane fade <?php echo $tab == 'navigasi' ? 'in active' : '';?>" id="navigasi" style="margin-bottom: 0;">
                  <div class="list-group" style="margin-bottom: 0;">
                    <div class="list-group-item"><i class="fa fa-user"></i> Akun</div>
                    <div class="list-group-item"><i class="fa fa-commenting"></i> Testimonial</div>
                    <div class="list-group-item"><i class="fa fa-newspaper-o"></i> Blog</div>
                    <div class="list-group-item"><i class="fa fa-exclamation-circle"></i> Ketentuan Layanan</div>
                    <div class="list-group-item"><i class="fa fa-question-circle"></i> F.A.Q</div>
                    <div class="list-group-item"><i class="fa fa-envelope"></i> Hubungi Kami</div>
                    <?php for ($i = 0; $i < count($app['navigation_menu']); $i++):?>
                    <a href="javascript:;" class="list-group-item" data-container="body" data-toggle="popover" data-placement="top" data-html="true" data-content="<?php echo html_escape('<div class="list-group"><a data-toggle="modal" data-target="#myModal" class="list-group-item" href="'.site_url('admin/modules/aplikasi-android/edit-menu-navigasi/'.$i).'"><i class="fa fa-pencil"></i> Edit</a><a data-toggle="modal" data-target="#myModal" class="list-group-item" href="'.site_url('admin/modules/aplikasi-android/hapus-menu-navigasi/'.$i).'"><span class="text-danger"><i class="fa fa-remove"></i> Hapus</span></a></div>');?>" data-trigger="focus"><i class="fa fa-chevron-right"></i> <?php echo html_escape($app['navigation_menu'][$i]['label']);?></a>
                    <?php endfor;?>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fade" id="customModal" tabindex="-1" role="dialog" aria-labelledby="customModal-label" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content2"></div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script type="text/javascript">$(document).on('show.bs.modal','.modal',function(event){var button=$(event.relatedTarget);if(button.data("target")=='#customModal'){$("head").append('<style id="css-content2" type="text/css">.modal-content2{position:relative;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #999;border:1px solid rgba(0,0,0,.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5)}@media (min-width:768px){.modal-content2{-webkit-box-shadow:0 5px 15px rgba(0,0,0,.5);box-shadow:0 5px 15px rgba(0,0,0,.5)}}</style>');$('.modal-content2').load($(event.relatedTarget).attr('href'));}var zIndex=1040+(10*$('.modal:visible').length);$(this).css('z-index',zIndex);setTimeout(function(){$('.modal-backdrop').not('.modal-stack').css('z-index',zIndex-1).addClass('modal-stack');},0);});$('#tabs a[data-toggle="tab"]').on('shown.bs.tab',function(e){if($(e.target).attr("href")=="#navigasi"){$("#konten-menu").hide();$("#navigasi-menu").show();}else{$("#navigasi-menu").hide();$("#konten-menu").show();}});</script>
  </body>
</html>