<?php
/**
 * Penalty search 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]
 * Sandro Roberto Weisheimer [sandrow@solis.coop.br]
 *
 * @since
 * Class created on 23/09/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 FrmPenaltySearch extends GnutecaForm
{
	public $MIOLO;
	public $module;
    public $busLibraryUnit;


    public function __construct()
    {
        $this->MIOLO  = MIOLO::getInstance();
        $this->module = MIOLO::getCurrentModule();
        $this->busLibraryUnit = $this->MIOLO->getBusiness($this->module, 'BusLibraryUnit');

        $this->setAllFunctions('Penalty', array('personId'));
        parent::__construct();
        if ( $this->primeiroAcessoAoForm() && strlen(MIOLO::_REQUEST('event')) == 0 )
        {
       	    $this->setFocus('penaltyIdS');
        }
    }


    public function createFields()
    {
        $penaltyIdS = new MTextField('penaltyIdS', $this->penaltyIdS->value, _M('Code', $this->module), FIELD_ID_SIZE);
        $validators[] = new MIntegerValidator('penaltyIdS');
        $fields[] = $penaltyIdS;

        $personIdLabelS = new MLabel(_M('Person code', $this->module) . ':');
        $personIdLabelS->setWidth(FIELD_LABEL_SIZE);
        $personIdS = new MLookupTextField('personIdS', '', '', FIELD_LOOKUPFIELD_SIZE);
        $personIdS->setContext($this->module, $this->module, 'Person', 'filler', 'personIdS,personIdDescriptionS');
        $personIdDescriptionS = new MTextField('personIdDescriptionS', $this->personIdDescriptionS, NULL, FIELD_DESCRIPTION_LOOKUP_SIZE);
        $personIdDescriptionS->setReadOnly(true);
        $fields[] = new MHcontainer('personIdContainerS', array($personIdLabelS, $personIdS, $personIdDescriptionS));
        $validators[] = new MIntegerValidator('personIdS', _M('Person code', $this->module));

        $observationS = new MTextField('observationS', $this->observationS->value, _M('Observation', $this->module), FIELD_DESCRIPTION_SIZE);
        $fields[] = $observationS;

        $internalObservationS = new MTextField('internalObservationS', $this->internalObservationS->value, _M('Internal observation', $this->module), FIELD_DESCRIPTION_SIZE);
        $fields[] = $internalObservationS;

        $lblDate             = new MLabel(_M('Penalty date', $this->module) . ':');
        $lblDate->setWidth(FIELD_LABEL_SIZE);
        $beginBeginPenaltyDateS     = new MCalendarField('beginBeginPenaltyDateS', $this->beginBeginPenaltyDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $endBeginPenaltyDateS       = new MCalendarField('endBeginPenaltyDateS', $this->endBeginPenaltyDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $fields[] = new MHContainer('hctDates', array($lblDate, $beginBeginPenaltyDateS, $endBeginPenaltyDateS));
        $validators[] = new MDateDMYValidator('beginBeginDateValidateS');

        $lblDate             = new MLabel(_M('Penalty end date', $this->module) . ':');
        $lblDate->setWidth(FIELD_LABEL_SIZE);
        $beginEndPenaltyDateS     = new MCalendarField('beginEndPenaltyDateS', $this->beginEndPenaltyDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $endEndPenaltyDateS       = new MCalendarField('endEndPenaltyDateS', $this->endEndPenaltyDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $fields[] = new MHContainer('hctDates', array($lblDate, $beginEndPenaltyDateS, $endEndPenaltyDateS));
        $validators[] = new MDateDMYValidator('beginEndDateValidateS');

        $operatorS = new MTextField('operatorS', $this->operatorS->value, _M('Operator', $this->module), 30);
        $fields[] = $operatorS;

        $this->busLibraryUnit->filterOperator = TRUE;
        $this->busLibraryUnit->labelAllLibrary = TRUE;
        $fields[] = new GnutecaSelection('libraryUnitIdS',   $this->libraryUnitId->value, _M('Library unit', $this->module), $this->busLibraryUnit->listLibraryUnit(), null, null, null, TRUE);

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