<? $this->headerSinistro($this->id_proposta, $this->id_processo); ?>

<form class="formDefault" id="formDefault" method="post">
	<input type="hidden" name="userVistoriaMesmaEmpresa" id="userVistoriaMesmaEmpresa" value="<?=$this->userVistoriaMesmaEmpresa?>" />
	<input type="hidden" name="hasRevistoria" id="hasRevistoria" value="<?=$this->hasRevistoria?>" />
	<input type="hidden" name="id_revistoria" id="id_revistoria" value="<?=$this->id_revistoria?>" />
	<input type="hidden" name="id_laudo_final" id="id_laudo_final" value="<?=$this->id_laudo_final?>" />
    <input type="hidden" name="idLaudoFinal" id="idLaudoFinal" value="<?=$this->id_laudo_final?>" />
	<input type="hidden" name="id_cobertura" id="id_cobertura" value="<?=$this->id_cobertura?>" />
	<input type="hidden" name="id_vistoria" id="id_vistoria" value="<?=$this->id_vistoria?>" />
	<input type="hidden" name="id_processo" id="id_processo" value="<?=$this->id_processo?>" />
	<input type="hidden" name="id_proposta" id="id_proposta" value="<?=$this->id_proposta?>" />
	<input type="hidden" name="laudoSalvo" id="laudoSalvo" value="<?=$this->laudoSalvo?>" />
	<input type="hidden" name="unidades_seguradas" id="unidades_seguradas" value="" />
	
	<input type="hidden" name="vl_perc_sem_cortes" id="vl_perc_sem_cortes" value="0" />
	<input type="hidden" name="vl_perc_cortes_batidas_tunica" id="vl_perc_cortes_batidas_tunica" value="5" />
	<input type="hidden" name="vl_perc_cortes_1_capa" id="vl_perc_cortes_1_capa" value="30" />
	<input type="hidden" name="vl_perc_cortes_2_capa" id="vl_perc_cortes_2_capa" value="70" />
	<input type="hidden" name="vl_perc_cortes_3_capa" id="vl_perc_cortes_3_capa" value="100" />
	
	
	<div class="area">
		<?
		if ($this->id_revistoria) {
			echo $this->getAvisosRevistoria($this->id_revistoria);
		} else {
			echo $this->getAvisosVistoria($this->id_vistoria);
		}
		?>
	</div>
	
	<? if ($this->id_revistoria): ?>
		<div class="area">
			<? echo $this->title('Revistoria realizada?'); ?>
			
			<div style="padding:10px 0 5px 10px">
				<input type='radio' name='fl_realizada' id='fl_realizada-S' value='S' <?=$this->fl_realizada == 'S' ? 'checked' : ''?> />
				<label>Sim</label>
			</div>
			
			<div style="padding:0 0 5px 10px">
				<input type='radio' name='fl_realizada' id='fl_realizada-N' value='N' <?=$this->fl_realizada == 'N' ? 'checked' : ''?> />
				<label>Não</label>
			</div>
			
			<div style="padding:0 0 5px 10px" class="<? echo (($this->id_revistoria && $this->fl_realizada == 'S') ? 'hide' : 'show')?>">
				<label>Motivo</label>
				<input type='radio' name='fl_realizada' id='fl_realizada-N' value='N' <?=$this->fl_realizada == 'N' ? 'checked' : ''?> />
			</div>
		</div>
	<? endif; ?>
	
	<div class="area <? echo (($this->id_revistoria && $this->fl_realizada == 'N') ? 'hide' : 'show');?>">
		<? echo $this->title("Identificação do evento"); ?>
		<br/>
		<table border="0" cellpadding="0" cellspacing="5">
			<tr>
				<td valign="middle" align="left" width="1%">
					<input type="checkbox" <?=$this->fl_evento_nao_constatado ? 'checked' : ''?> id="fl_evento_nao_constatado" name="fl_evento_nao_constatado" value="true">
					<label for="fl_evento_nao_constatado">Não constatou-se a ocorrência do evento comunicado.</label>
				</td>
			</tr>
			<tr>
				<td>
					<div class="element">
						<label for="dt_inicio_colheita" class="optional inputs_evento">Dt. Inicio Colheita</label>
						<input name="dt_inicio_colheita" id="dt_inicio_colheita" value="<?echo $this->dt_inicio_colheita?>" class="data inputs_evento" maxlength="10" size="11" type="text">
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="element">
						<label for="dt_recolhimento_producao" class="optional inputs_evento">Dt. Recolhimento Produção</label>
						<input name="dt_recolhimento_producao" id="dt_recolhimento_producao" value="<?echo $this->dt_recolhimento_producao?>" class="data inputs_evento" maxlength="10" size="11" type="text">
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="element">
						<label for="ds_coordenadas_geograficas" class="optional inputs_evento">Coordenadas Geográficas (Sede)</label>
						<input name="ds_coordenadas_geograficas" id="ds_coordenadas_geograficas" value="<?echo $this->ds_coordenadas_geograficas?>" class="coordenadas inputs_evento" maxlength="10" size="20" type="text">
					</div>
				</td>
			</tr>
		</table>
	</div>
	<br/>
	<div class="area">
		<? echo $this->title("Informações sobre quadras atingidas"); ?>
		<br/>		
		<table border="0" cellpadding="0" cellspacing="5">
			<tr>
				<td width="1%"><input type='radio' name='fl_area_atingida' id='fl_area_atingida-T' value='T' <?=$this->fl_area_atingida == "T" ? 'checked' : ''?> class="inputs_evento" /></td>
				<td width="1%" colspan="2"><label for="fl_area_atingida-T">Total</label></td>
				<td width="1%"><input type='radio' name='fl_area_atingida' id='fl_area_atingida-P' value='P' <?=$this->fl_area_atingida == "P" ? 'checked' : ''?> class="inputs_evento" /></td>
				<td width="1%"><label for="fl_area_atingida-P">Parcial</label></td>
				<td><input type="text" id="area_atingida_ha" name="area_atingida_ha" size="12" style="text-align: right" value="<?=$this->area_atingida_ha?>" readonly class="inputs_evento" /> ha</td>
			</tr>
		</table>
		
		<br/>
		<? echo $this->title("Quadras atingidas"); ?>

		<div id="div_quadras_vistoriadas"></div>
	</div>
	<div class="area">
		<br/>		
		<br/>
		<? echo $this->title("Observação do laudo"); ?>
		<textarea name="ds_observacao" id="ds_observacao" rows="4" style="width: 100%"><?=$this->ds_observacao?></textarea>
	</div>
	<br/>
	
	<?
	$LaudosFinais = new Sinistro_Model_LaudosFinais();
	$Row = $LaudosFinais->find($this->id_laudo_final)->current();
	
	
	?>
	
	<? if ($Row->countQuadras('safra12.laudos_finais_cebola_cura')): ?>
		<button type="button" id="btnEnviarLaudo">Enviar</button>
	<? endif; ?>
            
            <?if($LaudosFinais->getDsChaveStatus($this->id_laudo_final) == 'ENVIADO' && ($this->user->ds_nome_usuario == 'maria.cristina' || $this->user->ds_nome_usuario == 'fernando.nunes')):?>
                <button type="button" id="bntDevolverLaudo">Devolver</button>
            <?endif?>
	
	<?
	if ($Row->id_status == $LaudosFinais->getIdStatus('ENVIADO', 'LF') && $this->user->tp_usuario != 'F') {
		?>
		<script type="text/javascript">
		$(document).ready(function() {
			$('input, textarea, select').attr('disabled', true);
		});
		</script>
		<?
	}
	?>
	<button type="submit">Salvar</button>
</form>

<div class="hide" id="listQuadrasAreaAtingida" title="Selecione as quadras atingidas"></div>
<div class="hide" id="formitemsegurado"></div>