<?php
/**
 * PrefixSuffix form
 *
 * @author Sandro Roberto Weisheimer [sandrow@solis.coop.br]
 *
 * @version $Id$
 *
 * \b Maintainers \n
 * Eduardo Bonfandini [eduardo@solis.coop.br]
 * Jamiel Spezia [jamiel@solis.coop.br]
 * Luiz Gregory Filho [luiz@solis.coop.br]
 * Moises Heberle [moises@solis.coop.br]
 *
 * @since
 * Class created on 06/01/2009
 *
 * \b Organization: \n
 * SOLIS - Cooperativa de Solucoes Livres \n
 * The Gnuteca3 Development Team
 *
 * \b CopyLeft: \n
 * CopyLeft (L) 2008 SOLIS - Cooperativa de Solucoes Livres \n
 *
 * \b License: \n
 * Licensed under GPL (for further details read the COPYING file or http://www.gnu.org/copyleft/gpl.html )
 *
 * \b History: \n
 * See history in SVN repository: http://gnuteca.solis.coop.br
 */
class FrmPrefixSuffix extends GnutecaForm
{
    public $module;


    public function __construct()
    {
        $this->module = MIOLO::getCurrentModule();
        $this->setAllFunctions('PrefixSuffix', 'prefixSuffixId', array('prefixSuffixId', 'fieldId', 'subFieldId', 'content', 'type'), array('prefixSuffixId'));
     parent::__construct();
        $this->setFocus('fieldId');
    }


    /**
     * Default method to define fields
     **/
    public function createFields()
    {
        if ( $this->function == 'update' )
        {
            $prefixSuffixId = new MTextField('prefixSuffixId', $this->prefixSuffixId->value, _M('Code', $this->module), FIELD_ID_SIZE);
            $prefixSuffixId->setReadOnly(TRUE);
            $fields[] = $prefixSuffixId;
            $validators[] = new MRequiredValidator('PrefixSuffixId');
        }

        $fieldId        = new MTextField('fieldId', $this->fieldId->value, _M('Field', $this->module), FIELD_DESCRIPTION_SIZE);
        $validators[]   = new MRequiredValidator('fieldId');
        $fields[]       = $fieldId;

        $subFieldId     = new MTextField('subFieldId', $this->subFieldId->value, _M('Subfield', $this->module), FIELD_DESCRIPTION_SIZE);
        $validators[]   = new MRequiredValidator('subFieldId');
        $fields[]       = $subFieldId;

        $content        = new MTextField('content', $this->content->value, _M('Content', $this->module), FIELD_DESCRIPTION_SIZE);
        $validators[]   = new MRequiredValidator('content');
        $fields[]       = $content;

        $type           = new GnutecaSelection('type', $this->type->value, _M('Type', $this->module), $this->business->listTypes(), null, null, null, TRUE);

        $fields[]       = $type;

        $this->setFields($fields);
        $this->setValidators($validators);
	}


    public function loadFields()
    {
        $this->business->getPrefixSuffix( MIOLO::_REQUEST('prefixSuffixId'));
        $this->business->form_ = $this->business->form;
        $this->setData($this->business);
    }


    public function tbBtnSave_click($sender = NULL)
    {
        $data = $this->getData();
        $data->form = $data->form_;
        parent::tbBtnSave_click($sender, $data);
    }
}
?>
