<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Tagihan #<?php echo $trx->tg_id;?></title>
    <?php include_once(VIEWPATH.'includes/head.php'); ?>
  </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><a href="<?php echo site_url('admin/transaksi/tagihan');?>">Tagihan</a></li>
        <li class="active"><span>Detail</span></li>
      </ul>
      <div class="row">
        <div class="col-sm-6 col-md-8">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-list-alt"></i> Tagihan #<?php echo $trx->tg_id;?></h3>
            </div>
            <div class="panel-body">
              <div class="table-responsive">
                <table class="table table-striped">
                  <tbody>
                    <tr><td>Tagihan</td><td><?php echo html_escape($trx->tg_title);?></td></tr>
                    <tr><td>Keterangan</td><td><?php echo tg_keterangan($trx->us_id, $trx->tg_title, json_decode($trx->tg_opsi,true), true);?></td></tr>
                    <tr><td>Pembayaran</td><td><?php echo html_escape($this->payment->{$trx->tg_payment}->nama);?></td></tr>
                    <tr><td>Jumlah</td><td><?php echo format_uang2($trx->tg_amount, $trx->tg_rate, $this->payment->{$trx->tg_payment}->template, $this->payment->{$trx->tg_payment}->round);?></td></tr>
                    <tr><td>Tanggal</td><td><?php echo format_tanggal($trx->tg_tanggal);?></td></tr>
                    <tr><td>Status</td><td><?php echo tg_status($trx->tg_tanggal, $trx->tg_status, $exp_time);?></td></tr>
                  </tbody>
                </table>
              </div>
            </div>
            <div class="panel-footer hidden-print">
              <a class="btn btn-danger" data-toggle="modal" data-target="#myModal" href="<?php echo site_url('admin/transaksi/tagihan/delete/' . $trx->tg_id);?>"><i class="fa fa-remove"></i> Hapus</a>
            </div>
          </div>
        </div>
        <div class="col-sm-6 col-md-4 hidden-print">
          <?php if ($trx->us_username):?>
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-user"></i> User</h3>
            </div>
            <div class="panel-body">
              <div class="table-responsive">
                <table class="table table-striped" style="margin-bottom: 0;">
                  <tbody>
                    <tr><td>Nama Lengkap</td><td><a href="<?php echo site_url('admin/users/profil/'.$trx->us_id);?>"><?php echo ($trx->us_verified ? '<span class="text-success"><i class="fa fa-check-circle"></i></span> ' : '') . html_escape($trx->us_name);?></a></td></tr>
                    <tr><td>Saldo</td><td><?php echo format_uang2($trx->us_balance, 0);?></td></tr>
                    <tr><td>Total Transaksi</td><td><?php echo $trx->us_total_order;?> sukses</td></tr>
                    <tr><td>Masuk Terakhir</td><td><?php echo format_tanggal($trx->us_lastdate);?></td></tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          <?php endif;?>
          <?php if ($trx->tg_payment =='balance'):?>
          <div class="alert alert-success">
            <h3>Sukses</h3>Pembayaran sudah diselesaikan dengan menggunakan saldo akun.
          </div>
          <?php else:?>
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-money"></i> Bayar dengan <?php echo $this->payment->{$trx->tg_payment}->nama;?></h3>
            </div>
            <div class="panel-body">
              <?php if ($trx->tg_status == 'pending' && $trx->tg_tanggal < $exp_time):?>
              <div class="alert alert-danger">
                <h3>Tidak Berlaku</h3>Pembayaran belum diselesaikan dan tagihan sudah tidak berlaku lagi.
              </div>
              <?php elseif ($trx->tg_status == 'pending'):?>
              <div class="alert alert-info">
                <h3>Menunggu Pembayaran</h3>Pembayaran belum diselesaikan dan masih berlaku sampai <?php echo format_tanggal($trx->tg_tanggal + (3600 * $this->system->set['jam_pembayaran']));?>.
              </div>
              <?php elseif ($trx->tg_status == 'refund'):?>
              <div class="alert alert-danger">
                <h3>Refund</h3>Pembayaran dikembalikan.
              </div>
              <?php else:?>
              <div class="alert alert-success">
                <h3>Lunas</h3>Pembayaran berhasil diselesaikan. <a class="alert-link" href="<?php echo site_url('admin/payments/'.$trx->tg_payment.'/mutasi');?>">Lihat mutasi &raquo;</a>
              </div>
              <?php endif;?>
              <?php if (@$trx->keterangan): ?>
              <div class="table-responsive">
                <table class="table table-striped">
                  <tbody>
                    <tr><td>Tanggal</td><td><?php echo format_tanggal($trx->tanggal);?></td></tr>
                    <tr><td>Keterangan</td><td><?php echo nl2br(html_escape($trx->keterangan));?></td></tr>
                    <tr><td>Kredit</td><td><?php echo $trx->kredit;?></td></tr>
                  </tbody>
                </table>
              </div>
              <?php endif;?>
            </div>
          </div>
          <?php endif;?>
          <?php if ($opsi && isset($opsi['sn'])){unset($opsi['sn']);} if ($opsi):?>
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-info-circle"></i> Opsi Tagihan</h3>
            </div>
            <div class="panel-body">
              <div class="table-responsive">
                <table class="table table-striped">
                  <tbody>
                    <?php foreach ($opsi as $info_key=>$info_val):?>
                    <tr><td><?php echo html_escape($info_key);?></td><td><?php echo html_escape(is_array($info_val) ? json_encode($info_val) : $info_val);?></td></tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          <?php endif;?>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
  </body>
</html>