<?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" class="total">
		<tr>
			<td height="320" valign="top" id="manutencaodisplay">
				<div class="acessibilidade">
                	<span>
					<?php if (array_key_exists('add', $links)) : ?>
						<input type="button" id="inserir" name="inserir" class="form_inserir" value="<?php echo translateAdmin('Inserir');?>" onClick="location='<?php echo $this->link($links['add']); ?>';">
					<?php endif; ?>
                    </span>
				</div>
				<br />
				<table border="0" align="center" cellspacing="0" width="98%" class="total">
				<thead class="teste">
					<tr style=" border-right:1px solid #CCCCCC; border-left:1px solid #CCCCCC;">
						<th class="labellist" nowrap style="padding-left:5px; width: 80px; text-transform:uppercase;"><font color="#FFFFFF">Id</font></th>
						<th class="labellist" nowrap style="padding-left:5px; width: 200px; text-transform:uppercase;"><font color="#FFFFFF"><?php echo translateAdmin('Moeda');?></font></th>
						<th class="labellist" nowrap style="padding-left:5px; width: 150px; text-transform:uppercase;"><font color="#FFFFFF"><?php echo translateAdmin('Cambio');?></font></th>
						<th class="labellist" nowrap style="padding-left:5px; text-transform:uppercase;"><font color="#FFFFFF"><?php echo translateAdmin('Criado');?></font></th>
					</tr>
				</thead>
				<?php if(isset($cambios_activos) && is_array($cambios_activos)):
					foreach ($cambios_activos as $cambio) : ?>
						<tr class="row1" style=" border-right:1px solid #CCCCCC; border-left:1px solid #CCCCCC;">
							<td><?php echo $cambio['id']; ?></td><td><?php echo $cambio['nome']; ?></td><td><?php echo $cambio['cambio']?></td><td><?php echo $cambio['criado']; ?></td>
						</tr>
					<?php endforeach; ?>
				<?php endif;?>
				<tr>
					<td colspan="4" style="border:none;">&nbsp;</td>
				</tr>
				<?php if(isset($moedas) && is_array($moedas) && count($moedas) > 1) :
				$num_moedas = 0;
				?><form action="" method="post">
				<?php 
				if(isset($message) && $message) :?>
					<tr>
						<td colspan="4" style="color:red"><?php echo $message; ?></td>
					</tr>
				<?php endif;?>
					<tr style=" border:1px solid #CCCCCC; background-color:#f2fbdd;">
						<td colspan="4" align="center">
					<span style="border:none; text-align:right; font-weight:bold; text-transform:uppercase;"><?php echo translateAdmin('Inserir moeda');?></span>
					&nbsp;
						<?php if(count($moedas) > 2) :?>
						<select name="nome">
							<?php	foreach ($moedas as $moeda) {
							if($num_moedas == 0) { $num_moedas ++; continue;}?>
								<option value="<?php echo $moeda['nome'] ?>">&nbsp;<?php echo $moeda['nome'] ?>&nbsp;</option>
							<?php } ?>
						</select>
						<?php else :?>
							<?php echo $moedas[1]['nome'];?> <input type="hidden" name="nome" value="<?php echo $moedas[1]['nome'];?>">
						<?php endif; ?>
					&nbsp;
						<input type="text" name="cambio" value="" />
					&nbsp;
						<input type="submit" name="submit_cambio_gravar" id="submit_cambio_gravar" style="background-color:#f2fbdd;" value="<?php echo translateAdmin('Gravar');?>" class="form_submit"/> 	
					</td>
				</tr>
				</form>
				<tr>
					<td colspan="4" style="border:none;"></td>
				</tr>
				<?php endif; ?>
				<thead>
					<?php if ($rowset): ?>
						<tr>
							<td colspan="4"><h2><?php echo translateAdmin('Hist&oacute;rico Cambios'); ?></h2></td>
						</tr>
						<tr style=" border-right:1px solid #CCCCCC; border-left:1px solid #CCCCCC;">
							<?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; ?>
						</tr>
					</thead>
					<tbody>
					<?php
					$cycle = $this->cycle('row1', 'row2', 'row3');
					$i = 0; // alteracao - Thiago Brito
					?>
					<?php foreach($rowset as $row): ?>
					<?php
					// altera&ccedil;&atilde;o - Thiago Brito - para colocar onMouseOver e onMouseOut nas linhas //
            $i++;
            $currentClass = "";
            $currentClass = 'row3';
            //
            // altera&ccedil;&atilde;o - Thiago Brito - para colocar onMouseOver e onMouseOut nas linhas //
            ?>
			<tr id="line_<?php echo $i; ?>" class="<?php echo $currentClass; ?>" style=" border-right:1px solid #CCCCCC; border-left:1px solid #CCCCCC;">
				<?php foreach($cols as $col): ?>
					<?php if ($col == $to_string): ?>
						<td><?php echo $row->{$col}; ?></td>
					<?php elseif (array_key_exists($col, $modelCols) && $modelCols[$col]->getType() == 'Boolean'): ?>
                        <tdalign="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}): ?>
                        <td><img src="/uploads/<?php echo $modelCols[$col]->getParam('target'); ?>/small_<?php echo $row->{$col}; ?>" /></td>
                    <?php elseif (array_key_exists($col, $modelCols) && $modelCols[$col]->getType() == 'ForeignKey'): ?>
                        <?php
                        $foreignModel = Goweb::getModelInstance($modelCols[$col]->getParam('model'), 'db', false);
                        $foreignModel->find($row->{$col});
                        $value = $foreignModel->nome;
                        ?>
                        <td><?php echo $value; ?></td>
                    <?php else: ?>
                        <td><?php echo $row->{$col}; ?></td>
                    <?php endif; ?>
                <?php endforeach; ?>
         </tr>
         <?php endforeach; ?>
      </tbody>
      <?php endif; ?>
				</table> 
	    	</td>
	  	</tr>
	  	<tr>
	    	<td height="15" valign="top">
	        	<div class="acessibilidade">
                	<span>
	            	<?php if (array_key_exists('add', $links)) : ?>
	            	<input type="button" id="inserir" name="inserir" class="form_inserir" value="<?php echo translateAdmin('Inserir');?>" onClick="location='<?php echo $this->link($links['add']); ?>';">
	            	<?php endif; ?>
                    </span>
	        	</div>
	        	<div class="paginator"><?php echo $paginator_output; ?></div>
	    	</td>
	  	</tr>
	</table>
</div>