<?php

class Regulacao_Form_Lvp001 extends Agro_Form {
    private $_readOnly = null;
	private $_readOnlyAll = null;

	public function init() {

        $modelStatus = new Sistema_Model_Status();
		$dados = $this->getDados();

		if($dados['readonly'] == true){
			$this->setReadOnly(true);
		}

		$this->addElement('select', 'id_status_analise', array(
			'decorators' => $this->elementDecorator,
			'MultiOptions' => $modelStatus->getCombo('VP_ANALISE'),
			'label' => 'Status de Análise',
			'required' => ''
		));

		$this->addElement('select', 'status_analise', array(
			'decorators' => $this->elementDecorator,
			'MultiOptions' => $modelStatus->getComboSimples('VP_ANALISE'),
			'label' => '',
			'required' => ''
		));

		$this->addElement('textarea', 'ds_descricao', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Descrição',
			'required' => false,
			'style' => 'width:300px;height:80px;',
		));

		$this->addElement('checkbox', 'fl_necessario_endosso', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Necessário Endosso',
			'required' => false,
            'style' => 'margin-top:5px;',
		));

		$this->addElement('text', 'dt_prazo_retorno', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Prazo para retorno',
			'required' => false,
            'style' => 'margin-top:5px;',
            'class' => 'data',
		));

		$this->addElement('checkbox', 'fl_nova_vistoria_custo_perito', array(
			'decorators' => $this->elementDecorator,
			'label' => 'Nova Vistoria - Custo Perito',
			'required' => false,
            'style' => 'margin-top:5px;',
		));

        $this->addElement('textarea', 'ds_descricao_previa', array(
          'decorators' => $this->elementDecorator,
          'label' => 'Descrição',
          'required' => false,
          'style' => 'width:300px;height:80px;',
        ));

        $this->addElement('select', 'id_status_alteracao', array(
            'decorators' => $this->elementDecorator,
            'MultiOptions' => $modelStatus->getCombo('VP_STATUS_ALTERACAO'),
            'label' => 'Status da Alteração - VP'
        ));

        $this->addElement('select', 'id_pendencia', array(
            'decorators' => $this->elementDecorator,
            'label' => 'Pendências',
            'required' => false
        ));
	}

    public function setReadOnly($value){
        $this->_readOnly = ($value ? $value : null);
    }

    public function getReadOnly(){
        return $this->_readOnly;
    }

	public function populate(array $values) {

		if (array_key_exists('id_variedade', $values)) {
			$values['id_variedade'] = $values['id_variedade'];
		}

        $values['ds_descricao_previa'] = $values['ds_descricao'];

		parent::populate($values);
	}
}
