dolibarr  9.0.0
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@zendsi.com>
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 <http://www.gnu.org/licenses/>.
18  */
19 
30 {
34  public $db;
35 
39  public $error='';
40 
44  public $rowid;
45 
49  public $fk_pcg_version;
50 
51  public $pcg_type;
52  public $pcg_subtype;
53 
57  public $label;
58 
59  public $account_number;
60  public $account_parent;
61 
67  function __construct($db)
68  {
69  $this->db = $db;
70  }
71 
72 
80  function fetch($rowid = 0, $ref = '')
81  {
82  global $conf;
83 
84  if ($rowid > 0 || $ref)
85  {
86  $sql = "SELECT a.pcg_version, a.label, a.active";
87  $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a";
88  $sql .= " WHERE";
89  if ($rowid) {
90  $sql .= " a.rowid = '" . $rowid . "'";
91  } elseif ($ref) {
92  $sql .= " a.pcg_version = '" . $ref . "'";
93  }
94 
95  dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
96  $result = $this->db->query($sql);
97  if ($result) {
98  $obj = $this->db->fetch_object($result);
99 
100  if ($obj) {
101  $this->id = $obj->rowid;
102  $this->rowid = $obj->rowid;
103  $this->pcg_version = $obj->pcg_version;
104  $this->ref = $obj->pcg_version;
105  $this->label = $obj->label;
106  $this->active = $obj->active;
107 
108  return $this->id;
109  } else {
110  return 0;
111  }
112  } else {
113  $this->error = "Error " . $this->db->lasterror();
114  $this->errors[] = "Error " . $this->db->lasterror();
115  }
116  }
117  return - 1;
118  }
119 
120 
127  function create($user)
128  {
129  $now = dol_now();
130 
131  $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system";
132  $sql .= " (date_creation, fk_user_author, numero, label)";
133  $sql .= " VALUES ('" . $this->db->idate($now) . "'," . $user->id . ",'" . $this->db->escape($this->numero) . "','" . $this->db->escape($this->label) . "')";
134 
135  dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
136  $resql = $this->db->query($sql);
137  if ($resql) {
138  $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system");
139 
140  if ($id > 0) {
141  $this->rowid = $id;
142  $result = $this->rowid;
143  } else {
144  $result = - 2;
145  $this->error = "AccountancySystem::Create Erreur $result";
146  dol_syslog($this->error, LOG_ERR);
147  }
148  } else {
149  $result = - 1;
150  $this->error = "AccountancySystem::Create Erreur $result";
151  dol_syslog($this->error, LOG_ERR);
152  }
153 
154  return $result;
155  }
156 }
print $object label
hash of file content (md5_file(dol_osencode($destfull))
Definition: edit.php:153
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
fetch($rowid=0, $ref='')
Load record in memory.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
__construct($db)
Constructor.
dol_now($mode='gmt')
Return date for now.
Class to manage accountancy systems.
create($user)
Insert accountancy system name into database.