<?php $this->loadCss('/admin/media/css/dtree.css'); ?>
<?php $this->loadJavascript('/admin/media/js/dtree.js'); ?>

<div id="accoes_bg" style="z-index:1;">
    <div id="titulo_accao" style="z-index:1;">
        <?php if (isset($section_title)): ?>
        <nobr><?php echo translateAdmin('Listagem de');?> <?php echo $section_title; ?></nobr>
        <?php endif; ?>
    </div>
</div>

<script type="text/javascript">
//<![CDATA[
var selection = false;

function invert() {
    if ( selection == false ) {
        selection = true; 
    } else {
        selection = false;
    }

    for (var i=0; i<document.deleteList.elements.length; i++) {
        var e = document.deleteList.elements[i];
        if ( selection == true ) {
            e.checked = true;
        } else {
            e.checked = false; 
        }
    }
}

function clean() {
    selection = false;
    document.deleteList.selectAll.checked = false;
}
//]]>
</script>

<div id="conteudo">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <?php if (isset($tree)): ?>
    <td rowspan="2" valign="top" id="tr_tree">
        <div id="tree">
            <?php echo $tree->getTitle(); ?> | <a href="<?php echo $tree->openAllLink(); ?>"><?php echo translateAdmin('Expandir tudo');?></a> | <a href="<?php echo $tree->closeAllLink(); ?>"><?php echo translateAdmin('Fechar tudo');?></a><br /><br />
            <?php echo $tree->render(); ?>
        </div>
    </td>
    <?php endif; ?>
    <td height="320" valign="top" id="manutencaodisplay">
        <div class="acessibilidade">
        	<span>
            <input type="button" id="inserir" name="inserir" class="form_inserir" value="<?php echo translateAdmin('Inserir');?>" onClick="location='<?php echo $links['add']; ?>';">
            <input type="button" id="inserir" name="inserir" class="form_exportar" value="<?php echo translateAdmin('Exportar');?>" onClick="location='<?php echo $links['excel']; ?>';">
            <?/*
            <img src="/admin/media/images/imprimir.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Imprimir');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Imprimir');?></a>&nbsp;        
            <img src="/admin/media/images/permissoes.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Permiss&otilde;es');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Permiss&otilde;es');?></a>&nbsp;
            */?>
            </span>
        </div>
        <br />
        <table border="0" align="center" cellspacing="0" width="98%">
        <thead>
         <?php if ($rowset): ?>
         <tr>
            <th class="actions" style="width:20px; text-align:center; white-space:nowrap;"><input type="checkbox" name="selectAll" id="selectAll" onclick="invert();" style="padding:0; margin:0;" class="checkbox" /></th>
            <?php foreach($cols as $col): ?>
                <?php if ($ordering == $col): ?>
                    <?php if ($sorting == 'desc'): ?>
                        <th nowrap class="sorted" style="padding-left:5px;"><a href="<?php echo $this->link($links['list'], "ordering=$col&sorting=asc"); ?>" class="asc"><?php echo $labels[$col]; ?></a></th>
                    <?php else: ?>
                        <th nowrap class="sorted" style="padding-left:5px;"><a href="<?php echo $this->link($links['list'], "ordering=$col&sorting=desc"); ?>" class="desc"><?php echo $labels[$col]; ?></a></th>
                    <?php endif; ?>
                <?php else: ?>
                    <th nowrap class="labellist" style="padding-left:5px;"><a href="<?php echo $this->link($links['list'], "ordering=$col&sorting=desc"); ?>"><?php echo $labels[$col]; ?></a></th>
                <?php endif; ?>
            <?php endforeach; ?>
            <th class="actions"><?php echo translateAdmin('Ac&ccedil;&otilde;es');?></th>
         </tr>         
      </thead>
      <form name="deleteList" id="deleteList" action="<?php echo $this->link($links['deletelist'], "page={$page}"); ?>" method="post">
      <tbody>
         <?php
         $cycle = $this->cycle('row1', 'row2', 'row3');
         $i = 0; // alteração - Thiago Brito
         ?>
         <?php foreach($rowset as $row): ?>
            <?php
            // alteração - Thiago Brito - para colocar onMouseOver e onMouseOut nas linhas //
            $i++;
            $currentClass = "";
            $currentClass = $cycle->getCurrent();
            $on_click = "location='" . $this->link($links['edit'] . $row->{$primary} . "/", "page={$page}") . "';";
            $on_over  = "$('line_" . $i . "').className='" . $cycle->getOverValue() . "';";
            $on_out   = "$('line_" . $i . "').className='" . $currentClass . "';";
            //
            // alteração - Thiago Brito - para colocar onMouseOver e onMouseOut nas linhas //
            ?>
            <tr id="line_<?php echo $i; ?>" class="<?php echo $currentClass; ?>">
                <td align="center" style="width:20px; text-align:center;">
                <input type="checkbox" name="ids[]" id="ids[]" value="<?php echo $row->id; ?>" style="padding:0; margin:0;" class="checkbox" />
                </td>
                <?php foreach($cols as $col): ?>
                    <?php if ($col == $to_string): ?>        
                        <td onMouseOver="<?php echo $on_over; ?>" onMouseOut="<?php echo $on_out; ?>" style="cursor:pointer;" onClick="<?php echo $on_click; ?>"><?php echo $row->{$col}; ?></td>
                    <?php elseif (array_key_exists($col, $modelCols) && $modelCols[$col]->getType() == 'Boolean'): ?>
                        <td onMouseOver="<?php echo $on_over; ?>" onMouseOut="<?php echo $on_out; ?>" style="cursor:pointer;" onClick="<?php echo $on_click; ?>" align="center"><img src="/admin/media/images/icon_<?php echo ($row->{$col} == '1') ? 'true' : 'false'; ?>.gif" border="0" /></td>
                    <?php elseif (array_key_exists($col, $modelCols) && $modelCols[$col]->getType() == 'Image' && $row->{$col}): ?>
                        <?php $imageSize = @getimagesize(WWW_PATH .'/uploads/' . $modelCols[$col]->getParam('target') . '/' . $row->{$col}); ?>
                        <td onMouseOver="<?php echo $on_over; ?>" onMouseOut="<?php echo $on_out; ?>" style="cursor:pointer;" onClick="<?php echo $on_click; ?>"><img src="<?php echo $modelCols[$col]->getParam('target'); ?>/small_<?php echo $row->{$col}; ?>" /></td>
                    <?php else: ?>
                        <td onMouseOver="<?php echo $on_over; ?>" onMouseOut="<?php echo $on_out; ?>" style="cursor:pointer;" onClick="<?php echo $on_click; ?>"><?php echo $row->{$col}; ?></td>
                    <?php endif; ?>
                <?php endforeach; ?>
                <td onMouseOver="<?php echo $on_over; ?>" onMouseOut="<?php echo $on_out; ?>" align="center"><a href="<?php echo $this->link($links['delete'] . $row->{$primary}, "page={$page}"); ?>" class="deletelink" onclick="javascript:return confirm('Tem a certeza que deseja remover o item seleccionado?');"><img src="/admin/media/images/icon_trash.gif" alt="Remover" border="0" /></a></td>
            </tr>
         <?php endforeach; ?>
         <tr>
            <td colspan="<?php echo (count($cols) + 2); ?>"><a href="#" class="deletelink" onclick="javascript:questionSubmitForm('deleteList', '<?php echo translateAdmin('Tem a certeza que deseja remover os itens seleccionados');?>?');"><?php echo translateAdmin('Remover itens seleccionados');?></a></td>
         </tr>
      </tbody>
      </form>
      <br />
      <?php endif; ?>
   </table> 
    </td>
  </tr>
  <tr>
    <td height="15" valign="top">
        <div class="acessibilidade" style="z-index:1; ">
        	<span>
            <input type="button" id="inserir" name="inserir" class="form_inserir" value="<?php echo translateAdmin('Inserir');?>" onClick="location='<?php echo $links['add']; ?>';">
            <input type="button" id="inserir" name="inserir" class="form_exportar" value="<?php echo translateAdmin('Exportar');?>" onClick="location='<?php echo $links['excel']; ?>';">
            <?/*
            <img src="/admin/media/images/imprimir.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Imprimir');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Imprimir');?></a>&nbsp;        
            <img src="/admin/media/images/permissoes.gif"  border="0" align="absmiddle" hspace="3" title="<?php echo translateAdmin('Permiss&otilde;es');?>" /><a href="#" class="linksacessibilidade"><?php echo translateAdmin('Permiss&otilde;es');?></a>&nbsp;
            */?>
            </span>
        </div>
        <div class="paginator"><?php echo $paginator_output; ?></div>
    </td>
  </tr>
</table>
</div>
