<?php
$Validacoes = new Produto_Model_Validacoes();
$Ciclos = new Produto_Model_Ciclos();
$modelCondicoesEspeciais = new Produto_Model_CondicoesEspeciais();
$this->showPrint = true;

$producaoGarantida    = $this->proposta->atributos('PROPRIEDADE', 'PROD_PRODUCAO_GARANTIDA');
$coberturasAdicionais = $this->proposta->coberturas_contratadas('adicional');
$coberturaPrincipal   = $this->proposta->coberturas_contratadas('principal');
$questionarios        = $this->proposta->questionarios();
$beneficiarios        = $this->proposta->beneficiarios();
$propriedade          = $this->proposta->propriedade();
$proponente           = $this->proposta->proponente();
$proponente_ppe       = $this->proposta->proponente_ppe();
$respostas            = $this->proposta->respostas();
$corretor             = $this->proposta->corretor();
$carencia             = $this->proposta->carencia();
$produto              = $this->proposta->produto();
$croquis              = $this->proposta->croquis();
$pessoa_autorizada    = $this->proposta->pessoa_autorizada();
$producao_forrageira  = $this->proposta->producao_forrageira();
$safra                = $this->proposta->safra();

$beneficiarioAutorizado = [];
$circular642 = false;
$dataCriacaoProposta = Agro_Util::formatDate($this->proposta->dt_criacao);

$dtTransmissaoMae = $this->proposta->dt_transmissao;
$date = DateTime::createFromFormat('Y-m-d H:i:s', $dtTransmissaoMae);

$dtTransmissaoMaeFormatada = !$date ? (new DateTime('now')) : $date;

if ($this->proposta->id !== $this->proposta->id_proposta_mae) {
    $propostaMae = (new Seguro_Model_Propostas())->find($this->proposta->id_proposta_mae)->current();
    $dataCriacaoProposta = Agro_Util::formatDate($propostaMae['dt_criacao']);
	$dtTransmissaoMae = $propostaMae['dt_transmissao'];
	
	$dtTransmissaoMaeFormatada = DateTime::createFromFormat('Y-m-d H:i:s', $dtTransmissaoMae);
}

if (Agro_Util::validaDataInicioFim('22/05/2022', $dataCriacaoProposta)) {
    $circular642 = true;
}

$paginalAtual = 0;
$totalPaginas = 0;
$fontSize = 'font-size: 12px;';
$statusProposta = $this->proposta->status();

$barcodeSign = '';
if ($this->apenasPrint) {
	$barcodeSign = '-SIGN';
}

$infoSexo = '';
$colspanDataNascimento = 3;
if (!empty(trim($proponente['ds_sexo']))) {
	$sexo = $proponente['ds_sexo'] == 'M' ? 'MASCULINO' : 'FEMININO';
	$infoSexo = '<td nowrap="nowrap" colspan="2"><div><span style="font-weight: bold;">Sexo</span></div>'. $sexo .'</td>';
	$colspanDataNascimento = 2;
}

$alterarNomeCoberturas = strtotime($dtTransmissaoMae) >= strtotime('2023-09-04');

//Para caso o usuário não tenha relogado após a melhoria entrar em produção
if (DATA_ALTERACAO_CONDICOES_PROPOSTA === 'DATA_ALTERACAO_CONDICOES_PROPOSTA') {
	$condicoesGeraisSUSEP = false;
} else {
	$condicoesGeraisSUSEP = Agro_Util::validaDataInicioFim(DATA_ALTERACAO_CONDICOES_PROPOSTA, $dataCriacaoProposta);
}

$labelFraseRestricoes = 'Avisos Importantes para o Proponente';
$labelFraseOutrosRiscosExcluidos = 'Riscos Excluídos, Perdas Não Cobertas, Condições Complementares e/ou Condições Particulares';

$tdStyle = '
	border-bottom: none;
	border-top: none;
	font-size: 12px; 
	padding: 2.5 1px 2.5 1px;
';

$linhasFrasesRestricoes = Agro_Util::montaLinhasTabelaIgnorandoTabelas($produto['ds_frase_restricoes'] ?? '', $tdStyle);

$tdStyle .= 'font-weight: bold';
$linhasFraseOutrosRiscosExcluidosCoberturaPrincipal = Agro_Util::montaLinhasTabelaIgnorandoTabelas(
	$coberturaPrincipal['ds_frase_outros_riscos_excluidos'] ?? '',
	$tdStyle
);

foreach ($coberturasAdicionais as $coberturaAdicional) {
	if (!empty($coberturaAdicional['ds_frase_outros_riscos_excluidos'])) {
		$linhasFraseOutrosRiscosExcluidosCoberturaAdicionais .= Agro_Util::montaLinhasTabelaIgnorandoTabelas(
			$coberturaAdicional['ds_frase_outros_riscos_excluidos'] ?? '',
			$tdStyle
		);
	}
}
?>
<link rel="stylesheet" href="/resources/css/seguro/propostaprint.css" type="text/css" media="print" />
<link rel="stylesheet" href="/resources/css/seguro/propostaview.css" type="text/css" media="screen" />

<?php
$temDocumentoNatureza = !empty(trim($proponente['ds_documento_natureza']));
$temNomeOrgao = !empty(trim($proponente['ds_nome_orgao']));
$temDocumentoExpedicao = !empty($proponente['dt_documento_exp']);
$colspanTipoSegurado = !$temDocumentoNatureza && !$temNomeOrgao && !$temDocumentoExpedicao ? 5: 2;
?>

<div class="no-print">
  <?=$this->headerProposta($this->proposta, $paginalAtual, $totalPaginas, false, '');?>
</div>

