46 public $errors = array();
99 public function fetch($rowid = 0, $ref =
'')
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";
108 $sql .=
" a.rowid = ".((int) $rowid);
110 $sql .=
" a.pcg_version = '".$this->db->escape($ref).
"'";
113 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
114 $result = $this->db->query($sql);
116 $obj = $this->db->fetch_object($result);
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;
131 $this->error =
"Error ".$this->db->lasterror();
132 $this->errors[] =
"Error ".$this->db->lasterror();
149 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"accounting_system";
150 $sql .=
" (date_creation, fk_user_author, label, pcg_version, active)";
152 . $this->db->idate($now) .
"',"
153 . ((int) $user->id) .
",'"
154 . $this->db->escape($this->label) .
"','"
155 . $this->db->escape($this->pcg_version) .
"',"
156 . ((int) $this->active) .
")";
158 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
159 $resql = $this->db->query($sql);
161 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"accounting_system");
166 $result = $this->rowid;
169 $this->error =
"AccountancySystem::Create Error $result: " . $this->db->lasterror();
174 $this->error =
"AccountancySystem::Create Error $result: " . $this->db->lasterror();
Class to manage accountancy systems.
fetch($rowid=0, $ref='')
Load record in memory.
create($user)
Insert accountancy system name into database.
__construct($db)
Constructor.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
dol_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.