<script type="text/javascript" src="/resources/jquery/jquery.cpfcnpj.js"></script>

<fieldset style="padding:0;">
	<legend>Informe o nome do Proponente</legend>
	<form id="formSearchProponentes" method="post" style="padding:0;margin:0;background:#FFFFFF;">
		<input type="hidden" name="tipo" id="tipo" value="<?=$this->tipo?>"  />
		<input type="hidden" name="id" id="id" value="<?=$this->id?>"  />
		<input type="hidden" name="id_condicao_pagamento_proponente" id="id_condicao_pagamento_proponente" value="<?=$this->id?>"  />
		
		<div class="geral">
			<div class="row">
				<div class="field">
					<label>Proponente</label>
					<input type="text" name="ds_nome_proponente" id="ds_nome_proponente" size="50" />
				</div>
				<div class="field">
					<label>Tipo de Pessoa</label>
					<select name="tp_pessoa" id="tp_pessoa">
					    <option value="F" label="FÍSICA">FÍSICA</option>
					    <option value="J" label="JURÍDICA">JURÍDICA</option>
					</select>
				</div>
				<div class="field">
					<label>CPF/CNPJ</label>
					<input type="text" name="cpf_cnpj" id="cpf_cnpj" value="" maxlength="20" class="cpf_cnpj" size="20">
				</div>
				
				<div class="field">
					<label>&nbsp;</label>
					<button type="button" name="bttBuscarProponentes" id="bttBuscarProponentes">Buscar</button>
				</div>
			</div>
		</div>
	</form>
</fieldset>

<fieldset style="padding:0;" id="proponentesRelacionados">
	<legend>Proponentes Relacionados</legend>
	<form method="post" id="formDesmarcarProponente" style="padding:0;margin:0;background:#FFFFFF;">
		<input type="hidden" name="tipo" id="tipo" value="<?=$this->tipo?>"  />
		<input type="hidden" name="id" value="<?=$this->id?>"  />
		
		<div style="overflow:auto;height:200px;">
			<table width="100%" cellpadding="5" cellspacing="1" class="grid_gray">
				<thead>
					<tr>
						<th>&nbsp;</th>
						<th>Proponentes Relacionados</th>
					</tr>
				</thead>
				<tbody id="list-proponentes-relacionados">
					<? if ($this->proponentes->count()): ?>
						<? foreach($this->proponentes as $relacionado): ?>
							<tr id="proponente_<?=$relacionado->id?>">
								<td width="1%"><input checked type="checkbox" name="id_proponente[]" value="<?=$relacionado->id?>" class="desmarcar_proponente" /></td>
								<td><?=$relacionado->ds_nome_proponente;?> (<?=$relacionado->cpf_cnpj;?>)</td>
							</tr>
						<? endforeach; ?>
					<? else: ?>
						<tr>
							<td colspan="2">Nenhum proponente relacionado.</td>
						</tr>
					<? endif; ?>
				</tbody>
			</table>
		</div>
	</form>
</fieldset>

<fieldset style="padding:0;" id="proponentesRelacionar"  class="hide">
	<legend>Proponentes Encontrados</legend>
	<form method="post" id="formRelacionaProponente" style="padding:0;margin:0;background:#FFFFFF;">
		<input type="hidden" name="tipo" id="tipo" value="<?=$this->tipo?>"  />
		<input type="hidden" name="id" value="<?=$this->id?>"  />
		<input type="hidden" name="id_produto" value="<?=$this->id_produto?>"  />

		<div style="overflow:auto;height:200px;">
			<table width="100%" cellpadding="5" cellspacing="1" class="grid_gray">
				<thead>
					<tr>
						<th>&nbsp;</th>
						<th>Proponentes Encontrados</th>
					</tr>
				</thead>
				<tbody id="list-proponentes"></tbody>
			</table>
			<button type="button" id="bttRelacionarProponentes" name="bttRelacionarProponentes">Relacionar</button>
			<button type="button" id="bttCancelarRelacionamento" name="bttCancelarRelacionamento">Cancelar</button>
		</div>
	</form>
</fieldset>