<link rel="stylesheet" href="/resources/css/sinistro/laudos.css" type="text/css" media="screen" />


<? if ($this->dados['id_revistoria']) {?>
	<?=$this->title('Formulário de Laudo de Revistoria Final para Tomate de Mesa - Granizo')?>
<? } else {?>
	<?=$this->title('Formulário de Laudo Final para Tomate de Mesa - Granizo')?>
<? }?>		

<form action="/safra13/lftomatemesagranizo/savelaudo" class="formTomateMesaGranizo" id="formTomateMesaGranizo" method="post">

	<input type="hidden" name="id_laudo_final" id="id_laudo_final" value="<?=$this->dados['id_laudo_final']?>" />
	<input type="hidden" name="id_vistoria" id="id_vistoria" value="<?=$this->dados['id_vistoria']?>" />
	<input type="hidden" name="id_revistoria" id="id_revistoria" value="<?=$this->dados['id_revistoria']?>" />
	<input type="hidden" name="id_proposta" id="id_proposta" value="<?=$this->dados['id_proposta']?>" />
	<input type="hidden" name="id_cobertura" id="id_cobertura" value="<?=$this->dados['id_cobertura']?>" />
	<input type="hidden" name="id_processo" id="id_processo" value="<?=$this->dados['id_processo']?>" />
	<input type="hidden" name="has_revistoria" id="has_revistoria" value="<?=$this->dados['has_revistoria']?>" />
	<input type="hidden" name="user_vistoria_mesma_empresa" id="user_vistoria_mesma_empresa" value="<?=$this->dados['user_vistoria_mesma_empresa']?>" />

	<div class="geral">
		<br>
		<?=$this->headerSinistro($this->dados['id_proposta'], $this->dados['id_processo'])?>
		
		<? if ($this->dados['revistoria']) {?>
			<?=$this->getAvisosRevistoria($this->dados['revistoria']['id_revistoria'])?>
			
		<? } else {?>
			<?=$this->getAvisosVistoria($this->dados['id_vistoria'])?>
			
		<? }?>		
				
		<div id="container" style="<?=$this->dados['id_laudo_final'] || (count($this->vistoriadores) > 0) ? 'display: ' : 'display: none' ?>">
			<? if ($this->dados['revistoria']) {?>
				<fieldset>
					<legend>Motivo da Revistoria</legend>
					<table width="100%" border="0" cellspacing="0">
						<tr>
							<td>
								<label><?=$this->dados['revistoria']['ds_motivo']?></label>
							</td>
						</tr>
					</table>
				</fieldset>				
				<fieldset>
					<table width="100%" border="0" cellspacing="0">
						<tr>
							<td width="15%">
								<label>Revistoria realizada?</label>
							</td>
							<td width="10%" align="center">
								<input type='radio' name='fl_realizada' id='fl_realizada-S' value='S' <?=$this->dados['revistoria']['fl_realizada'] == 'S' ? 'checked' : ''?> />
								<label>Sim</label>
							</td>
							<td width="75%">
								<input type='radio' name='fl_realizada' id='fl_realizada-N' value='N' <?=$this->dados['revistoria']['fl_realizada'] == 'N' ? 'checked' : ''?> />
								<label>Não</label>
							</td>
						</tr>
					</table>
				</fieldset>		
				<? 
					$display = '';
					if ($this->dados['revistoria']['id_revistoria'] && $this->dados['revistoria']['fl_realizada'] == 'S') {
						$display = 'none';					
					}
				?>		
				<div id="motivoNaoRealizada" style="display: <?=$display?>">
					<fieldset>
						<div class="row">
							<label>Motivo:</label>
							<textarea name="ds_motivo_nao_realizada" id="ds_motivo_nao_realizada" rows="4" cols="100"><?=$this->dados['revistoria']['ds_motivo_nao_realizada']?></textarea>
						</div>
					</fieldset>				
				</div>
			<? }?>		
			<? 
				$display = '';
				if ($this->dados['revistoria'] && $this->dados['revistoria']['fl_realizada'] == 'N') {
					$display = 'none';					
				}
			?>	
			<div class="bloco">
				<fieldset>
					<legend>Identificação do Evento</legend>
					<div class="content">
						<table>
							<tr>
								<td>
									<input type="checkbox" name="fl_evento_nao_constatado" id="fl_evento_nao_constatado" <?=($this->dados['fl_evento_nao_constatado'] == 1 ? 'checked="checked"' : '')?> value="<?=$this->dados['fl_evento_nao_constatado'];?>" />
									Não constatou-se a ocorrência do evento comunicado.								
								</td>
							</tr>
						</table>
						
						<br />
						
						<table class="detalhesEvento">
							<tr>
								<td width="18%" >
									Acompanhado de vento: 
								</td>
								<td width="6%">
									<input type="radio" name="fl_acompanhado_vento" class="fl_acompanhado_vento" <?=($this->dados['fl_acompanhado_vento'] == 1 ? 'checked="checked"' : '')?> value="1"/>
									Sim
								</td>
								<td width="6%">
									<input type="radio" name="fl_acompanhado_vento" class="fl_acompanhado_vento" <?=($this->dados['fl_acompanhado_vento'] == 0 ? 'checked="checked"' : '')?> value="0"/>
									Não
								</td>
								<td width="20%" align="right">
									Direção do Vento: 
								</td>
								<td width="30%">
									<input type="text" name="ds_direcao_evento" id="ds_direcao_evento" value="<?=$this->dados['ds_direcao_evento']?>" <?=($this->dados['fl_acompanhado_vento'] == 0 ? 'disabled="disabled"' : '')?>/>
								</td>
							</tr>
							
							<tr>
								<td width="18%" >
									Acompanhado de chuva: 
								</td>
								<td width="6%">
									<input type="radio" name="fl_acompanhado_chuva" class="fl_acompanhado_chuva" <?=($this->dados['fl_acompanhado_chuva'] == 1 ? 'checked="checked"' : '')?> value="1"/>
									Sim
								</td>
								<td width="6%">
									<input type="radio" name="fl_acompanhado_chuva" class="fl_acompanhado_chuva" <?=($this->dados['fl_acompanhado_chuva'] == 0 ? 'checked="checked"' : '')?> value="0"/>
									Não
								</td>
								<td width="20%" align="right">
									Diâmetro médio do granizo: 
								</td>
								<td width="30%">
									<input type="text" name=ds_diametro_medio_granizo id="ds_diametro_medio_granizo" class="integer" value="<?=$this->dados['ds_diametro_medio_granizo']?>" <?=($this->dados['fl_acompanhado_chuva'] == 0 ? 'disabled="disabled"' : '')?> />
								</td>
							</tr>
							
							<tr>
								<td width="18%" >
									Danos em benfeitorias: 
								</td>
								<td width="6%">
									<input type="radio" name="fl_danos_benfeitorias" id="fl_danos_benfeitorias_s" <?=($this->dados['fl_danos_benfeitorias'] == 1 ? 'checked="checked"' : '')?> value="1" />
									Sim
								</td>
								<td colspan="3" width="6%">
									<input type="radio" name="fl_danos_benfeitorias" id="fl_danos_benfeitorias_n" <?=($this->dados['fl_danos_benfeitorias'] == 0 ? 'checked="checked"' : '')?> value="0" />
									Não
								</td>
							</tr>
						</table>
						
						<br />
						
						<table class="detalhesEvento">
							<tr>
								<td width="50%">
									Coordenadas geográficas da propriedade / Área plantada:
								</td>
								<td width="50">
									<input type="text" name="ds_coordenadas" value="<?=$this->dados['ds_coordenadas']?>" class="coordenadas"/>
								</td>
							</tr>
						</table>
						
						<br />
						
						<table class="detalhesEvento">
							<tr>
								<td width="25%">
									Área atingida: 
								</td>
								<td width="25%">
									<input type="radio" name="fl_area_atingida" class="fl_area_atingida" id="fl_area_atingida_t" <?=($this->dados['fl_area_atingida'] == 'T' ? 'checked="checked"' : '')?> value="T" />
									Total
								</td>
								<td width="25%">
									<input type="radio" name="fl_area_atingida" class="fl_area_atingida" id="fl_area_atingida_p" <?=($this->dados['fl_area_atingida'] == 'P' ? 'checked="checked"' : '')?> value="P" />
									Parcial
								</td>
								<td width="25%">
									<input type="text" name="ds_ha" id="ds_ha" value="<?=$this->dados['ds_ha']?>" size="10" readonly="readonly"/>
									ha
								</td>
								
							</tr>
						</table>
					</div>
				</fieldset>
			</div>	
			<div id="dadosLaudo">
				
				<fieldset class="fieldset_laudo_final" style='margin-left:5px;width:98%'>
					<div id="div_quadras_vistoriadas" >
					
						<table width="100%" class="grid">
							<thead>
								<tr>
									<th align="center" width="1%"> Item </th>
									<th align="center" width="10%"> Quadra </th>
									<th align="center" width="15%"> Variedade</th>
									<th align="center" width="10%"> Área</th>
									<th align="center" width="10%"> LMGA</th>
									<th align="center" width="15%"> Não vistoriada</th>
									<th align="center" width="10%"> % de dano</th>
									<th align="center" colspan="2"> Laudo Final</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach($this->dados['dados_quadra'] as $quadra):?>
									<tr>
										<td align="center">
											<input name="itens_segurados[]" value="<?=$quadra['id'];?>" type="hidden">
											<label id="nr_item-<?=$quadra['id'];?>"><?=$quadra['nr_item_segurado'];?></label>
										</td>
										<td align="center">
											<?=$quadra['ds_item_segurado'];?>
										</td>
										<td align="center">
											<?=$quadra['ds_nome_variedade'];?>
										</td>
										<td align="center">
											<?=$quadra['vl_area'];?>
										</td>
										<td align="center">
											<?=$quadra['vl_lmga'];?>
										</td>
										<td align="center">
											<select id="id_motivo_quadra_nao_vistoriada[<?=$quadra['id'];?>]" name="id_motivo_quadra_nao_vistoriada[<?=$quadra['id'];?>]">
												<option value="">Selecione o motivo</option>
												<?foreach ($this->dados['motivo_nao_realizada'] as $motivo){?>
													<option value="<?=$motivo['id']?>"><?=$motivo['ds_motivo']?></option>
												<?}?>
											</select>
										</td>
										<td align="center">
											<label><?=Agro_Util::formatDbCurrency($valor = $quadra['vl_percent_perdas'], $precision = 2, $decimal = '.');?></label>
										</td>
										
										<td align="center">											
											<a class="ClassificacaoFrutosTomateMesa" href="/safra13/lftomatemesagranizo/formclassificacaofrutos/id_item_segurado/<?=$quadra['id']?>/id_proposta/<?=$this->dados['id_proposta']?>/id_processo/<?=$this->dados['id_processo']?>/id_vistoria/<?=$this->dados['id_vistoria']?>/id_laudo_final/<?=$this->dados['id_laudo_final']?>/id_cobertura/<?=$this->dados['id_cobertura']?>" >Classificação dos Frutos</a>	
										</td>
										
										<td align="center">											
											<a class="TotalizacaoPerdasTomateMesa" href="/safra13/lftomatemesagranizo/formtotalizacaoperdas/id_item_segurado/<?=$quadra['id']?>/id_proposta/<?=$this->dados['id_proposta']?>/id_processo/<?=$this->dados['id_processo']?>/id_vistoria/<?=$this->dados['id_vistoria']?>/id_laudo_final/<?=$this->dados['id_laudo_final']?>/id_cobertura/<?=$this->dados['id_cobertura']?>" >Totalização de Perdas</a>	
										</td>
									</tr>
								<?php endforeach;?>
							</tbody>
						</table>
					</div>
				</fieldset>
	
				<fieldset>
					<legend>Dados Adicionais</legend>
					<div class="row">
						<label>Observações:</label>
						<textarea name="ds_observacao" id="ds_observacao" rows="4" cols="100"><?=$this->dados['ds_observacao']?></textarea>
					</div>
					<div class="row">
						<?=$this->formAssinatura->fl_assinatura_regulador?>
					</div>
		
					<div class="row">
						<?=$this->formAssinatura->fl_assinatura_segurado?>
					</div>
				</fieldset>
			</div>
			<fieldset id="fieldset-buttons">
				<input type="button" id="btnSalvarLaudo" value="Salvar"/>
				<input type="button" id="voltar" value="Voltar" onclick="location.href='/sinistro/processo/view/id/<?=$this->dados['id_processo']?>'" />
			</fieldset>
		</div>
	</div>
</form>

<script type="text/javascript">
	if ( $("#fl_evento_nao_constatado").is(':checked') ){
		$(".detalhesEvento input").attr("disabled", "disabled");
		
		
	} else {
		$(".detalhesEvento input").removeAttr('disabled');

	}	
</script>