<!-- DADOS DO PROPONENTE -->
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th style="background-color: white;" colspan="6"><div><span style="font-family: verdana, sans-serif; font-size: 9px;">Dados do Proponente</span></div></th>
		</tr>
	</thead>
	<tbody>
		<? if ($proponente['tp_pessoa'] == 'F'): ?>
			<tr>
				<td colspan=3><div><span style="font-weight: bold;">Nome/Razão Social</span></div> <?=$proponente['ds_nome_proponente']?></td>
				<td nowrap="nowrap" colspan=3><div><span style="font-weight: bold;">CPF/CNPJ</span></div> <?=$proponente['cpf_cnpj']?></td>
			</tr>
			<tr>
				<td colspan=6>
					<div><span style="font-weight: bold;">Nome Social</span></div>
					<?=($proponente['fl_nome_social']) ? $proponente['ds_nome_social'] : '-'?>
				</td>
			</tr>
			<tr>
				<td nowrap="nowrap" valign="top"><div><span style="font-weight: bold;">Profissão</span></div> <?=$proponente['ds_profissao']?></td>
				<td nowrap="nowrap" valign="top" colspan="2"><div><span style="font-weight: bold;">E-mail</span></div> <?=$proponente['ds_email_proponente']?></td>
				<td nowrap="nowrap" colspan="<?= $colspanDataNascimento?>"><div><span style="font-weight: bold;">Data de Nascimento</span></div> <?=Agro_Util::formatDate($proponente['dt_nascimento'], Zend_Date::DATES)?></td>
          
				<?= $infoSexo?>
			</tr>
			<tr>
          <?php
          if ($temDocumentoNatureza) {
            ?>
            <td nowrap="nowrap">
              <div>
                <span style="font-weight: bold;">Documento</span>
              </div> <?=$proponente['ds_documento_natureza']?> <?=$proponente['ds_documento_numero']?>
            </td>
            <?php
          }

          if ($temNomeOrgao) {
              ?>
            <td nowrap="nowrap">
              <div>
                <span style="font-weight: bold;">Órgão Expedição</span>
              </div> <?=$proponente['ds_nome_orgao']?>
            </td>
              <?php
          }
          ?>
				<td nowrap="nowrap">
          <div>
            <span style="font-weight: bold;">Renda Mensal</span>
          </div> <?=$proponente['ds_faixa_remuneracao']?>
        </td>
          <?php
          if ($temDocumentoExpedicao) {
              ?>
            <td nowrap="nowrap">
              <div>
                <span style="font-weight: bold;">Data Expedição</span>
              </div> <?=Agro_Util::formatDate($proponente['dt_documento_exp'], Zend_Date::DATES)?>
            </td>
              <?php
          }
          ?>
				<td nowrap="nowrap" colspan="<?=$colspanTipoSegurado?>">
					<? if ($proponente['tp_segurado'] == 'P'): ?>
						<div><span style="font-weight: bold;">Segurado</span></div> PROPRIETÁRIO
					<? elseif ($proponente['tp_segurado'] == 'A'): ?>
						<div><span style="font-weight: bold;">Segurado</span></div> ARRENDATÁRIO
					<? elseif ($proponente['tp_segurado'] == 'O'): ?>
						<div><span style="font-weight: bold;">Segurado</span></div> OUTROS
					<? elseif ($proponente['tp_segurado'] == 'R'): ?>
						<div><span style="font-weight: bold;">Segurado</span></div> PARCEIRO
					<? endif; ?>
				</td>
			</tr>
			<tr>
				<td colspan=6>
					<div><span style="font-weight: bold;">O proponente é Pessoa Politicamente Exposta?</span></div> <?=($proponente['fl_politicamente_exposto'] == 2 ? 'Sim' : 'Não')?>
					<p align="justify" style="font-size: 85%; margin-top: 5px">Circular Susep nº 445/2012 - Art 4º: Consideram-se pessoas politicamente expostas os agentes públicos que desempenham ou tenham desempenhado, nos cinco anos anteriores, no Brasil ou em países, territórios e dependências estrangeiras, cargos, empregos ou funções públicas relevantes, assim como seus representantes, familiares e outras pessoas de seu relacionamento próximo.</p>
				</td>
			</tr>
		<? elseif ($proponente['tp_pessoa'] == 'J'): ?>
			<tr>
				<td nowrap="nowrap" colspan="3" width=70%><div><span style="font-weight: bold;">Nome/Razão Social</span></div> <?=$proponente['ds_nome_proponente']?></td>
				<td nowrap="nowrap" width=30%><div><span style="font-weight: bold;">CPF/CNPJ</span></div> <?=$proponente['cpf_cnpj']?></td>
				<td nowrap="nowrap">
					<? if ($proponente['tp_segurado'] == 'P'): ?>
						<div><span style="font-weight: bold;">Segurado</span></div> PROPRIETÁRIO
					<? elseif ($proponente['tp_segurado'] == 'A'): ?>
						<div><span style="font-weight: bold;">Segurado</span></div> ARRENDATÁRIO
					<? elseif ($proponente['tp_segurado'] == 'O'): ?>
						<div><span style="font-weight: bold;">Segurado</span></div> OUTROS
					<? endif; ?>
				</td>
			</tr>
			<tr>
				<td nowrap="nowrap" colspan="3"><div><span style="font-weight: bold;">Atividade Econômica</span></div> <?=$proponente['ds_nome_atividade_economica']?>&nbsp;</td>
				<td nowrap="nowrap"><div><span style="font-weight: bold;">Receita Operacional Bruta Anual</span></div> <?=$proponente['ds_renda_bruta']?></td>
				<td nowrap="nowrap"><div><span style="font-weight: bold;">Patrimônio Líquido</span></div> <?=$proponente['ds_patrimonio']?></td>
			</tr>
			<tr>
				<td colspan=5>
					<div><span style="font-weight: bold;">Existe Sócio, Controlador, Administrador e/ou Procurador que sejam Pessoa Politicamente Exposta?</span></div> <?=($proponente['fl_parentesco_politicamente_exposto'] == 2 ? 'Sim' : 'Não')?>
                    <? if($proponente['fl_parentesco_politicamente_exposto'] == 2): ?>
                        <? foreach($proponente_ppe as $ppe):
                        	switch($ppe['tp_relacionamento']){
                        		case 'S': $tp_relacionamento = 'Sócio'; break;
                        		case 'C': $tp_relacionamento = 'Controlador'; break;
                        		case 'A': $tp_relacionamento = 'Administrador'; break;
                        		case 'P': $tp_relacionamento = 'Procurador'; break;
                        	}
                        	$arPpe[] = $ppe['ds_nome_socio']." (".$ppe['ds_nro_cpf'].") - ".$tp_relacionamento;    
                        endforeach; ?>
                        <p align="justify">
                            Relacionamento(s): <?=implode($arPpe,", ");?>
                        </p>
                    <? endif; ?>
					<p align="justify" style="font-size: 85%; margin-top: 5px">Circular Susep nº 445/2012 - Art 4º: Consideram-se pessoas politicamente expostas os agentes públicos que desempenham ou tenham desempenhado, nos cinco anos anteriores, no Brasil ou em países, territórios e dependências estrangeiras, cargos, empregos ou funções públicas relevantes, assim como seus representantes, familiares e outras pessoas de seu relacionamento próximo.</p>
				</td>
			</tr>			
		<? endif; ?>
	</tbody>
</table>
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th colspan="3" style="background-color: white;">Endereço do Proponente</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><div><span style="font-weight: bold;">Endereço</span></div> <?=$proponente['ds_endereco_rua']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Número</span></div> <?=$proponente['ds_endereco_nro']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Complemento</span></div> <?=$proponente['ds_endereco_complem']?>&nbsp;</td>
		</tr>
		<tr>
			<td><div><span style="font-weight: bold;">Bairro</span></div><?=$proponente['ds_endereco_bairro']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">CEP</span></div><?=$proponente['ds_endereco_cep']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Município/UF</span></div><?=$proponente['ds_nome_municipio']?>/<?=$proponente['ds_sigla']?>&nbsp;</td>
		</tr>
		<tr>
			<td width=33%><div><span style="font-weight: bold;">Telefone Principal</span></div> <?=$proponente['ds_tel_residencia']?>&nbsp;</td>
			<td width=33%><div><span style="font-weight: bold;">Telefone Celular</span></div> <?=$proponente['ds_tel_celular']?>&nbsp;</td>
			<td width=33%><div><span style="font-weight: bold;">Telefone Propriedade</span></div> <?=$proponente['ds_tel_propriedade']?>&nbsp;</td>
		</tr>
	</tbody>
</table>

