<?php
/**
 *
 * @author Moises Heberle [moises@solis.coop.br]
 *
 * @version $Id$
 *
 * \b Maintainers \n
 * Eduardo Bonfandini [eduardo@solis.coop.br]
 * Jamiel Spezia [jamiel@solis.coop.br]
 * Moises Heberle [moises@solis.coop.br]
 *
 * @since
 * Class created on 24/02/2010
 *
 * \b Organization: \n
 * SOLIS - Cooperativa de Solucoes Livres \n
 * The Gnuteca3 Development Team
 *
 * \b CopyLeft: \n
 * CopyLeft (L) 2010 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
 */

include("GnutecaWebServices.class.php");

class gnuteca3WebServicesMaterial extends GnutecaWebServices
{
    /**
     * Attributes
     */
    public $busSearchFormat;



    /**
     * Contructor method
     */
    public function __construct()
    {
        parent::__construct();

        $this->busSearchFormat = $this->MIOLO->getBusiness($this->module, 'BusSearchFormat');
    }
    
    /**
     * Obtem uma string formatada com a informacao do material 
     *
     * @param (int) $clientId
     * @param (String) $clientPassword base64 encoded
     * @param (int) $controlNumber
     * @param (int) $searchFormatId
     * @param (String) $returnType
     * 
     * @return (mixed) $content
     */
    public function getMaterialInformation($clientId, $clientPassword, $controlNumber, $searchFormatId = null, $returnType = null)
    {
        // CHECA ACESSO AO METHODO
        parent::__setClient($clientId, $clientPassword);
        if(!parent::__checkMethod('getMaterialInformation', false))
        {
            return parent::__getErrorStr();
        }
   
        //Busca o formato padrao de retorno, caso nao seja passado
        if (!$searchFormatId && (WEB_SERVICE_MATERIAL_DEFAULT_SEARCH_FORMAT_ID != 'WEB_SERVICE_MATERIAL_DEFAULT_SEARCH_FORMAT_ID'))
        {
            $searchFormatId = (int) WEB_SERVICE_MATERIAL_DEFAULT_SEARCH_FORMAT_ID;
        }
        
        $content = $this->busSearchFormat->getFormatedString($controlNumber, $searchFormatId);
        
        return $this->returnType($content, $returnType);
    }
}
?>