<?php

class SqlDoaSociete
{

    public static function rqGetDoaSociete($ID_DOA)
    {
        $sql = 'select * from DOA_SOC with(nolock) WHERE ID_DOA = \'' . ReplaceSqlPointeur($ID_DOA).'\'';
        return new RequeteSQL($sql, DB_OXASQLDB);
    }

    public static function rqGetDoaGroupeSociete($CODE = null, $CODE_STE = null)
    {
        $sql = 'select * from GROUPSOC with(nolock)' . (! is_null($CODE) ? ' WHERE CODE_GRP =  \'' . ReplaceSqlPointeur($CODE) . '\'' : '') . 'ORDER BY RS_GRP';
        return new RequeteSQL($sql, DB_OXASQLDB);
    }

    /**
     * TODO EDP A REVOIR important car il faut etre dans le p�rim�tre
     * de la vue utilisateur � minima
     */
    public static function rqGetSocieteByGroupe($GROUPE)
    {
        $sql = 'select * from SOCIETE with(nolock) WHERE GROUPE =  \'' . ReplaceSqlPointeur($GROUPE) . '\'';
        return new RequeteSQL($sql, DB_OXASQLDB);
    }

    public static function rqGetSocieteByCode($CODE_STE = null)
    {
        $sql = 'select * from SOCIETE with(nolock)' . (! is_null($CODE_STE) ? ' WHERE CODE_STE =  \'' . ReplaceSqlPointeur($CODE_STE) . '\'' : '');
        return new RequeteSQL($sql, DB_OXASQLDB);
    }

    public static function rqDOA_AjouteSociete($ID_DOA, $TYPE_GS, $CODE)
    {
        $sql = 'insert into DOA_SOC (ID_DOA, TYPE_GS, CODE) values (\'' . ReplaceSqlPointeur($ID_DOA) . '\',\'' . ReplaceSqlPointeur($TYPE_GS) . '\',' . '\'' . ReplaceSqlPointeur($CODE) . '\'' . ')';
        return new RequeteSQL($sql, DB_OXASQLDB);
    }

    public static function rqDOA_SupprimeSociete($ID_DOA, $TYPE_GS, $CODE)
    {
        $sql = 'delete from DOA_SOC WHERE ID_DOA = \'' . ReplaceSqlPointeur($ID_DOA) . '\' AND TYPE_GS=\'' . ReplaceSqlPointeur($TYPE_GS) . '\' AND CODE = \'' . ReplaceSqlPointeur($CODE) . '\'';
        return new RequeteSQL($sql, DB_OXASQLDB);
    }

    public static function rqGetDoaSoc($ID_DOA, $TYPE_GS, $CODE)
    {
        $sql = 'select * from DOA_SOC with(nolock) ' . 'WHERE ID_DOA = \'' . ReplaceSqlPointeur($ID_DOA) . '\' AND TYPE_GS = \'' . ReplaceSqlPointeur($TYPE_GS) . '\' AND CODE = \'' . ReplaceSqlPointeur($CODE) . '\'';
        return new RequeteSQL($sql, DB_OXASQLDB);
    }
}	
	