<!-- DADOS DA PROPRIEDADE -->
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th colspan="5" style="background-color: white;">Dados da Propriedade</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td width="30%"><div><span style="font-weight: bold;">Endereço</span></div> <?=$propriedade['ds_endereco']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Número</span></div> <?=$propriedade['ds_endereco_nro']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Complemento</span></div> <?=$propriedade['ds_endereco_complemento']?>&nbsp;</td>
			<td width="20%"><div><span style="font-weight: bold;">Bairro</span></div> <?=$propriedade['ds_endereco_bairro']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">CEP</span></div> <?=$propriedade['ds_endereco_cep']?>&nbsp;</td>
		</tr>
		<tr>
			<td><div><span style="font-weight: bold;">Município/UF</span></div> <?=$propriedade['ds_nome_municipio']?>/<?=$propriedade['ds_sigla']?>&nbsp;</td>
			<td colspan="3"><div><span style="font-weight: bold;">Nome da Propriedade</span></div> <?=$propriedade['ds_nome_propriedade']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Código BACEN</span></div> <?=$propriedade['cd_bacen']?>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="5"><div><span style="font-weight: bold;"><?=(strtotime($this->proposta['dt_vigencia_inicio']) >= strtotime('2016-01-01') ? 'Dica de acesso à Sede' : 'Ref. para Localização') ?></span></div> <?=$propriedade['ds_referencia_localizacao']?>&nbsp;</td>
		</tr>
		<tr>
			<td colspan="5">
			<div><span style="font-weight: bold;">Coordenadas Geográficas</span></div> <?=$propriedade['ds_coordenadas']?>&nbsp;
				<? if ($propriedade['ds_coordenadas']){
					$stCoordenada = str_replace(" ,", "", $propriedade['ds_coordenadas']);
					$stCoordenada = str_replace(",", "", $stCoordenada);
					$stCoordenada = str_replace("-", "", $stCoordenada);
					$arCoordenada = explode(" ",$stCoordenada);
					?>
                    <a style="color: blue; text-decoration: underline;" href="/scripts/kml/proposta/<?=$this->proposta->id?>" target="_blank">Download para Google Earth</a>
				<? } ?>
			</td>
		</tr>
		<tr>
			<td colspan="5">
			    <? (count($pessoa_autorizada) == 0 ? $existe = false: $existe = true) ?>
			<div><span style="font-weight: bold;">Há representante(s) do proponente a acompanhar a(s) vistoria(s)? </span></div>
				<?
				if ($existe) {
					foreach($pessoa_autorizada as $pessoa){
						$cpf = ($pessoa['cpf_cnpj'] ? '/ CPF: '.$pessoa['cpf_cnpj'] : '');
						echo ($pessoa['ds_pessoa_autorizada'] ? 'Nome: '.$pessoa['ds_pessoa_autorizada'].' '.$cpf  : '&nbsp;');
						echo ($pessoa['ds_telefone'] ? ' / Telefone: '.$pessoa['ds_telefone'] : '&nbsp;');
						echo ($pessoa['ds_grau_parentesco'] ? ' / Parentesco e/ou Grau de Relacionamento: '.$pessoa['ds_grau_parentesco'] : '&nbsp;');
						echo '<br>';
					}
				} else {
				    echo "Não";
				}
				?>
			</td>
		</tr>
	</tbody>
</table>

<!-- DADOS DOS BENEFICIARIOS -->
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th style="background-color: white;" colspan="<?=(count($beneficiarios) ? 5 : 0)?>">Cláusula Beneficiária</th>
		</tr>
	</thead>
	<tbody>
		<? $i = 1; ?>
		<? if (count($beneficiarios)): ?>
			<tr>
				<td><span style="font-weight: bold;">Favorecido</span></td>
				<td><span style="font-weight: bold;">Nome Social</span></td>
				<td><span style="font-weight: bold;">Qualidade</span></td>
				<td><span style="font-weight: bold;">Valor</span></td>
				<td><span style="font-weight: bold;">Documento</span></td>
			</tr>
			<? foreach ($beneficiarios as $beneficiario): ?>
				<? if ($i <= 2): ?>
					<? if (strtoupper($beneficiario['ds_tipo_conta']) == 'S' and $beneficiario['ds_nome_banco']): ?>
						<tr>
							<td><?=$beneficiario['ds_nome_banco']; ?>&nbsp;</td>
							<td>-&nbsp;</td>
							<td><?=$beneficiario['ds_qualidade_beneficiario']?>&nbsp;</td>
							<td><?=$this->currency($beneficiario['vl_limite_beneficio']);?>&nbsp;</td>
							<td><?=$beneficiario['nr_cpf_cnpj']?>&nbsp;</td>
						</tr>
					<? else: ?>
						<tr>
							<td><?=$beneficiario['ds_nome_beneficiarios']?>&nbsp;</td>
							<td><?=(!empty($beneficiario['ds_nome_social'])) ? $beneficiario['ds_nome_social'] : '-'?>&nbsp;</td>
							<td><?=$beneficiario['ds_qualidade_beneficiario']?>&nbsp;</td>
							<td><?=$this->currency($beneficiario['vl_limite_beneficio']);?>&nbsp;</td>
							<td><?=$beneficiario['nr_cpf_cnpj']?>&nbsp;</td>
						</tr>
					<? endif; ?>
				<? endif; ?>

				<?
            if ($beneficiario['fl_favorecido_autorizacao_credito']) {
              $beneficiarioAutorizado['nome'] = $beneficiario['ds_conta'] === 's' ? $beneficiario['ds_nome_banco']: $beneficiario['ds_nome_beneficiarios'];
              $beneficiarioAutorizado['cpf_cnpj'] = $beneficiario['nr_cpf_cnpj'];
            }

            $i++;
        ?>
			<? endforeach; ?>
		<? else: ?>
			<tr>
				<td align="center">Nenhum beneficiário cadastrado.</td>
			</tr>
		<? endif; ?>
	</tbody>
</table>

<!-- DADOS DA COBERTURA BASICA -->
<?
	$colspanCobertura = ($this->proposta->versao_endosso(false) == 0) ? 8 : 7;
	$condicoesEspeciais = $modelCondicoesEspeciais->getByProdutoCobertura($this->proposta->id_produto, $coberturaPrincipal['id_cobertura'], $dtTransmissaoMaeFormatada);
	$tituloCondicaoEspecial = !empty($condicoesEspeciais) ? $condicoesEspeciais['ds_titulo'] : '';
	$tituloCoberturaPrincipal = strtotime($this->proposta['dt_vigencia_inicio']) > strtotime('2015-02-04') ? "Demonstrativo - Cobertura Principal" : 'Demonstrativo do Prêmio - Cobertura Básica';
	$tituloCoberturaPrincipal .= $alterarNomeCoberturas ? " - {$tituloCondicaoEspecial}" : "";
