<? if (!$this->error): ?>
	<!-- Armazena id_proposta para utilizar em um novo cadastro -->		
	<input type="hidden" id="id_proposta" value="<?=$this->id_proposta?>" />
	<div>
	    <?if($this->ds_status_processo != 'CANCELADO'):?>
	    	<?
	    	if(Agro_Util::checkPermission('atendimento:chamado:index') && $this->isProcessoEmpresaAtiva){
	    	?>
	    	<a class="showListChamadosSinistro" href="/atendimento/chamado/formchamadosinistro/id_proposta/<?=$this->id_proposta?>/id_departamento/23/novo/1">
	    		<button style="height: 35px;">
					<img style="vertical-align:center;" src="/resources/imagens/mini/novo.png" alt="Novo Chamado" title="Novo Chamado" border="0">
					<span style="vertical-align:super;">Novo Chamado</span>
				</button>
			</a>				
			<?}?>
		<?endif?>
	</div>
	<? if($this->response != false): ?>
		<table class='grid' cellspacing='1' cellpadding='0' border='0' id='tablePagination'>		
			<thead>
				<tr>
					<th nowrap="nowrap">Código</th>
					<th nowrap="nowrap">Status</th>
					<th nowrap="nowrap">Prioridade</th>
					<th nowrap="nowrap">Criação</th>
					<th nowrap="nowrap">Tipo</th>	
					<th nowrap="nowrap">Departamento</th>
					<th nowrap="nowrap">Destinatário</th>					
					<th nowrap="nowrap">Empresa</th>					
					<th nowrap="nowrap">Ações</th>
				</tr>
			</thead>
			<tbody>
				<?
				$ModelChamados = new Atendimento_Model_Chamado();
				$i = 0;
				foreach ($this->response as $item):

					if ($i % 2 == 0) {
						$class = '';
					} else {
						$class = "highlight";
					}

					$naolido = $ModelChamados->getFilhosNaoLidos($item['id']);

					if($naolido){
						$style = 'style="background-color: lightgreen; text-align:center;"';
						$iconeLido = '';
					}else{
						$style = 'style="text-align:center;"';
						//$iconeLido = '<a id="'.$item['id'].'" class="icon_recicla" href="#"><img src="/resources/imagens/mini/recicla.png" border="0" alt="recicla.png" title="Marcar como não-lido" style="cursor:pointer" /></a>';
					}
					
					switch($item['ds_tipo_destinatario']){
						case 'C': $ds_destinatario = 'CORRETOR';    break;
						case 'S': $ds_destinatario = 'SEGURADORA';  break;
						case 'V': $ds_destinatario = 'VISTORIADOR'; break;
						default:  $ds_destinatario = 'CORRETOR';
					}

					?>
					<tr class="<?=$class?>" <?=$style;?>>
						<td nowrap='nowrap' align="center"><?=($item['id'] ? str_pad($item['id'], 6, 0, STR_PAD_LEFT) : '&nbsp;'); ?></td>
						<td nowrap='nowrap'><?=($item['ds_status'] ? $item['ds_status'] : '&nbsp;'); echo '&nbsp;'.$iconeLido;?></td>
						<td nowrap='nowrap'><?=($item['ds_descricao'] ? $item['ds_descricao'] : '&nbsp;'); ?></td>
						<td nowrap='nowrap'><?=($item['ds_nome_usuario'] ? $item['ds_nome_usuario'].' - '.($item['dt_criacao'] ? Agro_Util::formatDate($item['dt_criacao'], 'dd/MM/y HH:mm:ss') : '&nbsp;') : '&nbsp;'); ?></td>
						<td nowrap='nowrap'><?=($item['ds_tipo_chamado'] ? $item['ds_tipo_chamado'] : '&nbsp;'); ?></td>
						<td nowrap='nowrap'><?=($item['ds_nome_departamento'] ? $item['ds_nome_departamento'] : '&nbsp;'); ?></td>
						<td nowrap='nowrap'><?=($ds_destinatario ? $ds_destinatario : '&nbsp;'); ?></td>
						<td nowrap='nowrap'>
							<?=(($item['ds_nome_fantasia'] && (Sistema_Model_Usuarios::usuarioLogadoFuncionarioAgro() || $item['ds_tipo_destinatario'] == 'V')) ? $item['ds_nome_fantasia'] : '&nbsp;'); ?>
						</td>
						
						<td align='center' width='1%' nowrap='nowrap'>
							<a class="icon_view" href="/atendimento/chamado/view/id/<?=$item['id']?>">
								<img src="/resources/imagens/mini/view.png" border="0" alt="view.png" title="Visualizar Chamado" style="cursor:pointer" />
							</a>
						</td>
					</tr>
					<?
					$i++;
				endforeach;
				?>
			</tbody>
		</table>
<!--		--><?//=$this->paginationControl($this->paginator, 'Sliding'); ?>
	<? else: ?>
		<div align="center" style="margin-top: 20px"><b>Não existem chamados para a proposta <?=$this->id_proposta;?> (Segurado: <?=$this->ds_nome_segurado;?>)</b></div>
	<? endif; ?>
<? else: ?>
	<?= $this->showListError($this->error); ?>
<? endif; ?>
