<?php
  /**
   * Products List
   *
   * @package Wojo Framework
   * @author wojoscripts.com
   * @copyright 2016
   * @version $Id: _products_list.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_PRODUCTS;?></h2>
  </div>
  <div class="columns content-right mobile-50 mobile-content-left mobile-order-2">
    <a href="<?php echo Url::url(Router::$path, "new/");?>" class="wojo small primary basic rounded button"><i class="icon plus alt"></i><?php echo Lang::$word->PRD_NEW;?></a>
  </div>
  <div class="columns shrink mobile-50 mobile-order-3 mobile-content-right">
    <a class="wojo disabled mini icon button"><i class="icon unordered list"></i></a>
    <a href="<?php echo Url::url(Router::$path, "grid/");?>" class="wojo mini primary icon button"><i class="icon grid list"></i></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=title|DESC");?>" class="item<?php echo Url::setActive("order", "title");?>">
      <?php echo Lang::$word->NAME;?>
    </a>
    <a href="<?php echo Url::url(Router::$path, "?order=price|DESC");?>" class="item<?php echo Url::setActive("order", "price");?>">
      <?php echo Lang::$word->PRD_PRICE;?>
    </a>
    <a href="<?php echo Url::url(Router::$path, "?order=sales|DESC");?>" class="item<?php echo Url::setActive("order", "sales");?>">
      <?php echo Lang::$word->PURCHASES;?>
    </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 big 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->PRD_EMPTY;?></p>
</div>
<?php else:?>
<?php foreach($this->data as $row):?>
<div class="wojo soft shadow card" id="item_<?php echo $row->id;?>">
  <div class="header">
    <div class="row horizontal-gutters align-bottom">
      <div class="column shrink"><img src="<?php echo Product::hasThumb($row->thumb, $row->id);?>" alt="" class="wojo small image"></div>
      <div class="column">
        <p class="wojo small text"><a href="<?php echo Url::url("/admin/categories/edit",  $row->category_id);?>"><?php echo $row->name;?></a>
        </p>
        <span class="wojo bold text">
        <a class="inverted" href="<?php echo Url::url(Router::$path, "edit/" . $row->id);?>"><?php echo $row->title;?></a>
        </span></div>
      <div class="column shrink align-top">
        <?php echo Utility::formatMoney($row->price);?>
      </div>
    </div>
  </div>
  <div class="footer half-padding">
    <div class="row align-middle">
      <div class="column">
        <div class="wojo horizontal small divided list">
          <div class="item">
            <div class="header"><span class="wojo caps light text"><?php echo Lang::$word->COMMENTS;?></span>
              <span class="wojo caps text"><?php echo $row->comments;?></span>
            </div>
          </div>
          <div class="item">
            <div class="header"><span class="wojo caps light text"><?php echo Lang::$word->PURCHASES;?></span>
              <span class="wojo text"><?php echo ($row->sales > 0) ? $row->sales : '-/-';?></span>
            </div>
          </div>
          <div class="item">
            <div class="header">
              <span class="wojo caps light text"><?php echo Lang::$word->MEMBERSHIP;?></span>
              <span class="wojo caps text"><?php echo $row->memberships ? $row->memberships : '-/-';?></span>
            </div>
          </div>
          <div class="item">
            <div class="header"><span class="wojo caps light text"><?php echo Lang::$word->LIKES;?></span>
              <span class="wojo text"><?php echo $row->likes;?></span>
            </div>
          </div>
        </div>
      </div>
      <div class="column 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(Router::$path, "edit/" . $row->id);?>"><i class="icon pencil"></i>
              <?php echo Lang::$word->EDIT;?></a>
            <a class="item" href="<?php echo Url::url(Router::$path, "history/" . $row->id);?>"><i class="icon history"></i>
              <?php echo Lang::$word->HISTORY;?></a>
            <div class="wojo basic divider"></div>
            <a data-set='{"option":[{"delete": "deleteProduct","title": "<?php echo Validator::sanitize($row->title, "spchar");?>","id":<?php echo $row->id;?>}],"action":"delete","parent":"#item_<?php echo $row->id;?>"}' class="wojo bold text item action">
              <i class="icon negative trash"></i>
              <?php echo Lang::$word->DELETE;?></a>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<?php endforeach;?>
<?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 thick 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>