<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Admin &gt; Testimonial</title>
    <?php include_once(VIEWPATH. 'includes/head.php'); ?>
    <style type="text/css">
      #action-links nav {float:right}
      .table-filter {background-color: #fff;border-bottom: 1px solid #eee;}
      .table-filter tbody tr:hover {cursor: pointer;background-color: #eee;}
      .table-filter tbody tr td {padding: 10px;vertical-align: middle;border-top-color: #eee;}
      .table-filter tbody tr.selected td {background-color: #eee;}
      .table-filter tr td:first-child {width: 38px;}
      .table-filter tr td:nth-child(2) {width: 35px;}
      .ckbox {position: relative;}
      .ckbox input[type="checkbox"] {opacity: 0;}
      .ckbox label {-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}
      .ckbox label:before {content: '';top: 1px;left: 0;width: 18px;height: 18px;display: block;position: absolute;border-radius: 2px;border: 1px solid #bbb;background-color: #fff;}
      .ckbox input[type="checkbox"]:checked + label:before {border-color: #2BBCDE;background-color: #2BBCDE;}
      .ckbox input[type="checkbox"]:checked + label:after {top: 3px;left: 3.5px;content: '\e013';color: #fff;font-size: 11px;font-family: 'Glyphicons Halflings';position: absolute;}
      .table-filter .trx {color: #ccc;text-align: center;display: block;}
      .table-filter a.trx:hover {color: #337ab7;}
      .table-filter .pull-left i {font-size: 40px;}
      .table-filter .media-meta {font-size: 11px;color: #999;}
      .table-filter .media .title {font-size: 14px;font-weight: bold;line-height: normal;margin: 0;}
      .table-filter .media .title span, .table-filter .media .title a.pull-right {font-size: .8em;margin-right: 20px;}
      @media(max-width:768px){.table-filter .pull-left i {font-size: 20px;}}
    </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>Testimonial</span></li>
      </ul>
      <div class="row">
        <div class="col-sm-12">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-comments-o"></i> Testimonial</h3>
            </div>
            <div class="panel-body">
              <div class="row">
                <div class="col-sm-4 col-md-3 col-lg-2" style="margin-bottom: 15px;">
                  <a class="btn btn-danger btn-block" data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/testimonial/clear/'.$label);?>"><i class="fa fa-trash"></i> Hapus semua</a>
                </div>
                <div class="col-sm-offset-4 col-sm-4 col-md-offset-6 col-md-3 col-lg-offset-8 col-lg-2" style="margin-bottom: 15px;">
                  <div class="dropdown">
                    <button type="button" id="filter" class="btn btn-default btn-block" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-filter"></i> <?php echo ($label == 'accepted' ? 'Disetuji' : ($label == 'moderated' ? 'Moderasi' : 'Semua'));?> <i class="caret"></i></button>
                    <ul class="dropdown-menu" aria-labelledby="filter">
                      <li class="<?php echo $label == 'all' ? 'active' : '';?>"><a href="<?php echo site_url('admin/testimonial');?>">Semua</a></li>
                      <li class="<?php echo $label == 'moderated' ? 'active' : '';?>"><a href="<?php echo site_url('admin/testimonial/moderated');?>">Moderasi</a></li>
                      <li class="<?php echo $label == 'accepted' ? 'active' : '';?>"><a href="<?php echo site_url('admin/testimonial/accepted');?>">Disetujui</a></li>
                    </ul>
                  </div>
                </div>
              </div>
              <?php if (!$total):?>
              <div class="alert alert-warning" style="margin-bottom: 0;">
                Tidak ada testimonial.
              </div>
              <?php else:?>
              <?php echo form_open();?>
              <div class="table-container">
                <table class="table table-filter">
                  <tbody>
                    <?php foreach ($results as $message): ?>
                    <tr id="testimonial-<?php echo $message->id;?>">
                      <td><div class="ckbox"><input type="checkbox" id="checkbox<?php echo $message->id;?>" name="testimonial_id[]" value="<?php echo $message->id;?>"/><label for="checkbox<?php echo $message->id;?>"></label></div></td>
                      <td><?php if ($message->tr_id):?><a class="trx" href="<?php echo site_url('admin/transaksi/view/'.$message->tr_id);?>" class="star"><i class="fa fa-shopping-bag"></i></a><?php endif;?></td>
                      <td>
                        <div class="media">
                          <a href="<?php echo $message->us_id ? site_url('admin/users/profil/'.$message->us_id) : '#';?>" class="pull-left"><?php echo ($message->us_id ? '<i class="fa fa-user"></i>' : '<i class="fa fa-user-secret"></i>');?></a>
                          <div class="media-body">
                            <span class="media-meta pull-right"><?php echo format_tanggal($message->tanggal);?></span>
                            <h4 class="title">
                              <a href="<?php echo $message->us_id ? site_url('admin/users/profil/'.$message->us_id) : '#';?>"><?php echo html_escape($message->nama);?></a> <a data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/sms/kirim?phone='.urlencode($message->no_hp));?>"><small>(<?php echo html_escape($message->no_hp);?>)</small></a>
                              <?php if ($message->moderasi):?>
                              <a class="pull-right btn btn-success btn-xs" data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/testimonial/confirm/'.$message->id);?>" title="Setujui"><i class="fa fa-check"></i></a>
                              <?php endif;?>
                            </h4>
                            <p class="summary"><?php echo nl2br(html_escape($message->pesan));?></p>
                          </div>
                        </div>
                      </td>
                    </tr>
                    <?php endforeach;?>
                  </tbody>              
                </table>
              </div>
              <div class="row" id="action-links">
                <div class="col-xs-12 col-sm-4 col-md-3">
                  <div class="input-group">
                    <select class="form-control input-sm" name="mass_action">
                      <option value="">-- Yang ditandai --</option>
                      <option value="delete">Hapus</option>
                      <option value="accepted">Menyetujui</option>
                    </select>
                    <span class="input-group-btn"><button class="btn btn-primary btn-sm" type="submit">GO</button></span>
                  </div>
                </div>
                <div style="margin-bottom: 15px;" class="col-xs-12 visible-xs"></div>
                <div class="col-xs-12 col-sm-8 col-md-9">
                  <?php echo pagination(site_url('admin/testimonial/'.$label), $start, $total, $this->system->set['list_per_page'], '/%d');?>
                </div>
              </div>
              <?php echo form_close();?>
              <?php endif;?>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script>$(document).ready(function(){$('.ckbox label').on('click', function(){var attr = $("#"+$(this).attr('for')).attr('selected');if (typeof attr !== typeof undefined && attr !== false){$("#"+$(this).attr('for')).removeAttr('selected');}else{$("#"+$(this).attr('for')).attr('selected','selected');}$(this).parents('tr').toggleClass('selected');});});</script>
  </body>
</html>