<? $AvisoEncerramento = new Sinistro2_Model_AvisosEncerramento(); ?>

<? if (!$this->error): ?>
	<? if(count($this->paginator)): ?>
		<table class='grid' cellspacing='1' cellpadding='0' border='0' id='tablePagination'>
			<thead>
				<tr>
					<th nowrap="nowrap">Proposta</th>
					<th nowrap="nowrap">Apólice</th>
					<th nowrap="nowrap">Nome Segurado</th>
					<th nowrap="nowrap">Safra</th>
					<th nowrap="nowrap">Produto</th>
					<th nowrap="nowrap">Vigência</th>
					<th nowrap="nowrap">Ações</th>
				</tr>
			</thead>
			<tbody>
				<?
				$i = 0;
				foreach ($this->paginator as $item):
					if ($i % 2 == 0) {
						$class = '';
					} else {
						$class = "highlight";
					}
					
					$msgEncerramento = false;
					
					?>
					<tr class="<?=$class?>">
						<td align="center"><?=($item['id_proposta_mae'] ? $item['id_proposta_mae'] : '&nbsp;'); ?></td>
						<td align="center"><?=($item['nr_apolice'] ? $item['nr_apolice'] : '&nbsp;'); ?></td>
						<td align="left" nowrap='nowrap'><?=($item['ds_nome_proponente'] ? $item['ds_nome_proponente'] : '&nbsp;'); ?></td>
						<td align="center"><?=($item['ds_nome_safra'] ? $item['ds_nome_safra'] : '&nbsp;'); ?></td>
						<td align="left"><?=($item['ds_nome_produto'] ? $item['ds_nome_produto'] : '&nbsp;'); ?></td>
						<td align="center"><?=$item['dt_vigencia_inicio']." a ".$item['dt_vigencia_fim']; ?></td>
						<td align='center' width='1%' nowrap='nowrap'>	
						<?if($AvisoEncerramento->existemQuadrasParaEncerrar($item['id_proposta'])):?>
							<a href="/sinistro2/envioaviso/form/proposta/<?=$item['id_proposta']?>/id_proposta_mae/<?=$item['id_proposta_mae']?>">
								<img src="/resources/imagens/mini/aviso_sinistro.png" alt="envio_aviso_sinistro.png" title="Enviar Aviso de Sinistro" border="0">
							</a>
						<?else:?>
							<? $msgEncerramento = true; ?>
						<?endif;?>
						</td>
					</tr>
					
					<?if($msgEncerramento):?>
						<tr class="<?=$class?>">
							<td colspan="7" class="lei_encerramento_colheita">
								O Aviso de Encerramento de Colheita determina automaticamente o final do período de cobertura sendo vedado o início de um novo processo de regulação baseado em Aviso de Sinistro com data posterior ao do encerramento de colheita.
							</td>
						</tr>
					<?endif;?>
					
					<?
					$i++;
				endforeach;
				?>
			</tbody>
		</table>
		
		<?=$this->paginationControl($this->paginator, 'Sliding'); ?>
	<? endif; ?>
<? else: ?>
	<?= $this->showListError($this->error); ?>
<? endif; ?>
