<?php
  /**
   * View Download
   *
   * @package Wojo Framework
   * @author wojoscripts.com
   * @copyright 2017
   * @version $Id: view.tpl.php, v1.00 2017-05-05 10:12:05 gewa Exp $
   */
  if (!defined("_WOJO"))
      die('Direct access to this location is not allowed.');
?>
<?php include_once(THEMEBASE . '/snippets/dashNav.tpl.php');?>
<div class="padding">
  <h2><?php echo Lang::$word->FRONT_FPROP;?></h2>
  <?php if(!$this->row):?>
  <?php echo Message::msgSingleError(Lang::$word->FM_ERROR);?>
  <?php else:?>
  <div class="row horizontal-gutters">
    <div class="columns shrink"><a href="<?php echo Url::url('/product', $this->row->slug);?>"><img src="<?php echo Product::hasThumb($this->row->thumb, $this->row->pid);?>" class="wojo normal basic image"></a>
    </div>
    <div class="columns">
      <h4>
        <a href="<?php echo Url::url('/product', $this->row->slug);?>"><?php echo $this->row->title;?></a>
      </h4>
      <div class="wojo space divider"></div>
      <p><?php echo Validator::sanitize($this->row->body, "string", 300);?></p>
    </div>
  </div>
  <div class="wojo big space divider"></div>
  <?php if($this->row->type == "cdkey"):?>
  <h4><?php echo Lang::$word->PRD_CDKEY;?></h4>
  <div class="wojo segment"><?php echo $this->row->cdkey;?></div>
  <?php if($this->data):?>
  <div class="wojo very relaxed divided flex list align-middle">
    <?php foreach($this->data as $row):?>
    <div class="item">
      <a href="<?php echo SITEURL;?>/download.php?paid=<?php echo $row->token;?>" class="wojo shadow content half-padding shrink" style="background-color:<?php echo Product::fileStyle($row->extension);?>"><?php echo Product::fileIcon($row->extension, "small");?></a>
      <div class="content margin-left">
        <p class="header"><?php echo $row->alias;?></p>
        <p class="wojo small text"><?php echo Date::doDate("long_date", $row->created);?>
          <span class="wojo separator"></span>
          <?php echo File::getSize($row->filesize);?></p>
      </div>
      <div class="content shrink"><a href="<?php echo SITEURL;?>/download.php?paid=<?php echo $this->row->tid;?>&amp;token=<?php echo $row->token;?>" class="wojo tiny primary button"><?php echo Lang::$word->DOWNLOAD;?></a>
      </div>
    </div>
    <?php endforeach;?>
  </div>
  <?php endif;?>
  <?php else:?>
  <h4><?php echo Lang::$word->FM_FILES;?></h4>
  <div class="wojo space divider"></div>
  <?php if($this->data):?>
  <div class="wojo very relaxed divided flex list align-middle">
    <?php foreach($this->data as $row):?>
    <div class="item">
      <a href="<?php echo SITEURL;?>/download.php?paid=<?php echo $row->token;?>" class="wojo shadow content half-padding shrink" style="background-color:<?php echo Product::fileStyle($row->type);?>"><?php echo Product::fileIcon($row->type, "small");?></a>
      <div class="content margin-left">
        <p class="header"><?php echo $row->alias;?></p>
        <p class="wojo small text"><?php echo Date::doDate("long_date", $row->created);?>
          <span class="wojo separator"></span>
          <?php echo File::getSize($row->filesize);?></p>
      </div>
      <div class="content shrink"><a href="<?php echo SITEURL;?>/download.php?paid=<?php echo $this->row->tid;?>&amp;token=<?php echo $row->token;?>" class="wojo tiny primary button"><?php echo Lang::$word->DOWNLOAD;?></a>
      </div>
    </div>
    <?php endforeach;?>
  </div>
  <?php endif;?>
  <?php if ($this->stats['expiry'] > 0) :?>
  <div class="wojo active indicating success progress" data-percent="<?php echo $this->stats['bar'];?>" data-total="100">
    <div class="bar" style="width:<?php echo $this->stats['bar'];?>%">
      <div class="progress"><?php echo $this->stats['bar'];?>%</div>
    </div>
    <div class="label"><?php echo Lang::$word->FM_ERROR6;?>
      <?php echo $this->stats['counter'];?>. <?php echo $this->stats['status'];?></div>
  </div>
  <?php else:?>
  <div class="wojo active indicating success progress" data-percent="100" data-total="100">
    <div class="bar" style="width:100%">
      <div class="progress">100%</div>
    </div>
    <div class="label">
      <?php echo $this->stats['status'];?></div>
  </div>
  <?php endif;?>
  <?php endif;?>
  <?php if ($this->stats['expired']):?>
  <a href="<?php echo Url::url('/product', $this->row->slug);?>" class="wojo primary button"><?php echo Lang::$word->FM_BUY;?></a>
  <?php endif;?>
  <?php endif;?>
</div>