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

Acc_Tva is used for to map the table tva_rate parameter are. More...

Public Member Functions

 __construct ($p_init, $p_tva_id=0)
 delete ()
 get_info ()
 get_parameter ($p_string)
 get_side ($p_side)
 get the account of the side (debit or credit)
 insert ()
 load ()
 Load the VAT,.
 save ()
 set_parameter ($p_string, $p_value)
 update ()
 verify ()

Static Public Member Functions

static test_me ()
 Test function.

Private Attributes

 $cn

Static Private Attributes

static $variable

Detailed Description

Acc_Tva is used for to map the table tva_rate parameter are.

Definition at line 38 of file class_acc_tva.php.


Constructor & Destructor Documentation

Acc_Tva::__construct ( p_init,
p_tva_id = 0 
)

Definition at line 48 of file class_acc_tva.php.

References cn, and poste.

    {
        $this->cn=$p_init;
        $this->tva_id=$p_tva_id;
        $this->poste="";
    }

Member Function Documentation

Definition at line 170 of file class_acc_tva.php.

References $res, $sql, and cn.

    {
        $sql="delete from tva_rate where tva_id=$1";
        $res=$this->cn->exec_sql($sql,array($this->tva_id));
    }

Definition at line 76 of file class_acc_tva.php.

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

Definition at line 54 of file class_acc_tva.php.

References $idx, and echo.

    {
        if ( array_key_exists($p_string,self::$variable) )
        {
            $idx=self::$variable[$p_string];
            return $this->$idx;
        }

        echo  (__FILE__.":".__LINE__.'Erreur attribut inexistant');
    }
Acc_Tva::get_side ( p_side)

get the account of the side (debit or credit)

Parameters:
$p_sideis d or C
Returns:
the account to use
Note:
call first load if tva_poste is empty

Definition at line 154 of file class_acc_tva.php.

References $cred, $deb, and load().

    {
        if ( strlen($this->tva_poste) == 0 ) $this->load();
        list($deb,$cred)=explode(",",$this->tva_poste);
        switch ($p_side)
        {
        case 'd':
                return $deb;
            break;
        case 'c':
            return $cred;
            break;
        default:
            throw (new Exception (__FILE__.':'.__LINE__." param est d ou c, on a recu [ $p_side ]"));
        }
    }

Definition at line 94 of file class_acc_tva.php.

References $err, $res, $sql, cn, Database\fetch_result(), and verify().

Referenced by save().

    {
        if ( $this->verify() != 0 ) return;
        $sql="select tva_insert($1,$2,$3,$4,$5)";

        $res=$this->cn->exec_sql(
                 $sql,
                 array($this->tva_label,
                       $this->tva_rate,
                       $this->tva_comment,
                       $this->tva_poste,
                        $this->tva_both_side)
             );
        $this->tva_id=$this->cn->get_current_seq('s_tva');
        $err=Database::fetch_result($res);
    }

Load the VAT,.

Note:
if the label is not found then we get an message error, so the best is probably to initialize the VAT object with default value

Definition at line 132 of file class_acc_tva.php.

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

Referenced by get_side().

    {
        $sql="select tva_id,tva_label,tva_rate, tva_comment,tva_poste,tva_both_side from tva_rate where tva_id=$1";
        $res=$this->cn->exec_sql(
                 $sql,
                 array($this->tva_id)
             );

        if ( $this->cn->size() == 0 ) return -1;

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

Definition at line 85 of file class_acc_tva.php.

References insert(), and update().

    {

        if (  $this->tva_id == 0 )
            $this->insert();
        else
            $this->update();
    }
Acc_Tva::set_parameter ( p_string,
p_value 
)

Definition at line 64 of file class_acc_tva.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');


    }
static Acc_Tva::test_me ( ) [static]

Test function.

Definition at line 178 of file class_acc_tva.php.

References $a, $cn, echo, and id.

    {
        $cn=new Database(dossier::id());
        $a=new Acc_Tva($cn);
        echo $a->get_info();
        $a->set_parameter("id",1);
        $a->load();
        $a->set_parameter("id",0);
        $a->set_parameter("rate","0.2222");
        $a->set_parameter("label","test");
        $a->save();
        $a->load();
        print_r($a);

        $a->set_parameter("comment","un cht'it test");
        $a->save();
        $a->load();
        print_r($a);

        $a->delete();
    }

Definition at line 111 of file class_acc_tva.php.

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

Referenced by save().

    {
        if ( $this->verify() != 0 ) return;
        $sql="update tva_rate set tva_label=$1,tva_rate=$2,tva_comment=$3,tva_poste=$4,tva_both_side=$5 ".
             " where tva_id = $6";
        $res=$this->cn->exec_sql(
                 $sql,
                 array($this->tva_label,
                       $this->tva_rate,
                       $this->tva_comment,
                       $this->tva_poste,
                       $this->tva_both_side,
                       $this->tva_id)
             );

    }

Definition at line 81 of file class_acc_tva.php.

Referenced by insert(), and update().

    {
        // Verify that the elt we want to add is correct
    }

Field Documentation

Acc_Tva::$cn [private]

$cn database connection

Definition at line 40 of file class_acc_tva.php.

Referenced by test_me().

Acc_Tva::$variable [static, private]
Initial value:
array("id"=>"tva_id",
                                   "label"=>"tva_label",
                                   "rate"=>"tva_rate",
                                   "comment"=>"tva_comment",
                                   "account"=>"tva_poste",
                                    "both_side"=>'tva_both_side')

Definition at line 41 of file class_acc_tva.php.


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