<?php
/**
 * gtcFormContentDetail 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 07/04/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 BusinessGnuteca3BusFormContentDetail extends GnutecaBusiness
{
    public $formContentId;
    public $field;
    public $value;

    public $formContentIdS;
    public $fieldS;
    public $valueS;

    public $_table;
    public $_pkeys;
    public $_cols;


    public function __construct()
    {
        $this->_table = 'gtcFormContentDetail';
        $this->_pkeys = 'formContentId,
                         field';
        $this->_cols  = 'value';
        parent::__construct($this->_table, $this->_pkeys, $this->_cols);
    }


    public function insertFormContentDetail()
    {
    	if ($this->removeData)
    	{
    		return FALSE;
    	}
        return $this->autoInsert();
    }


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


    public function deleteFormContentDetail($formContentId, $field=NULL)
    {
    	$msql = new MSQL(null, $this->_table);
    	$msql->setWhere('formContentId = ?');
    	$msql->addParameter($formContentId);
    	if ($field)
    	{
    		$msql->setWhere('field = ?');
    		$msql->addParameter($field);
    	}
        return $this->execute( $msql->delete() );
    }


    public function getFormContentDetail($formContentId, $field)
    {
        $this->clear();
        return $this->autoGet($formContentId, $field);
    }


    public function searchFormContentDetail($toObject = FALSE)
    {
        $this->clear();
        $filters = array(
            'formContentId'     => 'equals',
            'field'             => 'ilike',
            'value'             => 'ilike',
        );
        return $this->autoSearch($filters, $toObject);
    }


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