<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Admin &gt; Transaksi</title>
    <?php include_once(VIEWPATH. 'includes/head.php'); ?>
    <style type="text/css">.panel-body.xxx{padding-bottom: 0;}.panel-body.xxx div.row>div>button{margin-bottom: 15px;}.panel-body.xxx div.row>div>nav{float:right;margin-bottom:15px;}</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><a href="<?php echo site_url('admin/transaksi');?>">Transaksi</a></li>
        <li class="active"><span>Tagihan</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-money"></i> Tagihan</h3>
            </div>
            <div class="panel-body xxx">
              <div class="row">
                <div class="col-sm-4 col-md-3 col-lg-2" style="margin-bottom: 15px;">
                  <a class="btn btn-default btn-block" href="<?php echo site_url('admin/transaksi/tagihan/create');?>" data-toggle="modal" data-target="#myModal"><i class="fa fa-plus"></i> Membuat</a>
                </div>
                <div class="col-sm-8 col-md-9 col-lg-10">
                  <div class="row">
                    <div class="col-sm-offset-4 col-sm-4" style="margin-bottom: 15px;">
                      <form method="get" action="<?php echo site_url('admin/transaksi/tagihan');?>">
                        <div class="input-group">
                          <input class="form-control" type="text" name="username" placeholder="Cari Username..." value="<?php echo set_value('username', $this->input->get('username'));?>"/>
                          <span class="input-group-btn">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
                          </span>
                        </div>
                      </form>
                    </div>
                    <div class="col-sm-4" style="margin-bottom: 15px;">
                      <form method="get" action="<?php echo site_url('admin/transaksi/tagihan');?>">
                        <div class="input-group">
                          <input class="form-control" type="number" name="id" placeholder="Cari ID Tagihan..." value="<?php echo set_value('id', $this->input->get('id'));?>"/>
                          <span class="input-group-btn">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
                          </span>
                        </div>
                      </form>
                    </div>
                  </div>
                </div>
              </div>
              <?php if (!$results):?>
              <div class="alert alert-warning" style="margin-bottom: 15px;">Tidak ada riwayat tagihan</div>
              <?php else:?>
              <?php echo form_open();?>
              <div class="table-responsive">
                <table class="table table-bordered">
                  <thead>
                    <tr>
                      <th class="text-center" style="width: 40px;"><input type="checkbox" id="select-all"/></th>
                      <th>ID</th>
                      <th>User</th>
                      <th>Tagihan</th>
                      <th>Keterangan</th>
                      <th>Pembayaran</th>
                      <th>Jumlah</th>
                      <th>Tanggal</th>
                      <th style="width: 80px;text-align:center">Status</th>
                      <th class="text-center" style="width:80px">Tindakan</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php foreach ($results as $res):?>
                    <tr>
                      <td class="text-center"><input type="checkbox" class="checkbox1" name="tag_id[]" value="<?php echo $res->tg_id;?>"/></td>
                      <td><a href="<?php echo site_url('admin/transaksi/tagihan/view/'.$res->tg_id);?>"><?php echo $res->tg_id;?></a></td>
                      <td><?php echo ($res->us_username ? '<a href="'.site_url('admin/users/profil/'.$res->us_id).'">'.html_escape($res->us_name).'</a>' : '');?></td>
                      <td><?php echo html_escape($res->tg_title);?></td>
                      <td><?php echo tg_keterangan($res->us_id, $res->tg_title, json_decode($res->tg_opsi,true), true);?></td>
                      <td><?php echo html_escape($this->payment->{$res->tg_payment}->nama);?></td>
                      <td><?php echo format_uang($res->tg_amount, $res->tg_rate, $this->payment->{$res->tg_payment}->template, $this->payment->{$res->tg_payment}->round);?></td>
                      <td><?php echo format_tanggal($res->tg_tanggal);?></td>
                      <td style="width: 80px;text-align:center"><?php echo tg_status($res->tg_tanggal, $res->tg_status, $expired);?></td>
                      <td class="text-center" style="width:80px"><a class="btn btn-danger btn-xs" data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/transaksi/tagihan/delete/' . $res->tg_id);?>" title="Hapus"><i class="fa fa-remove"></i></a></span></td>                      
                    </tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
              <div class="row">
                <div class="col-sm-4 col-md-3">
                <button class="btn btn-danger btn-block btn-sm" type="submit"><i class="fa fa-trash"></i> Hapus yang ditandai</button>
                </div>
                <div class="col-sm-8 col-md-9">
                <?php echo pagination(site_url('admin/transaksi/tagihan/page/'), $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(){$('#select-all').click(function(event){if(this.checked){$('.checkbox1').each(function(){this.checked=true;})}else{$('.checkbox1').each(function(){this.checked=false;})}});});</script>
  </body>
</html>