noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions | Static Private Attributes
Dossier Class Reference

manage the current dossier, everywhere we need to know to which folder we are connected, because we can't use $_SESSION, we need to pass the dossier_id via a _GET or a POST variable private static $variable=array("id"=>"dos_id", "name"=>"dos_name", "desc"=>"dos_description"); More...

Public Member Functions

 __construct ($p_id)
 get_info ()
 get_parameter ($p_string)
 get_user_folder ($sql="")
 Return all the users as an array.
 load ()
 save ()
 set_parameter ($p_string, $p_value)
 show_dossier ($p_type, $p_first=0, $p_max=0, $p_Num=0)
 update ()

Static Public Member Functions

static check ()
 check if gDossier is set
static connect ()
static get ()
 return a string to put to gDossier into a GET
static get_version ($p_cn)
static hidden ()
 return a string to set gDossier into a FORM
static id ()
 return the $_REQUEST['gDossier'] after a check
static name ($id=0)
 retrieve the name of the current dossier
static synchro_admin ($p_id)
 connect to folder and give to admin.

Static Private Attributes

static $variable

Detailed Description

manage the current dossier, everywhere we need to know to which folder we are connected, because we can't use $_SESSION, we need to pass the dossier_id via a _GET or a POST variable private static $variable=array("id"=>"dos_id", "name"=>"dos_name", "desc"=>"dos_description");

Definition at line 39 of file class_dossier.php.


Constructor & Destructor Documentation

Dossier::__construct ( p_id)

Definition at line 44 of file class_dossier.php.

References cn.

    {
        $this->cn=new Database();       // Connect to the repository
        $this->dos_id=$p_id;
    }

Member Function Documentation

static Dossier::check ( ) [static]

check if gDossier is set

Definition at line 137 of file class_dossier.php.

References $_REQUEST, $id, echo_error(), and exit.

Referenced by get(), hidden(), id(), and name().

    {
        if ( ! isset ($_REQUEST['gDossier']) )
        {
            echo_error ('Dossier inconnu ');
            exit('Dossier invalide ');
        }
        $id=$_REQUEST['gDossier'];
        if ( is_numeric ($id) == 0 ||
                strlen($id)> 6 ||
                $id > 999999)
            exit('gDossier Invalide : '.$id);

    }
static Dossier::connect ( ) [static]

Definition at line 250 of file class_dossier.php.

References $cn, $id, and id().

        {
                $id = Dossier::id();
                $cn = new Database($id);
                return $cn;
        }
static Dossier::get ( ) [static]

return a string to put to gDossier into a GET

Definition at line 152 of file class_dossier.php.

References check().

    {
        self::check();
        return "gDossier=".$_REQUEST['gDossier'];

    }

Definition at line 198 of file class_dossier.php.

    {
        return var_export(self::$variable,true);
    }
Dossier::get_parameter ( p_string)

Definition at line 176 of file class_dossier.php.

References $idx, and exit.

    {
        if ( array_key_exists($p_string,self::$variable) )
        {
            $idx=self::$variable[$p_string];
            return $this->$idx;
        }
        else
            exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
    }
Dossier::get_user_folder ( sql = "")

Return all the users as an array.

Definition at line 106 of file class_dossier.php.

References $res, $sql, and cn.

    {

        $sql="
            select
                use_id,
                use_first_name,
                use_name,
                use_login,
                use_active,
                use_admin,
                ag_dossier
            from
            ac_users  as ac
            left join    (select array_to_string(array_agg(dos_name),',') as ag_dossier,jt.use_id as jt_use_id
                        from ac_dossier as ds
                        join  jnt_use_dos as jt on (jt.dos_id=ds.dos_id)
                        join priv_user as pu on (pu.priv_jnt=jt.jnt_id)
                        where
                        pu.priv_priv != 'X'
                        group by jt.use_id) as dossier_name on (jt_use_id=ac.use_id)
            where
            use_login!='phpcompta'
            $sql
            ";

        $res=$this->cn->get_array($sql);
        return $res;
        }
static Dossier::get_version ( p_cn) [static]

Definition at line 245 of file class_dossier.php.

        {
                return $p_cn->get_value('select val from version');
        }
static Dossier::hidden ( ) [static]

return a string to set gDossier into a FORM

Definition at line 160 of file class_dossier.php.

References check().

Referenced by Acc_Parm_Code\form().

    {
        self::check();
        return '<input type="hidden" id="gDossier" name="gDossier" value="'.$_REQUEST['gDossier'].'">';
    }
static Dossier::id ( ) [static]

return the $_REQUEST['gDossier'] after a check

Definition at line 50 of file class_dossier.php.

References $_REQUEST, and check().

Referenced by Tag\add_clear_button(), Tag\button_search(), connect(), Pre_Op_Advanced\display(), ITva_Popup\display(), Acc_Ledger\input(), Html_Table\test_me(), and Acc_Ledger_Info\test_me().

    {
        self::check();
        return $_REQUEST['gDossier'];
    }

