<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  
  <head>
    <title>
      Detail Transaksi <?php echo $this->payment->paypal->nama;?>
    </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/payments');?>">Metode Pembayaran</a></li>
        <li class="active"><span><?php echo html_escape($this->payment->paypal->nama);?></span></li>
      </ul>
      <div class="row">
        <div class="col-sm-4 col-md-3">
          <?php
          $params = array(array(
            'title' => html_escape($this->payment->paypal->nama),
            'links' => array(
                array('Overview', site_url('admin/payments/paypal'), 'fa fa-eye'),
                array('Mutasi', site_url('admin/payments/paypal/mutasi'), 'fa fa-history', true),
                array('Settings', site_url('admin/payments/paypal/settings'), 'fa fa-cog'),
                array('Daftar Email', site_url('admin/payments/paypal/email_lists'), 'fa fa-at'),
            )
          ));
          echo sidebar_menu($params);
          ?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="row">
            <div class="col-sm-12 col-md-6">
              <div class="panel panel-default">
                <div class="panel-heading">
                  <h3>
                    <i class="fa fa-info-circle"></i> Rincian Pembayaran
                  </h3>
                </div>
                <div class="panel-body">
                  <?php
                  if ($whitelist):
                  $total_users = count(json_decode($whitelist->users,true));
                  ?>
                  <div class="well well-sm">
                    <div class="table-responsive">
                      <table class="table table-striped" style="margin-bottom: 0;">
                        <tbody>
                          <tr>
                            <td>User</td>
                            <td><?php if ($whitelist->us_name):?><a href="<?php echo site_url('admin/users/profil/'.$whitelist->us_id);?>"><?php echo html_escape($whitelist->us_name);?></a><?php else:?>Tidak ada<?php endif;?> <?php echo $total_users ? '(<span>'.$total_users.' users</span>)' : '';?></td>
                          </tr>
                          <tr>
                            <td>Email</td>
                            <td><?php echo $whitelist->email;?></td>
                          </tr>
                          <tr>
                            <td>Whitelist</td>
                            <td><?php echo $whitelist->whitelist ? 'Ya' : 'Tidak';?></td>
                          </tr>
                          <tr>
                            <td>Payment</td>
                            <td>$ <?php echo $whitelist->total_amount;?> (<?php echo $whitelist->total_payment;?> trx)</td>
                          </tr>
                        </tbody>
                      </table>
                    </div>
                  </div>
                  <?php endif;?>
                  <?php if ($details):?>
                  <div class="table-responsive">
                    <table class="table table-striped">
                      <tbody>
                        <?php foreach ($details as $data_key=>$data_val):?>
                        <tr>
                          <td style="width: 140px;"><?php echo $data_key;?></td>
                          <td><?php echo in_array($data_key, array('EMAIL', 'PAYERSTATUS', 'COUNTRYCODE')) ? '<span class="text-info"><strong>'.html_escape($data_val).'</strong></span>' : html_escape($data_val);?></td>
                        </tr>
                        <?php endforeach;?>
                      </tbody>
                    </table>
                  </div>
                  <?php else:?>
                  <div class="alert alert-info">
                    Rincian pembayaran tidak tersedia.
                  </div>
                  <?php endif;?>
                  <div class="text-center">
                    <a href="https://history.paypal.com/webscr?cmd=_history-details-from-hub&id=<?php echo $this->uri->segment(5)?>" target="_blank" class="btn btn-default btn-sm">Lihat di PayPal.com</a>
                  </div>
                </div>            
              </div>
            </div>
            <div class="col-sm-12 col-md-6">
              <div class="panel panel-default">
                <?php if ($trx):?>
                <div class="panel-heading">
                  <h3><i class="fa fa-list-alt"></i> Transaksi</h3>
                </div>
                <?php elseif ($deposit):?>
                <div class="panel-heading">
                  <h3><i class="fa fa-money"></i> Deposit</h3>
                </div>
                <?php endif;?>
                <div class="panel-body">
                  <?php if ($trx):?>
                  <?php if ($trx->us_username):?>
                  <div class="well well-sm">
                    <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 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>
                  <?php endif;?>
                  <?php include (VIEWPATH.'/admin/transaksi/'.$trx->op_produk.'.php');?>
                  <div class="text-center">
                    <a href="<?php echo site_url('admin/transaksi/view/'.$trx->tr_id)?>" class="btn btn-default btn-sm">Lihat transaksi</a>
                  </div>
                  <?php elseif ($deposit):?>
                  <div class="well well-sm">
                    <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/'.$deposit->us_id);?>"><?php echo html_escape($deposit->us_name);?></a></td>
                          </tr>
                          <tr>
                            <td>Saldo</td>
                            <td><?php echo format_uang2($deposit->us_balance, 0);?></td>
                          </tr>
                          <tr>
                            <td>Total Transaksi</td>
                            <td><?php echo $deposit->us_total_order;?> sukses</td>
                          </tr>
                          <tr>
                            <td>Masuk Terakhir</td>
                            <td><?php echo format_tanggal($deposit->us_lastdate);?></td>
                          </tr>
                        </tbody>
                      </table>
                    </div>
                  </div>
                  <div class="table-responsive">
                    <table class="table table-striped">
                      <tbody>
                        <tr>
                          <td>ID</td><td><?php echo $deposit->de_id;?></td>
                        </tr>
                        <tr>
                          <td>Tanggal</td><td><?php echo format_tanggal($deposit->de_tanggal)?></td>
                        </tr>
                        <tr>
                          <td>Jumlah</td><td><?php echo format_uang2($deposit->de_amount, $deposit->de_rate, $this->payment->{$deposit->de_payment}->template, $this->payment->{$deposit->de_payment}->round);?></td>
                        </tr>
                        <tr>
                          <td>Status</td><td><?php echo ucfirst(str_replace('_',' ',$deposit->de_status));?></td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                  <div class="text-center">
                    <a href="<?php echo site_url('admin/riwayat-deposit/view/'.$deposit->de_id)?>" class="btn btn-default btn-sm">Lihat deposit</a>
                  </div>
                  <?php else:?>
                  <div class="alert alert-warning">
                    Tidak ada rincian transaksi.
                  </div>
                  <?php endif;?>
                </div>
              </div>              
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
  </body>

</html>