noalyss
Version-9
include
class
noalyss_parameter_folder.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 Class to manage the company parameter (address, name...)
22
*/
23
/*!
24
* \brief Class to manage the company parameter (address, name...)
25
*/
26
27
class
Noalyss_Parameter_Folder
28
{
29
var
$db
;
30
var
$MY_NAME
;
31
var
$MY_TVA
;
32
var
$MY_STREET
;
33
var
$MY_NUMBER
;
34
var
$MY_CP
;
35
var
$MY_TEL
;
36
var
$MY_PAYS
;
37
var
$MY_COMMUNE
;
38
var
$MY_FAX
;
39
var
$MY_ANALYTIC
;
40
var
$MY_STRICT
;
41
var
$MY_TVA_USE
;
42
var
$MY_PJ_SUGGEST
;
43
var
$MY_CHECK_PERIODE
;
44
var
$MY_DATE_SUGGEST
;
45
var
$MY_ALPHANUM
;
46
var
$MY_UPDLAB
;
47
var
$MY_STOCK
;
48
var
$MY_DEFAULT_ROUND_ERROR_DEB
;
49
var
$MY_DEFAULT_ROUND_ERROR_CRED
;
50
var
$MY_ANC_FILTER
;
51
var
$MY_CURRENCY
;
52
53
54
// constructor
55
function
__construct
($p_cn)
56
{
57
$this->
db
=$p_cn;
58
$Res
=$p_cn->exec_sql(
"select * from parameter where pr_id like 'MY_%'"
);
59
for
(
$i
= 0;
$i
<
Database::num_row
(
$Res
);
$i
++)
60
{
61
$row
=
Database::fetch_array
(
$Res
,
$i
);
62
$key=
$row
[
'pr_id'
];
63
$elt=
$row
[
'pr_value'
];
64
// store value here
65
$this->{
"$key"
}=$elt;
66
}
67
68
}
69
function
check_anc_filter
($p_value)
70
{
71
$tmp_value=$p_value;
72
$tmp_value=preg_replace(
"/[0-9]|,/"
,
''
, $p_value);
73
if
( $tmp_value !=
""
) {
74
throw
new
Exception (sprintf(_(
"Valeur invalide %s"
),$tmp_value),1000);
75
}
76
if
(trim($p_value) ==
""
) {
77
throw
new
Exception (sprintf(_(
"Erreur Filtre analytique %s"
),$tmp_value),1001);
78
79
}
80
81
}
82
function
check
($p_attr, $p_value)
83
{
84
$ret_value=$p_value;
85
switch
($p_attr)
86
{
87
case
'MY_STRICT'
:
88
89
if
(empty(trim($p_value)) ||($p_value!=
'Y'
&&$p_value!=
'N'
))
90
{
91
$ret_value=
'N'
;
92
}
93
94
break
;
95
case
'MY_ANC_FILTER'
:
96
try
97
{
98
$p_value=str_replace(
" "
,
""
, $p_value);
99
$this->
check_anc_filter
($p_value);
100
$ret_value=$p_value;
101
}
102
catch
(Exception $exc)
103
{
104
throw
$exc;
105
}
106
107
break
;
108
default :
109
$ret_value=htmlspecialchars($p_value);
110
}
111
return
$ret_value;
112
}
113
114
/*!
115
**************************************************
116
* \brief save the parameter into the database by inserting or updating
117
*
118
*
119
* \param $p_attr give the attribut name
120
*
121
*/
122
function
save
($p_attr)
123
{
124
try
{
125
$value
=$this->
check
($p_attr,$this->$p_attr);
126
127
// check if the parameter does exist
128
if
( $this->
db
->get_value(
'select count(*) from parameter where pr_id=$1'
,array($p_attr)) != 0 )
129
{
130
$Res
=$this->
db
->exec_sql(
"update parameter set pr_value=$1 where pr_id=$2"
,
131
array(
$value
,$p_attr));
132
}
133
else
134
{
135
136
$Res
=$this->
db
->exec_sql(
"insert into parameter (pr_id,pr_value) values( $1,$2)"
,
137
array($p_attr,
$value
));
138
139
}
140
}
catch
(Exception
$e
) {
141
throw
$e
;
142
}
143
144
}
145
146
/*!
147
**************************************************
148
* \brief save data
149
*
150
*
151
*/
152
function
update
()
153
{
154
155
$this->
save
(
'MY_NAME'
);
156
$this->
save
(
'MY_TVA'
);
157
$this->
save
(
'MY_STREET'
);
158
$this->
save
(
'MY_NUMBER'
);
159
$this->
save
(
'MY_CP'
);
160
$this->
save
(
'MY_TEL'
);
161
$this->
save
(
'MY_PAYS'
);
162
$this->
save
(
'MY_COMMUNE'
);
163
$this->
save
(
'MY_FAX'
);
164
$this->
save
(
'MY_ANALYTIC'
);
165
$this->
save
(
'MY_STRICT'
);
166
$this->
save
(
'MY_TVA_USE'
);
167
$this->
save
(
'MY_PJ_SUGGEST'
);
168
$this->
save
(
'MY_CHECK_PERIODE'
);
169
$this->
save
(
'MY_DATE_SUGGEST'
);
170
$this->
save
(
'MY_ALPHANUM'
);
171
$this->
save
(
'MY_UPDLAB'
);
172
$this->
save
(
'MY_STOCK'
);
173
$this->
save
(
'MY_DEFAULT_ROUND_ERROR_DEB'
);
174
$this->
save
(
'MY_DEFAULT_ROUND_ERROR_CRED'
);
175
$this->
save
(
"MY_ANC_FILTER"
);
176
177
}
178
/**
179
* Check if an accounting match the anc_filter
180
* @param string $p_accounting
181
* @return boolean FALSE does not match , TRUE matches
182
*/
183
function
match_analytic
($p_accounting)
184
{
185
$string
=
"/^["
.$this->MY_ANC_FILTER.
"]+/"
;
186
if
( preg_match(
$string
,$p_accounting) == 0 )
return
FALSE;
187
return
TRUE;
188
}
189
190
}
$e
$e
Definition:
result_cat_card_summary.php:26
Noalyss_Parameter_Folder\$MY_UPDLAB
$MY_UPDLAB
Definition:
noalyss_parameter_folder.class.php:46
$string
$string
Definition:
ajax_get_receipt.php:54
Noalyss_Parameter_Folder
Class to manage the company parameter (address, name...)
Definition:
noalyss_parameter_folder.class.php:27
db
$SecUser db
Definition:
export_security_pdf.php:118
Noalyss_Parameter_Folder\$MY_PJ_SUGGEST
$MY_PJ_SUGGEST
Definition:
noalyss_parameter_folder.class.php:42
Noalyss_Parameter_Folder\$MY_CP
$MY_CP
Definition:
noalyss_parameter_folder.class.php:34
Noalyss_Parameter_Folder\$MY_DEFAULT_ROUND_ERROR_CRED
$MY_DEFAULT_ROUND_ERROR_CRED
Definition:
noalyss_parameter_folder.class.php:49
DatabaseCore\fetch_array
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
Definition:
database_core.class.php:745
Noalyss_Parameter_Folder\$MY_TVA_USE
$MY_TVA_USE
Definition:
noalyss_parameter_folder.class.php:41
Noalyss_Parameter_Folder\$MY_COMMUNE
$MY_COMMUNE
Definition:
noalyss_parameter_folder.class.php:37
Noalyss_Parameter_Folder\$MY_DEFAULT_ROUND_ERROR_DEB
$MY_DEFAULT_ROUND_ERROR_DEB
Definition:
noalyss_parameter_folder.class.php:48
Noalyss_Parameter_Folder\$MY_ALPHANUM
$MY_ALPHANUM
Definition:
noalyss_parameter_folder.class.php:45
Noalyss_Parameter_Folder\$MY_CHECK_PERIODE
$MY_CHECK_PERIODE
Definition:
noalyss_parameter_folder.class.php:43
Noalyss_Parameter_Folder\$MY_ANC_FILTER
$MY_ANC_FILTER
Definition:
noalyss_parameter_folder.class.php:50
Noalyss_Parameter_Folder\update
update()
save data
Definition:
noalyss_parameter_folder.class.php:152
$value
$value
Definition:
export_document.php:41
Noalyss_Parameter_Folder\$MY_STRICT
$MY_STRICT
Definition:
noalyss_parameter_folder.class.php:40
Noalyss_Parameter_Folder\match_analytic
match_analytic($p_accounting)
Check if an accounting match the anc_filter.
Definition:
noalyss_parameter_folder.class.php:183
Noalyss_Parameter_Folder\$MY_TVA
$MY_TVA
Definition:
noalyss_parameter_folder.class.php:31
$i
$i
Definition:
action_document_type_mtable_input.php:83
Noalyss_Parameter_Folder\$MY_NAME
$MY_NAME
Definition:
noalyss_parameter_folder.class.php:30
Noalyss_Parameter_Folder\$MY_STOCK
$MY_STOCK
Definition:
noalyss_parameter_folder.class.php:47
DatabaseCore\num_row
static num_row($ret)
wrapper for the function pg_NumRows
Definition:
database_core.class.php:734
Noalyss_Parameter_Folder\$MY_ANALYTIC
$MY_ANALYTIC
Definition:
noalyss_parameter_folder.class.php:39
Noalyss_Parameter_Folder\$MY_PAYS
$MY_PAYS
Definition:
noalyss_parameter_folder.class.php:36
Noalyss_Parameter_Folder\$db
$db
Definition:
noalyss_parameter_folder.class.php:29
Noalyss_Parameter_Folder\$MY_NUMBER
$MY_NUMBER
Definition:
noalyss_parameter_folder.class.php:33
Noalyss_Parameter_Folder\$MY_STREET
$MY_STREET
Definition:
noalyss_parameter_folder.class.php:32
Noalyss_Parameter_Folder\check_anc_filter
check_anc_filter($p_value)
Definition:
noalyss_parameter_folder.class.php:69
Noalyss_Parameter_Folder\$MY_FAX
$MY_FAX
Definition:
noalyss_parameter_folder.class.php:38
$Res
$Res
Definition:
export_security_pdf.php:117
Noalyss_Parameter_Folder\__construct
__construct($p_cn)
Definition:
noalyss_parameter_folder.class.php:55
Noalyss_Parameter_Folder\$MY_TEL
$MY_TEL
Definition:
noalyss_parameter_folder.class.php:35
Noalyss_Parameter_Folder\check
check($p_attr, $p_value)
Definition:
noalyss_parameter_folder.class.php:82
Noalyss_Parameter_Folder\$MY_CURRENCY
$MY_CURRENCY
Definition:
noalyss_parameter_folder.class.php:51
Noalyss_Parameter_Folder\save
save($p_attr)
save the parameter into the database by inserting or updating
Definition:
noalyss_parameter_folder.class.php:122
$row
$row
Definition:
ajax_anc_detail_operation.php:33
Noalyss_Parameter_Folder\$MY_DATE_SUGGEST
$MY_DATE_SUGGEST
Definition:
noalyss_parameter_folder.class.php:44