<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  
  <head>
    <title>
      Testimonial | <?php echo html_escape($this->system->set['site_name']) . PHP_EOL; ?>
    </title>
    <?php include_once(VIEWPATH.'includes/head.php'); ?>
  </head>
  
  <body>
    <?php include_once(VIEWPATH.'includes/navbar.php'); ?>
    <div class="container">
      <div class="row">
        <div class="col-sm-8">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-comments"></i> Testimonial</h3>
            </div>
            <?php if (!$total):?>
            <div class="panel-body">
              <div class="alert alert-warning" style="margin-bottom: 0;">Belum ada testimonial</div>
            </div>
            <?php else:?>
            <ul class="list-group">
              <?php foreach ($results as $testi):?>
              <li class="list-group-item <?php echo (isset($_GET['saved']) && $_GET['saved'] == $testi->id ? ($testi->moderasi ? 'list-group-item-warning' : 'list-group-item-success') : '');?>" id="testi-<?php echo $testi->id;?>">
                <div class="list-group-item-heading">
                  <span class="text-muted pull-right">
                    <small><i class="fa fa-clock-o"></i> <?php echo format_tanggal($testi->tanggal);?></small>
                  </span>
                  <strong><i class="fa fa-<?php echo $testi->us_id ? 'user' : 'user-secret';?>"></i> <?php echo html_escape($testi->nama);?></strong>&nbsp;
                  <span class="text-muted">(<?php echo substr($testi->no_hp, 0, -3);?>XXX)</span>
                </div>
                <div class="list-group-item-text">
                  <?php echo nl2br(html_escape($testi->pesan)) . PHP_EOL;?>
                </div>
              </li>
              <?php endforeach;?>
            </ul>
            <?php
            $pagination = pagination(site_url('testimonial/index/'), $start, $total, $this->system->set['list_per_page'],'%d');
            if ($pagination) {
            ?>
            <div class="panel-footer">
              <?php echo $pagination;?>
            </div>
            <?php
            } ?>
            <?php endif;?>
          </div>
        </div>
        <div class="col-sm-4">
          <div class="panel panel-default" id="kirim-testimonial">
            <div class="panel-heading">
              <h3><i class="fa fa-pencil"></i> Kirim Testimonial</h3>
            </div>
            <div class="panel-body">
              <?php if ($this->session->has_userdata('testi')):?>
              <div class="alert alert-success" style="margin-bottom: 0;">Terima kasih sudah mengirimkan testimonial</div>
              <?php else:?>
              <?php echo form_open();?>
                <div class="form-group">
                  <label for="nama">Nama</label>
                  <input type="text" class="form-control" name="nama" id="nama" value="<?php echo set_value('nama',($this->user->is_user() ? $this->user->data['us_name'] : ''));?>" placeholder="Nama" maxlength="32" <?php echo ($this->user->is_user() ? 'disabled="disabled"' : '');?> />
                </div>
                <div class="form-group">
                  <label for="no_hp">No. HP</label>
                  <input type="text" class="form-control" name="no_hp" id="no_hp" value="<?php echo set_value('no_hp', ($this->user->is_user() ? $this->user->data['us_phone'] : ''));?>" placeholder="Nomor HP" maxlength="16" />
                </div>
                <div class="form-group">
                  <label for="pesan">Pesan</label>
                  <textarea class="form-control" name="pesan" id="pesan" rows="6" maxlength="160"><?php echo set_value('pesan');?></textarea>
                </div>
                <div class="form-group">
                  <label for="captcha">Kode Keamanan</label>
                  <div class="input-group">
                    <span class="input-group-addon" style="padding: 0;">
                      <img src="<?php echo site_url('captcha');?>" style="" alt="Captcha"/>
                    </span>
                    <input type="text" class="form-control input-lg" name="captcha" id="captcha" maxlength="5" size="5" required="required" placeholder="Kode keamanan"/>
                  </div>
                </div>
                <div>
                  <button type="submit" name="submit" value="send" class="btn btn-primary">Kirim</button>
                </div>
              <?php echo form_close();?>
              <?php endif;?>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
  </body>

</html>