<?php
/**
 * LinkOfFieldsBetweenSpreadhseet form
 *
 * @author Moises Heberle [moises@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 02/12/2008
 *
 * \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 FrmLinkOfFieldsBetweenSpreadsheets extends GnutecaForm
{
	public $MIOLO;
	public $module;
	public $busMarcTagListingOption;


    public function __construct()
    {
    	$this->MIOLO   = MIOLO::getInstance();
    	$this->module  = MIOLO::getCurrentModule();
    	$this->busMarcTagListingOption = $this->MIOLO->getBusiness($this->module, 'BusMarcTagListingOption');
        $this->setAllFunctions('LinkOfFieldsBetweenSpreadsheets', array('category', 'level'), 'linkOfFieldsBetweenSpreadsheetsId', array('category', 'level', 'tag'));
        parent::__construct();
        if (($this->function == 'search') || (!$this->function))
        {
        	$this->setFocus('linkOfFieldsBetweenSpreadsheetsId');
        }
    }


    public function createFields()
    {
        if ( $this->function == 'update' )
        {
            $linkOfFieldsBetweenSpreadsheetsId = new MTextField('linkOfFieldsBetweenSpreadsheetsId', null, _M('Code', $this->module), FIELD_ID_SIZE);
            $linkOfFieldsBetweenSpreadsheetsId->setReadOnly(TRUE);
            $fields[] = $linkOfFieldsBetweenSpreadsheetsId;
            $validators[] = new MRequiredValidator('linkOfFieldsBetweenSpreadsheetsId');
        }

        $listCategory = $this->busMarcTagListingOption->listMarcTagListingOption('CATEGORY');
        $listLevel    = $this->busMarcTagListingOption->listMarcTagListingOption('LEVEL');

        $fields[]     = new GnutecaSelection('category',     null, _M('Category', $this->module),      $listCategory);
        $validators[] = new MRequiredValidator('category');
        $fields[]     = new GnutecaSelection('level',        null, _M('Level', $this->module),         $listLevel);
        $validators[] = new MRequiredValidator('level');
        $fields[]     = new MTextField('tag',   null, _M('Tag', $this->module), FIELD_ID_SIZE);
        $validators[] = new MRequiredValidator('tag');
        $fields[]     = new GnutecaSelection('categorySon',  null, _M('Category son', $this->module),      $listCategory);
        $validators[] = new MRequiredValidator('categorySon');
        $fields[]     = new GnutecaSelection('levelSon',     null, _M('Level son', $this->module),         $listLevel);
        $validators[] = new MRequiredValidator('levelSon');
        $fields[]     = new MTextField('tagSon',   null, _M('Tag son', $this->module),    FIELD_ID_SIZE);
        $validators[] = new MRequiredValidator('tagSon', null, 3);
        $fields[]     = new GnutecaSelection('type',         null, _M('Type', $this->module),          $this->business->listTypes());

        $this->setFields($fields);
        if (($this->function == 'insert') || ($this->function == 'update'))
        {
            $this->setValidators($validators);
        }
    }
}
?>
