<?php use_helper('Javascript', 'tvtl', 'ModalBox'); ?>
<?php $sf_context->getResponse()->addJavascriptCommand('setCategory('.$cat_id.');'); ?>
<?php include_component('entry', 'listtabs', array('cat_id'=>$cat_id, 'tab'=>2)) ?>

<div class="document docgroup">
  <h2>
    <label><?php echo blogStore::getPostLink($cat_id, 'present') ?></label>
    <?php echo blogStore::getCategoryPath($cat_id) ?>
  </h2>
  <div class="content">
  <?php foreach ($groups as $gr_id => $group): ?>
    <?php $cache_file = "present_lesson_{$cat_id}_{$gr_id}"; ?>
    <?php if (!begin_html_cache($cache_file)) continue ?>
    <?php foreach ($group as $key => $title): ?>
      <?php TblblogentryPeer::getEntryByLessons($cat_id, $key, $entries, $count) ?>
      <?php if (count($entries) == 0) continue ?>
      <b><?php echo link_to($title, "/present/samelesson?cat_id=$cat_id". ($key? '&lesson='.$key: '')).' ('.$count.' bài)' ?></b><br>
      <?php foreach ($entries as $index => $entry): ?>
        <?php echo $entry->getObject()->getGlobalThumb($catItem->getListType($index)) ?>
      <?php endforeach ?>
      <hr>
    <?php endforeach ?>
    <?php end_html_cache($cache_file); ?>

    <?php if ($gr_id == 0 && count($groups) > 1): ?>
      <center><h2><div id="next-view">Đang mở tiếp, xin chờ một chút...</div></h2></center>
      <?php $sf_context->getResponse()->addJavascriptCommand('reloadLessonList("present", '.$cat_id.');'); ?>
      <?php break ?>
    <?php endif ?>
  <?php endforeach ?>
  </div>
</div>
