<script type="text/javascript" src="/resources/javascript/sinistro2/avisogeral.js"></script>
<style>
	.direita {
		text-align: right;
	}
</style>
<form class="formDefault" id="formDefault" name="formDefault" method="post">
	<input type="hidden" name="processo" value="<?=$this->processo?>" />
	<input type="hidden" name="proposta" value="<?=$this->proposta?>" />

	<div class="geral">
		<?=$this->getHeaderProposta($this->proposta, $this->processo)?>

		<br />
		<?=$this->title('Informações da Colheita');?>
		<br />

		<div class="row">
			<label style="padding-bottom: 3px;"><b>Data de encerramento de colheita</b></label>
			<input type="text" class="data" size="30"  name="dt_encerramento_colheita" id="dt_encerramento_colheita" value="<?=$this->dt_encerramento_colheita?>" />
		</div>

		<?
		   $FormasPagamento = new Sistema_Model_FormasPagamento();
		   $fpagamentos = $FormasPagamento->getFormasPagamento();
		   $Bancos = new Sistema_Model_Bancos();
		   $bancos = $Bancos->getBancos();
		   $User = Zend_Auth::getInstance()->getIdentity();
		?>

		<? //if (($User->tp_usuario == 'C') || ($User->tp_usuario == 'P'): ?>
		<!-- If intencional para não exibir o bloco em função da solicitação 2814
		se pedirem para voltar, como geralmente acontece -->
		<? if (1 == 2): ?>
			<br />
			<?=$this->title('Informações bancárias do segurado e beneficiários.');?>
			<br />
				<div class="row">
					<table class="grid2">
						<thead><tr>
							<th>Proponente/Beneficiário</th>
							<th>CPF/CNPJ</th>
							<th>Forma de Pagamento</th>
							<th>Banco</th>
							<th>Agência</th>
							<th>Conta Corrente</th>
						</tr></thead>
						<?
							if(count($this->informacoes_bancarias)>0):
								$i=0;
						?>
							<? foreach ($this->informacoes_bancarias as $inf): ?>
		                        <tr>
		                            <td width="25%">
		                                <input type="hidden" name="cpf_cnpj_<?=$i;?>" id="cpf_cnpj_<?=$i;?>" value="<?=$inf['cpf_cnpj'];?>" />
		                                <input type="hidden" name="id_proposta_<?=$i;?>" id="id_proposta_<?=$i;?>" value="<?=$inf['id_proposta'];?>" />
		                                <input type="hidden" name="id_<?=$i;?>" id="id_<?=$i;?>" value="<?=$inf['id'];?>" />
		                                <?=$inf['ds_nome'];?>
		                            </td>
		                            <td width="15%">
		                                <?=$inf['cpf_cnpj'];?>
		                            </td>
		                            <td align="center">
		                                <select name="f_pagamento_<?=$i;?>" id="f_pagamento_<?=$i;?>" onChange="limpaCampos(<?=$i?>);">
		                                    <option name="nulo" value="">Selecione</option>
		                                <? foreach ($fpagamentos as $f): ?>
		                                        <option value="<?=$f->id;?>"  <?=($inf['id_forma_pagamento'] == $f->id ?'selected':'');?> ><?=$f->ds_forma_pagamento;?></option>
		                                <? endforeach; ?>
		                                </select>
		                            </td>
		                            <td align="center">
		                                <select name="banco_<?=$i;?>" id="banco_<?=$i;?>">
		                                    <option name="nulo" value="">Selecione</option>
		                                <?  foreach ($bancos as $b): ?>
		                                        <option value="<?=$b->id;?>" <?=($inf['id_banco'] == $b->id ? 'selected' : '');?> ><?=$b->nr_banco;?> - <?=$b->ds_nome_banco;?></option>
		                                <?  endforeach; ?>
		                                </select>
		                            </td>
		                            <td width="15%" align="right">
		                                <input class="direita" type="text" size="15" name="agencia_<?=$i;?>" id="agencia_<?=$i;?>" value="<?=($inf['nu_agencia'] ? $inf['nu_agencia'] : '');?>" />-
		                                <input type="text" name="digito_agencia_<?=$i;?>" id="digito_agencia_<?=$i;?>" size="2" maxlength="2" value="<?=(is_null($inf['nu_digito_agencia']) === false ? $inf['nu_digito_agencia'] : '');?>" />
		                            </td>
		                            <td width="15%" align="right">
		                                <input class="direita" type="text" size="15" name="conta_corrente_<?=$i;?>" id="conta_corrente_<?=$i;?>" value="<?=(is_null($inf['nu_conta_corrente']) === false ? $inf['nu_conta_corrente'] : '');?>" />-
		                                <input type="text" name="digito_conta_corrente_<?=$i;?>" id="digito_conta_corrente_<?=$i;?>" size="2" maxlength="2" value="<?=(is_null($inf['nu_digito_conta_corrente']) === false ? $inf['nu_digito_conta_corrente'] : '');?>" />
		                            </td>
		                        </tr>
		                        <? $i++; ?>
							<? endforeach; ?>
							<input type='hidden' name="num_linhas" id="num_linhas" value="<?=$i;?>" />
						<? endif; ?>
					</table>
				</div>
		<? endif; ?>

		<br />
		<?=$this->title('Unidades Seguradas');?>
		<br />

		<table width="100%" class="grid" cellpadding="2" cellspacing="1">
			<thead>
				<tr>
					<th align="center" width="2%">
						<input type="checkbox" name="checkAll" id="checkAll" />
					</th>
					<th align="center" width="1%">
						Item
					</th>
					<th align="center">
						Quadra/Talhão
					</th>
					<th align="center">
						Variedade
					</th>
					<th align="center">
						Área (ha)
					</th>
					<th align="center">
						LMGA (R$)
					</th>
				</tr>
			</thead>

			<?
			 foreach ($this->itensSegurados as $item):
			 	$checked = '';
			 	if (array_key_exists($item['id'], $this->listDadosItens)) {
			 		$checked = 'checked';
			 	}

		 		$disabled = null;
			 	if($item['vl_lmga'] == 0){
			 		$disabled = 'disabled';
			 	}

			?>
			<tr>
				<td align="center">
					<input type="checkbox" <?=$checked?> <?=$disabled?> class="itens_segurados" id="item_segurado-<?=$item['id']?>" name="itens_segurados[]" value="<?=$item['id']?>">
				</td>
				<td align="center">
					<label for="item_segurado-<?=$item['id']?>"><?=$item['nr_item_segurado']?></label>
				</td>
				<td align="center">
					<label for="item_segurado-<?=$item['id']?>"><?=$item['ds_item_segurado']?></label>
				</td>
				<td align="center">
					<label for="item_segurado-<?=$item['id']?>"><?=$item['ds_nome_variedade']?></label>
				</td>
				<td align="right">
					<label for="item_segurado-<?=$item['id']?>"><?=$item['vl_area']?></label>
				</td>
				<td align="right">
					<label for="item_segurado-<?=$item['id']?>"><?=Agro_Util::formatDbCurrency($item['vl_lmga'])?></label>
				</td>
			</tr>
			<?endforeach;?>
		</table>

		<br />
		<br />

		<button id="btnEnviarAviso" name="btnEnviarAviso" type="button">Enviar aviso de encerramento de colheita</button>
	</div>
</form>
