<?php use_helper('I18N', 'Object', 'Validation', 'Javascript', 'tvtl','ModalBox'); ?>
<?php echo form_tag('/admin/listblogentry','method=POST name=listblogentry ') ?><?php echo input_hidden_tag('search',1)?>
<div>
  <div class="wfull nowrap">
    <div class="span-8">&nbsp;
      <!--Tìm kiếm <?php echo input_tag('keysearch',$keyword, 'style="width:200px;height:25px;" onfocus = "this.value=\'\'" ') ?>
      <?php echo submit_tag('Tìm')?>-->
    </div>
    <div class="span-10" style="text-align: right">
    <?php $typeList = array(''=>'Tất cả'); ?>
    <?php foreach (sfConfig::get('app_entry_type') as $v) $typeList[$v] = myUtility::vietUpcase(commonData::getCatTypeName($v), true); ?>
    Chọn loại tài nguyên: <?php echo select_tag('entry_type', options_for_select($typeList, $entry_type), array('onchange'=>'submit()'))?>
    </div>
  </div>
<table class="table-content" width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <th width="5%"><input type="checkbox" name="all" id = "all" onclick="checkAll(document.listblogentry.entry);" /></th>
    <th width="20%" align="left" >
        <?php echo link_to('Tiêu đề','/admin/listblogentry',
        'title="Sắp xếp theo tiêu đề"') ?>
        <?php //echo $nicknameSign?>
    </th>
    <th width="20%" align="left">
        Ảnh đại diện
    </th>
    <th width="12%">
        Người đưa lên
    </th>
    <th width="10%" align="center">
        Ngày đưa lên
    </th>
    <th width="10%">Loại</th>
    <th width="5%" align="center">
        Điểm
    </th>
  </tr>

  <?php foreach ($pager->getResult() as $tblblogentry): ?>
  <?php if ($tblblogentry->getEntryStatus() >= 2) continue; ?>
  <tr class="row<?php echo $i%2;?>">
  	<td width="5%">
  	 <input type="checkbox" name="entry[]" onclick="setCheckAll(document.listblogentry.entry);" id="entry" value="<?php echo $tblblogentry->getEntryId()?>" />
  	</td>
    <td>
      <?php echo link_to($tblblogentry->getObject()->getName(), '/'.$tblblogentry->getModule().'/show?entry_id=' . $tblblogentry->getEntryId()) ?>
      <br>
      (<?php echo blogStore::$catTree->getCatItem($tblblogentry->getEntryCategory())->name ?>)
    </td>
    <td>
      <?php echo $tblblogentry->getObject()->getThumbnail() ?>
    </td>
    <td>
      <?php $user = $tblblogentry->getTbluser() ?>
      <?php if ($user) echo m_link_to($user->getUsFullName(), '/user/show?id='.$tblblogentry->getEntryUser()); ?>
    </td>
    <td>
       	<?php echo $tblblogentry->getEntryCreatedate('d-m-Y H:i:s')?>
    </td>
    <td>
      <?Php echo ucfirst(commonData::getCatTypeName($tblblogentry->getEntryType()))?>
    </td>
    <td>
			<?php echo $tblblogentry->getEntryScore()?>
    </td>
  </tr>
  <?php endforeach;?>
</table>

<div style="height:50px;">
  <div style="margin-left:5px;">
  <?php echo link_to('xóa tài nguyên','#','onclick=return isCheck(document.listblogentry.entry)')?>
  </div>
  <div style="margin-top: 10px;text-align:center;">
    <?php $pageNav = showPageNav13($pager, '/admin/listblogentry?'); ?>
    <?php echo $pageNav ?>
  </div>
</div>
</form>
<style>
  li {
    list-style-type: none;
  }
</style>
<?php $url = url_for('/admin/deleteEntry') ?>
<?php $sf_context->getResponse()->addJavascriptCommand(<<<EOD
function isCheck(entries) {
  var url = "$url";
  var result = false;
  if(entries.type == 'checkbox') {
    if(entries.checked == true) {
      result = true;
    }
  } else {
    for(var i = 0; i < entries.length; i++) {
      if (entries[i].checked == true) {
        result = true;
        break;
      }
    }
  }
  if (result == false ) {
    alert('Bạn phải chọn ít nhất một tài nguyên');
    return false;
  }
  if (confirm('Bạn có chắc chắn không') == true) {
    document.listblogentry.action = url;
    document.listblogentry.submit();
  } else {
    return false;
  }
  return false;
}
EOD
); ?>