<?php
  /**
   * User Manager
   *
   * @package Wojo Framework
   * @author wojoscripts.com
   * @copyright 2016
   * @version $Id: _users_grid.tpl.php, v1.00 2016-01-08 10:12:05 gewa Exp $
   */
  if (!defined("_WOJO"))
      die('Direct access to this location is not allowed.');
?>
<div class="row half-gutters align-middle">
  <div class="column shrink mobile-100 mobile-order-1">
    <h2><?php echo Lang::$word->META_M_USERS;?></h2>
  </div>
  <div class="columns content-right mobile-50 mobile-content-left mobile-order-2">
    <a href="<?php echo Url::url("/admin/users", "new/");?>" class="wojo small primary basic rounded button">
      <i class="icon plus alt"></i>
      <?php echo Lang::$word->USR_NEW;?></a>
  </div>
  <div class="columns shrink mobile-50 mobile-order-3 mobile-content-right">
    <a href="<?php echo Url::url("/admin/users");?>" class="wojo mini icon primary button"><i class="icon unordered list"></i></a>
    <a class="wojo disabled mini icon button"><i class="icon grid list"></i></a>
    <a href="<?php echo ADMINVIEW . '/helper.php?exportUsers';?>" class="wojo small basic button"><?php echo Lang::$word->EXPORT;?></a>
  </div>
</div>
<div class="half-top-padding">
  <div class="wojo divided horizontal link list align-center">
    <div class="disabled item wojo bold text">
      <?php echo Lang::$word->SORTING_O;?>
    </div>
    <a href="<?php echo Url::url(Router::$path);?>" class="item<?php echo Url::setActive("order", false);?>">
      <?php echo Lang::$word->RESET;?>
    </a>
    <a href="<?php echo Url::url(Router::$path, "?order=items|DESC");?>" class="item<?php echo Url::setActive("order", "items");?>">
      <?php echo Lang::$word->PURCHASES;?>
    </a>
    <a href="<?php echo Url::url(Router::$path, "?order=email|DESC");?>" class="item<?php echo Url::setActive("order", "email");?>">
      <?php echo Lang::$word->EMAIL;?>
    </a>
    <a href="<?php echo Url::url(Router::$path, "?order=fname|DESC");?>" class="item<?php echo Url::setActive("order", "fname");?>">
      <?php echo Lang::$word->NAME;?>
    </a>
    <div class="item"><a href="<?php echo Url::sortItems(Url::url(Router::$path), "order");?>" data-tooltip="ASC/DESC"><i class="icon triangle unfold more link"></i></a>
    </div>
  </div>
</div>
<div class="half-top-padding"><?php echo Validator::alphaBits(Url::url(Router::$path), "letter", "wojo small bold text horizontal link divided list align-center");?>
</div>
<div class="wojo space divider"></div>
<?php if(!$this->data):?>
<div class="content-center"><img src="<?php echo ADMINVIEW;?>/images/notfound.png" alt="">
  <p class="wojo small thick caps text"><?php echo Lang::$word->USR_EMPTY;?></p>
</div>
<?php else:?>
<div class="wojo big space divider"></div>
<div class="masonry">
  <?php foreach($this->data as $row):?>
  <div class="item" id="item_<?php echo $row->id;?>">
    <div class="wojo soft shadow attached card">
      <div class="header">
        <div class="row align-middle">
          <div class="columns">
            <a class="wojo bold inverted text" href="<?php echo Url::url("/admin/users/edit/" . $row->id);?>"><?php echo $row->fullname;?></a>
          </div>
          <div class="columns shrink">
            <div class="wojo pointing top right dropdown"> <i class="icon horizontal ellipsis link"></i>
              <div class="small menu">
                <a class="item" href="<?php echo Url::url("/admin/users/edit/" . $row->id);?>"><i class="icon pencil"></i>
                  <?php echo Lang::$word->EDIT;?></a>
                <a class="item" href="<?php echo Url::url("/admin/users/history/" . $row->id);?>"><i class="icon history"></i>
                  <?php echo Lang::$word->HISTORY;?></a>
                <div class="wojo basic divider"></div>
                <a data-set='{"option":[{"trash": "trashUser","title": "<?php echo Validator::sanitize($row->fullname, "spchar");?>","id":<?php echo $row->id;?>}],"action":"trash","parent":"#item_<?php echo $row->id;?>"}' class="wojo bold text item action">
                  <i class="icon trash"></i>
                  <?php echo Lang::$word->TRASH;?></a>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="content">
        <div class="content-center half-bottom-margin">
          <a href="<?php echo Url::url("/admin/users/edit/" . $row->id);?>"><img src="<?php echo UPLOADURL;?>/avatars/<?php echo $row->avatar ? $row->avatar : "blank.svg" ;?>" alt="" class="wojo basic circular normal image"></a>
        </div>
        <div class="row no-all-gutters align-middle">
          <div class="columns"><span class="wojo small text"><?php echo Date::doDate("short_date", $row->created);?></span></div>
          <div class="columns content-center"><?php echo Utility::accountLevelToType($row->userlevel);?></div>
          <div class="columns content-right"><?php echo Utility::status($row->active, $row->id);?>
          </div>
        </div>
      </div>
      <div class="wojo basic divider"></div>
      <div class="footer half-padding">
        <p>
          <?php echo Lang::$word->EMAIL;?>: <a href="<?php echo Url::url("/admin/mailer", "?email=" . urlencode($row->email));?>"><?php echo $row->email;?></a>
        </p>
        <p><?php echo Lang::$word->PURCHASES;?>: <?php echo ($row->items > 0) ? $row->items : '-/-';?></p>
        <p><?php echo Lang::$word->MEMBERSHIP;?>: <?php echo ($row->membership_id > 0) ? $row->mtitle : '-/-';?></p>
        <p>ip: <?php echo $row->lastip;?></p>
      </div>
    </div>
  </div>
  <?php endforeach;?>
</div>
<?php endif;?>
<div class="row half-gutters-mobile half-gutters-phone align-middle">
  <div class="columns shrink mobile-100 phone-100">
    <div class="wojo small demi text"><?php echo Lang::$word->TOTAL . ': ' . $this->pager->items_total;?> / <?php echo Lang::$word->CURPAGE . ': ' . $this->pager->current_page . ' '. Lang::$word->OF . ' ' . $this->pager->num_pages;?></div>
  </div>
  <div class="columns mobile-100 phone-100 content-right mobile-content-left"><?php echo $this->pager->display_pages('small');?></div>
</div>