Definition at line 226 of file class_dossier.php.

References $idx, $res, $row, $sql, $value, cn, Database\fetch_array(), and Database\num_row().

    {

        $sql="select dos_name,dos_description from ac_dossier where dos_id=$1";

        $res=$this->cn->exec_sql(
                 $sql,
                 array($this->dos_id)
             );

        if ( Database::num_row($res) == 0 ) return;
        $row=Database::fetch_array($res,0);
        foreach ($row as $idx=>$value)
        {
            $this->$idx=$value;
        }

    }
static Dossier::name ( id = 0) [static]

retrieve the name of the current dossier

Definition at line 166 of file class_dossier.php.

References $_REQUEST, $cn, $id, $name, and check().

    {
        self::check();

        $cn=new Database();
        $id=($id==0)?$_REQUEST['gDossier']:$id;
        $name=$cn->get_value("select dos_name from ac_dossier where dos_id=$1",array($_REQUEST['gDossier']));
        return $name;
    }

Definition at line 203 of file class_dossier.php.

References update().

    {
        $this->update();
    }
Dossier::set_parameter ( p_string,
p_value 
)

Definition at line 186 of file class_dossier.php.

References $idx, and exit.

    {
        if ( array_key_exists($p_string,self::$variable) )
        {
            $idx=self::$variable[$p_string];
            $this->$idx=$p_value;
        }
        else
            exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');


    }
Dossier::show_dossier ( p_type,
p_first = 0,
p_max = 0,
p_Num = 0 
)
Parameters:
p_typestring : all for all dossiers lim for only the dossier where we've got rights

Show the folder where user have access. Return : nothing ++

Definition at line 62 of file class_dossier.php.

References $Max, $row, and cn.

    {
        $l_user=$_SESSION['g_user'];
        if ( $p_max == 0 )
        {
            $l_step="";
        }
        else
        {
            $l_step="LIMIT $p_max OFFSET $p_first";
        }

        if ( $p_type == "all")
        {
            $l_sql="select *, 'W' as priv_priv from ac_dossier ORDER BY dos_name  ";
            $p_Num=$this->cn->count_sql($l_sql);
        }
        else
        {
            $l_sql="select * from jnt_use_dos
                   natural join ac_dossier
                   natural join ac_users
                   inner join priv_user on priv_jnt=jnt_id where
                   use_login='".$l_user."' and priv_priv !='NO'
                   order by dos_name ";
            $p_Num=$this->cn->count_sql($l_sql);
        }
        $l_sql=$l_sql.$l_step;
        $p_res=$this->cn->exec_sql($l_sql);


        $Max=$this->cn->size();
        if ( $Max == 0 ) return null;
        for ( $i=0;$i<$Max; $i++)
        {
          $row[]=$this->cn->fetch($i);
        }
        return $row;
    }
static Dossier::synchro_admin ( p_id) [static]

connect to folder and give to admin.

the profile Admin(builtin)

Parameters:
int$p_iddossier::id()

synchro global

Definition at line 260 of file class_dossier.php.

References $cn, $e, $repo, and echo_warning().

        {
                // connect to target
                $cn=new Database($p_id);

                if (! $cn->exist_table("profile_menu"))
                {
                        echo_warning("Dossier invalide");
                        return;
                }
                // connect to repo
                $repo=new Database();

                $a_admin=$repo->get_array("select use_login from ac_users where
                        use_admin=1 and use_active=1");
                try
                {
                        /**
                         * synchro global
                         */
                        $cn->start();
                        for ($i=0;$i<count($a_admin);$i++)
                        {
                                $exist=$cn->get_value("select p_id from profile_user
                                        where user_name=$1",array($a_admin[$i]['use_login']));
                                if ( $exist == "")
                                {
                                        $cn->exec_sql("insert into profile_user(user_name,p_id) values($1,1)",
                                                        array($a_admin[$i]['use_login']));
                                }

                        }
                        $cn->commit();
                } catch(Exception $e)
                {
                        echo_warning($e->getMessage());
                        $cn->rollback();
                }
        }

Definition at line 208 of file class_dossier.php.

References $res, $sql, cn, and trim().

Referenced by save().

    {
        if ( strlen(trim($this->dos_name))== 0 ) return;

        if ( $this->cn->get_value("select count(*) from ac_dossier where dos_name=$1 and dos_id<>$2",
                                  array($this->dos_name,$this->dos_id)) !=0 )
            return ;

        $sql="update ac_dossier set dos_name=$1,dos_description=$2 ".
             " where dos_id = $3";
        $res=$this->cn->exec_sql(
                 $sql,
                 array(trim($this->dos_name),
                       trim($this->dos_description),
                       $this->dos_id)
             );
    }

Field Documentation

Dossier::$variable [static, private]
Initial value:
array("id"=>"dos_id",
                                   "name"=>"dos_name",
                                   "desc"=>"dos_description")

Definition at line 41 of file class_dossier.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations