<?php

class Seguro_Form_BeneficiarioArquivo extends Agro_Form {

	public function init() {
		$this->addElement('hidden', 'id_beneficiario', array('decorators' => $this->buttonDecorator));
		$this->addElement('hidden', 'id', array('decorators' => $this->buttonDecorator));
		$this->addElement('hidden', 'id_arquivo', array('decorators' => $this->buttonDecorator));

		$this->addElement('select', 'tp_pessoa', array(
			'MultiOptions' => array('F'=>'FÍSICA','J'=>'JURÍDICA'),
			'decorators' => $this->elementDecorator,
			'label' => 'Tipo Pessoa',
			'required' => true
		));

		$this->addElement('text', 'cpf_cnpj', array(
			'validators' => array(array('validator'=> new Agro_Validate_CpfCnpj())),
			'decorators' => $this->elementDecorator,
			'label' => 'CPF/CNPJ',
			'class' => 'cpf_cnpj',
			'maxlength' => 18,
			'size' => 19,
			'required' => true
		));

		$this->addElement('text', 'ds_nome_beneficiario', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Nome Beneficiário',
			'required' => true,
			'maxlength' => 100,
			'size' => 70
		));


		$this->arquivo = $this->createElement('file','arquivo');
		$this->arquivo->setDestination(APPLICATION_PATH . '/upload_files/beneficiarios/');
		$this->arquivo->setLabel('Arquivo');
		$this->arquivo->setRequired(false);
		$this->addElement($this->arquivo);

		$TipoArquivoProcesso = new Sistema_Model_TipoArquivoProcesso();
		$this->id_tipo_arquivo = $this->createElement('select', 'id_tipo_arquivo');
		$this->id_tipo_arquivo->addMultiOptions($TipoArquivoProcesso->getComboTiposArquivosBeneficiario());
		$this->id_tipo_arquivo->setRequired(false);
		$this->id_tipo_arquivo->setLabel('Tipo');
		$this->addElement($this->id_tipo_arquivo);


	}

	public function populate(array $values) {
		$values['id_beneficiario'] = $values['id'];
		parent::populate($values);
	}

	public function isValid($params){
		return parent::isValid($params);
	}
}
