noalyss
Version-9
include
class
acc_parm_code.class.php
Go to the documentation of this file.
1
<?php
2
/*
3
* This file is part of NOALYSS.
4
*
5
* NOALYSS is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* NOALYSS is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with NOALYSS; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*/
19
// Copyright Author Dany De Bontridder danydb@aevalys.eu
20
/*! \file
21
* \brief Manage the table parm_code which contains the custom parameter
22
* for the module accountancy
23
*/
24
/*!
25
* \brief Manage the table parm_code which contains the custom parameter
26
* for the module accountancy
27
*/
28
29
class
Acc_Parm_Code
30
{
31
var
$db
;
/*!< $db database connection */
32
var
$p_code
;
/*!< $p_code parm_code.p_code primary key */
33
var
$p_value
;
/*!< $p_value parm_code.p_value */
34
var
$p_comment
;
/*!< $p_comment parm_code.p_comment */
35
// constructor
36
function
__construct
($p_cn,
$p_id
=-1)
37
{
38
$this->
db
=$p_cn;
39
$this->p_code=
$p_id
;
40
if
(
$p_id
!= -1 )
41
$this->
load
();
42
}
43
/*!
44
**************************************************
45
* \brief
46
* Load all parmCode
47
* return an array of Acc_Parm_Code object
48
*
49
* \return array
50
*/
51
52
function
load_all
()
53
{
54
$sql
=
"select * from parm_code order by p_code"
;
55
$Res
=$this->
db
->exec_sql(
$sql
);
56
$r
=
Database::fetch_all
(
$Res
);
57
$idx
=0;
58
$array
=array();
59
60
if
(
$r
===
false
)
return
null
;
61
foreach
(
$r
as
$row
)
62
{
63
$o=
new
Acc_Parm_Code
($this->
db
,$row[
'p_code'
]);
64
$array
[
$idx
]=$o;
65
$idx
++;
66
}
67
68
return
$array
;
69
}
70
/*!
71
**************************************************
72
* \brief update a parm_object into the database
73
* p_code is _not_ updatable
74
* \return
75
* nothing
76
*/
77
function
save
()
78
{
79
// if p_code=="" nothing to save
80
if
( $this->p_code== -1)
return
;
81
// check if the account exists
82
$acc=
new
Acc_Account_Ledger
($this->
db
,$this->p_value);
83
if
( $acc->load() ==
false
)
84
{
85
alert
(_(
"Ce compte n'existe pas"
));
86
}
87
else
88
{
89
$this->p_comment=
sql_string
($this->p_comment);
90
$this->p_value=
sql_string
($this->p_value);
91
$this->p_code=
sql_string
($this->p_code);
92
$sql
=
"update parm_code set "
.
93
"p_comment='"
.$this->p_comment.
"' "
.
94
",p_value='"
.$this->p_value.
"' "
.
95
"where p_code='"
.$this->p_code.
"'"
;
96
$Res
=$this->
db
->exec_sql(
$sql
);
97
}
98
}
99
/*!
100
**************************************************
101
* \brief Display an object, with the <TD> tag
102
*
103
* \return
104
* string
105
*/
106
function
display
()
107
{
108
$r
=
""
;
109
$r
.=
'<TD>'
.$this->p_code.
'</TD>'
;
110
$r
.=
'<TD>'
.h($this->p_comment).
'</TD>'
;
111
$r
.=
'<TD>'
.$this->p_value.
'</TD>'
;
112
113
return
$r
;
114
}
115
/*!
116
**************************************************
117
* \brief Display a form to enter info about
118
* a parm_code object with the <TD> tag
119
*
120
* \return string
121
*/
122
function
form
()
123
{
124
$comment=
new
IText
();
125
$comment->name=
'p_comment'
;
126
$comment->value=
$this->p_comment
;
127
$comment->size=45;
128
$value
=
new
IPoste
();
129
$value
->name=
'p_value'
;
130
$value
->value=
$this->p_value
;
131
$value
->size=7;
132
$value
->set_attribute(
'ipopup'
,
'ipop_account'
);
133
$value
->set_attribute(
'account'
,
'p_value'
);
134
$poste
=
new
IText
();
135
$poste
->setReadOnly(
true
);
136
$poste
->size=strlen($this->p_code)+1;
137
$poste
->name=
'p_code'
;
138
$poste
->value=
$this->p_code
;
139
$r
=
""
;
140
$r
.=
'<tr>'
;
141
$r
.=
'<td align="right"> Code </td>'
;
142
$r
.=
'<TD>'
.$poste->input().
'</TD>'
;
143
$r
.=
'</tr>'
;
144
$r
.=
'<tr>'
;
145
$r
.=
'<td align="right"> Commentaire </td>'
;
146
$r
.=
'<TD>'
.$comment->input().
'</TD>'
;
147
$r
.=
'</tr>'
;
148
$r
.=
'<tr>'
;
149
$r
.=
'<td align="right"> Poste comptable </td>'
;
150
$r
.=
'<TD>'
.$value->input();
151
$r
.=
'<span id="p_value_label"></span></td>'
;
152
$r
.=
'</tr>'
;
153
$r
.=
Dossier::hidden
();
154
return
$r
;
155
156
}
157
158
/*!
159
**************************************************
160
* \brief
161
* Complete a parm_code object thanks the p_code
162
*
163
* \return array
164
*/
165
166
function
load
()
167
{
168
if
( $this->p_code == -1 )
return
"p_code non initialisé"
;
169
$sql
=
'select * from parm_code where p_code=$1 '
;
170
171
$Res
=$this->
db
->exec_sql(
$sql
,array($this->p_code));
172
173
if
(
Database::num_row
(
$Res
) == 0 )
return
'INCONNU'
;
174
$row
=
Database::fetch_array
(
$Res
,0);
175
$this->p_value=
$row
[
'p_value'
];
176
$this->p_comment=
$row
[
'p_comment'
];
177
178
}
179
180
}
sql_string
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition:
ac_common.php:511
alert
alert($p_msg, $buffer=false)
alert in javascript
Definition:
ac_common.php:738
$p_id
$p_id
Definition:
ajax_accounting.php:33
$sql
$sql
Definition:
ajax_add_concerned_card.php:100
$r
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
Definition:
ajax_add_concerned_card.php:53
$array
$array
Definition:
ajax_add_concerned_card.php:115
$row
$row
Definition:
ajax_anc_detail_operation.php:33
$idx
$idx
Definition:
ajax_bookmark.php:79
Acc_Account_Ledger
Manage the account from the table jrn, jrnx or tmp_pcmn.
Definition:
acc_account_ledger.class.php:28
Acc_Parm_Code
Manage the table parm_code which contains the custom parameter for the module accountancy.
Definition:
acc_parm_code.class.php:30
Acc_Parm_Code\__construct
__construct($p_cn, $p_id=-1)
Definition:
acc_parm_code.class.php:36
Acc_Parm_Code\$p_comment
$p_comment
Definition:
acc_parm_code.class.php:34
Acc_Parm_Code\display
display()
Display an object, with the tag.
Definition:
acc_parm_code.class.php:106
Acc_Parm_Code\load_all
load_all()
Load all parmCode return an array of Acc_Parm_Code object
Definition:
acc_parm_code.class.php:52
Acc_Parm_Code\$db
$db
Definition:
acc_parm_code.class.php:31
Acc_Parm_Code\load
load()
Complete a parm_code object thanks the p_code
Definition:
acc_parm_code.class.php:166
Acc_Parm_Code\save
save()
update a parm_object into the database p_code is not updatable
Definition:
acc_parm_code.class.php:77
Acc_Parm_Code\form
form()
Display a form to enter info about a parm_code object with the tag.
Definition:
acc_parm_code.class.php:122
Acc_Parm_Code\$p_code
$p_code
Definition:
acc_parm_code.class.php:32
Acc_Parm_Code\$p_value
$p_value
Definition:
acc_parm_code.class.php:33
DatabaseCore\fetch_all
static fetch_all($ret)
wrapper for the function pg_fetch_all
Definition:
database_core.class.php:768
DatabaseCore\fetch_array
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
Definition:
database_core.class.php:757
DatabaseCore\num_row
static num_row($ret)
wrapper for the function pg_num_rows
Definition:
database_core.class.php:744
Dossier\hidden
static hidden()
return a string to set gDossier into a FORM
Definition:
dossier.class.php:202
IPoste
show a button, for selecting a account and a input text for manually inserting an account the differe...
Definition:
iposte.class.php:75
IText
Html Input.
Definition:
itext.class.php:30
$Res
$Res
Definition:
dossier.inc.php:317
$value
$value
Definition:
export_document.php:41
db
$SecUser db
Definition:
export_security_pdf.php:118
$poste
$poste
Definition:
lettering.account.inc.php:37