dolibarr
18.0.6
Main Page
Related Pages
Topics
Classes
Files
File List
File Members
dolibarr_18.0
htdocs
accountancy
class
accountancysystem.class.php
Go to the documentation of this file.
1
<?php
2
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
4
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
29
class
AccountancySystem
30
{
34
public
$db;
35
39
public
$error =
''
;
40
44
public
$errors = array();
45
49
public
$rowid;
50
54
public
$fk_pcg_version;
55
59
public
$pcg_type;
60
64
public
$numero;
65
69
public
$label;
70
74
public
$account_number;
75
79
public
$account_parent;
80
86
public
function
__construct
($db)
87
{
88
$this->db = $db;
89
}
90
91
99
public
function
fetch
($rowid = 0, $ref =
''
)
100
{
101
global $conf;
102
103
if
($rowid > 0 || $ref) {
104
$sql =
"SELECT a.rowid, a.pcg_version, a.label, a.active"
;
105
$sql .=
" FROM "
.MAIN_DB_PREFIX.
"accounting_system as a"
;
106
$sql .=
" WHERE"
;
107
if
($rowid) {
108
$sql .=
" a.rowid = "
.((int) $rowid);
109
} elseif ($ref) {
110
$sql .=
" a.pcg_version = '"
.$this->db->escape($ref).
"'"
;
111
}
112
113
dol_syslog
(get_class($this).
"::fetch"
, LOG_DEBUG);
114
$result = $this->db->query($sql);
115
if
($result) {
116
$obj = $this->db->fetch_object($result);
117
118
if
($obj) {
119
$this->
id
= $obj->rowid;
120
$this->
rowid
= $obj->rowid;
121
$this->pcg_version = $obj->pcg_version;
122
$this->
ref
= $obj->pcg_version;
123
$this->label = $obj->label;
124
$this->active = $obj->active;
125
126
return
$this->id;
127
}
else
{
128
return
0;
129
}
130
}
else
{
131
$this->error =
"Error "
.$this->db->lasterror();
132
$this->errors[] =
"Error "
.$this->db->lasterror();
133
}
134
}
135
return
-1;
136
}
137
138
145
public
function
create
($user)
146
{
147
$now =
dol_now
();
148
149
$sql =
"INSERT INTO "
.MAIN_DB_PREFIX.
"accounting_system"
;
150
$sql .=
" (date_creation, fk_user_author, numero, label)"
;
151
$sql .=
" VALUES ('"
.$this->db->idate($now).
"',"
.((int) $user->id).
",'"
.$this->db->escape($this->numero).
"','"
.$this->db->escape($this->label).
"')"
;
152
153
dol_syslog
(get_class($this).
"::create"
, LOG_DEBUG);
154
$resql = $this->db->query($sql);
155
if
($resql) {
156
$id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"accounting_system"
);
157
158
if
($id > 0) {
159
$this->
rowid
= $id;
160
$result = $this->rowid;
161
}
else
{
162
$result = - 2;
163
$this->error =
"AccountancySystem::Create Error $result"
;
164
dol_syslog
($this->error, LOG_ERR);
165
}
166
}
else
{
167
$result = - 1;
168
$this->error =
"AccountancySystem::Create Error $result"
;
169
dol_syslog
($this->error, LOG_ERR);
170
}
171
172
return
$result;
173
}
174
}
ref
$object ref
Definition
info.php:78
AccountancySystem
Class to manage accountancy systems.
Definition
accountancysystem.class.php:30
AccountancySystem\fetch
fetch($rowid=0, $ref='')
Load record in memory.
Definition
accountancysystem.class.php:99
AccountancySystem\create
create($user)
Insert accountancy system name into database.
Definition
accountancysystem.class.php:145
AccountancySystem\__construct
__construct($db)
Constructor.
Definition
accountancysystem.class.php:86
dol_now
dol_now($mode='auto')
Return date for now.
Definition
functions.lib.php:3103
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition
functions.lib.php:1788
rowid
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid
Definition
invoice.php:1632
Generated on Mon Sep 2 2024 01:00:19 for
dolibarr
by Doxygen 1.11.0