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

contains the object for the poste_analytique (table poste_analytique) More...

Public Member Functions

 add ()
 Anc_Account ($p_db, $p_id=0)
 debug ()
 delete ()
 display_list ()
 form ()
 get_by_id ()
 get_by_name ($p_name)
 retrieve data thanks the name
 get_from_array ($p_array)
 get_list ()
 return an array of object Poste_Analytique
 update ()

Static Public Member Functions

static make_array_name ($cn, $pa_id)
static test_me ()

Data Fields

 $amount
 $db
 $description
 $ga_id
 $id
 $name
 $pa_id

Private Member Functions

 fetch_from_db ($p_where)
 retrieve data from the database and fill the object
 format_data ()

Detailed Description

contains the object for the poste_analytique (table poste_analytique)

Definition at line 36 of file class_anc_account.php.


Member Function Documentation

Definition at line 98 of file class_anc_account.php.

References $e, $ga_id, $sql, db, echo, format_data(), name, and trim().

    {
        $this->format_data();
        if ( strlen($this->name) == 0)
            return;
        if ( $this->ga_id == null || strlen(trim($this->ga_id)) == 0 )
            $ga_id="NULL";
        else
            $ga_id="'".$this->ga_id."'";
        $sql="insert into poste_analytique (
             po_name ,
             pa_id,
             po_amount,
             po_description,
             ga_id
             ) values ($1,$2,$3,$4,$5)";

        try
        {
            $this->db->exec_sql($sql,array($this->name,$this->pa_id,$this->amount,$this->description,$ga_id));

        }
        catch (Exception $e)
        {
            if ( DEBUG ) print_r($e);
            echo "<p class=\"notice\">Doublon : l'enregistrement n'est pas sauve</p>";
        }

    }
Anc_Account::Anc_Account ( p_db,
p_id = 0 
)

Definition at line 45 of file class_anc_account.php.

References db.

Referenced by get_list(), and test_me().

    {
        $this->db=$p_db;
        $this->id=$p_id;
        $this->ga_id=null;
    }

Definition at line 224 of file class_anc_account.php.

References echo.

    {
        echo "id ".$this->id."<br>";
        echo "name ".$this->name."<br>";
        echo "pa_id ".$this->pa_id."<br>";
        echo "amount ".$this->amount."<br>";
        echo "description ".$this->description."<br>";
        echo "ga_id ".$this->ga_id."<br>";
    }

Definition at line 170 of file class_anc_account.php.

References $sql, and db.

    {
        $sql="delete from poste_analytique where po_id=".$this->id;
        $this->db->exec_sql($sql);
    }

Definition at line 210 of file class_anc_account.php.

References $array, $line, echo, and get_list().

    {
        $array=$this->get_list();
        if ( empty($array) )
        {
            echo "Vide";
            return;
        }
        foreach ($array as $line)
        {
            echo $line->id." / ".$line->name." / ".$line->description."/".
            $line->amount." / ".$line->pa_id."/".$line->ga_id."<br>";
        }
    }
Anc_Account::fetch_from_db ( p_where) [private]

retrieve data from the database and fill the object

Parameters:
$p_wherethe where clause

Definition at line 55 of file class_anc_account.php.

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

Referenced by get_by_id(), and get_by_name().

    {
        $sql="select po_id,
             po_name ,
             pa_id,
             po_amount,
             po_description,
             ga_id
             from poste_analytique
             where ".
             $p_where;

        $ret=$this->db->exec_sql($sql);
        if ( Database::num_row($ret) == 0 )return null;
        $line=Database::fetch_array($ret);

        $this->id=$line['po_id'];
        $this->name=$line['po_name'];
        $this->pa_id=$line['pa_id'];
        $this->amount=$line['po_amount'];
        $this->description=$line['po_description'];
        $this->ga_id=$line['ga_id'];


    }

Definition at line 233 of file class_anc_account.php.

References $pa, $r, db, HtmlInput\hidden(), name, and td().

    {
        $r='';
        $wName=new IText("po_name",$this->name);
        $wAmount=new INum("po_amount",$this->amount);
        $wDescription=new IText("po_description",$this->description);
        $aGroup_analytic=$this->db->make_array("select ga_id,ga_id from groupe_analytique where pa_id=".$this->pa_id,1);
        if ( count($aGroup_analytic) > 1 )
        {
            $wGa_id=new ISelect("ga_id");
            $wGa_id->value=$aGroup_analytic;
            $wGa_id->selected=$this->ga_id;
            $wGa_id->table=1;
        }
        else
        {
            $wGa_id=new ISpan();
        }
        $pa=new Anc_Plan($this->db,$this->pa_id);
        $pa->get();
        $wPaName=new IText("",$pa->name);
        $wPaName->table=1;
        $wPaName->readOnly=true;

        $wName->table=1;
        $wAmount->table=1;
        $wDescription->table=1;
        $r.=HtmlInput::hidden("pa_id",$this->pa_id);
        $r.=HtmlInput::hidden("po_id",$this->id);

        $r.="<table>";

        $r.="<tr>";
        $r.=td(_('Nom'));
        $r.=$wName->input();
        $r.="</tr>";

        $r.="<tr>";
        $r.=td(_('Montant'));
        $r.=$wAmount->input();
        $r.="</tr>";


        $r.="<tr>";
        $r.=td(_('Description'));
        $r.=$wDescription->input();
        $r.="</tr>";

        $r.="<tr>";
        $r.=td(_('Plan Analytique'));
        $r.=$wPaName->input();
        $r.="</tr>";

        $r.="<tr>";
        $r.=td(_('Groupe'));
        $r.=$wGa_id->input();
        $r.="</tr>";

        $r.="</table>";
        return $r;

    }
Anc_Account::format_data ( ) [private]