?>
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th style="background-color: white;" colspan="<?=$colspanCobertura?>"><?=$tituloCoberturaPrincipal?></th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><div><span style="font-weight: bold;">Cultura</span></div><?=$produto['ds_nome_cultura']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Código BACEN</span></div><?=$produto['cd_bacen']?></td>
			<td><div><span style="font-weight: bold;">Área Total</span></div><?=$this->proposta->area()?>ha</td>
			<td><div><span style="font-weight: bold;">Unidades Seguradas</span></div><?=$this->proposta->count_itens_segurados()?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">LMGA</span></div>R$<?=Agro_Util::formatDbCurrency($this->proposta->lmga());?></td>
			<td>
				<div><span style="font-weight: bold;"><?=($producaoGarantida ? ($produto["ds_nome_cultura"] == "Pastagem" ? 'Franquia' : 'NC')  : 'Franquia')?></span></div>
				<?=$coberturaPrincipal['vl_franquia']?>% 
				<?if($produto["ds_nome_cultura"] == "Pastagem"):?>
					- R$<?=Agro_Util::formatDbCurrency(($this->proposta->lmga() * $coberturaPrincipal['vl_franquia']) / 100);?>
				<?endif;?>
			</td>
			<?if($this->proposta->versao_endosso(false) == 0):?>
				<td><div><span style="font-weight: bold;">Taxa</span></div><?=number_format($coberturaPrincipal['vl_taxa'],2,'.','')?>%</td>
			<? endif; ?>
			<td><div><span style="font-weight: bold;">Prêmio Tarifário</span></div>R$<?=Agro_Util::formatDbCurrency($coberturaPrincipal['vl_premio']);?>&nbsp;</td>
		</tr>
	</tbody>
</table>

<!-- DADOS DAS COBERTURAS ADICIONAIS -->
<?
$countAutomaticas = 0;
foreach ($coberturasAdicionais as $cobertura) {
	if ($cobertura['fl_contratacao_automatica']) $countAutomaticas++;
}

$colspanCobertura = ($this->proposta->versao_endosso(false) == 0) ? 6 : 5;

if ($coberturasAdicionais && (count($coberturasAdicionais) > $countAutomaticas)): ?>
	<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
		<thead>
			<tr>
				<th style="background-color: white;" colspan="<?=$colspanCobertura?>"><?=(strtotime($this->proposta['dt_vigencia_inicio']) > strtotime('2015-02-04') ? 'Demonstrativo - Coberturas Adicionais' : 'Demonstrativo do Prêmio - Coberturas Adicionais')?></th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td colspan="<?=($alterarNomeCoberturas) ? 2 : 1?>"><span style="font-weight: bold;">Cobertura</span></td>
				<td><span style="font-weight: bold;">Franquia</span></td>
				<?if($this->proposta->versao_endosso(false) == 0):?>
					<td><span style="font-weight: bold;">Taxa</span></td>
				<? endif; ?>
				<td><span style="font-weight: bold;">LMI</span></td>
				<td align="right"><span style="font-weight: bold;">Prêmio Adicional</span></td>
			</tr>
			<? foreach ($coberturasAdicionais as $cobertura): ?>
				<?
				if (!$cobertura['fl_contratacao_automatica']){
					if ($cobertura['ds_chave_cobertura'] == 'COB_PROTECAO_FITO'){
						$vl_lmi = $this->proposta->area_liquida() * 100;
					} else {
						$vl_lmi = ($cobertura['vl_lmi'] * $this->proposta->lmga())/100;
					}
				?>
					<tr>
						<td><?=$cobertura['ds_nome_cobertura']?></td>
						<?php
							if ($alterarNomeCoberturas) {
								$condicoesEspeciais = $modelCondicoesEspeciais->getByProdutoCobertura($this->proposta->id_produto, $cobertura['id_cobertura'], $dtTransmissaoMaeFormatada);
								$tituloCondicaoEspecial = !empty($condicoesEspeciais) ? trim($condicoesEspeciais['ds_titulo']) : '';
								echo "<td>{$tituloCondicaoEspecial}</td>";
							}
						?>
						<td><?=($cobertura['fl_exibir_franquia']) ? $cobertura['vl_franquia']."%" : '-'; ?></td>
						<?if($this->proposta->versao_endosso(false) == 0):?>
							<td><?=number_format($cobertura['vl_taxa'],2,'.','')."%" ; ?></td>
						<? endif; ?>
						<td><?=$this->currency($vl_lmi)?></td>
						<td align="right"><?=($cobertura['vl_premio'] ? Agro_Util::formatDbCurrency($cobertura['vl_premio']) : '-');?></td>
					</tr>
				<? } ?>
			<? endforeach; ?>
		</tbody>
	</table>
<? endif; ?>

<!-- -->
<? if($produto["ds_nome_cultura"] == "Pastagem"): ?>
	<? 
	$count = 1;
	foreach($producao_forrageira as $indice) :
		$arProducaoForrageira[$count]['ano'] = $indice['ano'];
		$arProducaoForrageira[$count]['indice'] = $indice['indice'];
		$indiceEsperado = $indice['indice_esperado'];
		$count++;
	endforeach; 
	?>
	
	<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
		<tr>
			<th></th>
			<th style="background-color: white;" colspan="5" align="center">Histórico do Índice de Produção Forrageira das áreas de pastagens seguradas</th>
		</tr>
		<tr>
			<td width=30% align="left"><b>Ano</b></td>
			<td align="center"><?=$arProducaoForrageira[1]['ano'];?></td>
			<td align="center"><?=$arProducaoForrageira[2]['ano'];?></td>
			<td align="center"><?=$arProducaoForrageira[3]['ano'];?></td>
			<td align="center"><?=$arProducaoForrageira[4]['ano'];?></td>
			<td align="center"><?=$arProducaoForrageira[5]['ano'];?></td>
		</tr>
		<tr>
			<td width=30% align="left"><b>Índice de Produção Forrageira</b></td>
			<td align="center"><?=number_format($arProducaoForrageira[1]['indice'],2,',','.');?></td>
			<td align="center"><?=number_format($arProducaoForrageira[2]['indice'],2,',','.');?></td>
			<td align="center"><?=number_format($arProducaoForrageira[3]['indice'],2,',','.');?></td>
			<td align="center"><?=number_format($arProducaoForrageira[4]['indice'],2,',','.');?></td>
			<td align="center"><?=number_format($arProducaoForrageira[5]['indice'],2,',','.');?></td>
		</tr>
	</table>
	<table width="37%" cellpadding="0" cellspacing="1" class="gadget" style="margin-bottom: 5px;">
		<tr>
			<td width=85%><b>Índice de Produção Forrageira Esperado (IPFE<sub style="font-size: 7pt;">M</sub>)</b></td>
			<td align="center"><?=number_format($indiceEsperado,2,',','.');?></td>
		</tr>
	</table>
	<p style="margin-bottom: 15px;">Importante: o valor do Índice de Produção Forrageira Anual e o Índice de Produção Forrageira Esperado (IPFE<sub style="font-size: 7pt;">M</sub>) já estão ponderados pelas Áreas das Pequenas Áreas Forrageiras.</p>
<? endif; ?>
<!-- -->

<!-- DADOS DE COBRANCA -->
<?
if ($this->proposta->isEndosso()) {
	switch ($this->proposta->tipo_endosso()) {
		case 'COBRANCA':
			$this->boxCobrancaAumento($this->proposta);
			break;
		case 'REDUCAO':
			$this->boxCobrancaReducao($this->proposta);
			break;
		case 'SEM_MOVIMENTO':
			$this->boxCobrancaSemMovimento($this->proposta);
			break;
		default:
			$this->boxCobrancaDefault($this->proposta, true);
			break;
	}
} else {
	$this->boxCobrancaDefault($this->proposta, true);
}
?>

