dolibarr  13.0.2
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 
30 {
34  public $db;
35 
39  public $error = '';
40 
44  public $rowid;
45 
49  public $fk_pcg_version;
50 
54  public $pcg_type;
55 
59  public $numero;
60 
64  public $label;
65 
69  public $account_number;
70 
74  public $account_parent;
75 
81  public function __construct($db)
82  {
83  $this->db = $db;
84  }
85 
86 
94  public function fetch($rowid = 0, $ref = '')
95  {
96  global $conf;
97 
98  if ($rowid > 0 || $ref)
99  {
100  $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
101  $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
102  $sql .= " WHERE";
103  if ($rowid) {
104  $sql .= " a.rowid = ".((int) $rowid);
105  } elseif ($ref) {
106  $sql .= " a.pcg_version = '".$this->db->escape($ref)."'";
107  }
108 
109  dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
110  $result = $this->db->query($sql);
111  if ($result) {
112  $obj = $this->db->fetch_object($result);
113 
114  if ($obj) {
115  $this->id = $obj->rowid;
116  $this->rowid = $obj->rowid;
117  $this->pcg_version = $obj->pcg_version;
118  $this->ref = $obj->pcg_version;
119  $this->label = $obj->label;
120  $this->active = $obj->active;
121 
122  return $this->id;
123  } else {
124  return 0;
125  }
126  } else {
127  $this->error = "Error ".$this->db->lasterror();
128  $this->errors[] = "Error ".$this->db->lasterror();
129  }
130  }
131  return -1;
132  }
133 
134 
141  public function create($user)
142  {
143  $now = dol_now();
144 
145  $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
146  $sql .= " (date_creation, fk_user_author, numero, label)";
147  $sql .= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')";
148 
149  dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
150  $resql = $this->db->query($sql);
151  if ($resql) {
152  $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system");
153 
154  if ($id > 0) {
155  $this->rowid = $id;
156  $result = $this->rowid;
157  } else {
158  $result = - 2;
159  $this->error = "AccountancySystem::Create Error $result";
160  dol_syslog($this->error, LOG_ERR);
161  }
162  } else {
163  $result = - 1;
164  $this->error = "AccountancySystem::Create Error $result";
165  dol_syslog($this->error, LOG_ERR);
166  }
167 
168  return $result;
169  }
170 }
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
dol_now($mode= 'auto')
Return date for now.
$conf db
API class for accounts.
Definition: inc.php:54
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
__construct($db)
Constructor.
Class to manage accountancy systems.
create($user)
Insert accountancy system name into database.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
fetch($rowid=0, $ref= '')
Load record in memory.