<?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 FrmRenewSearch extends GnutecaForm
{
	public $MIOLO;
	public $module;
	public $busLibraryUnit;
    public $busRenewType;


    public function __construct($data = null)
    {
    	$this->MIOLO  = MIOLO::getInstance();
    	$this->module = MIOLO::getCurrentModule();
        $this->busLibraryUnit = $this->MIOLO->getBusiness($this->module, 'BusLibraryUnit');
        $this->busRenewType   = $this->MIOLO->getBusiness($this->module, 'BusRenewType');
        $this->setAllFunctions('Renew', array('loanId'));
        parent::__construct();
        if ( $this->primeiroAcessoAoForm() && strlen(MIOLO::_REQUEST('event')) == 0 )
        {
            $this->setFocus('renewIdS');
        }
    }


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

        $personLabel    = new MLabel(_M('Person', $this->module));
        $personLabel    ->setWidth(FIELD_LABEL_SIZE);
        $personId       = new MLookupTextField('personIdS', '', '', FIELD_LOOKUPFIELD_SIZE);
        $personId->setContext($this->module, $this->module, 'activeperson', 'filler', 'personIdS,personIdDescriptionS');
        $personIdDesc   = new MTextField('personIdDescriptionS', $this->loanIdDescription, NULL, FIELD_DESCRIPTION_LOOKUP_SIZE);
        $personIdDesc   ->setReadOnly(true);
        $fields[]       = new MHContainer('pContainer', array($personLabel, $personId, $personIdDesc) );

        $loanIdLabelS = new MLabel(_M('Loan code', $this->module) . ':');
        $loanIdLabelS->setWidth(FIELD_LABEL_SIZE);
        $loanIdS = new MLookupTextField('loanIdS', '', '', FIELD_LOOKUPFIELD_SIZE);
        $loanIdS->setContext($this->module, $this->module, 'Loan', 'filler', 'loanIdS,loanIdDescriptionS,returnForecastDateS');
        $loanIdS->baseModule = $this->module;
        $loanIdDescriptionS = new MTextField('loanIdDescriptionS', $this->loanIdDescriptionS, NULL, FIELD_DESCRIPTION_LOOKUP_SIZE);
        $loanIdDescriptionS->setReadOnly(true);
        $validators[] = new MIntegerValidator('loanIdS');
        $fields[] = new MHcontainer('loanIdContainerS', array($loanIdLabelS, $loanIdS, $loanIdDescriptionS));

        $renewTypeIdS = new GnutecaSelection('renewTypeIdS', $this->renewTypeIdS->value, _M('Renew type', $this->module), $this->busRenewType->listRenewType());
        $fields[] = $renewTypeIdS;


        $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);

        $lblDate             = new MLabel(_M('Renew date', $this->module) . ':');
        $lblDate->setWidth(FIELD_LABEL_SIZE);
        $beginRenewDateS     = new MCalendarField('beginRenewDateS', $this->beginRenewDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $endRenewDateS       = new MCalendarField('endRenewDateS', $this->endRenewDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $fields[] = new MHContainer('hctDates', array($lblDate, $beginRenewDateS, $endRenewDateS));

        $lblDate                   = new MLabel(_M('Return forecast date', $this->module) . ':');
        $lblDate->setWidth(FIELD_LABEL_SIZE);
        $beginReturnForecastDateS  = new MCalendarField('beginReturnForecastDateS', $this->beginReturnDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $endReturnForecastDateS    = new MCalendarField('endReturnForecastDateS', $this->endReturnForecastDateS->value, null, FIELD_DATE_SIZE, null, 'calendar-win2k-1');
        $fields[] = new MHContainer('hctDates', array($lblDate, $beginReturnForecastDateS, $endReturnForecastDateS));

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

        $fields[] = new MTextField('itemNumberS', NULL, _M('Item number', $this->module), FIELD_ID_SIZE);

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