<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  
  <head>
    <title>
      Daftar Email <?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><a href="<?php echo site_url('admin/payments/paypal');?>"><?php echo html_escape($this->payment->paypal->nama);?></a></li>
        <li class="active"><span>Daftar Email</span></li>
      </ul>
      <div class="row">
        <div class="col-sm-12">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3>
                <a class="pull-right" href="<?php echo site_url('admin/payments/paypal/add_whitelist');?>" style="font-size: 18px;color:#333;cursor:pointer;" data-toggle="modal" data-target="#myModal" title="Tambah email"><i class="fa fa-plus"></i></a>
                <i class="fa fa fa-at"></i> Daftar Email
              </h3>
            </div>
            <div class="panel-body">
              <div class="row">
                <div class="col-sm-4 col-md-3">
                  <div class="btn-group btn-group-justified" role="group" style="margin-bottom: 15px;">
                    <a href="<?php echo site_url('/admin/payments/paypal/email_lists/1/1');?>" class="btn btn-<?php echo $whitelist ? 'success' : 'default';?>"><i class="fa fa-check-circle"></i> Whitelist</a>
                    <a href="<?php echo site_url('/admin/payments/paypal/email_lists/0/1');?>" class="btn btn-<?php echo !$whitelist ? 'success' : 'default';?>"><i class="fa fa-at"></i> Semua</a>
                  </div>
                </div>
                <div class="col-sm-offset-2 col-md-offset-5 col-sm-6 col-md-4">
                  <form method="get" action="<?php echo current_url();?>" style="margin-bottom: 15px;">
                    <div class="input-group">
                      <input class="form-control" name="search" placeholder="Cari Email; 4 s/d 64 karakter..." value="<?php echo html_escape($search);?>" />
                      <span class="input-group-btn"><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button></span>                      
                    </div>
                  </form>
                </div>
              </div>
              <?php if (!$total):?>
              <div class="alert alert-warning">Tidak ada daftar.</div>
              <?php else:?>
              <div class="table-responsive">
                <table class="table">
                  <thead>
                    <tr>
                      <th>User</th>
                      <th>Email</th>
                      <th>Name</th>
                      <th>PayPal ID</th>
                      <th>Status</th>
                      <th>Country</th>
                      <th>Payment</th>
                      <th>Whitelist</th>
                      <th style="width: 100px;" class="text-center">Action</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php
                    foreach ($results as $result):
                    $total_users = count(json_decode($result->users, true));
                    ?>
                    <tr>
                      <td><?php echo ($result->us_name ? '<a href="'.site_url('admin/users/profil/'.$result->us_id).'">'.html_escape($result->us_name).'</a>' : 'Tidak ada') . ($total_users > 1 ? ' (<span>'.$total_users.' users</span>)' : '');?></td>
                      <td><?php
                      if ($search) {
                        echo preg_replace("/$search/i",'<span style="color:red;font-weight:bold">${0}</span>', $result->email) . PHP_EOL;
                      }
                      else
                        echo $result->email . PHP_EOL;
                      ?></td>
                      <td><?php echo html_escape($result->fullname);?></td>
                      <td><?php echo $result->payerid?></td>
                      <td><?php echo $result->payerstatus?></td>
                      <td><?php echo $result->countrycode?></td>
                      <td>$ <?php echo $result->total_amount;?> (<?php echo $result->total_payment;?> trx)</td>
                      <td><?php echo $result->whitelist ? 'Ya' : 'Tidak';?></td>
                      <td class="text-center" style="vertical-align: middle;width:100px;">
                        <a data-toggle="modal" data-target="#myModal" class="btn btn-default btn-xs" href="<?php echo site_url('admin/payments/paypal/edit_whitelist/'.$result->id.'/'.$page);?>"><i class="fa fa-edit"></i></a>
                        &nbsp;
                        <a data-toggle="modal" data-target="#myModal" class="btn btn-danger btn-xs" href="<?php echo site_url('admin/payments/paypal/delete_whitelist/'.$result->id.'/'.$page);?>"><i class="fa fa-remove"></i></a>
                      </td>
                    </tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
              <?php echo pagination(site_url('admin/payments/paypal/email_lists/'.$whitelist),$start,$total,$this->system->set['list_per_page'],'/%d?search='.urlencode($search));?>
              <?php endif; ?>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
  </body>

</html>