<?php use_helper('I18N', 'tvtl', 'ModalBox'); ?>

<div id='doc_content'>
  <?php $baseLink = '/document/same?entry_id='.$entry_id.'&same=' ?>
  <?php $showTitle = array('text'=>$tbldocument->getObject()->getShortName(), 'options'=>array('style'=>'width:300px; overflow: hidden; white-space: nowrap;')) ?>
  <?php echo gridTab(array('show'=>$showTitle, 'author'=>'Cùng tác giả', 'downloader'=>'Lịch sử tải về'), $baseLink, $same, 'doc_content') ?>

  <div class="doc document">
    <?php switch ($same):
      case 'author': ?>
        <h2>Cùng tác giả <?php echo $tbldocument->getTbluser()->getObject()->getHtmlName() ?></h2>
        <label><?php echo showPageNav13($pager, $baseLink.'&same='.$same, 'doc_content') ?></label>
        <div class="content">
          <?php foreach ($tblblogentrys as $i=>$tblblogentry): ?>
            <?php echo $tblblogentry->getObject()->getGlobalThumb(); ?>
          <?php endforeach; ?>
        </div>
        <?php break; ?>

      <?php case 'downloader': ?>
        <h2>Các thành viên đã tải về</h2>
        <label><?php echo showPageNav13($pager, $baseLink.'&same='.$same, 'doc_content'); ?></label>
        <div class="content">
          <?php foreach ($pager->getResult() as $usdoc): ?>
            <div class="userinfo">
              <?php $user = TbluserPeer::retrieveByPk($usdoc->getUsdocUser()); ?>
              <?php if (!$user) continue; ?>
              <?php echo $user->getObject()->getHtmlName(true) ?><br/>
              tải lúc <?php echo date('H:i d/m/Y', strtotime($usdoc->getUsdocDate())); ?>
            </div>
          <?php endforeach ?>
        </div>
        <?php break; ?>

      <?php default: ?>
        <h2>
          <?php echo $tbldocument->getDocName() ?>
          <label>
            <?php echo mm_link_need_login(image_tag('/images/layout1/download.png'), '/document/download?doc_id='.$tbldocument->getDocId(), false, array('title'=>'Nhấn vào đây để tải về')) ?>
            <?php echo $tblblogentry->getObject()->getEditLink('/document/edit') ?>
            <?php echo $tblblogentry->getObject()->getDeleteLink('/document/predelete') ?>
          </label>
        </h2>
        <div class="content">
          <div class="docthumb"><?php echo $tbldocument->getObject()->getPreview() ?></div>
          <?php include_component('entry', 'approve', array('tblblogentry'=>$tblblogentry)) ?>
          <b>Nguồn: </b><?php echo $tbldocument->getDocSource() ?><br>
          <b>Người gửi: </b><?php echo $tbldocument->getTbluser()->getObject()->getHtmlName(false, true) ?><br>
          <b>Ngày gửi: </b><?php echo $tbldocument->getDocDate('H\h:i\' d-m-Y') ?><br>
          <b>Dung lượng: </b><?php echo myUtility::formatFilesize($tbldocument->getDocFilesize()) ?><br>
          <b>Số lượt tải: </b><?php echo $tbldocument->getDocHit() ?><br>
          <b>Mô tả: </b><?php echo $tbldocument->getDocDesc() ?>
          <hr>
          <div align="right" style="float:right; line-height: 170%">
            <b><?php echo mm_link_need_login('Nhấn vào đây để tải về', 'document/download?doc_id='.$tbldocument->getDocId())?></b><br/>
            <b><?php echo mm_link_need_login('Nhắn tin cho tác giả', $tblblogentry->getObject()->getMessageLink()) ?></b><br/>
            <b><?php echo mm_link_need_login('Báo tư liệu sai quy định', 'entry/complain?entry_id=' . $entry_id, true)?></b><br/>
            <?php if ($tbldocument->getDocType()=='swf'): ?>
              <b><?php echo link_to('Xem toàn màn hình', $tbldocument->getObject()->getPreviewUrl(), array('target'=>'_blank')) ?><br></b>
            <?php endif ?>
            <b><?php echo link_to('Mở thư mục chứa tư liệu này', $tblblogentry->getListUrl()) ?></b><br>
          </div>
          <?php include_component('entry', 'showlike', array('tblblogentry' => $tblblogentry)); ?>
        </div>
        <?php include_component('block', 'advbanner', array('name'=>'preview')); ?>
      <?php break; ?>
    <?php endswitch; ?>
  </div>
</div>
