<link rel="stylesheet" href="/resources/css/sinistro2/liquidacao.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/resources/css/seguro/propostaview.css" type="text/css" media="screen" />

<form action="/sinistro2/liquidacao/liquidarmanual" method="post" id="formLiquidacao">
	<input type="hidden" name="id_proposta" value="<? echo $this->dados['PARAMS']['id_proposta']?>">
	<input type="hidden" name="id_processo" value="<? echo $this->dados['PARAMS']['id_processo']?>">
	<input type="hidden" name="independente" value="<? echo $this->dados['PARAMS']['independente']?>">
    <input type="hidden" name="id_cobertura" value="<? echo $this->dados['PARAMS']['id_cobertura']?>">
    <input type="hidden" name="id_liquidacao" value="<? echo $this->dados['PARAMS']['id_liquidacao']?>">
    	
	<?
  $ocultarEmpresaVistoria = true;

  if (Sistema_Model_Usuarios::usuarioLogadoFuncionarioAgro()
      || in_array($this->user->id_role, [Sistema_Model_Roles::ID_VISTORIADOR, Sistema_Model_Roles::ID_VISTORIADOR_RESP])) {
      $ocultarEmpresaVistoria = false;
  }

  echo $this->headerSinistro($this->dados['PARAMS']['id_proposta'], $this->dados['PARAMS']['id_processo'], $ocultarEmpresaVistoria, true);
  echo $this->title('Unidades Seguradas à serem Liquidadas');
  ?>

	<br>
	<?=$this->form->tp_liquidacao;?>
	<br>
	
	<table width="100%" class="grid" cellpadding="2" cellspacing="1">
		<thead>
	        <tr>
	        	<th width="2%"> <input type="checkbox" id="checkAll"> </th>
	            <th width="1%">Item</th>
	            <th>Quadra</th>
	            <th>Variedade</th>
	            <th>Área</th>
	            <th>LMGA</th>
	            <th>Regulação de Perdas</th>
	            <th>Final de Colheita</th>
	        </tr>
	    </thead>
	    <tbody>
	    	<?$manual=false;?>
			<?foreach ($this->dados['QUADRAS'] as $Quadra):?>
				<tr align="center" >
					<td> <input type="checkbox" name="id_item_segurado[]" class="chkItem" value="<? echo $Quadra['id_item_segurado']?>" <?echo ($Quadra['vl_lmga'] <= 0 ? "disabled" : "")?>></td>
					<td><? echo $Quadra['nr_item_segurado']?></td>
					<td><? echo $Quadra['ds_item_segurado']?></td>
					<td><? echo $Quadra['ds_nome_variedade']?></td>
					<td><? echo $Quadra['vl_area']?></td>
					<td><? echo Agro_Util::formatDbCurrency($Quadra['vl_lmga'])?></td>
					<td>
						<?if ($Quadra['COBERTURAS']){?>
							<?foreach ($Quadra['COBERTURAS'] as $cobertura):?>
								<input type="hidden" name="coberturas-<?echo $Quadra['id_item_segurado']?>[]" value="<? echo $cobertura['id_cobertura']?>">							
								<div class="regulacao">
									<div class="titleCobertura"><?echo "{$cobertura['ds_nome_cobertura']}";?></div>
									<div class="dadosCobertura">
										Prejuízo:  <input type="text" name="vl_prejuizo_total-<?echo $Quadra['id_item_segurado']?>-<?echo $cobertura["id_cobertura"]?>"  size="18px" class="decimal" />
										<br/>
										Indenização: <input type="text" name="vl_indenizacao-<?echo $Quadra['id_item_segurado']?>-<?echo $cobertura["id_cobertura"]?>"  size="15px" class="decimal" />
									</div>
								</div>
							<?endforeach;?>
						<?} else {?>
							<div class="semLaudos">Não há coberturas contratadas</div>
						<?}?>
						
					</td>
					<td><? echo $Quadra['dt_encerramento_colheita']?></td>					
				</tr>
		    <?endforeach;?>
	   </tbody> 
	</table>
	<br>
	<br>	
	<?echo $this->title("Observação");?>
	<br />
	<textarea id="ds_observacao" name="ds_observacao" cols="100" rows="10"></textarea>
	<br />
	<br /><button type="button" id="btnExecutaLiquidacao">Liquidar quadras selecionadas</button>
	
</form>