<?php
class Sinistro2_Form_TipoLaudoPreliminar extends Agro_Form {
	
	public function init()
	{
		$existeImportacaoXml = false;
		if (!empty($this->_request['id'])) {
			$tipoLaudoPreliminar = (new Sinistro2_Model_TipoLaudoPreliminar())->find($this->_request['id'])->current();
			$existeImportacaoXml = !empty($tipoLaudoPreliminar['fl_import_xml']) ? true : false;
		}

		$this->addElement('hidden', 'id', array('decorators' => $this->elementDecorator));
		
		$this->addElement('text', 'ds_nome_tipo_laudo_preliminar', array(
			'decorators' => $this->elementDecorator,
			'required' => true,
			'label' => 'Nome'
		));
		
		$this->addElement('text', 'ds_chave', array(
			'decorators' => $this->elementDecorator,
			'required' => true,
			'label' => 'Chave',
		));
		
		$this->addElement('textarea', 'ds_descricao_tipo_laudo_preliminar', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Descrição',
			'cols' => 50,
			'rows' => 5
		));
		
		$GrupamentoCultura = new Produto_Model_GrupamentoCulturas();
		$this->addElement('select', 'id_grupamento_cultura', array(
			'MultiOptions' => $GrupamentoCultura->fetchPairs('id', 'ds_nome_grupamento_cultura', false, false, 1, false, true, 'ASC'),
			'decorators' => $this->elementDecorator,
			'label' => 'Grupamento Cultura',
			'required' => true
		));
			
		$this->addElement('text', 'ds_versao', [
            'decorators' => $this->elementDecorator,
            'required' => true,
            'label' => 'Versão'
        ]);

        $this->addElement('checkbox', 'can_import_xml', [
            'decorators' => $this->elementDecorator,
            'label' => 'Existe importação de XML?',
			'checked' => $existeImportacaoXml
        ]);
	}
}