<!-- NOVA PAGINA -->
<?= $this->footerProposta($this->proposta, $this->isEnviarDocusign) ?>
<div  style="page-break-before: always;"></div>


<!-- OBSERVACOES DA PROPOSTA -->
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th style="background-color: white;">Observação</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
			<? $observacao = $this->proposta->observacoes(); ?>
			<? foreach($observacao as $observacao_principal) {
				if($observacao_principal['fl_principal']){?>
					<?=nl2br($observacao_principal['ds_observacao']);?>
				<?}
			}?>
			&nbsp;
			</td>
		</tr>
	</tbody>
</table>

<!-- INFORMACOES DO CORRETOR -->
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th style="background-color: white;" colspan="4">Corretor</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><div><span style="font-weight: bold;">Corretora:</span></div> <?=$corretor['ds_nome_fantasia']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Número SUSEP:</span></div> <?=$corretor['nr_susep']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Participação:</span></div> <?=$corretor['ds_nome_corretor']?>&nbsp;</td>
			<td><div><span style="font-weight: bold;">Telefone:</span></div> <?=$corretor['ds_telefone_contato_seguro_agricola']?>&nbsp;</td>
		</tr>
	</tbody>
</table>

<!-- DADOS DE LOCAIS DE ENTREGA DE SEMENTE (SE HOUVER) -->
<? if(count($this->locais_entrega)): ?>
	<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
		<thead>
			<tr>
				<th style="background-color: white;">Local de Entrega de Sementes</th>
			</tr>
		</thead>
		<tbody>
			<table width="100%" cellpadding="5" cellspacing="1" class="gadget">
				<thead>
					<tr>
						<th style="background-color: white;">CNPJ</th>
						<th style="background-color: white;">Nome</th>
						<th style="background-color: white;">Município/UF</th>
					</tr>
				</thead>
				<tbody>
					<? foreach ($this->locais_entrega as $local): ?>
						<tr  style="background-color: white;">
						<? if ($local['id_cooperativa'] == 1): // armazenamento próprio ?>
							<td align="center">-</td>
							<td><?=$local['ds_nome_cooperativa']?></td>
							<td align="center">-</td>
						<? else: ?>
							<td align="center"><?=$local['cnpj']?></td>
							<td><?=$local['ds_nome_cooperativa']?></td>
							<td align="center"><?=$local['ds_nome_municipio'].'/'.$local['ds_sigla']?></td>
						<? endif; ?>
						</tr>
					<? endforeach; ?>
				</tbody>
			</table>
		</tbody>
	</table>
<? endif; ?>

<!-- DADOS DO QUESTIONARIO -->
<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th style="background-color: white;">Questionário</th>
		</tr>
	</thead>
	<tbody>
        <tr>
            <td>
                <p>Atenção: É fundamental que todas as informações fornecidas na formação do contrato de seguro sejam completas e precisas. O descumprimento do dever de informar pode resultar na perda de direitos ou na anulação do contrato de seguro. Caso tenha dúvidas sobre quais informações são relevantes, consulte nosso atendimento.</p>
            </td>
        </tr>
		<tr>
			<td><?=$this->questionarioView($this->proposta);?></td>
		</tr>
	</tbody>
</table>

<?= $this->footerProposta($this->proposta, $this->isEnviarDocusign) ?>

<div style="page-break-before: always;"></div>

<!-- DADOS DAS UNIDADES -->
<?= $this->unidadesView($this->proposta, true, array(), 'PRO', true, $this->isEnviarDocusign, false); ?>


<!-- DADOS DOS CROQUIS -->
<? $countCroquis = count($croquis);?>
<? foreach ($croquis as $index => $croqui): ?>
	<? if (file_exists(PATH_CROQUI."/".$croqui['ds_nome_arquivo'])): ?>
		<div  style="page-break-before: always;"></div>
		
		<? list($width, $height) = getimagesize(PATH_CROQUI."/".$croqui['ds_nome_arquivo']); ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
			<thead>
				<tr>
					<th style="background-color: white;">Croqui <?=$index+1?></th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<?php if($this->apenasPrint) { ?>
						<td align="center"><img src="<?= PATH_CROQUI."/".$croqui['ds_nome_arquivo'] ?>" height="<?=($height > 700 ? 700 : $height)?>" width="<?=($width > 650 ? 650 : $width)?>" /></td>
					<?php } else { ?>
						<td align="center"><img src="/agronet/file/croqui/name/<?= $croqui['ds_nome_arquivo'] ?>" height="<?=($height > 700 ? 700 : $height)?>" width="<?=($width > 650 ? 650 : $width)?>" /></td>
					<?php } ?>
				</tr>
			</tbody>
		</table>
		<?= $this->footerProposta($this->proposta, $this->isEnviarDocusign) ?>
	<? endif;?>
<? endforeach; ?>

<div style="page-break-before: always;"></div>

<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
    <thead>
      <tr>
        <th style="background-color:white; font-size:12px;"><?=  $labelFraseRestricoes?></th>
      </tr>
    </thead>
    <tbody>
		<? if (!empty($produto['ds_frase_padrao_orcamento']) && $this->proposta['id_status'] === Seguro_Model_Propostas::ID_STATUS_NAO_ENVIADA):?>
			<tr>
				<td class="carencia" style="padding: 5px;">
					<p style='font-size:12px;'><?= $produto['ds_frase_padrao_orcamento'] ?></p><br>
				</td>
			</tr>
		<? endif;?>

		<?php echo $linhasFrasesRestricoes ?>
		<tr><td style="border-bottom:1px solid #000; border-top:none;"></td></tr>

		<?php if(strtoupper($Produto->ds_nome_produto) == strtoupper('AgroBrasil PG Milho Pipoca')): ?>
			<tr>
				<td>
					<?php
					// TEXTO EXCLUSIVO PARA MILHO PIPOCA
						$ModelProduto = new Produto_Model_Produtos();
						$Produto = $ModelProduto->getRow($this->proposta->id_produto);
					?>
						<br />
						<b>
						CONDIÇÕES PARTICULARES 1:<br />
						A COBERTURA TERMINARÁ 160 DIAS APÓS A DATA DE PLANTIO.<br /><br />

						CONDIÇÕES PARTICULARES 2:<br />
						RISCO EXCLUÍDO DO SEGURO: EXCESSO DE CHUVA PRÓXIMO A COLHEITA
						</b>
						<br /><br />
				</td>
			</tr>
		<? endif; ?>
    </tbody>
</table>

<!-- NOVA PAGINA -->
<?= $this->footerProposta($this->proposta, $this->isEnviarDocusign) ?>
<div style="page-break-before: always;"></div>


