36 public $element =
'cpaiement';
41 public $table_element =
'c_paiement';
54 public $accountancy_code;
84 if (isset($this->
code)) {
87 if (isset($this->libelle)) {
88 $this->libelle = trim($this->libelle);
90 if (isset($this->label)) {
91 $this->label = trim($this->label);
93 if (isset($this->
type)) {
96 if (isset($this->active)) {
97 $this->active = trim($this->active);
99 if (isset($this->accountancy_code)) {
100 $this->accountancy_code = trim($this->accountancy_code);
102 if (isset($this->module)) {
103 $this->module = trim($this->module);
112 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.
'(';
118 $sql .=
'accountancy_code,';
120 $sql .=
') VALUES (';
121 $sql .=
' '.(!isset($this->entity) ?
getEntity(
'c_paiement') : $this->entity).
',';
122 $sql .=
' '.(!isset($this->
code) ?
'NULL' :
"'".$this->db->escape($this->
code).
"'").
',';
123 $sql .=
' '.(!isset($this->libelle) ?
'NULL' :
"'".$this->db->escape($this->libelle).
"'").
',';
124 $sql .=
' '.(!isset($this->
type) ?
'NULL' : $this->type).
',';
125 $sql .=
' '.(!isset($this->active) ?
'NULL' : $this->active).
',';
126 $sql .=
' '.(!isset($this->accountancy_code) ?
'NULL' :
"'".$this->db->escape($this->accountancy_code).
"'").
',';
127 $sql .=
' '.(!isset($this->module) ?
'NULL' :
"'".$this->db->escape($this->module).
"'");
135 $this->errors[] =
'Error '.$this->db->lasterror();
136 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
140 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
155 $this->
db->rollback();
173 public function fetch($id, $ref =
null)
180 $sql .=
" t.libelle as label,";
182 $sql .=
" t.active,";
183 $sql .=
" t.accountancy_code,";
185 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
187 $sql .=
' WHERE t.entity IN ('.getEntity(
'c_paiement').
')';
188 $sql .=
" AND t.code = '".$this->db->escape($ref).
"'";
190 $sql .=
' WHERE t.id = '.((int) $id);
195 $numrows = $this->
db->num_rows(
$resql);
197 $obj = $this->
db->fetch_object(
$resql);
199 $this->
id = $obj->id;
201 $this->
code = $obj->code;
202 $this->libelle = $obj->label;
203 $this->label = $obj->label;
204 $this->
type = $obj->type;
205 $this->active = $obj->active;
206 $this->accountancy_code = $obj->accountancy_code;
207 $this->module = $obj->module;
217 $this->errors[] =
'Error '.$this->db->lasterror();
218 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
240 if (isset($this->
code)) {
243 if (isset($this->libelle)) {
244 $this->libelle = trim($this->libelle);
246 if (isset($this->label)) {
247 $this->label = trim($this->label);
249 if (isset($this->
type)) {
252 if (isset($this->active)) {
253 $this->active = trim($this->active);
255 if (isset($this->accountancy_code)) {
256 $this->accountancy_code = trim($this->accountancy_code);
258 if (isset($this->module)) {
259 $this->module = trim($this->module);
268 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET';
269 $sql .=
' id = '.(isset($this->
id) ? $this->id :
"null").
',';
270 $sql .=
' code = '.(isset($this->
code) ?
"'".$this->db->escape($this->
code).
"'" :
"null").
',';
271 $sql .=
' libelle = '.(isset($this->libelle) ?
"'".$this->db->escape($this->libelle).
"'" :
"null").
',';
272 $sql .=
' type = '.(isset($this->
type) ? $this->
type :
"null").
',';
273 $sql .=
' active = '.(isset($this->active) ? $this->active :
"null").
',';
274 $sql .=
' accountancy_code = '.(isset($this->accountancy_code) ?
"'".$this->db->escape($this->accountancy_code).
"'" :
"null").
',';
275 $sql .=
' module = '.(isset($this->module) ?
"'".$this->db->escape($this->module).
"'" :
"null");
276 $sql .=
' WHERE id = '.((int) $this->
id);
283 $this->errors[] =
'Error '.$this->db->lasterror();
284 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
299 $this->
db->rollback();
317 public function delete(
User $user, $notrigger =
false)
336 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
337 $sql .=
' WHERE id = '.((int) $this->
id);
342 $this->errors[] =
'Error '.$this->db->lasterror();
343 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
349 $this->
db->rollback();
375 $this->accountancy_code =
'';
create(User $user, $notrigger=false)
Create object into database.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null)
Load object in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
update(User $user, $notrigger=false)
Update object into database.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db
API class for accounts.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...