<?php
/**
 *
 * Preference 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 28/07/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 FrmHolidaySearch 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('Holiday', array('holidayIdS','descriptionS'));
        parent::__construct();
        if ( $this->primeiroAcessoAoForm() && strlen(MIOLO::_REQUEST('event')) == 0 )
        {
            $this->setFocus('holidayIdS');
        }
    }

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

        $lblDate        = new MLabel(_M('Date', $this->module) . ':');
        $lblDate->setWidth(FIELD_LABEL_SIZE);

        $beginDateS          = new MCalendarField('beginDateS', $this->beginDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $validators[]   = new MDateDMYValidator('beginDateS');

        $endDateS          = new MCalendarField('endDateS', $this->endDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $validators[]   = new MDateDMYValidator('endDateS');

        $fields[] = new MHContainer('hctDates', array($lblDate, $beginDateS, $endDateS));

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

        $lbl = new MLabel(_M('All year', $this->module) . ':');
        $lbl->setWidth(FIELD_LABEL_SIZE);
        $occursAllYearS = new MRadioButtonGroup('occursAllYearS', null, GnutecaUtils::listYesNo(1), null, null, MRadioButtonGroup::LAYOUT_HORIZONTAL);
        $fields[] = new MHContainer('hctOccoursAllYearS', array($lbl, $occursAllYearS));

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

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