<!-- BLOCO 3 - CARÊNCIA -->
<?php if (is_array($carencia)): ?>

	<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
		<thead>
			<tr>
				<th style='font-size: 12px; background-color: white;'>Carência(s)</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td class="carencia" style="padding: 5px;">
					<?php
						/**
						 * Há casos onde uma condição especial tem vínculo com cobertura principal e cobertura adicional,
						 * então para evitar uma possível repetição de texto foi utilizado um dicionário com hash
						 */
						$map = [];
						foreach ($carencia as $item):
							$hash = hash('sha256', $item['ds_condicao_especial']);
							if (isset($map[$hash])) {
								continue;
							}

							echo "<div style='font-size: 12px; font-weight: bold; white-space: pre-line;'>{$item['ds_condicao_especial']}</div>";
							$map[$hash] = true;
						endforeach;
					?>
				</td>
			</tr>
		</tbody>
	</table>
<?php endif; ?>

<? if($produto["ds_nome_cultura"] == "Pastagem"): ?>
	<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
	<thead>
		<tr>
			<th style="background-color: white;">Informações Adicionais</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td class=carencia>
				<p>O Proponente declara ter ciência e concordar que o monitoramento, medição e tratamentos dos índices apurados durante todo o período de garantia serão realizados pelas empresas especificadas neste documento: <br />
				- Airbus DS Geo SA: provedor responsável por dados, monitoramento e processamento de dados <br /> 
				- Agritask Ltd: provedor responsável pela disponibilização dos dados
				</p>
			</td>
		</tr>
	</tbody>
	</table>
<? 
	echo $this->footerProposta($this->proposta, $this->isEnviarDocusign);
	echo '<div style="page-break-before: always;"></div>';
	endif; 
?>

<? // BLOCO ESPECÍFICO PARA MAÇÃ TELADA
if($this->proposta->id_produto == 713): ?>
	<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
		<thead>
			<tr>
				<th style="background-color: white;">Particularidade do Cultivo Protegido</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td class=carencia>
				Inclui-se na cobertura, mediante pagamento de prêmio específico, com o que se desconsidera a exclusão prevista nas condições especiais do cultivo protegido: Frutas cobertas por telas ou plástico anti-granizo entre 5 (cinco) e 10 (dez) anos de fabricação. Telas ou plástico anti-granizo entre 5 (cinco) e 10 (dez) anos de fabricação. Telas ou plástico anti-granizo que apresentem bolsões ou vãos entre fileiras entre 20 (vinte) e 50 (cinquenta) centímetros. Telas ou plástico anti-granizo que apresentem ângulo entre 20 (vinte) e 30 (trinta) graus de inclinação. O Custo Unitário do homem/dia passa de R$ 30,00 para R$ 80,00. O Custo do Metro Quadrado da tela passa de R$ 1,10 para R$ 1,30.
				</td>
			</tr>
		</tbody>
	</table>
<? endif;
// FIM BLOCO ESPECÍFICO PARA MAÇÃ TELADA ?>

<?php
	$possuiCondicoesParticulares = false;
	if (!empty($coberturaPrincipal['ds_frase_condicoes_particulares'])) {
		$possuiCondicoesParticulares = true;
	}

	if (!$possuiCondicoesParticulares) {
		foreach ($coberturasAdicionais as $coberturaAdicional) {
			if (!empty($coberturaAdicional['ds_frase_condicoes_particulares'])) {
				$possuiCondicoesParticulares = true;
				break;
			}
		}
	}
?>

	
	<!-- BLOCO 1.1 - RISCOS EXCLUÍDOS E/OU PERDAS NÃO COBERTAS  -->
	<?php if (!empty($coberturaPrincipal['ds_frase_outros_riscos_excluidos']) || !empty($coberturaAdicional['ds_frase_outros_riscos_excluidos'])): ?>
		<?= $this->footerProposta($this->proposta, $this->isEnviarDocusign) ?>
		<div style="page-break-before: always;"></div>
		
		
	<div>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
			<thead>
				<tr>
					<th style='font-size: 12px; background-color: white;'><?= $labelFraseOutrosRiscosExcluidos ?></th>
				</tr>
			</thead>
			<tbody>
				<? if (!empty($linhasFraseOutrosRiscosExcluidosCoberturaPrincipal)):?>
					<?php echo $linhasFraseOutrosRiscosExcluidosCoberturaPrincipal ?>
					<tr><td style="border-bottom:1px solid #000; border-top:none;"></td></tr>
				<? endif; ?>

				<? if (!empty($linhasFraseOutrosRiscosExcluidosCoberturaAdicionais)):?>
					<tr><td><br></td></tr>
					<?php echo $linhasFraseOutrosRiscosExcluidosCoberturaAdicionais ?>
					<tr><td style="border-bottom:1px solid #000; border-top:none;"></td></tr>
				<? endif; ?>
			</tbody>
		</table>
	</div>
<?php endif; ?>


<?php 
	echo $this->footerProposta($this->proposta, $this->isEnviarDocusign);
	echo '<div style="page-break-before: always;"></div>';
?>

<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
  <thead>
    <tr>
      <th style="font-size: 12px;background-color:white;">DECLARAÇÕES DO CORRETOR DE SEGUROS</th>
    </tr>
  </thead>
  <tbody>
	<tr>
		<td style="border-bottom:none;">
			<p style="font-size:12px;">Declaro, sob minha responsabilidade profissional, que:</p>
		</td>
	</tr>
    <tr>
      <td style="border-bottom:none; border-top:none; padding-left:20px; padding-top:6px;">
		<p style="font-size:12px; padding-top:6px;">&#8226; <b>Identificação e Representação</b> - Atuo nesta contratação como corretor devidamente registrado na SUSEP e, quando aplicável, como representante do proponente, nos termos da lei.</p>
		<br>
		<p style="font-size:12px; padding-top:6px;">&#8226; <b>Entrega da Proposta</b> - Entreguei ao proponente, em suporte duradouro, a proposta completa com as condições aplicáveis e informei o prazo legal para análise pela seguradora.</p>
		<br>
		<p style="font-size:12px; padding-top:6px;">&#8226; <b>Orientação Básica</b> - Esclareci ao proponente a importância de responder ao questionário de risco, quando houver, de forma completa e verdadeira, alertando sobre as consequências legais de omissões ou informações falsas.</p>
      </td>
    </tr>
	<tr>
	  <td style="padding-top:6px; border-top:none;" >
		<p style="font-size:12px;">[X] Eu me responsabilizo e declaro estar formalmente autorizado e/ou ser o responsável legal, pelo titular destes dados pessoais a fornecê-los a Essor.</p>
	  </td>
	</tr>
  </tbody>
</table>

<?= $this->footerProposta($this->proposta, $this->isEnviarDocusign) ?>
<?= "<div  style='page-break-before: always;'></div>" ?>

