<?php
/**
 * gtcSearchFormatColumn 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 08/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 BusinessGnuteca3BusSearchFormatColumn extends GnutecaBusiness
{
    public $searchFormatId;
    public $column;


    public function __construct()
    {
        $table = 'gtcSearchFormatColumn';
        $pkeys = 'searchFormatId,
                  "column"';
        $cols  = '';
        parent::__construct($table, $pkeys, $cols);
    }


    public function insertSearchFormatColumn()
    {
    	$msql = new MSQL($this->columns, $this->tables);
    	$sql = $msql->insert(array($this->searchFormatId, $this->column));
        return $this->execute($sql);
    }


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


    public function deleteSearchFormatColumn($searchFormatId, $column = NULL)
    {
        $msql = new MSQL($this->columns, $this->tables);
        $msql->setWhere('searchFormatId = ?');
        $msql->addParameter($searchFormatId);
        if ($column)
        {
        	$msql->setWhere('column = ?');
        	$msql->addParameter($column);
        }
        return $this->execute( $msql->delete() );
    }


    public function getSearchFormatColumn($searchFormatId)
    {
        $this->clear();
        return $this->autoGet($searchFormatId);
    }


    public function searchSearchFormatColumn($toObject = FALSE)
    {
        $this->clear();
        $filters = array(
            'searchFormatId'    => 'equals',
            'column'            => 'equals',
        );
        return $this->autoSearch($filters, $toObject);
    }


    public function listSearchFormatColumn($associative = FALSE)
    {
        return $this->autoList(null, $associative);
    }


    /**
     * Get SimpleSearch form grid column names
     *
     */
    public function listColumns()
    {
    	$columns = array(
    	   'Image',
    	   'Data',
    	   'Exemplarys'
    	);
        foreach ($columns as $col)
        {
        	$out[$col] = _M($col, $this->module);
        }
        return $out;
    }
}
?>
