<?

class Produto_Form_Validacoes extends Agro_Form {
	public $id;
	public $ds_nome_validacao;
	public $ds_chave;
	public $ds_acao;
	public $id_tipo_validacao;
	public $ds_descricao_validacao;

	public function init() {
		$this->id = $this->createElement('hidden', 'id');
		$this->id->setDecorators($this->buttonDecorator);
		$this->addElement($this->id);

		$this->ds_nome_validacao = $this->createElement('text', 'ds_nome_validacao');
		$this->ds_nome_validacao->setDecorators($this->elementDecorator);
		$this->ds_nome_validacao->setRequired(true);
		$this->ds_nome_validacao->setAttrib('size', '50');
		$this->ds_nome_validacao->setAttrib('maxlength', '40');
		$this->ds_nome_validacao->setLabel('Nome');
		$this->addElement($this->ds_nome_validacao);

		$this->ds_chave = $this->createElement('text', 'ds_chave');
		$this->ds_chave->setDecorators($this->elementDecorator);
		$this->ds_chave->setRequired(true);
		$this->ds_chave->setAttrib('size', '50');
		$this->ds_chave->setAttrib('maxlength', '40');
		$this->ds_chave->setLabel('Chave');
		$this->addElement($this->ds_chave);

		$TipoValidacao = new Produto_Model_Tipovalidacao();
		$this->id_tipo_validacao = $this->createElement('select', 'id_tipo_validacao');
		$this->id_tipo_validacao->setDecorators($this->elementDecorator);
		$this->id_tipo_validacao->addMultiOptions($TipoValidacao->getCombo());
		$this->id_tipo_validacao->setRequired(true);
		$this->id_tipo_validacao->setLabel('Tipo de Validaçao');
		$this->addElement($this->id_tipo_validacao);

		$arr[' '] = '';
		$arr['produto/validacoesdensidade/index'] = 'Variedade PE Densidade';
		$arr['produto/validacoesvariedadedensidade/index'] = 'Variedade Densidade';
		$arr['produto/validacoesvariedadeidade/index'] = 'Variedade Idade';
		$arr['produto/validacoeszoneamento/index'] = 'Zoneamento Grãos';
		$arr['produto/validacoessubvencao/index'] = 'Limites de Subvenção';
		$arr['produto/validacoessubvencaogrupos/index'] = 'Limites de Subvenção por Grupos';
		$arr['produto/validacoescapacidade/index'] = 'Limites de Capacidade';

		$this->ds_acao = $this->createElement('select', 'ds_acao');
		$this->ds_acao->setDecorators($this->elementDecorator);
		$this->ds_acao->addMultiOptions($arr);
		$this->ds_acao->setRequired(false);

		$this->ds_acao->setAttrib('maxlength', '40');
		$this->ds_acao->setLabel('Ação');
		$this->addElement($this->ds_acao);


		$this->ds_descricao_validacao = $this->createElement('textarea', 'ds_descricao_validacao');
		$this->ds_descricao_validacao->setDecorators($this->elementDecorator);
		$this->ds_descricao_validacao->setAttrib('rows', '5');
		$this->ds_descricao_validacao->setAttrib('cols', '48');
		$this->ds_descricao_validacao->setLabel('Descrição');
		$this->addElement($this->ds_descricao_validacao);
		
		$this->fl_ativo = $this->createElement('select', 'fl_ativo');
		$this->fl_ativo->setDecorators($this->elementDecorator);
		$this->fl_ativo->addMultiOptions(array(0=>'Não',1=>'Sim'));
		$this->fl_ativo->setLabel('Ativo');
		$this->addElement($this->fl_ativo);

		$this->save = $this->createElement('button', 'salvar', array('type'=>'submit'));
		$this->save->setDecorators($this->buttonDecorator);
		$this->save->setLabel('Salvar');
		$this->addElement($this->save);

		$this->cancel = $this->createElement('button', 'cancelar', array('onclick'=>"location.href='/produto/validacoes'"));
		$this->cancel->setDecorators($this->buttonDecorator);
		$this->cancel->setLabel('Cancelar');
		$this->addElement($this->cancel);
	}
}