<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
  <thead>
    <tr>
      <th style="font-size: 12px; background-color:white;">DECLARAÇÕES E COMPROMISSOS DO PROPONENTE RELACIONADAS À EXECUÇÃO E CONFORMIDADE CONTRATUAL</th>
    </tr>
  </thead>
  <tbody>
		<?php if ($statusProposta != 'NAO_ENVIADA'): 
			$quebrarPaginaDeclaracao = true;	
		?>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">Eu, na qualidade de proponente, declaro para todos os fins legais que:</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>A) Veracidade das informações e natureza do risco</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">
					<b>Declaro</b>, sob minha responsabilidade, que <b>não tenho conhecimento</b> de que o risco desta proposta já tenha ocorrido ou seja impossível
					de ocorrer e que todas <b>as informações prestadas</b> são <b>verdadeiras, completas e atualizadas</b>.
				</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>B) Interesse legítimo e vínculo com o objeto</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">
					<b>Reconheço</b> que o <b>interesse segurado</b> decorre de <b>vínculo jurídico ou econômico direto</b> com o objeto do seguro (por exemplo:<b>propriedade, posse, uso, responsabilidade legal ou obrigação contratual</b>),
					sendo esse vínculo <b>essencial à validade do contrato</b>.
				</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>C) Dever de comunicar alterações relevantes</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">
					<b>Comprometo-me</b> a <b>informar imediatamente</b> à seguradora <b>qualquer alteração relevante</b> que afete o <b>interesse legítimo</b>, a <b>qualificação do(s) beneficiário(s)</b> ou a <b>estrutura contratual</b>, ciente de minha <b>responsabilidade civil e penal</b>.
				</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>D) Ciência das consequências por omissão ou má-fé</b></td>
			</tr>
			<tr >
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>Estou ciente</b> de que:</td>
			</tr>

			<tr style="border-bottom:none; border-top:none">
				<td style="border-bottom:none; border-top:none; padding-left:20px; padding-top:6px;">
					<table>
						<tr>
							<td style="border:none; font-size:12px; padding:5px 1px 5px 1px;">&#8226; se houver <b>omissão dolosa</b> (intencional), <b>perco o direito</b> à indenização e posso ter de <b>ressarcir despesas</b> à seguradora;</td>
						</tr>
						<tr>
							<td style="border:none; font-size:12px; padding:5px 1px 5px 1px;">&#8226; se houver <b>omissão culposa</b> (sem intenção), a <b>cobertura poderá ser reduzida proporcionalmente</b>;</td>
						</tr>
						<tr>
							<td style="border:none; font-size:12px; padding:5px 1px 5px 1px;">&#8226; se os fatos omitidos <b>tornarem a cobertura inviável</b> ou <b>incompatível</b> com o contrato, este <b>poderá ser cancelado</b>.</td>
						</tr>
					</table>
				</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>E) Compromisso com Direitos Humanos e Idoneidade</b></td>
			</tr>
			<tr>
				<td style="border-bottom:none; border-top:none; font-size:12px; padding:5px 1px 5px 1px;">Declaro, sob minha responsabilidade, que nem eu, nem o(s) beneficiário(s), nem quaisquer terceiros envolvidos na presente proposta de seguro: (i) estamos incluídos em listas oficiais de trabalho escravo, infantil ou em condições análogas à escravidão; (ii) constamos em listas de sanções nacionais ou internacionais, incluindo, mas não se limitando a, ONU, OFAC, União Europeia ou Reino Unido; (iii) fomos condenados por crimes relacionados à lavagem de dinheiro, financiamento ao terrorismo ou infrações correlatas.</td>
			</tr>

			<tr>
				<td style="border-bottom:none; border-top:none; font-size:12px; padding:5px 1px 5px 1px;">Estou ciente de que a falsidade ou omissão de qualquer dessas informações implicará a recusa da proposta pela Seguradora. Caso tais situações sejam identificadas durante a vigência da apólice, esta será cancelada de pleno direito.</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>F) Formação e Informação Prévia</b></td>
			</tr>
			<tr>
				<td style="border-bottom:none; border-top:none; font-size:12px; padding:5px 1px 5px 1px;">Confirmo que esta proposta foi feita de forma voluntária, por mim ou por um representante autorizado. Os meus dados de contato (endereço, telefone e e-mail) são corretos e usados para comunicações da seguradora. Comprometo-me a mantê-los atualizados, pois, se não fizer isso, qualquer aviso enviado para esses contatos será considerado recebido.</td>
			</tr>
			<tr>
				<td style="border-bottom:none; border-top:none; font-size:12px; padding:5px 1px 5px 1px;">Também confirmo que recebi todas as informações importantes para entender o contrato e as consequências de não informar corretamente os dados. Sou responsável por garantir que tudo o que informei é verdadeiro e completo. Respondi ao questionário de risco, quando necessário, com base no que sei, de forma clara e atualizada.</td>
			</tr>
			<tr>
				<td style="border-bottom:none; border-top:none; font-size:12px; padding:5px 1px 5px 1px;">Tenho ciência dos anexos a esta Proposta, <b>CUJAS CÓPIAS RECEBI NO ATO DA SUA ASSINATURA, ACEITANDO-OS NA ÍNTEGRA</b>.</td>
			</tr>
			<tr>
				<td style="border-bottom:none; border-top:none; font-size:12px; padding:5px 1px 5px 1px;">Se o seguro exigir informações contínuas (como averbações), sei que deixar de informar dados importantes pode fazer com que eu perca a cobertura, mesmo depois de um sinistro. Se a omissão não for intencional, vou pagar a diferença do prêmio e provar que agi de boa-fé.</td>
			</tr>
			<tr>
				<td style="border-top:none; font-size:12px; padding:5px 1px 5px 1px;">Reconheço ainda que o corretor de seguros pode me representar, na forma da lei.</td>
			</tr>
		<?php else:?>
			<tr>
				<td>
					<table>
						<? if (($statusProposta == 'NAO_ENVIADA') || ($statusProposta == 'NAO_ENVIADA_DEVOLVIDA')): ?>
							<tr>
								<td class="carencia">
								<p style="<?=$fontSize?>">Caso decida-se pela efetivação da proposta de seguro agrícola, entre em contato com o seu corretor e solicite o encaminhamento à seguradora.</p>
								</td>
							</tr>
						<? else: ?>
							<tr style="height: 30px;">
								<td style="width: 33%;">
								<b>Local e Data</b>
								<table width="100%">
									<tbody>
										<tr>
											<td align="center" border="0" style="border: 0 !important; border-style: none;">
												<p><?=$proponente['ds_nome_municipio']?> - <?=$proponente['ds_sigla']?></p>
												<div style="color: white;">
													data_assinatura
												</div>
											</td>
										</tr>
									</tbody>
								</table>
								</td>
								<td style="width: 33%;">
								<b>Assinatura do Proponente</b>
								<div style="color: white;">assinatura_do_proponente</div>
								</td>
								<!--<td style="position: relative; width: 33%;">-->
								<td style="width: 33%;">
								<?php if ($condicoesGeraisSUSEP) { ?>
									<div>
									<b>Assinatura do Corretor</b>
									<div style="color: white;">assinatura_do_corretor</div>
									</div>
									<br><br>
									<table style="border: none; border-collapse: collapse;">
										<tr>
											<td style="text-align:center; font-size:smaller; border:none;">
												<p>Assinatura opcional. Informações foram validadas através de autenticação em sistema.</p>
											</td>
										</tr>
									</table>
								<?php } else { ?>
									<b>Assinatura e Carimbo do Corretor</b>
									<div style="color: white;">assinatura_do_corretor</div>
								<?php }?>
								</td>
							</tr>
						<? endif; ?>
					</table>
				</td>
			</tr>
		<?php endif;?>
  </tbody>
