<?php if(!defined('PARENT')) { exit; }
$SQL = 'WHERE `approved` = \'no\' ';
$Q  = $DB->db_query("SELECT SQL_CALC_FOUND_ROWS * FROM `" . DB_PREFIX . "affiliates` $SQL ORDER BY `id` DESC LIMIT $limit," . PER_PAGE);
$NR = $DB->db_foundrows($Q);
?>

    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-right">
        <div class="btn-group">
          <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            <i class="fa fa-chevron-down fa-fw"></i>
          </button>
          <ul class="dropdown-menu dropdown-menu-right">
            <li><a href="?p=aff-add"><i class="fa fa-plus fa-fw"></i> <?php echo $msw_adm_aff_manage2; ?></a></li>
          </ul>
        </div>
      </div>
    </div>

    <div class="managepanel" style="margin-top:10px">
      <form method="post" action="?p=<?php echo $cmd; ?>">
      <div class="panel panel-default managearea">
        <div class="panel-heading">
          <?php echo $msw_adm_aff_manage; ?> (<?php echo mswNFM($NR); ?>)
        </div>
        <div class="panel-body">
          <div class="table-responsive">
           <table class="table table-striped table-hover" id="sortTable">
             <thead>
               <tr>
                 <th class="text-center"><input type="checkbox" name="c" value="yes" onclick="mswSC('.managearea .table td','delb')"></th>
                 <th data-sort="string"><?php echo $msw_adm_aff_manage15; ?></th>
                 <th data-sort="int"><?php echo $msw_adm_aff_approve4; ?></th>
                 <th data-sort="string"><?php echo $msw_adm_aff_approve5; ?></th>
                 <th>&nbsp;</th>
               </tr>
             </thead>
             <tbody>
               <?php
               if ($NR > 0) {
                 while ($AF = $DB->db_object($Q)) {
                 ?>
                 <tr id="idr_<?php echo $AF->id; ?>">
                   <td><input type="checkbox" name="fm[id][]" value="<?php echo $AF->id; ?>" onclick="mswSCG('.managearea .table td','delb')"></td>
                   <td><b><?php echo mswSH($AF->fname . ' ' . $AF->lname); ?></b>
                   <span class="smalldata">
                     <?php echo $msw_adm_aff_manage9 . '<span class="highlight">' . ($AF->commtier ? $AF->commtier : $msw_common17); ?></span><br>
                     <?php echo $msw_adm_aff_manage11 . '<span class="highlight">' .  mswAff($SETTINGS, $AF); ?></span>
                   </span>
                   </td>
                   <td><?php echo mswSH($AF->email); ?></td>
                   <td data-sort-value="<?php echo $AF->ts; ?>"><?php echo $DT->datedisplay($SETTINGS, $AF->ts); ?></td>
                   <td>
                     <a href="?p=aff-add&amp;id=<?php echo $AF->id; ?>&amp;rdr=<?php echo $cmd; ?>" title="<?php echo mswSH($msw_common4); ?>"><span class="fa-stack"><i class="fa fa-square fa-stack-2x"></i><i class="fa fa-pencil fa-stack-1x fa-inverse"></i></span></a>
                   </td>
                 </tr>
                 <?php
                 }
               } else {
                 $colspan = 5;
                 include(PATH . 'content/no-data.php');
               }
               ?>
             </tbody>
           </table>
         </div>
         <?php
         // Pagination..
         if ($NR > PER_PAGE) {
           $PGS = new pages(array(
             'count' => $NR,
             'text' => $msw_pages,
             'page' => $page,
             'admin' => 'yes',
             'flag' => '',
             'limit' => PER_PAGE,
             's' => $SETTINGS
           ));
           echo $PGS->display();
         }
         ?>
        </div>
      </div>
      <?php
      if ($NR > 0) {
      ?>
      <div class="act-button btngroups">
        <div class="btn-group">
          <button type="button" class="btn btn-info dropdown-toggle disabled" id="delb" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            <i class="fa fa-chevron-down fa-fw"></i> <?php echo $msw_adm_aff_approve2; ?>
          </button>
          <ul class="dropdown-menu">
            <li><a href="#" onclick="mswAction('<?php echo $cmd; ?>','.managepanel','no','yes');return false"><i class="fa fa-check fa-fw"></i> <?php echo $msw_adm_aff_approve3; ?></a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#" onclick="mswAction('<?php echo $cmd; ?>-del','.managepanel','no','yes');return false"><i class="fa fa-times fa-fw"></i> <?php echo $msw_common3; ?></a></li>
          </ul>
        </div>
      </div>
      <?php
      }
      ?>
      </form>
    </div>