26require_once NOALYSS_INCLUDE.
'/database/tmp_pcmn_sql.class.php';
33 array(
'label'=>
'Actif',
'value'=>
'ACT'),
34 array(
'label'=>
'Passif',
'value'=>
'PAS'),
35 array(
'label'=>
'Actif c. inverse',
'value'=>
'ACTINV'),
36 array(
'label'=>
'Passif c.inverse',
'value'=>
'PASINV'),
37 array(
'label'=>
'Produit',
'value'=>
'PRO'),
38 array(
'label'=>
'Produit Inverse',
'value'=>
'PROINV'),
39 array(
'label'=>
'Charge',
'value'=>
'CHA'),
40 array(
'label'=>
'Charge Inverse',
'value'=>
'CHAINV'),
41 array(
'label'=>
'Contexte',
'value'=>
'CON')
52 if ( trim($pcm_val) !=
"" ) {
53 $pcm_val=mb_strtoupper($pcm_val);
54 $pcm_val=$this->
db->get_value(
"select format_account($1)",
56 $id=$p_cn->
get_value(
"select id from tmp_pcmn where pcm_val=$1",[$pcm_val]);
60 $this->data_sql->pcm_val=$pcm_val;
65 return $this->data_sql->getp($p_string);
70 return $this->data_sql->setp($p_string,$p_value);
79 $ret=$this->data_sql->getp(
'pcm_lib');
86 return _(
"Poste inconnu");
99 return $this->data_sql->load();
104 $sql=
"select count(*) from tmp_pcmn where pcm_val=$1";
105 return $this->
db->get_value(
$sql,array($p_value));
112 $name=$this->data_sql->pcm_val;
113 $length_name=strlen(
$name);
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;
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]);
137 if ( $this->data_sql->pcm_val_parent == $this->data_sql->pcm_val)
140 if ( $this->data_sql->pcm_val_parent ==
"") {
142 $this->data_sql->pcm_val_parent=
$account;
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)
153 if ( $this->data_sql->pcm_direct_use !=
'N' && $this->data_sql->pcm_direct_use !=
'Y')
156 if ( trim($this->data_sql->pcm_val)==
""||trim($this->data_sql->pcm_val_parent)==
"")
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);
167 $this->data_sql->update();
172 $this->data_sql->insert();
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)
179 throw new Exception(_(
"Poste utilisé : effacement interdit"),
EXC_PARAM_VALUE);
181 $this->data_sql->delete();
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();
193 $this->data_sql->save();
194 }
catch (Exception
$e) {
Manage the account from the table tmp_pcmn.
set_parameter($p_string, $p_value)
__construct(Database $p_cn, $pcm_val="")
load()
Get all the value for this object from the database the data member are set.
get_lib()
Return the name of a account it doesn't change any data member.
find_by_value($p_pcm_val)
verify()
Check before inserting or updating.
find_parent()
Find the parent of an account.
get_value($p_sql, $p_array=null)
return the value of the sql, the sql will return only one value with the value
contains the class for connecting to Noalyss
ORM abstract of the table public.tmp_pcmn.