<?
$Validacoes = new Produto_Model_Validacoes();
$Ciclos = new Produto_Model_Ciclos();
$this->showPrint = true;
//$Acl = Agro_Acl::getInstance();
//$Acl->setAclProposta($this->module, 'view');
$this->date = new Zend_Date();
$this->dateFormat = 'dd/MM/Y';
?>
<link rel="stylesheet" href="/resources/css/seguro/proposta.css" type="text/css" media="screen" />
<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" />

<div class="proposta">

		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<tr>
				<td style="background: #FF0000; color: #FFFFFF; font-weight: bold; border: 1px solid black;">
					Aviso de Sinistro Nro: <?=$this->data['id_aviso']?>
					<?if($this->data['id_processo']):?>
					 - Processo de Sinistro Nro: <?=$this->data['id_processo']?>
					<?endif?>
					<br />
					Status do Aviso: <?=$this->data['ds_status']?>
					<?if($this->data['ds_motivo_recusa']):?>
					<br />Motivo da Recusa: <?=$this->data['ds_motivo_recusa']?>
					<?endif?>
				</td>
			</tr>
		</table>

	<?=$this->headerProposta($this->proposta, 1, 2, false) ?>
	<? //if ($Acl->isAllowed($this->module, 'dados_proponente')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="6" bgcolor="#F0F0F0">Dados do Proponente</th>
				</tr>
			</thead>
			<tbody>
				<? if ($this->proposta['proponente']['tp_pessoa'] == 'F'): ?>
					<tr>
						<td bgcolor="#FFFFFF" colspan=2><label><b>Nome/Razão Social</b></label> <?=$this->proposta['proponente']['ds_nome_proponente']?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap" width="1%"><label><b>CPF/CNPJ</b></label> <?=$this->proposta['proponente']['cpf_cnpj']?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap" width="1%"><label><b>Sexo</b></label> <?=($this->proposta['proponente']['ds_sexo'] == 'M' ? 'MASCULINO' : 'FEMININO')?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap" width="1%"><label><b>Data de Nascimento</b></label> <?=Agro_Util::formatDate($this->proposta['proponente']['dt_nascimento'], Zend_Date::DATES)?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap" width="1%"><label><b>Estado Civil</b></label> <?=$this->proposta['proponente']['ds_nome_estado_civil']?></td>
					</tr>
					<tr>
						<td bgcolor="#FFFFFF" nowrap="nowrap" valign="top"><label><b>E-mail</b></label> <?=$this->proposta['proponente']['ds_email_proponente']?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap"><label><b>Documento</b></label> <?=$this->proposta['proponente']['ds_documento_natureza']?> <?=$this->proposta['proponente']['ds_documento_numero']?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap"><label><b>Órgão Expedição</b></label> <?=$this->proposta['proponente']['ds_nome_orgao']?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap"><label><b>Data Expedição</b></label> <?=Agro_Util::formatDate($this->proposta['proponente']['dt_documento_exp'], Zend_Date::DATES)?></td>
						<td bgcolor="#FFFFFF" nowrap="nowrap" colspan="2">
							<? if ($this->proposta['proponente']['tp_segurado'] == 'P'): ?>
								<label><b>Segurado:</b></label> PROPRIETÁRIO
							<? elseif ($this->proposta['proponente']['tp_segurado'] == 'A'): ?>
								<label><b>Segurado:</b></label> ARRENDATÁRIO
							<? elseif ($this->proposta['proponente']['tp_segurado'] == 'O'): ?>
								<label><b>Segurado:</b></label> OUTROS
							<? endif; ?>
						</td>
					</tr>
				<? elseif ($this->proposta['proponente']['tp_pessoa'] == 'J'): ?>
					<tr>
						<td bgcolor="#FFFFFF"><label><b>Nome/Razão Social</b></label> <?=$this->proposta['proponente']['ds_nome_proponente']?></td>
						<td bgcolor="#FFFFFF"><label><b>CPF/CNPJ</b></label> <?=$this->proposta['proponente']['cpf_cnpj']?></td>
						<td bgcolor="#FFFFFF"><label><b>Atividade Econômica</b></label> <?=$this->proposta['proponente']['ds_documento_natureza']?> <?=$this->proposta['proponente']['ds_documento_numero']?></td>
					</tr>
				<? endif; ?>
			</tbody>
		</table>
	<? //endif; ?>
	
	<? //if ($Acl->isAllowed($this->module, 'endereco_proponente')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="3" bgcolor="#F0F0F0">Endereço do Proponente</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td bgcolor="#FFFFFF"><label><b>Endereço</b></label> <?=$this->proposta['proponente']['ds_endereco_rua']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Número</b></label> <?=$this->proposta['proponente']['ds_endereco_nro']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Complemento</b></label> <?=$this->proposta['proponente']['ds_endereco_complem']?>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#FFFFFF"><label><b>Bairro</b></label><?=$this->proposta['proponente']['ds_endereco_bairro']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>CEP</b></label><?=$this->proposta['proponente']['ds_endereco_cep']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Município/UF</b></label><?=$this->proposta['proponente']['ds_nome_municipio']?>/<?=$this->proposta['proponente']['ds_sigla']?>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#FFFFFF" width=33%><label><b>Telefone Principal</b></label> <?=$this->proposta['proponente']['ds_tel_residencia']?>&nbsp;</td>
					<td bgcolor="#FFFFFF" width=33%><label><b>Telefone Celular</b></label> <?=$this->proposta['proponente']['ds_tel_celular']?>&nbsp;</td>
					<td bgcolor="#FFFFFF" width=33%><label><b>Telefone Propriedade</b></label> <?=$this->proposta['proponente']['ds_tel_propriedade']?>&nbsp;</td>
				</tr>
			</tbody>
		</table>
	<? //endif; ?>

		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="3" bgcolor="#F0F0F0">Informações do Sinistro</th>
				</tr>
			</thead>
			<tbody>
				<tr>
                    <?
                        $colspan = 3;
                        $eventos = '';
                        foreach($this->data['eventos'] as $it):
                            $eventos .= $it['ds_nome_evento'] . ', ';
                        endforeach;
                        $eventos = substr($eventos, 0, strlen($eventos) - 2);
                    ?>
                        <td bgcolor="#FFFFFF">
                        	<label><b>Eventos:</b></label>
                            <?=$eventos?>
                        </td>
                        
                        <? $dataHoraSinistro = explode(' ',$this->data['dt_sinistro']);?>
                        <td bgcolor="#FFFFFF">
                            <label><b>Data do sinistro:</b></label>
                        <?=Agro_Util::formatDate($dataHoraSinistro[0], Zend_Date::DATES)?>
                        </td>
                        
                        <td bgcolor="#FFFFFF">
                            <label><b>Hora do sinistro:</b></label>
                            <? $hora = explode(':',$dataHoraSinistro[1]); echo $hora[0] . ':' . $hora[1]?>
                        </td>
                                                
                        <?if (in_array('COB_QUEDA_PARREIRAL', $this->listChaveCoberturas)): $colspan++ ?>
                        <td bgcolor="#FFFFFF">
                            <label><b>Ocorreu Queda de Parreiral?</b></label>
                            <?=$this->data['fl_ocorrencia_queda_parreiral'] ? 'Sim' : 'Não'?>
                        </td>
                        <?endif?>
                        
                        <?if (in_array('COB_REPLANTIO', $this->listChaveCoberturas)):$colspan++ ?>
                        <td bgcolor="#FFFFFF">
                            <label><b>Ocorreu Replantio?</b></label>
                            <?=$this->data['fl_ocorrencia_replantio'] ? 'Sim' : 'Não'?>
                        </td>
                        <?endif?>
				</tr>
				<tr>
                    <td bgcolor="#FFFFFF" colspan=<?=$colspan?>>
                    	<label><b>Observações:</b></label><br />
                        <?=$this->data['ds_observacoes']?>
                    </td>
				</tr>
				<tr>
                    <td bgcolor="#FFFFFF">
                        <label>Pessoa para contato:</label>
						<?=$this->data['ds_pessoa_contato']?>
					</td>
                    <td bgcolor="#FFFFFF">
                        <label><b>Telefone para contato:</b></label>
                        <?=$this->data['ds_telefone_contato']?>
                    </td>
                    <td bgcolor="#FFFFFF">
                        <?if($this->data['dsNomeEmpresaVistoriadora']):?>
                        <label><b>Empresa responsável pelo Processo de Sinistro:</b></label>
                        <?=$this->data['dsNomeEmpresaVistoriadora']?>
                        <?endif?>
                    </td>
                </tr>

			</tbody>
		</table>
	<? // ?>

	<? //Informações do Envio ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="3" bgcolor="#F0F0F0">Informações do Envio</th>
				</tr>
			</thead>
            <tbody>
                <tr>
                    <td bgcolor="#FFFFFF">
                    	<label><b>Responsável pelo preenchimento:</b></label>
                        <? if ($this->data['ds_nome_funcionario']) {?>
                            <?=$this->data['ds_nome_funcionario'] . " (" . $this->data['ds_nome_fantasia'] . ")" ?>
                        <? } else {?>
                            <?=$this->data['ds_nome_corretor']?>
                        <? }?>
                    </td>
                <tr>
                    <td bgcolor="#FFFFFF">
                    	<label><b>Data de Envio:</b></label>
                        <?=Agro_Util::formatDate($this->data['dt_criacao'], Zend_Date::DATES);?>
                    </td>
                </tr>
            </tbody>
        </tablE>
	<? //endif; ?>

	<? //if ($Acl->isAllowed($this->module, 'dados_propriedade')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="3" bgcolor="#F0F0F0">Dados da Propriedade</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td bgcolor="#FFFFFF"><label><b>Endereço</b></label> <?=$this->proposta['propriedade']['ds_endereco']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Número</b></label> <?=$this->proposta['propriedade']['ds_endereco_nro']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Complemento</b></label> <?=$this->proposta['propriedade']['ds_endereco_complemento']?>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#FFFFFF"><label><b>Bairro</b></label> <?=$this->proposta['propriedade']['ds_endereco_bairro']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>CEP</b></label> <?=$this->proposta['propriedade']['ds_endereco_cep']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Município/UF</b></label> <?=$this->proposta['propriedade']['ds_nome_municipio']?>/<?=$this->proposta['propriedade']['ds_sigla']?>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#FFFFFF" colspan="2"><label><b>Nome da Propriedade</b></label> <?=$this->proposta['propriedade']['ds_nome_propriedade']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Código BACEN</b></label> <?=$this->proposta['propriedade']['cd_bacen']?>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#FFFFFF" colspan="3"><label><b>Ref. para Localização</b></label> <?=$this->proposta['propriedade']['ds_referencia_localizacao']?>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#FFFFFF" colspan="3"><label><b>Coordenadas Geográficas</b></label> <?=$this->proposta['propriedade']['ds_coordenadas']?>&nbsp;</td>
				</tr>
				<tr>
					<td bgcolor="#FFFFFF" colspan="3">
						<label><b>Indique pessoas autorizadas a acompanhar a(s) vistoria(s), além do Proponente: </b></label>
						<?=($this->proposta['propriedade']['ds_pessoa_autorizada'] == 'N' ? 'Não' : '')?>
						<?=($this->proposta['propriedade']['ds_nome_outra_pessoa'] ? $this->proposta['propriedade']['ds_nome_outra_pessoa'] : '&nbsp;')?>
						<?=($this->proposta['propriedade']['ds_telefone_outra_pessoa'] ? ' / '.$this->proposta['propriedade']['ds_telefone_outra_pessoa'] : '&nbsp;')?>
					</td>
				</tr>
			</tbody>
		</table>
	<? //endif; ?>
	
	<? //if ($Acl->isAllowed($this->module, 'questionario')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th bgcolor="#F0F0F0">Questionário</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td bgcolor="#FFFFFF"><?=$this->montaQuetionarioView($this->proposta['questionarios']);?></td>
				</tr>
			</tbody>
		</table>
	<? //endif; ?>
	
	<? //if ($Acl->isAllowed($this->module, 'clausula_beneficiaria')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="<?=(count($this->proposta['beneficiarios']) ? 4 : 0)?>" bgcolor="#F0F0F0">Cláusula Beneficiária</th>
				</tr>
			</thead>
			<tbody>
				<? $i = 1; ?>
				<? if (count($this->proposta['beneficiarios'])): ?>
					<tr>
						<td bgcolor="#FFFFFF"><label><b>Favorecido</b></label></td>
						<td bgcolor="#FFFFFF"><label><b>Qualidade</b></label></td>
						<td bgcolor="#FFFFFF"><label><b>Valor</b></label></td>
						<td bgcolor="#FFFFFF"><label><b>Documento</b></label></td>
					</tr>
					<?php
					//print_r($this->proposta['beneficiarios']);die;
					?>
					<? foreach ($this->proposta['beneficiarios'] as $beneficiario): ?>
						<? if ($i <= 2): ?>
							<? if (strtoupper($beneficiario['ds_tipo_conta']) == 'S' and $beneficiario['ds_nome_banco']): ?>
								<tr>
									<td bgcolor="#FFFFFF"><?=$beneficiario['ds_nome_banco']." (Ag.:".$beneficiario['ds_agencia'].")"; ?>&nbsp;</td>
									<td bgcolor="#FFFFFF"><?=$beneficiario['ds_qualidade_beneficiario']?>&nbsp;</td>
									<td bgcolor="#FFFFFF"><?=$this->currency($beneficiario['vl_limite_beneficio']);?>&nbsp;</td>
									<td bgcolor="#FFFFFF"><?=$beneficiario['nr_cpf_cnpj']?>&nbsp;</td>
								</tr>
							<? else: ?>
								<tr>
									<td bgcolor="#FFFFFF"><?=$beneficiario['ds_nome_beneficiarios']?>&nbsp;</td>
									<td bgcolor="#FFFFFF"><?=$beneficiario['ds_qualidade_beneficiario']?>&nbsp;</td>
									<td bgcolor="#FFFFFF"><?=$this->currency($beneficiario['vl_limite_beneficio']);?>&nbsp;</td>
									<td bgcolor="#FFFFFF"><?=$beneficiario['nr_cpf_cnpj']?>&nbsp;</td>
								</tr>
							<? endif; ?>
						<? endif; ?>
						
						<? $i++; ?>
					<? endforeach; ?>
				<? else: ?>
					<tr>
						<td bgcolor="#FFFFFF" align="center">Nenhum beneficiário cadastrado.</td>
					</tr>
				<? endif; ?>
			</tbody>
		</table>
	<? //endif; ?>
	
	<? //if ($Acl->isAllowed($this->module, 'demonstrativo_premio')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="9" bgcolor="#F0F0F0">Demonstrativo da Franquia - Cobertura Básica</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td bgcolor="#FFFFFF"><label><b>Cultura</b></label><?=$this->proposta['produto']['ds_nome_cultura']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Código BACEN</b></label><?=$this->proposta['produto']['cd_bacen']?></td>
					<td bgcolor="#FFFFFF"><label><b>Área Total da Cultura</b></label><?=$this->proposta['cobertura_principal']['IS']['area']?>ha</td>
					<td bgcolor="#FFFFFF"><label><b>Unidades Seguradas</b></label><?=$this->proposta['cobertura_principal']['IS']['total']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>LMGA</b></label><?=($this->proposta['cobertura_principal']['IS']['lmga'] ? Agro_Util::formatDbCurrency($this->proposta['cobertura_principal']['IS']['lmga']) : '-');?></td>
					<td bgcolor="#FFFFFF"><label><b><?=($this->proposta['atributos']['propriedades']['PROD_PRODUCAO_GARANTIDA']['ds_valor'] ? 'NC' : 'Franquia')?></b></label><?=$this->proposta['cobertura_principal']['vl_franquia']?>%</td>
				</tr>
			</tbody>
		</table>
		
		<? if ($this->proposta['coberturas_adicionais']): ?>
			<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
				<thead>
					<tr>
						<th colspan="4" bgcolor="#F0F0F0">Demonstrativo da Franquia - Coberturas Adicionais</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td bgcolor="#FFFFFF"><label><b>Cobertura</b></label></td>
						<td bgcolor="#FFFFFF"><label><b>Franquia</b></label></td>
					</tr>
					<? foreach ($this->proposta['coberturas_adicionais'] as $cobertura): ?>
						<?
							if ($cobertura['ds_chave_cobertura'] == 'COB_PROTECAO_FITO'){
								$vl_lmi = $this->proposta['cobertura_principal']['IS']['area'] * 100;
							} else {
								$vl_lmi = ($cobertura['vl_lmi'] * $this->proposta['cobertura_principal']['IS']['lmga'])/100;
							}
						?>
						<tr>
							<td bgcolor="#FFFFFF"><?=$cobertura['ds_nome_cobertura']?>&nbsp;</td>
							<td bgcolor="#FFFFFF"><?=($cobertura['fl_exibir_franquia']) ? $cobertura['vl_franquia']."%" : '-'; ?></td>
						</tr>
					<? endforeach; ?>
				</tbody>
			</table>
		<? endif; ?>
	<? //endif; ?>
	
	<? //if ($Acl->isAllowed($this->module, 'corretor')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th colspan="4" bgcolor="#F0F0F0">Corretor</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td bgcolor="#FFFFFF"><label><b>Corretora:</b></label> <?=$this->proposta['corretor']['ds_nome_fantasia']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Número SUSEP:</b></label> <?=$this->proposta['corretor']['nr_susep']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Participação:</b></label> <?=$this->proposta['corretor']['ds_nome_corretor']?>&nbsp;</td>
					<td bgcolor="#FFFFFF"><label><b>Telefone:</b></label> <?=$this->proposta['corretor']['ds_numero']?> <?=($this->proposta['corretor']['ds_ramal'] ? '/ '.$this->proposta['corretor']['ds_ramal'] : '')?>&nbsp;</td>
				</tr>
			</tbody>
		</table>
	<? //endif; ?>
	
	<? if ($this->proposta['ds_observacao']): ?>
		<? //if ($Acl->isAllowed($this->module, 'observacao')): ?>
			<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
				<thead>
					<tr>
						<th bgcolor="#F0F0F0">Observação</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td bgcolor="#FFFFFF"><?=$this->proposta['ds_observacao']?>&nbsp;</td>
					</tr>
				</tbody>
			</table>
		<? //endif; ?>
	<? endif; ?>
	
	<? //if ($Acl->isAllowed($this->module, 'carencia')): ?>
		<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
			<thead>
				<tr>
					<th bgcolor="#F0F0F0">Carência para Início de Vigência da Cobertura dos Riscos</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td bgcolor="#FFFFFF">
						<? if (is_array($this->proposta['carencia'])): ?>
							<b>
							<? foreach ($this->proposta['carencia'] as $cobertura): ?>
								<?=$cobertura['ds_condicao_especial']."<br />"?>
							<? endforeach; ?>
							</b>
						<? endif; ?>
					</td>
				</tr>
			</tbody>
		</table>
	<? //endif; ?>
	
	<? //if ($Acl->isAllowed($this->module, 'anexos_arquivos')): ?>
    <?
        // Variáveis para totalização de valores
        $vl_total_area = 0;
        $vl_total_lmga = 0;
        
        // Contador de colunas exibidas
        $colspan = 0;
    ?>
		<div class="no-print">
			<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
				<thead>
					<tr>
						<th bgcolor="#F0F0F0">Unidades Seguradas</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td bgcolor="#FFFFFF">
							<table width="100%" cellpadding="1" cellspacing="0">
								<tr>
									<td bgcolor="#FFFFFF"><label><b>Item</b></label></td>
									<? foreach ($this->proposta['atributos']['unidades_seguradas'] as $atributo): ?>
										<?
										if($atributo['ds_chave_rn'] == 'IS_FRANQUIA_PARCIAL' || $atributo['ds_chave_rn'] == 'IS_PREMIO_PARCIAL') {
										    continue;
										}
										if ($this->proposta['questionarios']['QUEST_PRODUTIVIDADE_DECLARADA']['resposta'] == 2) {
											if ($atributo['ds_chave_rn'] == 'IS_AREA' or $atributo['ds_chave_rn'] == 'IS_PRODUTIVIDADE') {
												continue;
											}
										} else {
												if ($atributo['ds_chave_rn'] == 'IS_PRODUCAO_PLANTA' or $atributo['ds_chave_rn'] == 'IS_NRO_PLANTAS') {
												continue;
											}
										}
										
										if ($atributo['ds_chave_rn'] == 'IS_COORDENADAS_GEOGRAFICAS' || $atributo['ds_chave_rn'] == 'IS_LOCAL') {
											continue;
										}
										?>
										<td bgcolor="#FFFFFF" align="center"><label><b><?=$atributo['ds_descricao_atributo']?></b></label></td>
									<? $colspan++;endforeach; ?>
								</tr>
								<? if (is_array($this->proposta['unidades_seguradas'])): ?>
									<? foreach ($this->proposta['unidades_seguradas'] as $unidade): ?>
										<?
                                        // Soma os valores de área e lmga da quadra atual aos totalizadores
                                        $vl_total_area += $unidade['is_area'];
                                        $vl_total_lmga += $unidade['is_lmga_parcial'];
										
										$background2 = '';
										$background = '';
										
										if ($unidade['is_ciclo_variedade'] && $this->user->tp_usuario == 'F') {
											if (!$Validacoes->verificaDataSemeadura($this->proposta['produto']['id_validacao'], $this->proposta['questionarios']['QUEST_TIPO_SOLO']['resposta'], $this->proposta['id_produto'], $unidade['is_ciclo_variedade'], $this->proposta['propriedade']['id_municipio_propriedade'], $unidade['is_data_semeadura'])) {
												$background = '#FFBBBC';
												$background2 = '#FFDDDE';
											}
										}
										?>
										
										<tr>
											<td bgcolor="#FFFFFF" style="background:<?=$background?>" class="border_gray_top" align="center"><?=$unidade['is_item'];?></td>
											<?
											foreach ($this->proposta['atributos']['unidades_seguradas'] as $atributo):
												if ($this->proposta['questionarios']['QUEST_PRODUTIVIDADE_DECLARADA']['resposta'] == 2) {
													if ($atributo['ds_chave_rn'] == 'IS_AREA' or $atributo['ds_chave_rn'] == 'IS_PRODUTIVIDADE') {
														continue;
													}
												} else {
														if ($atributo['ds_chave_rn'] == 'IS_PRODUCAO_PLANTA' or $atributo['ds_chave_rn'] == 'IS_NRO_PLANTAS') {
														continue;
													}
												}
												
												if ($atributo['ds_chave_rn'] == 'IS_COORDENADAS_GEOGRAFICAS' || $atributo['ds_chave_rn'] == 'IS_LOCAL') {
													continue;
												}

												if($atributo['ds_chave_rn'] == 'IS_PRODUTIVIDADE'){
													$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_produtividade']);
												}
												if($atributo['ds_chave_rn'] == 'IS_AREA'){
													$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_area']);
												}
												if($atributo['ds_chave_rn'] == 'IS_VALOR_TONELADA'){
													$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_valor_tonelada']);
												}
												if($atributo['ds_chave_rn'] == 'IS_LMGA_PARCIAL'){
													$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_lmga_parcial']);
												}
												if($atributo['ds_chave_rn'] == 'IS_ESPACAMENTO_COMPOSTO'){
													$unidade['is_espacamento_composto'] = $unidade['is_espacamento_simples'];
												}
												if($atributo['ds_chave_rn'] == 'IS_VARIEDADES'){
													$unidade['is_variedades'] = $unidade['is_nome_variedades'];
												}
												if($atributo['ds_chave_rn'] == 'IS_PORTAENXERTO'){
													$unidade['is_portaenxerto'] = $unidade['is_nome_portaenxerto'];
												}
												?>
												<td bgcolor="#FFFFFF" align="center" class="border_gray_top" nowrap="nowrap" style="background:<?=$background?>">
													<?=$unidade[strtolower($atributo['ds_chave_rn'])];?>
												</td>
											<? endforeach; ?>
										</tr>
										
										<? if($unidade['is_coordenadas_geograficas']): ?>
											<tr>
												<td bgcolor="#FFFFFF" colspan="100" style="background:<?=$background2?>">
													[<b>Coordenadas Geográficas:</b> <?=$unidade['is_coordenadas_geograficas']?> - <b>Local</b> <?=($unidade['is_local'] == 'C' ? 'Centro' : 'Lateral')?>]<br />
												</td>
											</tr>
										<? endif; ?>
										
									<? endforeach; ?>
								<? endif; ?>
                                <tr style="background:#F0F0F0; text-align:center; font-weight:bold">
                                    <td style="background:transparent;" colspan="<?=($colspan - 3)?>" />
                                    <td style="background:transparent;"><?=Agro_Util::formatDbCurrency($vl_total_area)?></td>
                                    <td style="background:transparent;" />
                                    <td style="background:transparent;" />
                                    <td style="background:transparent;"><?=Agro_Util::formatDbCurrency($vl_total_lmga)?></td>
                                </tr>
							</table>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		
		<div class="no-view">
            <table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
            <thead>
                <tr>
                    <th bgcolor="#F0F0F0">Unidades Seguradas</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td bgcolor="#FFFFFF">
                    <table width="100%" cellpadding="1" cellspacing="1">
                        <tr>
                            <td bgcolor="#FFFFFF"><label><b>Item</b></label></td>
                            <?
                            foreach ($this->proposta['atributos']['unidades_seguradas'] as $atributo) {
                                
                                if($atributo['ds_chave_rn'] == 'IS_FRANQUIA_PARCIAL' || $atributo['ds_chave_rn'] == 'IS_PREMIO_PARCIAL') {
                                    continue;
                                }
                                if ($this->proposta['questionarios']['QUEST_PRODUTIVIDADE_DECLARADA']['resposta'] == 2) {
                                    if ($atributo['ds_chave_rn'] == 'IS_AREA' or $atributo['ds_chave_rn'] == 'IS_PRODUTIVIDADE') {
                                        continue;
                                    }
                                } else {
                                    if ($atributo['ds_chave_rn'] == 'IS_PRODUCAO_PLANTA' or $atributo['ds_chave_rn'] == 'IS_NRO_PLANTAS') {
                                        continue;
                                    }
                                }
                                
                                if ($atributo['ds_chave_rn'] == 'IS_COORDENADAS_GEOGRAFICAS' || $atributo['ds_chave_rn'] == 'IS_LOCAL') {
                                    continue;
                                }
                                
                                ?><td bgcolor="#FFFFFF" align="center"><label><b><?=$atributo['ds_descricao_atributo']?></b></label></td><?
                            }
                            ?>
                        </tr>
			<?
			/*
			// Total de Linhas por página
			$linhasPorPagina = 50;
			
			// Busca quantas unidades tem na proposta
			$totalUnidades = count($this->proposta['unidades_seguradas']);
			
			// Busca Quantas Coberturas tem na proposta
			$totalCoberturas = count($this->proposta['coberturas_adicionais'])+1;
			
			// Multiplica a quantidade de unidades por total de coberturas, soma 1 para contabilizar a tr da unidade
			$totalLinhas = ($totalCoberturas*$totalUnidades);
			
			// Busca o total de quebras que terao na impressao
			$totalPaginas = ceil($totalLinhas / $linhasPorPagina);
			$i=1;$j=1;$k=1;
			*/
			if (is_array($this->proposta['unidades_seguradas'])) {
				foreach ($this->proposta['unidades_seguradas'] as $unidade) {
					//if (($i == 1) or (round($i % $linhasPorPagina) == 1)) {
						?>

						

						<?
						//$j++;
					//}
					?>
					
					<tr style="background:">
						<td bgcolor="#FFFFFF"  class="border_gray_top" align="center"><?=$unidade['is_item'];?></td>
						<?
						foreach ($this->proposta['atributos']['unidades_seguradas'] as $atributo) {
						    
					        if($atributo['ds_chave_rn'] == 'IS_FRANQUIA_PARCIAL' || $atributo['ds_chave_rn'] == 'IS_PREMIO_PARCIAL') {
                                continue;
                            }
                            if ($this->proposta['questionarios']['QUEST_PRODUTIVIDADE_DECLARADA']['resposta'] == 2) {
                                if ($atributo['ds_chave_rn'] == 'IS_AREA' or $atributo['ds_chave_rn'] == 'IS_PRODUTIVIDADE') {
                                    continue;
                                }
                            } else {
                                if ($atributo['ds_chave_rn'] == 'IS_PRODUCAO_PLANTA' or $atributo['ds_chave_rn'] == 'IS_NRO_PLANTAS') {
                                    continue;
                                }
                            }
                            
                            if ($atributo['ds_chave_rn'] == 'IS_COORDENADAS_GEOGRAFICAS' || $atributo['ds_chave_rn'] == 'IS_LOCAL') {
                                continue;
                            }
						    
							if($atributo['ds_chave_rn'] == 'IS_PRODUTIVIDADE'){
								$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_produtividade']);
							}
							if($atributo['ds_chave_rn'] == 'IS_AREA'){
								$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_area']);
							}
							if($atributo['ds_chave_rn'] == 'IS_VALOR_TONELADA'){
								$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_valor_tonelada']);
							}
							if($atributo['ds_chave_rn'] == 'IS_LMGA_PARCIAL'){
								$unidade[strtolower($atributo['ds_chave_rn'])] = Agro_Util::formatDbCurrency($unidade['is_lmga_parcial']);
							}
							if($atributo['ds_chave_rn'] == 'IS_ESPACAMENTO_COMPOSTO'){
								$unidade['is_espacamento_composto'] = $unidade['is_espacamento_simples'];
							}
	                        if($atributo['ds_chave_rn'] == 'IS_VARIEDADES'){
                                $unidade['is_variedades'] = $unidade['is_nome_variedades'];
                            }
							?><td bgcolor="#FFFFFF" align="center" class="border_gray_top" nowrap="nowrap"><?=$unidade[strtolower($atributo['ds_chave_rn'])];?></td><?
						}
						?>
					</tr>
					
					<? if($unidade['is_coordenadas_geograficas']): ?>
						<tr>
							<td bgcolor="#FFFFFF" colspan="100">
								[<b>Coordenadas Geográficas:</b> <?=$unidade['is_coordenadas_geograficas']?> - <b>Local</b> <?=($unidade['is_local'] == 'C' ? 'Centro' : 'Lateral')?>]<br />
							</td>
						</tr>
					<? endif; ?>
					
					<?
					
				}
			}
			?>
                <tr style="background:#F0F0F0; text-align:center; font-weight:bold">
                    <td style="background:transparent;" colspan="<?=($colspan - 3)?>" />
                    <td style="background:transparent;"><?=Agro_Util::formatDbCurrency($vl_total_area)?></td>
                    <td style="background:transparent;" />
                    <td style="background:transparent;" />
                    <td style="background:transparent;"><?=Agro_Util::formatDbCurrency($vl_total_lmga)?></td>
                </tr>
            </table></td></tr></tbody></table>
		</div>
		
		<? foreach ($this->proposta['croquis'] as $index => $croqui): ?>
			<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
				<thead>
					<tr>
						<th bgcolor="#F0F0F0">Anexos 2 - Croqui <?=$index+1?></th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td bgcolor="#FFFFFF" align="center"><img src="/agronet/file/croqui/name/<?=$croqui['ds_nome_arquivo']?>" /></td>
					</tr>
				</tbody>
			</table>
		<? endforeach; ?>
	<? //endif; ?>

    <form class="formDefault" name="formAceitacaoAviso" id="formAceitacaoAviso" method="post">
        <input type="hidden" name="dadosGravados" id="dadosGravados" value="<?=$this->dadosGravados?>">
	<? if ($this->data['ds_chave_status'] == 'PENDENTE' && /*Agro_Util::checkPermission('sinistro:aviso:aceitacao')*/$this->adminView):?>
		<?
			if($this->informacoesAdicionais){
		?>
				<table width="100%" cellpadding="0" cellspacing="1" class="gadget" bgcolor="#999999">
					<thead>
						<tr>
							<th colspan="3" bgcolor="#F0F0F0">Aviso</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>
							<table width="100%" cellspacing="0" cellpadding="0" class="grid_gray">
							<thead>
								<tr>
		                        <th width="100%" align="center" colspan="3">Informações Adicionais da Proposta</th>
		                        </tr>
		                    </thead>
		                        <tr>
		                        <td><strong>Observação</strong></td>
		                        <td><strong>Usuário</strong></td>
		                        <td><strong>Data</strong></td>
		                        </tr>
		
		                        <?
		                        foreach($this->informacoesAdicionais as $infoAdicional){
		                        	?>
			                        <tr>
		 								<td class="border_gray_top"><?=$infoAdicional['ds_observacao']; ?></td>
			                            <td class="border_gray_top"><?=$infoAdicional['ds_nome_usuario']; ?></td>
			                        	<td class="border_gray_top"><?=Agro_Util::formatDate($infoAdicional['dt_criacao'],Zend_Date::DATES); ?></td>
			                        </tr>
		                        	<?
		                        }
		                        ?>
		
							</table>
			<?}?>
					</td>
				</tr>
				<tr>
	                <td>
                        <?=$this->form->id_proposta?>
                        <?=$this->form->id_processo?>
                        <?=$this->form->id_aviso?>
                        <input type="hidden" name="dt_sinistro" value="<?=Agro_Util::formatDate($dataHoraSinistro[0], Zend_Date::DATES)?>">
                        <input type="hidden" name="status_aviso" id="status_aviso" value="">
                        <input type="hidden" name="idEmpresaProcesso" id="idEmpresaProcesso" value="<?=$this->idEmpresaProcesso?>">
                        
                        <table width="100%" cellspacing="1" cellpadding="0" class="grid_gray">
                            <thead>
                                <tr>
                                    <th width="50%" align="center">Aceitar Aviso</td>
                                    <th width="50%" align="center">Recusar Aviso</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr valign="top">
                                    <td>
                                        <?if($this->form->id_processo->getValue()):?>
                                            <?=$this->message('Esta Proposta já possui um Processo de Sinistro: '.$this->form->id_processo->getValue(), 'alert');?>
                                        <?endif?>
                                        <?if($this->vistoriadoraByCpfCnpjNome):?>
                                            <?=$this->message('O segurado de CPF/CNPJ nro.'.$this->proposta['proponente']['cpf_cnpj'].' já possuiu uma proposta sinistrada e encaminhada para a empresa '.$this->vistoriadoraByCpfCnpjNome, 'alert');?>
                                        <?endif?>
                                        <?if(count($this->data['arAvisosExistentes']) > 0):?>
                                            <?=$this->message('Esta proposta já possui aviso para um sinistro ocorrido na mesma data.', 'alert');?>
                                            <table width="100%" cellspacing="1" cellpadding="0" class="grid_gray">
                                                <thead>
                                                    <tr>
                                                        <th align="center">Aviso</td>
                                                        <th align="center">Dt. Sinistro</td>
                                                        <th align="center">Status</td>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                <?foreach($this->data['arAvisosExistentes'] as $AvisoAnterior):?>
                                                    <tr>
                                                        <td align="center"><?=$AvisoAnterior['id']?></td>
                                                        <td align="center"><?=$AvisoAnterior['dt_sinistro']?></td>
                                                        <td align="center"><?=$AvisoAnterior['ds_status']?></td>
                                                    </tr>
                                                <?endforeach?>
                                                </tbody>
                                            </table>
                                        <?endif?>
                                        <div class="row" style="display:table; margin-top: 5px;">
                                            <?=$this->form->empresas?>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="row"><?=$this->form->motivo_recusa?></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input type="button" name="enviar" id="btnEnviar" value="Enviar aviso à empresa vistoriadora">
                                    </td>
                                    <td>
                                        <input type="button" name="recusar" id="btnRecusar" value="Recusar Aviso">
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <div class="jqmWindow" id="listVistoriasPendentes">
                            <?=$this->title('Vistorias Pendentes')?>
                            
                            <div class="geral">
                                <div style="overflow:auto; height: 200px; width: 500px" id="div_vistorias_pendentes">
                                </div>
                                <div>
                                    <input type="button" id="btnSalvarVistorias" value="Ok" />
                                    &nbsp;&nbsp;
                                    <input type="button" id="btnFecharVistoriasPendentes" value="Fechar" />
                                </div>
                            </div>
                            <hr style="clear:both;" />
                        </div>

	                </td>
				</tr>
			</tbody>
		</table>
	<?endif;?>
    </form>
</div>