<?php
/* Busqueda de registros de la tabla GSS_Compania redefinidos por el usuario. */
class GSS_CompaniaFN extends BaseGSS_CompaniaFN
{
    /**
     * Recupero el Id + 1
     *
     * @return int
     */
    public static function recuperarId()
    {
        $s_Sql = "SELECT IF( MAX( IdCompania ) IS NULL, 1, MAX( IdCompania ) + 1 ) i_Id FROM GSS_Compania;";
        $o_ResultSet = Conexion::getConexion()->prepareStatement( $s_Sql )->executeQuery();
        $o_ResultSet->next();
        return $o_ResultSet->getInt( 'i_Id' );
    }

    public static function buscarCompania( $IdCompania=null )
    {
        if( is_null( $IdCompania ) )
        {
            $s_IdCompania = 1;
        }
        else
        {
            $s_IdCompania = $IdCompania;
        }
        $o_GSS_CompaniaFN = new GSS_CompaniaFN();
        $o_GSS_CompaniaBN = $o_GSS_CompaniaFN->selectByPk( $s_IdCompania );
        return $o_GSS_CompaniaBN;
    }
    
    public static function selectActivos()
    {
        $o_GSS_CompaniaFN = new GSS_CompaniaFN();
        $o_GSS_CompaniaFN->setEstado( "A" );
        return $o_GSS_CompaniaFN->select();
    }
}