Definition at line 157 of file class_anc_account.php.

References isNumber(), and name.

Referenced by add(), and update().

    {

        $this->name=$this->name;
        $this->pa_id=$this->pa_id;
        $this->amount=$this->amount;
        if (strlen($this->amount) == 0 )
            $this->amount=0.0;
        if ( isNumber($this->amount) ==0 )
            $this->amount=0;

        $this->description=$this->description;
    }

Definition at line 80 of file class_anc_account.php.

References fetch_from_db().

    {
        $this->fetch_from_db("po_id=".$this->id);
    }
Anc_Account::get_by_name ( p_name)

retrieve data thanks the name

Parameters:
$p_namename of the analytic account

Definition at line 89 of file class_anc_account.php.

References echo, fetch_from_db(), name, and sql_string().

    {
        $p_name=sql_string($p_name);
        if ( $p_name == null )
            $p_name=$this->name;

        $this->fetch_from_db("po_name='".$p_name."'");
        echo "id = ".$this->id;
    }

Definition at line 295 of file class_anc_account.php.

References $p_array, and name.

    {
        $this->name=(isset ($p_array['po_name']))?$p_array['po_name']:"";
        $this->description=(isset ($p_array['po_description']))?$p_array['po_description']:"";
        $this->pa_id=(isset ($p_array['pa_id']))?$p_array['pa_id']:"";
        $this->amount=(isset ($p_array['po_amount']))?$p_array['po_amount']:0;
        $this->id=(isset ($p_array['po_id']))?$p_array['po_id']:-1;
        //    $this->ga_id=(isset($p_array['ga_id']) && $p_array['ga_id'] == "-1" )?null:2;
        $this->ga_id=(isset($p_array['ga_id']) && $p_array['ga_id'] != "-1" )?$p_array['ga_id']:null;
    }

return an array of object Poste_Analytique

Definition at line 178 of file class_anc_account.php.

References $array, $ex, $line, $object, $ret, $sql, Anc_Account(), db, and Database\fetch_all().

Referenced by display_list().

    {
        $sql="select po_id,
             po_name ,
             pa_id,
             po_amount,
             po_description,
             ga_id
             from poste_analytique ".
             "   order by po_name";

        $ex=$this->db->exec_sql($sql);
        $ret=Database::fetch_all($ex);
        if ( $ret  == null )
            return null;

        $array=array();
        foreach ($ret as $line)
        {
            $object=new Anc_Account($this->db);

            $object->id=$line['po_id'];
            $object->name=$line['po_name'];
            $object->pa_id=$line['pa_id'];
            $object->amount=$line['po_amount'];
            $object->description=$line['po_description'];
            $object->ga_id=$line['ga_id'];
            $array[]=clone $object;
        }

        return $array;
    }
static Anc_Account::make_array_name ( cn,
pa_id 
) [static]

Definition at line 127 of file class_anc_account.php.

References $a, $cn, and $pa_id.

    {
        $a=$cn->make_array("select  po_name,po_name from poste_analytique ".
                           " where ".
                           " pa_id =".$pa_id." order by po_name ");
        return $a;
    }
static Anc_Account::test_me ( ) [static]

Definition at line 305 of file class_anc_account.php.

References $cn, $pa_id, Anc_Account(), echo, and id.

    {
        $cn=new Database(dossier::id());
        $pa_id=$cn->get_value("select max(pa_id) from plan_analytique");
        $o=new Anc_Account($cn);
        echo "<h1>Poste_Analytique</h1>";
        echo "<h2>get_list</h2>";
        $ee=$o->get_list();
        print_r($ee);
        //var_dump($ee);

        echo "<h2>Add some </h2>";
        $o->pa_id=$pa_id;
        $o->name="test1";
        $o->add();


        $o->name="test2";
        $o->add();

        $o->name="test3";
        $o->add();

        $o->name="test4";
        $o->add();

        $o->name="test5";
        $o->add();

        echo "<h2> remove test1</h2>";
        $o->get_by_name("test1");
        $o->delete();
        $o->display_list();

        $o->get_by_name("test4");
        echo "<hr>".$o->id."<hr>";
        $o->name="Test Four";
        $o->update();
        $o->display_list();
        $o->delete();
        $o->display_list();
    }

Definition at line 134 of file class_anc_account.php.

References $e, $sql, db, echo, format_data(), and name.

    {
        $this->format_data();
        if ( strlen($this->name) == 0)
            return;
        $sql="update poste_analytique ".
             " set po_name=$1".
             " ,pa_id=$2".
             " ,po_amount=$3".
             " ,po_description=$4".
             " ,ga_id=$5".
             " where po_id=$6";
        try
        {
            $this->db->exec_sql($sql,array($this->name,$this->pa_id,$this->amount,
                                           $this->description,$this->ga_id,$this->id));
        }
        catch (Exception $e)
        {
            echo "<p class=\"notice\">Doublon : l'enregistrement n'est pas sauve</p>";
        }

    }

Field Documentation

Anc_Account::$amount

po_amount just an amount

Definition at line 41 of file class_anc_account.php.

Anc_Account::$db

database connection

Definition at line 43 of file class_anc_account.php.

Anc_Account::$description

po_description description of the post

Definition at line 42 of file class_anc_account.php.

Anc_Account::$ga_id

FK to the table groupe analytique

Definition at line 44 of file class_anc_account.php.

Referenced by add().

Anc_Account::$id

$id is po_id

Definition at line 38 of file class_anc_account.php.

Anc_Account::$name

po_name

Definition at line 39 of file class_anc_account.php.

Anc_Account::$pa_id

pa_id fk to the plan_analytique(pa_id)

Definition at line 40 of file class_anc_account.php.

Referenced by make_array_name(), and test_me().


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