<?php

class Endosso_Form_Proponente extends Agro_Form {
	
	public function init() {
		$Propostas = new Endosso_Model_Propostas();
		
		$this->addElement('hidden', 'id', array('decorators' => $this->buttonDecorator));
		$this->addElement('hidden', 'id_proposta', array('decorators' => $this->buttonDecorator));
		$this->addElement('hidden', 'id_municipio', array('decorators' => $this->buttonDecorator));
		$this->addElement('hidden', 'id_proponente_original', array('decorators' => $this->buttonDecorator));
		
		$this->addElement('text', 'cpf_cnpj', array(
			'validators' => array(array('validator'=> new Agro_Validate_CpfCnpj())),
			'decorators' => $this->elementDecorator,
			'label' => 'CPF/CNPJ',
			'class' => 'cpf_cnpj',
			'required' => true,
			'maxlength' => 18,
			'size' => 19
		));
		
		$this->addElement('select', 'tp_pessoa', array(
			'MultiOptions' => array('F'=>'FÍSICA','J'=>'JURÍDICA'),
			'decorators' => $this->elementDecorator,
			'label' => 'Tipo Pessoa'
		));
		
		$this->addElement('select', 'tp_segurado', array(
			'MultiOptions' => array('', 'P'=>'PROPRIETÁRIO','A'=>'ARRENDATÁRIO', 'O'=>'OUTROS'),
			'decorators' => $this->elementDecorator,
			'label' => 'Tipo do Segurado'
		));
		
		$this->addElement('text', 'ds_nome_proponente', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Nome',
			'required' => true,
			'maxlength' => 100,
			'size' => 45
		));
		
		$this->addElement('text', 'ds_email_proponente', array(
			'validators' => array(array('validator'=> new Zend_Validate_EmailAddress())),
			'decorators' => $this->elementDecorator,
			'label' => 'E-mail',
			'maxlength' => 100,
			'class' => 'email',
			'size' => 45
		));
		
		$this->addElement('select', 'ds_sexo', array(
			'MultiOptions' => array('F'=>'FEMININO','M'=>'MASCULINO'),
			'decorators' => $this->elementDecorator,
			'label' => 'Sexo',
			'required' => true
		));
		
		$this->addElement('text', 'dt_nascimento', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Dt. Nascimento',
			'class' => 'data',
			'maxlength' => 10,
			'size' => 11
		));
		
		$this->addElement('select', 'id_estado_civil', array(
			'MultiOptions' => $Propostas->comboEstadosCivis(),
			'decorators' => $this->elementDecorator,
			'label' => 'Estado Civil'
		));
		
		$this->addElement('select', 'ds_documento_natureza', array(
			'MultiOptions' => array('RG' => 'RG', 'RNE' => 'RNE'),
			'decorators' => $this->elementDecorator,
			'label' => 'Doc.',
			'class' => 'required'
		));
		
		$this->addElement('text', 'ds_documento_numero', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Nº Documento',
			'class' => 'integer required',
			'maxlength' => 12,
			'size' => 12
		));
		
		$this->addElement('select', 'id_orgao_expedidor', array(
			'MultiOptions' => $Propostas->comboOrgaosExpedidores(),
			'decorators' => $this->elementDecorator,
			'class' => 'required',
			'label' => 'Órgão Expedidor'
		));
		
		$this->addElement('select', 'id_atividade_economica', array(
			'MultiOptions' => $Propostas->comboAtividadeEconomica(),
			'decorators' => $this->elementDecorator,
			'label' => 'Atividade Economica',
			'style' => 'width:100%'
		));
		
		$this->addElement('text', 'dt_documento_exp', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Dt. Expedição',
			'class' => 'data required',
			'maxlength' => 10,
			'size' => 11
		));
		
		$this->addElement('text', 'ds_endereco_rua', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Endereço',
			'maxlength' => 100,
			'required' => true,
			'class' => 'upper',
			'size' => 32
		));
		
		$this->addElement('text', 'ds_endereco_nro', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Número',
			'class' => 'integer',
			'required' => true,
			'maxlength' => 8,
			'size' => 8
		));
		
		$this->addElement('text', 'ds_endereco_complem', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Complemento',
			'maxlength' => 100,
			'class' => 'upper',
			'size' => 8
		));
		
		$this->addElement('text', 'ds_endereco_bairro', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Bairro',
			'required' => true,
			'maxlength' => 30,
			'class' => 'upper',
			'size' => 30
		));
		
		$this->addElement('text', 'ds_endereco_cep', array(
			'decorators' => $this->elementDecorator,
			'label' => 'CEP',
			'maxlength' => 10,
			'required' => true,
			'class' => 'cep',
			'size' => 10
		));
		
		$this->addElement('text', 'ds_sigla', array(
			'decorators' => $this->elementDecorator,
			'label' => 'UF',
			'disable' => true,
			'size' => 2
		));
		
		$this->addElement('text', 'ds_nome_municipio', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Município',
			'disable' => true,
			'size' => 40
		));
		
		$this->addElement('text', 'ds_tel_residencia', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Residencial',
			'class' => 'telefone',
			'maxlength' => 20,
			'required' => false,
			'size' => 14
		));
		
		$this->addElement('text', 'ds_tel_propriedade', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Propriedade',
			'class' => 'telefone',
			'maxlength' => 20,
			'required' => false,
			'size' => 14
		));
		
		$this->addElement('text', 'ds_tel_celular', array(
			'decorators' => $this->elementDecorator,
			'class' => 'telefone',
			'label' => 'Celular',
			'maxlength' => 20,
			'required' => false,
			'size' => 14
		));
		
		$this->addElement('checkbox', 'fl_inadimplente', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Inadimplente'
		));
		
		$this->addElement('checkbox', 'fl_validacao_receita', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Validar na Receita'
		));
	}
	
	public function populate(array $values) {
		$values['dt_documento_exp'] = Agro_Util::formatDate($values['dt_documento_exp']);
		$values['dt_nascimento'] = Agro_Util::formatDate($values['dt_nascimento']);
		
		parent::populate($values);
	}
	
}