<?php
/**
 * InterchangeItem business
 *
 * @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 20/02/2009
 *
 * \b Organization: \n
 * SOLIS - Cooperativa de Solucoes Livres \n
 * The Gnuteca3 Development Team
 *
 * \b CopyLeft: \n
 * CopyLeft (L) 2009 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 BusinessGnuteca3BusInterchangeItem extends GnutecaBusiness
{
    public $interchangeItemId;
    public $interchangeId;
    public $controlNumber;
    public $content;

    public $interchangeItemIdS;
    public $interchangeIdS;
    public $controlNumberS;
    public $contentS;


    public function __construct()
    {
    	$table = 'gtcInterchangeItem';
    	$pkeys = 'interchangeItemId';
    	$cols  = 'interchangeId,
    	          controlNumber,
    	          content';
        parent::__construct($table, $pkeys, $cols);
    }


    public function insertInterchangeItem()
    {
    	if ($this->removeData)
    	{
    		if ($this->interchangeItemId)
    		{
    			$this->deleteInterchangeItem($this->interchangeItemId);
    		}
    		return TRUE;
    	}
    	if ($this->interchangeItemId)
    	{
            return $this->updateInterchangeItem();
    	}
        return $this->autoInsert();
    }


    public function updateInterchangeItem()
    {
        return $this->autoUpdate();
    }


    public function getInterchangeItem($interchangeItemId)
    {
        $this->clear();
        $data = $this->autoGet($interchangeItemId);
        return $data;
    }


    public function deleteInterchangeItem($interchangeItemId)
    {
        return $this->autoDelete($interchangeItemId);
    }


    public function searchInterchangeItem($toObject = FALSE)
    {
        $filters = array(
            'interchangeItemId'=> 'equals',
            'interchangeId'    => 'equals',
            'controlNumber' => 'equals',
            'content'       => 'ilike'
        );
        $this->clear();
        return $this->autoSearch($filters, $toObject);
    }


    public function listInterchangeItem()
    {
        return $this->autoList();
    }


    public function setData($data)
    {
    	$this->controlNumber = NULL;
    	$this->content       = NULL;
    	parent::setData($data);
    }
}
?>