</table>

<?php if ($quebrarPaginaDeclaracao): ?>
<div  style="page-break-before: always;"></div>

<table width="100%" cellpadding="0" cellspacing="1" class="gadget">
  <thead>
    <tr>
      <th style="font-size: 12px; background-color:white;">DECLARAÇÕES E COMPROMISSOS DO PROPONENTE RELACIONADAS À EXECUÇÃO E CONFORMIDADE CONTRATUAL</th>
    </tr>
  </thead>
  <tbody>
		<?php if ($statusProposta != 'NAO_ENVIADA'): ?>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>G) Conhecimento do Contrato e dos Riscos Excluídos</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">Declaro que li e compreendi as Condições Contratuais, conforme indicado no item “Avisos Importantes ao Proponente”, incluindo os riscos excluídos. Reconheço que a ausência de cobertura para tais riscos não configura falha contratual por parte da Seguradora.</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">Tenho ciência de que não terei direito a indenização se estiver em atraso no pagamento do prêmio, se o sinistro ocorrer antes da quitação das parcelas vencidas e não pagas (Art. 763 do Código Civil).</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>H) Declaração sobre Interesse Legítimo, Conhecimento do Risco e Veracidade das Informações</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">Estou contratando este seguro para proteger algo que me interessa ou que interessa a outra pessoa. Tenho ligação com o que está sendo segurado (como dono, responsável ou usuário).</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>Confirmo que: (i) o risco ainda não aconteceu; e (ii) as informações que dei são verdadeiras</b>.</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>Se eu omitir/esconder algo: (i) de propósito: posso perder o direito ao seguro e ter que devolver o que recebi; (ii) sem querer: o seguro pode cobrir menos ou ser cancelado</b>.</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>Prometo avisar a seguradora se algo mudar que afete o seguro</b>.</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>I) Declaração sobre Beneficiários do Seguro</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">Os beneficiários que indiquei estão de acordo com a lei e têm um motivo legítimo para serem incluídos no seguro.</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>Declaro que: (i) a escolha foi feita corretamente, sem problemas legais; (ii) existe uma relação que justifica essa indicação; (iii) não há fraude ou má intenção.</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>Me comprometo a avisar a seguradora se algo mudar que afete os beneficiários ou o motivo pelo qual foram indicados.</b></td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>J) Cobertura Provisória</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">Solicito a cobertura provisória e autorizo o pagamento antecipado do prêmio. Em caso de recusa da proposta, a seguradora deverá comunicar expressamente sua decisão e reembolsar integralmente o valor pago, exceto se houver cobertura efetiva, hipótese em que poderá haver retenção proporcional ao período de vigência.</td>
			</tr>

			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>K) Declarações sobre os Programas de Subvenção</b></td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>DECLARO</b> que tomei ciência das Condições dos Programas de Subvenção ao Prêmio do Seguro dos Governos Federal e Estadual e <b>ESTOU DE ACORDO COM SUAS CONDIÇÕES</b>.</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">Se, por qualquer motivo, o Governo Federal e/ou Estadual não conceda subsídio ao prêmio para esta proposta, <b>ME RESPONSABILIZO PELO CUSTO INTEGRAL DO SEGURO</b>.</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;"><b>AUTORIZO</b> o uso de meio eletrônico pela Seguradora para o contato e envio de informações referentes ao seguro, inclusive envio de apólices e boletos.</td>
			</tr>
			<tr>
				<td style="font-size:12px; border-bottom:none; border-top:none; padding:5px 1px 5px 1px;">[X] Eu me responsabilizo e declaro estar formalmente autorizado e/ou ser o responsável legal, pelo titular destes dados pessoais a fornecê-los a Essor.</td>
			</tr>
		<?php endif;?>

		<tr>
			<td>
				<table>
					<? if (($statusProposta == 'NAO_ENVIADA') || ($statusProposta == 'NAO_ENVIADA_DEVOLVIDA')): ?>
						<tr>
							<td class="carencia">
							<p style="<?=$fontSize?>">Caso decida-se pela efetivação da proposta de seguro agrícola, entre em contato com o seu corretor e solicite o encaminhamento à seguradora.</p>
							</td>
						</tr>
					<? else: ?>
						<tr style="height: 30px;">
							<td style="width: 33%;">
								<b>Local e Data</b>
								<table width="100%">
									<tbody>
										<tr>
											<td align="center" border="0" style="border: 0 !important; border-style: none;">
												<p><?=$proponente['ds_nome_municipio']?> - <?=$proponente['ds_sigla']?></p>
												<div style="color: white;">
													data_assinatura
												</div>
											</td>
										</tr>
									</tbody>
								</table>
							</td>
							<td style="width: 33%;">
							<b>Assinatura do Proponente</b>
							<div style="color: white;">assinatura_do_proponente</div>
							</td>
							<!--<td style="position: relative; width: 33%;">-->
							<td style="width: 33%;">
							<?php if ($condicoesGeraisSUSEP) { ?>
								<div style="display:inline-block; text-align:left !important;">
								<b>Assinatura do Corretor</b>
								<div style="color: white;">assinatura_do_corretor</div>
								</div>
								<br><br>
								<table style="border: none; border-collapse: collapse;">
									<tr>
										<td style="text-align:center; font-size:smaller; border:none;">
											<p>Assinatura opcional. Informações foram validadas através de autenticação em sistema.</p>
										</td>
									</tr>
								</table>
							<?php } else { ?>
								<b>Assinatura e Carimbo do Corretor</b>
								<div style="color: white;">assinatura_do_corretor</div>
							<?php }?>
							</td>
						</tr>
					<? endif; ?>
				</table>
			</td>
		</tr>
  </tbody>
</table>
<?php endif; ?>

<script>
	$(document).ready(function () {
		document.querySelector('#bttPrint').removeAttribute('href');
		document.querySelector('#bttPrint').addEventListener('click', () => {
			const isSolicitacaoEndosso = window.location.href.includes('origemSolicitacaoEndosso');

			$.ajax({
				type : 'POST',
				url : '/seguro/proposta/viewprint',
				data: {idProposta: '<?php echo $this->proposta->id?>', isSolicitacaoEndosso: isSolicitacaoEndosso},
				dataType : 'json',
				success : function (response) {
					
					if (response.erro) {
						alert(response.mensagem);
						return;
					}

					// Decodifica Base64 para Blob
					var byteCharacters = atob(response.pdf);
					var byteNumbers = new Array(byteCharacters.length);
					for (var i = 0; i < byteCharacters.length; i++) {
						byteNumbers[i] = byteCharacters.charCodeAt(i);
					}
					var byteArray = new Uint8Array(byteNumbers);
					var blob = new Blob([byteArray], { type: 'application/pdf' });

					// Cria URL temporária
					var blobUrl = URL.createObjectURL(blob);

					// Cria iframe oculto e dispara impressão
					var iframe = document.createElement('iframe');
					iframe.style.display = 'none';
					iframe.src = blobUrl;
					iframe.onload = function() {
						iframe.contentWindow.print();
					};
					document.body.appendChild(iframe);


				},
				error : function (xhr, desc, er) {
					alert(xhr.responseText);
				}
			});
		});
	});
</script>