<?php
/**
 * gtcLinkOfFieldsBetweenSpreadsheets 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]
 *
 * @since
 * Class created on 02/12/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 BusinessGnuteca3BusLinkOfFieldsBetweenSpreadsheets extends GnutecaBusiness
{
    /**
     * Enter description here...
     *
     * @var unknown_type
     */
    public $linkOfFieldsBetweenSpreadsheetsId;
    public $category;
    public $level;
    public $tag;
    public $categorySon;
    public $levelSon;
    public $tagSon;
    public $type;

    /**
     * Enter description here...
     *
     */
    public function __construct()
    {
        $table = 'gtcLinkOfFieldsBetweenSpreadsheets';
        $pkeys = 'linkOfFieldsBetweenSpreadsheetsId';
        $cols  = 'category,
			      level,
			      tag,
			      categorySon,
			      levelSon,
			      tagSon,
			      type';

        parent::__construct($table, $pkeys, $cols);
    }


    /**
     * Enter description here...
     *
     * @return unknown
     */
    public function insertLinkOfFieldsBetweenSpreadsheets()
    {
        return $this->autoInsert();
    }


    /**
     * Enter description here...
     *
     * @return unknown
     */
    public function updateLinkOfFieldsBetweenSpreadsheets()
    {
        return $this->autoUpdate();
    }



    /**
     * Enter description here...
     *
     * @param unknown_type $linkOfFieldsBetweenSpreadsheetsId
     * @return unknown
     */
    public function deleteLinkOfFieldsBetweenSpreadsheets($linkOfFieldsBetweenSpreadsheetsId)
    {
        return $this->autoDelete($linkOfFieldsBetweenSpreadsheetsId);
    }


    /**
     * Enter description here...
     *
     * @param unknown_type $linkOfFieldsBetweenSpreadsheetsId
     * @return unknown
     */
    public function getLinkOfFieldsBetweenSpreadsheets($linkOfFieldsBetweenSpreadsheetsId)
    {
        $this->clear();
        return $this->autoGet($linkOfFieldsBetweenSpreadsheetsId);
    }


    /**
     * Enter description here...
     *
     * @param unknown_type $object
     * @return unknown
     */
    public function searchLinkOfFieldsBetweenSpreadsheets($object = false)
    {
        $this->clear();
        $filters = array(
            'linkOfFieldsBetweenSpreadsheetsId' => 'equals',
            'category'      => 'equals',
            'level'         => 'equals',
            'tag'           => 'ilike',
            'categorySon'   => 'equals',
            'levelSon'      => 'equals',
            'tagSon'        => 'ilike',
            'type'          => 'equals'
        );

        $args = $this->addFilters($filters);
        $this->setColumns($this->columns);
        $this->setTables($this->tables);
        $sql = $this->select($args);
        $rs  = $this->query($sql, $object);

        return $rs;
    }


    /**
     * Enter description here...
     *
     * @return unknown
     */
    public function listLinkOfFieldsBetweenSpreadsheets()
    {
        return $this->autoList();
    }


    /**
     * Enter description here...
     *
     * @return unknown
     */
    public function listTypes()
    {
        return array
        (
            1 => 'Copy',
            2 => 'Reference'
        );
    }


    /**
     * Enter description here...
     *
     * @param int $controlNumberFather
     * @param char(2) $sonCategory
     */
    public function getLinksByControlNumberFather($controlNumberFather, $sonCategory, $sonLevel)
    {
        $businessMaterialControl = $this->MIOLO->getBusiness($this->module, 'BusMaterialControl');

        $this->clear();

        $this->category     = $businessMaterialControl->getCategory($controlNumberFather);
        $this->level        = $businessMaterialControl->getLevel($controlNumberFather);
        $this->categorySon  = $sonCategory;
        $this->levelSon     = $sonLevel;
        $r = $this->searchLinkOfFieldsBetweenSpreadsheets(true);

        return $r;
    }



    function clean()
    {
         $this->linkOfFieldsBetweenSpreadsheetsId   =
         $this->category                            =
         $this->level                               =
         $this->tag                                 =
         $this->categorySon                         =
         $this->levelSon                            =
         $this->tagSon                              =
         $this->type                                = null;
    }

}
?>
