<?php

class Sistema_Form_Telefone extends Agro_Form {
    private bool $_origemCadastroVistoriador = false;

    public function __construct($options = false, array $parametros = [])
    {
        if (isset($parametros['origemCadastroVistoriador'])) {
            $this->_origemCadastroVistoriador = true;
        }

        parent::__construct($options);
    }

    public function init() {
		$this->addElement('hidden', 'id', array('decorators' => $this->elementDecorator));
		$this->addElement('hidden', 'id_usuario', array('decorators' => $this->elementDecorator));
		
		$tipoTelefone = new Sistema_Model_TiposTelefones();

        if (!$this->_origemCadastroVistoriador) {
            $optionsTipoTelefone = $tipoTelefone->fetchPairs('id', 'tp_telefone');
        } else {
            $optionsTipoTelefone = $tipoTelefone->getComboCadastroVistoriador();
        }

		$this->addElement('select', 'id_tipo_telefone', array(
			'MultiOptions' => $optionsTipoTelefone,
			'decorators' => $this->elementDecorator,
			'label' => 'Tipo',
			'required' => true
		));
		
		$this->addElement('text', 'ds_numero', array(
			'decorators' => $this->elementDecorator,
			'class' => 'telefone',
			'label' => 'Número',
			'required' => true,
			'maxlength' => 13,
			'size' => 14
		));
		
		$this->addElement('text', 'ds_ramal', array(
			'decorators' => $this->elementDecorator,
			'class' => 'integer',
			'label' => 'Ramal',
			'maxlength' => 4,
			'size' => 5
		));
	}
}