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

<?php echo form_tag('/entry/complain', array('id'=>'complainForm')) ?>
  <?php echo input_hidden_tag('entry_id', $entry_id) ?>
  <?php echo input_hidden_tag('submit', $entry_id) ?>
  <?php $reasons = $comments = $cm_names = '';
    $app_complain = sfConfig::get('app_entry_complain');
    foreach ($app_complain['type'] as $key => $complain) {
      if ($key == 6 && $tblblogentry->getEntryLesson() <= 0) continue;
      $id = 'cp_type_'.$key;
      $title = label_for($id, $complain, array('style'=>'font-weight:normal'));
      $reasons .= radiobutton_tag('cp_type', $key, $key==$cp_type, array('onclick'=>'showRadioComment(this)', 'id'=>$id)).' '.$title.'<br>';
      $comments .= content_tag('div', $app_complain['comment'][$key], array('id'=>'comment_'.$id, 'style'=>'display:none'));
      $cm_names .= ($cm_names == ''? '': ', ').'"comment_'.$id.'"';
    }?>
  <?php echo gridTable(array(
    array(2, 11),
    array('Tài liệu', content_tag('strong', $tblblogentry->getEntryType() == 0? $tblblogentry->getTblpresentation()->getLessonName(): $tblblogentry->getObject()->getName())),
    array('Lý do lỗi', form_error('cp_type').$reasons),
    array('Chi tiết lỗi', $comments.form_error('cp_note').textarea_tag('cp_note', $cp_note, array('size'=>'54x8'))),
  ), 'span-', null, array('style'=>'margin-top:10px')) ?>
  <br>
  <center><?php echo m_submit_tag('Gửi thông báo'). '&nbsp;&nbsp;'. m_finish('Đóng lại') ?></center>
</form>

<script>
showRadioComment = function(obj) {
  var names = new Array(<?php echo $cm_names ?>);
  for (var i=0; i<names.length; i++) $(names[i]).style.display = "none";
  $("comment_"+obj.id).style.display = "block";
  Modalbox.resizeToContent();
}
<?php if ($cp_type): ?>
showRadioComment($("cp_type_<?php echo $cp_type ?>"));
<?php endif ?>
$("cp_note").focus();
</script>
