<?

class Seguro_Form_PesquisaProposta extends Agro_Form {
	public $tipo_pesquisa;
	public $valor_pesquisa;
	private $options = array(
			'id_proposta' => 'Proposta',
			'nr_apolice' => 'Apólice',
			'ds_nome_proponente' => 'Segurado'
		);

	public $safra;
	
	public function init() {
		
		$options = array(
			'id_proposta' => 'Proposta',
			'nr_apolice' => 'Apólice',
			'ds_nome_proponente' => 'Segurado'
		);
		
		$this->tipo_pesquisa = $this->createElement('select', 'tipo_pesquisa');
        $this->tipo_pesquisa->setDecorators($this->elementDecorator);
        $this->tipo_pesquisa->setLabel('Tipo de Pesquisa');
		
        $this->tipo_pesquisa->setMultiOptions($options);
        $this->addElement($this->tipo_pesquisa);
		
		$this->valor_pesquisa = $this->createElement('text', 'valor_pesquisa');
		//$this->valor_pesquisa->setRequired(true);
        $this->valor_pesquisa->setDecorators($this->elementDecorator);
        $this->valor_pesquisa->setLabel('Valor da Pesquisa');
        $this->addElement($this->valor_pesquisa);  

		$Safras = new Relatorio_Model_Safras();


		$optionsSafras = $Safras->getCombo();
		
		foreach ($optionsSafras as $valor) {
			$opcoesFormatadas[$valor] = $valor;
		}
		$opcoesFormatadas['0'] = "--- Todas ---";
		
		$this->safra = $this->createElement('select', 'safra');
        $this->safra->setDecorators($this->elementDecorator);
        $this->safra->setLabel('Safra');
        $this->safra->setMultiOptions($opcoesFormatadas);
        $this->addElement($this->safra);

	}
	
	public function addOptions(array $options){
		foreach($options as $key => $item)
			$this->options[$key] = $item;
			
		$this->tipo_pesquisa->setMultiOptions($this->options);
	}
}