noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions | Data Fields
Anc_Plan Class Reference

Concerns the Analytic plan (table plan_analytique) More...

Public Member Functions

 add ()
 Anc_Plan ($p_cn, $p_id=0)
 count ()
 delete ()
 exist ()
 form ()
 get ()
 get_list ($p_order=" order by pa_name")
 get the list of all existing PA
 get_poste_analytique ($p_order="")
 get all the poste related to the current Analytic plan
 header ()
 show the header for a table for PA
 isAppend ()
 update ()

Static Public Member Functions

static hidden ($p_array)
 return an HTML string containing hidden input type to hold the differant PA_ID
static test_me ()

Data Fields

 $db
 $description
 $id
 $name

Detailed Description

Concerns the Analytic plan (table plan_analytique)

Definition at line 36 of file class_anc_plan.php.


Member Function Documentation

Definition at line 99 of file class_anc_plan.php.

References $description, $name, db, isAppend(), name, and sql_string().

    {
        $name=sql_string($this->name);
        if ( strlen($name) == 0)
            return;
        if ( $this->isAppend() == false) return;
        $description=sql_string($this->description);
        $this->db->exec_sql("insert into plan_analytique(pa_name,pa_description)".
                            " values (".
                            "'".$name."',".
                            "'".$description."')");
        $this->id=$this->db->get_current_seq('plan_analytique_pa_id_seq');

    }
Anc_Plan::Anc_Plan ( p_cn,
p_id = 0 
)

Definition at line 43 of file class_anc_plan.php.

References db, and name.

Referenced by test_me().

    {
        $this->db=$p_cn;
        $this->id=$p_id;
        $this->name="";
        $this->description="";
        $this->get();
    }

Definition at line 173 of file class_anc_plan.php.

References $a, and db.

Referenced by hidden().

    {
        $a=$this->db->count_sql("select pa_id from plan_analytique");
        return $a;
    }

Definition at line 81 of file class_anc_plan.php.

References db.

    {
        if ( $this->id == 0 ) return;
        $this->db->exec_sql("delete from plan_analytique where pa_id=".$this->id);
    }

Definition at line 178 of file class_anc_plan.php.

References $a, db, and Database\escape_string().

    {
        $a=$this->db->count_sql("select pa_id from plan_analytique where pa_id=".
                                Database::escape_string($this->pa_id));

        return ($a==0)?false:true;

    }

Definition at line 113 of file class_anc_plan.php.

References $ret, and name.

    {

        $wName=new IText('pa_name',$this->name);

        $wName->table=1;
        $wDescription=new IText('pa_description',$this->description);
        $wDescription->table=1;
        $wId=new IHidden("pa_id",$this->id);
        $ret="<TABLE>";
        $ret.='<tr>'.td(_('Nom')).$wName->input().'</tr>';
        $ret.="<tr>".td(_('Description')).$wDescription->input()."</tr>";
        $ret.="</table>";
        $ret.=$wId->input();
        return $ret;
    }

Definition at line 65 of file class_anc_plan.php.

References $a, $ret, $sql, db, Database\fetch_array(), name, and Database\num_row().

    {
        if ( $this->id==0) return;

        $sql="select pa_name,pa_description from plan_analytique where pa_id=".$this->id;
        $ret= $this->db->exec_sql($sql);
        if ( Database::num_row($ret) == 0)
        {
            return;
        }
        $a=  Database::fetch_array($ret,0);
        $this->name=$a['pa_name'];
        $this->description=$a['pa_description'];

    }
Anc_Plan::get_list ( p_order = " order by pa_name")

get the list of all existing PA

Returns:
an array of PA (not object)

Definition at line 55 of file class_anc_plan.php.

References $array, $ret, $sql, db, and Database\fetch_all().

Referenced by header().

    {
        $array=array();
        $sql="select pa_id as id,pa_name as name,".
             "pa_description as description from plan_analytique $p_order";
        $ret=$this->db->exec_sql($sql);
        $array=Database::fetch_all($ret);
        return $array;
    }
Anc_Plan::get_poste_analytique ( p_order = "")

get all the poste related to the current Analytic plan

Returns:
an array of Poste_analytic object

Definition at line 142 of file class_anc_plan.php.

