<?php

class Produto_Form_ValidacoesSubvencao extends Agro_Form {
	
	public function init() {
		$this->addElement('hidden', 'id_validacao', array('decorators' => $this->buttonDecorator));
		$this->id_validacao->setValue('5');
		$this->addElement('hidden', 'id', array('decorators' => $this->buttonDecorator));
		
		$Cultura = new Produto_Model_Culturas();
		$rsCulturas = $Cultura->getCombo();
		
		$this->addElement('select', 'id_cultura', array(
			'MultiOptions' => $rsCulturas,
			'decorators' => $this->elementDecorator,
			'label' => 'Cultura',
			'required' => true
		));

		$Corretor = new Sistema_Model_Corretores();
		$this->addElement('select', 'id_corretor', array(
			'MultiOptions' => $Corretor->fetchPairs('id', 'ds_nome_fantasia'),
			'decorators' => $this->elementDecorator,
			'label' => 'Corretor',
			'required' => true
		));
		
		$this->addElement('text', 'vl_limite_subvencao', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Valor Limite (R$)',
			'class' => 'currency',
			'required' => true,
			'maxlength' => 20,
			'size' => 20
		));

		$this->addElement('select', 'fl_ativo', array(
			'MultiOptions' => array(0=>'Não',1=>'Sim'),
			'decorators' => $this->elementDecorator,
			'label' => 'Ativo'
		));
	}
	
	public function populate($valores){
		$valores['vl_limite_subvencao'] = Agro_Util::formatDbCurrency($valores['vl_limite_subvencao']);
		return parent::populate($valores);
	}
}