<?php
/**
 * This file handles the connection and actions for gtcEmailControlDelayedLoan table
 *
 * @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 17/11/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 to manipulate the basConfig table
 **/
class BusinessGnuteca3BusEmailControlDelayedLoan extends GnutecaBusiness
{
    public $loanId;
    public $lastSent;
    public $amountSent;

    public $loanIdS;
    public $lastSentS;
    public $amountSentS;


    /**
     * Class constructor
     **/
    function __construct()
    {
        $table = 'gtcEmailControlDelayedLoan';
        $pkeys = 'loanId';
        $cols  = 'lastSent,
                  amountSent';
        parent::__construct($table, $pkeys, $cols);
    }


    /**
     * Insert a new record
     *
     * @return TRUE if succed, otherwise FALSE
     **/
    public function insertEmailControlDelayedLoan()
    {
        return $this->autoInsert();
    }


    /**
     * Update data from a specific record
     *
     * @return (boolean): TRUE if succeed, otherwise FALSE
     **/
    public function updateEmailControlDelayedLoan()
    {
        return $this->autoUpdate();
    }


    /**
     * Delete a record
     *
     * @param $loanId (integer)
     *
     * @return (boolean): TRUE if succeed, otherwise FALSE
     *
     **/
    public function deleteEmailControlDelayedLoan($loanId)
    {
        return $this->autoDelete($loanId);
    }


    /**
     * Return a specific record from the database
     *
     * @param $loanId (integer)
     *
     * @return (Object): Return an object of the type handled by the class
     **/
    public function getEmailControlDelayedLoan($loanId)
    {
        $this->clear();
        return $this->autoGet($loanId);
    }


    /**
     * Do a search on the database table handled by the class
     *
     * @param $object (bool): Case TRUE return as Object, otherwise Array
     *
     * @return (Array): An array containing the search results
     **/
    public function searchEmailControlDelayedLoan($object = false)
    {
        $this->clear();
        $filters = array(
            'loanId'     => 'equals',
            'lastSent'   => 'equals',
            'amountSent' => 'equals'
        );
        return $this->autoSearch($filters, $object);
    }


    /**
     * List all records from the table handled by the class
     *
     * @param None
     *
     * @return (Array): Return an array with the entire table
     *
     **/
    public function listEmailControlDelayedLoan()
    {
        return $this->autoList();
    }


    /**
     * Return a specific record from the database
     *
     * @param $loanId (integer)
     *
     * @return (Object): Return an object of the type handled by the class
     **/
    public function getLastSent($loanId)
    {
        $this->clear();
        $this->setTables($this->tables);
        $this->setColumns($this->columns);
        $this->setWhere('loanId = ?');
        $this->setOrderBy('lastSent DESC');
        $rs = $this->query($this->select(array($loanId)), true);
        return $rs[0];
    }
}
?>