References $all, $line, $obj, $r, $ret, $sql, db, Database\fetch_all(), and Database\num_row().

    {
        $sql="select po_id,po_name from poste_analytique where pa_id=".$this->id." $p_order";
        $r=$this->db->exec_sql($sql);
        $ret=array();
        if ( Database::num_row($r) == 0 )
            return $ret;

        $all=Database::fetch_all($r);
        foreach ($all as $line)
        {
            $obj=new Anc_Account($this->db,$line['po_id']);
            $obj->get_by_id();
            $ret[]=clone $obj;
        }
        return $ret;
    }

show the header for a table for PA

Returns:
string like

name...

Definition at line 162 of file class_anc_plan.php.

References $res, and get_list().

    {
        $res="";
        $a_plan=$this->get_list(" order by pa_id");
        if ( empty($a_plan)) return "";
        foreach ($a_plan as $r_plan)
        {
            $res.="<th>".h($r_plan['name'])."</th>";
        }
        return $res;
    }
static Anc_Plan::hidden ( p_array) [static]

return an HTML string containing hidden input type to hold the differant PA_ID

Parameters:
$p_arraycontains a array, it is the result of the fct Anc_Plan::get_list
Returns:
html string
See also:
Anc_Plan::get_list

Definition at line 194 of file class_anc_plan.php.

References $p_array, $r, and count().

Referenced by Acc_Ledger_Fin\confirm(), Acc_Ledger_Sold\confirm(), Acc_Ledger_Purchase\confirm(), and Acc_Ledger\confirm().

    {
        $r='';
        for ($i_anc=0;$i_anc <count($p_array);$i_anc++)
        {
            $r.=HtmlInput::hidden('pa_id[]',$p_array[$i_anc]['id']);
        }
        return $r;
    }

Definition at line 129 of file class_anc_plan.php.

References $count, and db.

Referenced by add().

    {
        $count=$this->db->get_value("select count(pa_id) from plan_analytique");

        if ( $count > 10 )
            return false;
        else
            return true;
    }
static Anc_Plan::test_me ( ) [static]

Definition at line 203 of file class_anc_plan.php.

References $a, $cn, Anc_Plan(), echo, and id.

    {
        $cn=new Database(dossier::id());
        echo "<h1>Plan analytique : test</h1>";
        echo "clean";
        $cn->exec_sql("delete from plan_analytique");

        $p=new Anc_Plan($cn);
        echo "<h2>Add</h2>";
        $p->name="Nouveau 1";
        $p->description="C'est un test";
        echo "Add<hr>";
        $p->add();
        $p->name="Nouveau 2";
        $p->add();
        $pa_id=$p->id;
        echo $p->id."/";
        $p->name="Nouveau 3";
        $p->add();
        echo $p->id."/";


        $p->name="Nouveau 4";
        $p->add();
        echo $p->id;

        echo "<h2>get</h2>";
        $p->get();
        var_dump($p);
        echo "<h2>Update</h2> ";
        $p->name="Update ";
        $p->description="c'est change";
        $p->update();
        $p->get();
        var_dump($p);
        echo "<h2>get_list</h2>";
        $a=$p->get_list();
        var_dump($a);
        echo "<h2>delete </h2>";
        $p->delete();


    }

Definition at line 87 of file class_anc_plan.php.

References $description, $name, db, name, and sql_string().

    {
        if ( $this->id==0) return;
        $name=sql_string($this->name);
        if ( strlen($name) == 0)
            return;

        $description=sql_string($this->description);
        $this->db->exec_sql("update plan_analytique set pa_name=$1,
                            pa_description=$2 where pa_id=$3",array($name,$description,$this->id));
    }

Field Documentation

Anc_Plan::$db

database connection

Definition at line 38 of file class_anc_plan.php.

Anc_Plan::$description

description of the PA plan_analytique.pa_description

Definition at line 40 of file class_anc_plan.php.

Referenced by add(), and update().

Anc_Plan::$id

id = plan_analytique.pa_id

Definition at line 41 of file class_anc_plan.php.

Anc_Plan::$name

name plan_analytique.pa_name

Definition at line 39 of file class_anc_plan.php.

Referenced by add(), and update().


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