noalyss Version-9
Public Member Functions | Data Fields | Static Public Attributes | Private Attributes
Acc_Account Class Reference

Manage the account from the table tmp_pcmn. More...

+ Collaboration diagram for Acc_Account:

Public Member Functions

 __construct (Database $p_cn, $pcm_val="")
 
 count ($p_value)
 
 delete ()
 
 find_by_value ($p_pcm_val)
 
 find_parent ()
 Find the parent of an account. More...
 
 get_lib ()
 Return the name of a account it doesn't change any data member. More...
 
 get_parameter ($p_string)
 
 insert ()
 
 load ()
 Get all the value for this object from the database the data member are set. More...
 
 save ()
 
 searchValue ($p_value)
 
 set_parameter ($p_string, $p_value)
 
 update ()
 
 verify ()
 Check before inserting or updating. More...
 

Data Fields

 $db
 

Static Public Attributes

static $type
 

Private Attributes

 $data_sql
 

Detailed Description

Manage the account from the table tmp_pcmn.

Definition at line 28 of file acc_account.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Account::__construct ( Database  $p_cn,
  $pcm_val = "" 
)
Parameters
type$p_cnDatabase connection
type$pcm_valAccounting tmp_pcmn.pcm_val

Definition at line 48 of file acc_account.class.php.

49 {
50 $this->db=$p_cn;
51 $id=-1;
52 if ( trim($pcm_val) != "" ) {
53 $pcm_val=mb_strtoupper($pcm_val);
54 $pcm_val=$this->db->get_value("select format_account($1)",
55 array($pcm_val));
56 $id=$p_cn->get_value("select id from tmp_pcmn where pcm_val=$1",[$pcm_val]);
57 }
58 if ( $id == "") { $id=-1;}
59 $this->data_sql=new Tmp_Pcmn_SQL($p_cn, $id);
60 $this->data_sql->pcm_val=$pcm_val;
61
62 }
get_value($p_sql, $p_array=null)
return the value of the sql, the sql will return only one value with the value
ORM abstract of the table public.tmp_pcmn.
$SecUser db

References $id, db, and DatabaseCore\get_value().

+ Here is the call graph for this function:

Member Function Documentation

◆ count()

Acc_Account::count (   $p_value)

Definition at line 102 of file acc_account.class.php.

103 {
104 $sql="select count(*) from tmp_pcmn where pcm_val=$1";
105 return $this->db->get_value($sql,array($p_value));
106 }

References $sql, and db.

◆ delete()

Acc_Account::delete ( )

Definition at line 174 of file acc_account.class.php.

174 {
175 // if already use cannot be deleted
176 if ( $this->data_sql->count("where pcm_val in (select j_poste from jrnx where j_poste=$1) or pcm_val_parent=$1",
177 [$this->data_sql->pcm_val]) > 0)
178 {
179 throw new Exception(_("Poste utilisé : effacement interdit"),EXC_PARAM_VALUE);
180 }
181 $this->data_sql->delete();
182
183 }
const EXC_PARAM_VALUE
Definition: constant.php:343

References EXC_PARAM_VALUE.

◆ find_by_value()

Acc_Account::find_by_value (   $p_pcm_val)

Definition at line 184 of file acc_account.class.php.

185 {
186 $id=$this->db->get_value("select id from tmp_pcmn where pcm_val=$1",[$p_pcm_val]);
187 $this->data_sql->setp("id",$id);
188 $this->data_sql->load();
189 }

References $id, and db.

◆ find_parent()

Acc_Account::find_parent ( )

Find the parent of an account.

Returns
string (pcm_val)

Definition at line 111 of file acc_account.class.php.

111 {
112 $name=$this->data_sql->pcm_val;
113 $length_name=strlen($name);
114 $parent="";
115 for ($i = 1;$i <$length_name;$i++) {
116 $parent=mb_substr($name, 0, $length_name-$i);
117 $exist=$this->db->get_value("select count(*) from tmp_pcmn where pcm_val=$1",[$parent]);
118 if ( $exist == 1) return $parent;
119 }
120
121 return $parent;
122 }

References $i, $name, and db.

Referenced by verify().

◆ get_lib()

Acc_Account::get_lib ( )

Return the name of a account it doesn't change any data member.

Returns
string with the pcm_lib

Definition at line 77 of file acc_account.class.php.

78 {
79 $ret=$this->data_sql->getp('pcm_lib');
80 if ( $ret !="")
81 {
82 return $ret;
83 }
84 else
85 {
86 return _("Poste inconnu");
87 }
88 }

References $ret.

◆ get_parameter()

Acc_Account::get_parameter (   $p_string)

Definition at line 63 of file acc_account.class.php.

64 {
65 return $this->data_sql->getp($p_string);
66 }

◆ insert()

Acc_Account::insert ( )

Definition at line 169 of file acc_account.class.php.

