<?php
$Telefones = new Atendimento_Model_ContatoTelefones(); 

?>
<? if (!$this->error): ?>
	<? if(count($this->paginator)): ?>
		<table class='grid' cellspacing='1' cellpadding='0' border='0' id='tablePagination'>
		<?
			$link = "/atendimento/contato/list/o/";
			$options = array(array('id'        => 'ds_nome_contato',
								   'nowrap'    => 'nowrap',
								   'link'      => $link . 'ds_nome_contato/s/' . ($this->orderby == 'ds_nome_contato' ? ($this->orderDirection == 'asc' ? 'desc' : 'asc') : 'asc'),
								   'descricao' => 'Contato',
								   'image'     => '/resources/imagens/'),
							 array('id' 	   => 'ds_razao_social',
								   'nowrap'    => 'nowrap',
								   'link'      => $link . 'ds_profissao/s/' . ($this->orderby == 'ds_profissao' ? ($this->orderDirection == 'asc' ? 'desc' : 'asc') : 'asc'),
								   'descricao' => 'Empresa',
								   'image'     => '/resources/imagens/'),
							 array('nowrap'    => 'nowrap',
							       'descricao' => 'Telefones'),
							 array('id' 	   => 'ds_nome_estado',
								   'nowrap'    => 'nowrap',
								   'link'      => $link . 'ds_nome_estado/s/' . ($this->orderby == 'ds_nome_estado' ? ($this->orderDirection == 'asc' ? 'desc' : 'asc') : 'asc'),
								   'descricao' => 'Estado',
								   'image'     => '/resources/imagens/'),
  							 array('id' 	   => 'ds_nome_municipio',
								   'nowrap'    => 'nowrap',
								   'link'      => $link . 'ds_nome_municipio/s/' . ($this->orderby == 'ds_nome_municipio' ? ($this->orderDirection == 'asc' ? 'desc' : 'asc') : 'asc'),
								   'descricao' => 'Município',
								   'image'     => '/resources/imagens/'),
							 array('nowrap'    => 'nowrap',
							       'descricao' => 'Ações'));
		?>
		
			<?=$this->listHeader($options, $this->order, $this->orderType);?>

			<tbody>
				<?
				$i = 0;
				foreach ($this->paginator as $item):
					if ($i % 2 == 0) {
						$class = '';
					} else {
						$class = "highlight";
					}
					
					$imgActive = ($item['fl_ativo'] ? 'active.png' : 'inactive.png');
					?>
					<tr class="<?=$class?>">
						<td nowrap='nowrap'>
							<?=($item['ds_nome_contato'] ? $item['ds_nome_contato'] : '&nbsp;'); ?>
						</td>
						<td nowrap='nowrap'><?=($item['ds_razao_social'] ? $item['ds_razao_social'] : '&nbsp;'); ?></td>
						<td nowrap='nowrap'><?= $Telefones->getTelefonesListagem($item['id']); ?></td>
						<td nowrap='nowrap'><?= $item['ds_nome_estado']; ?></td>
						<td nowrap='nowrap'><?= $item['ds_nome_municipio']; ?></td>
						<td align='center' width='1%' nowrap='nowrap'>
							<?=$this->iconView("atendimento", "contato", $item)?>
							<?=$this->iconEdit("atendimento", "contato", $item)?>
							<?=$this->iconActive("atendimento", "contato", $item)?>
							<?=$this->iconDelete("atendimento", "contato", $item)?>
						</td>
					</tr>
					<?
					$i++;
				endforeach;
				?>
			</tbody>
		</table>
		
		<?=$this->paginationControl($this->paginator, 'Sliding'); ?>
	<? endif; ?>
<? else: ?>
	<?= $this->showListError($this->error); ?>
<? endif; ?>