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

<div id="accoes_bg" style="z-index:1;">
    <div id="titulo_accao" style="z-index:1;">
        <?php if (isset($section_title)): ?>
        <?php echo translateAdmin('Listagem de');?> <?php echo $section_title; ?>
        <?php endif; ?>
    </div>
    <div id="pesquisa" style="z-index:1;">
    <div class="pesquisaLeft"></div>
    <div class="pesquisaForm">
        <?php echo $form_search->start(); ?>
		<?php echo $form_search->search->input; ?>
        <?php echo $form_search->submit->input; ?>
        <?php echo $form_search->end(); ?>
    </div>
    <div class="pesquisaRight"></div>
    </div>
</div>

<!--<div id="filtros"><img src="<?php echo $baseUrl;?>/admin/media/images/maisfiltro.gif" title="Filtros" />Filtros</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>
    <td height="320" valign="top" id="manutencaodisplay">
        
        <div id="tipo_campo">
        <form action="<?php echo $this->link($links['add']); ?>" method="post">
        <select name="element" id="element">
        <?php foreach ($elements_types as $key => $element): ?>
        <option value="<?php echo $key; ?>"><?php echo $element; ?></option>
        <?php endforeach; ?>   
        </select>
        <input type="submit" id="submit_element" name="submit_element" class="form_inserir_component" value="<?php echo translateAdmin('Inserir Campo');?>" />
        <input type="button" class="form_update_order" onclick='<?php echo $links['save_ordem']; ?>' value="<?php echo translateAdmin('Actualizar ordem') ?>" />
        </form>
        </div>
        
        <div class="acessibilidade"><span>&nbsp;</span></div>
        <br />
        <table border="0" align="center" cellspacing="0" width="98%">
        <?php if ($rowset): ?>
            <thead>
                <tr>
                    <?php foreach($cols as $col): ?>
                        <?php if ($ordering == $col): ?>
                            <?php if ($sorting == 'desc'): ?>
                                <th class="soted" nowrap="nowrap">
                                <a href="<?php echo $this->link($links['list'], "ordering=$col&sorting=asc"); ?>" class="asc"><?php echo $labels[$col]; ?></a>
                                </th>
                            <?php else: ?>
                                <th class="sorted" nowrap="nowrap">
                                <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 class="labellist" nowrap="nowrap"><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>
            <tbody id="table_sort">
                <?php $cycle = $this->cycle('1', '2', '3'); ?>
                <?php foreach($rowset as $row): ?>
                    <?php
                    $linha = $cycle->getCurrent();
                    $on_click = "location='" . $this->link($links['edit'] . $row->{$primary}, "page={$page}") . "';";
                    ?>
                    <tr id="line_<?php echo $row->{$primary}; ?>" class="row<?php echo $linha; ?>" onmouseover="this.className='row3';" onmouseout="this.className='row<?php echo $linha; ?>'">
                        <?php foreach($cols as $col): ?>
                            <?php if ($col == $to_string): ?>        
                                <td 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 style="cursor:pointer;" onclick="<?php echo $on_click; ?>" align="center"><img src="<?php echo $baseUrl;?>/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 style="cursor:pointer;" onclick="<?php echo $on_click; ?>"><img src="<?php echo $baseUrl;?>/uploads/<?php echo $modelCols[$col]->getParam('target'); ?>/small_<?php echo $row->{$col}; ?>" /></td>
                            <?php else: ?>
                                <td style="cursor:pointer;" onclick="<?php echo $on_click; ?>"><?php echo $row->{$col}; ?></td>
                            <?php endif; ?>
                        <?php endforeach; ?>
                        <td align="center" nowrap="nowrap">
                        <a href="<?php echo $this->link($links['delete'] . $row->{$primary} . "/", "page={$page}"); ?>" class="deletelink" onclick="javascript:return confirm('<?php echo translateAdmin('Tem a certeza que deseja remover o item seleccionado');?>?');"><img src="<?php echo $baseUrl;?>/admin/media/images/icon_trash.gif" alt="<?php echo translateAdmin('Remover');?>" border="0"  style="padding-left:5px;padding-right:5px;"/></a>
                        </td>
                    </tr>
                    <?php endforeach; ?>
            </tbody>
        <?php endif; ?>
        </table> 
    </td>
  </tr>
  <tr>
    <td height="15" valign="top">
        <div class="acessibilidade" style="z-index:1; "><span>&nbsp;</span></div>
        <div class="paginator"><?php echo $paginator_output; ?></div>
    </td>
  </tr>
</table>
</div>
<script type="text/javascript">
//<![CDATA[
Sortable.create("table_sort", { tag:"tr", containment:["table_sort"], ghosting:true })
//]]>
</script>