169 {
170 // check for Duplicate key, parent ... see Acc_Plan_MTable
171 $this->verify();
172 $this->data_sql->insert();
173 }
verify()
Check before inserting or updating.

References verify().

+ Here is the call graph for this function:

◆ load()

Acc_Account::load ( )

Get all the value for this object from the database the data member are set.

Returns
false if this account doesn't exist otherwise true

Definition at line 97 of file acc_account.class.php.

97 :bool
98 {
99 return $this->data_sql->load();
100 }

◆ save()

Acc_Account::save ( )

Definition at line 190 of file acc_account.class.php.

190 {
191 try {
192 $this->verify();
193 $this->data_sql->save();
194 } catch (Exception $e) {
195 throw $e;
196 }
197 }

References $e, and verify().

+ Here is the call graph for this function:

◆ searchValue()

Acc_Account::searchValue (   $p_value)

Definition at line 89 of file acc_account.class.php.

89 {
90
91
92 }

◆ set_parameter()

Acc_Account::set_parameter (   $p_string,
  $p_value 
)

Definition at line 68 of file acc_account.class.php.

69 {
70 return $this->data_sql->setp($p_string,$p_value);
71
72 }

◆ update()

Acc_Account::update ( )

Definition at line 164 of file acc_account.class.php.

164 {
165 // check for Duplicate key, parent ... see Acc_Plan_MTable
166 $this->verify();
167 $this->data_sql->update();
168 }

References verify().

+ Here is the call graph for this function:

◆ verify()

Acc_Account::verify ( )

Check before inserting or updating.

Definition at line 126 of file acc_account.class.php.

126 {
127 // check for Duplicate key, parent ... see Acc_Plan_MTable
128 $count=$this->data_sql->count(" where pcm_val =$1 and id <> $2",
129 [mb_strtoupper($this->data_sql->pcm_val),$this->data_sql->id]);
130 if ( $count > 0)
131 throw new Exception (_("Poste en double"),EXC_DUPLICATE);
132
133 if (noalyss_trim($this->data_sql->pcm_lib)=="")
134 throw new Exception (_("Libellé vide"),EXC_PARAM_VALUE);
135
136 // can not depend of itself
137 if ( $this->data_sql->pcm_val_parent == $this->data_sql->pcm_val)
138 throw new Exception (_("Poste parent incorrect"),EXC_PARAM_VALUE);
139
140 if ( $this->data_sql->pcm_val_parent == "") {
141 $account=$this->find_parent();
142 $this->data_sql->pcm_val_parent=$account;
143 if ($account == "")
144 throw new Exception (_("Poste Parent n'existe pas"),EXC_PARAM_VALUE);
145 }
146
147 // purpose not clear
148 if ( $this->data_sql->count(" where pcm_val = $1 and pcm_val <> $2",
149 [$this->data_sql->pcm_val_parent,$this->data_sql->pcm_val]) == 0)
150 throw new Exception (_("Poste Parent n'existe pas"),EXC_PARAM_VALUE);
151
152
153 if ( $this->data_sql->pcm_direct_use != 'N' && $this->data_sql->pcm_direct_use != 'Y')
154 throw new Exception (_("Paramètre incorrect"),EXC_PARAM_VALUE);
155
156 if ( trim($this->data_sql->pcm_val)==""||trim($this->data_sql->pcm_val_parent)=="")
157 throw new Exception (_("Paramètre incorrect"),EXC_PARAM_VALUE);
158
159 if ( strlen($this->data_sql->pcm_val)>40) {
160 throw new Exception (_("Poste comptable doit être de 40 caractères maximum"),EXC_PARAM_VALUE);
161 }
162
163 }
noalyss_trim($p_string)
Definition: ac_common.php:1545
find_parent()
Find the parent of an account.
const EXC_DUPLICATE
Definition: constant.php:345
$count

References $account, $count, EXC_DUPLICATE, EXC_PARAM_VALUE, find_parent(), and noalyss_trim().

Referenced by insert(), save(), and update().

+ Here is the call graph for this function:

Field Documentation

◆ $data_sql

Acc_Account::$data_sql
private

Definition at line 31 of file acc_account.class.php.

◆ $db

Acc_Account::$db

$db database connection

Definition at line 30 of file acc_account.class.php.

◆ $type

Acc_Account::$type
static
Initial value:
=array(
array('label'=>'Actif','value'=>'ACT'),
array('label'=>'Passif','value'=>'PAS'),
array('label'=>'Actif c. inverse','value'=>'ACTINV'),
array('label'=>'Passif c.inverse','value'=>'PASINV'),
array('label'=>'Produit','value'=>'PRO'),
array('label'=>'Produit Inverse','value'=>'PROINV'),
array('label'=>'Charge','value'=>'CHA'),
array('label'=>'Charge Inverse','value'=>'CHAINV'),
array('label'=>'Contexte','value'=>'CON')
)

Definition at line 32 of file acc_account.class.php.


The documentation for this class was generated from the following file: