<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title><?php echo ($provider == 'all' ? 'Harga '.html_escape($this->system->produk->$produk->nama) : ($provider && isset($providers[$produk]) && isset($providers[$produk][$provider]) ? 'Harga '.html_escape($this->system->produk->{$produk}->nama).' &gt; '.html_escape($providers[$produk][$provider]['op_nama']) : 'Daftar Harga'));?></title>
    <?php include_once(VIEWPATH. 'includes/head.php'); ?>
    <style type="text/css">@media (max-width:767px) { #left>.list-group{display:none;} }nav {margin-bottom: 15px; float: right;}.line-through{text-decoration: line-through;}</style>
  </head> 
  <body>
    <?php include_once(VIEWPATH. 'includes/navbar.php'); ?>
    <div class="container">
      <div class="row">
        <div class="col-sm-4 col-md-3">
          <div class="panel panel-default hidden-print" id="left">
            <div class="panel-heading" style="cursor: pointer;">
              <h3><span class="pull-right"><i class="fa fa-chevron-down"></i></span><i class="fa fa-tags"></i> Produk</h3>
            </div>
            <?php
            $out = '';
            foreach ($this->system->produk as $produk_key => $produk_val) {
              if ($produk_val->status == 'off')
                continue;
              $out.='<a class="list-group-item produk-heading" href="#" id="'.$produk_key.'"><h4 style="font-size:14px;font-weight:bold;margin:0"><span class="caret pull-right" style="margin-top:5px"></span>'.@$produk_val->mini_icon.' '.html_escape(strtoupper($produk_val->nama)).'</h4></a>';
              if (isset($providers[$produk_key])) {
                foreach ($providers[$produk_key] as $prov) {
                  $provider_id[$prov['op_id']] = $prov;
                  $out.='<a class="list-group-item list-'.$produk_key . ($provider && $provider == $prov['op_slug'] ? ' active' : '').'" href="'.site_url('harga/'.str_replace('_','-',$produk_key).'/'.$prov['op_slug']).'" style="display:'.($produk == $produk_key ? 'block' : 'none').'">&nbsp;&nbsp;&raquo; '.html_escape($prov['op_nama']).'</a>';
               }
              }
              $out.='<a class="list-group-item list-'.$produk_key . ($provider && $provider == "all" ? ' active' : '').'" href="'.site_url('harga/'.str_replace('_','-',$produk_key)).'" style="display:'.($produk == $produk_key ? 'block' : 'none').'">&nbsp;&nbsp;&raquo; Tampilkan Semua</a>';
            }
            if ($out) {
                echo '<div class="list-group">'.$out.'</div>';
            }
            else {
                echo '<div class="panel-body">Tidak ada daftar</div>';
            }
            ?>
          </div>
        </div>
        <div class="col-sm-8 col-md-9">
          <?php if ($total):?>
          <div class="panel panel-default">
            <div class="panel-heading">
              <h1><i class="fa fa-money"></i> <?php echo ($provider == 'all' ? 'Harga '.html_escape($this->system->produk->$produk->nama) : ($provider && isset($providers[$produk]) && isset($providers[$produk][$provider]) ? 'Harga '.html_escape($this->system->produk->{$produk}->nama).' &gt; '.html_escape($providers[$produk][$provider]['op_nama']) : 'Daftar Harga'));?></h1>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered">
                  <thead>
                    <tr>
                      <th style="vertical-align: middle; width: 130px; <?php echo ($produk != '' ? 'display:none;': '');?>">Jenis Produk</th>
                      <th style="vertical-align: middle; width: 170px; <?php echo ($produk != '' && $provider != 'all' ? 'display:none;': '');?>">Provider</th>
                      <?php if ($this->user->is_user()):?>
                      <th style="vertical-align: middle; width: 70px">Kode</th>
                      <?php endif;?>
                      <th style="vertical-align: middle;">Nominal</th>
                      <th colspan="2" style="width: 80px;" class="text-center">Harga</th>
                      <th style="vertical-align: middle; width: 54px;">Status</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php foreach ($vouchers as $voucher):?>
                    <tr>
                      <td style="<?php echo ($produk != '' ? 'display:none;': '');?>"><?php echo html_escape($this->system->produk->{$voucher->op_produk}->nama);?></td>
                      <td style="<?php echo ($produk != '' && $provider != 'all' ? 'display:none;': '');?>"><?php echo html_escape($voucher->op_nama);?></td>
                      <?php if ($this->user->is_user()):?>
                      <td><?php echo html_escape($voucher->vo_kode_trx);?></td>
                      <?php endif;?>
                      <td><a class="hidden-print" href="<?php echo site_url('produk/'.str_replace('_','-',$voucher->op_produk).'/'.$voucher->op_slug.'/'.str_link($voucher->vo_nominal).'-'.$voucher->vo_id);?>"><?php echo html_escape($voucher->vo_nominal);?></a><span class="visible-print"><?php echo html_escape($voucher->vo_nominal);?></span></td>
                      <td style="width: 55px;"><span data-toggle="tooltip" data-title="Harga Umum" class="<?php echo ($this->user->is_user() && $this->user->is_reseller ? 'line-through' : '');?>"><?php echo format_uang($voucher->vo_harga);?></span></td>
                      <td style="width: 55px;"><span data-toggle="tooltip" data-title="Harga Reseller"  class="<?php echo ($this->user->is_user() && !$this->user->is_reseller ? 'line-through' : '');?>"><?php echo format_uang($voucher->vo_harga_reseller ? $voucher->vo_harga_reseller : $voucher->vo_harga);?></span></td>
                      <td style="text-align: center;"><?php echo ($voucher->vo_status ? '<span class="text-success" data-toggle="tooltip" data-title="Tersedia"><i class="fa fa-check"></i></span>' : '<span class="text-danger" data-toggle="tooltip" data-title="Tidak tersedia"><i class="fa fa-times"></i></span>');?></td>
                    </tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
          </div>
          <div class="hidden-print"><?php echo pagination(site_url('harga'.($provider ? '/'.str_replace('_','-',$produk).'/'.$provider : '')), $start, $total, $this->system->set['list_per_page'],'?page=%d');?></div>
          <?php endif;?>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script>$(".produk-heading").click(function(){var produk = $(this).attr("id");$(".list-"+produk).toggle(400);return false;})</script>
    <script>$("#left>.panel-heading").click(function(){$(this).next().toggle(600);return false;})</script>
  </body>

</html>
