dolibarr 25.0.0-alpha
api_bankaccounts.class.php
1<?php
2/*
3 * Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
4 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22use Luracast\Restler\RestException;
23
24require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
25require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/bankcateg.class.php';
26require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
27
36{
40 public static $FIELDS = array(
41 'ref',
42 'label',
43 'type',
44 'currency_code',
45 'country_id'
46 );
47
51 public function __construct()
52 {
53 global $db;
54 $this->db = $db;
55 }
56
73 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '', $properties = '')
74 {
75 $list = array();
76
77 if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
78 throw new RestException(403);
79 }
80
81 $sql = "SELECT t.rowid FROM ".MAIN_DB_PREFIX."bank_account AS t LEFT JOIN ".MAIN_DB_PREFIX."bank_account_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
82 if ($category > 0) {
83 $sql .= ", " . MAIN_DB_PREFIX . "categorie_account as c";
84 }
85 $sql .= ' WHERE t.entity IN (' . getEntity('bank_account') . ')';
86 // Select accounts of given category
87 if ($category > 0) {
88 $sql .= " AND c.fk_categorie = " . ((int) $category) . " AND c.fk_account = t.rowid";
89 }
90 // Add sql filters
91 if ($sqlfilters) {
92 $errormessage = '';
93 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
94 if ($errormessage) {
95 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
96 }
97 }
98
99 $sql .= $this->db->order($sortfield, $sortorder);
100 if ($limit) {
101 if ($page < 0) {
102 $page = 0;
103 }
104 $offset = $limit * $page;
105
106 $sql .= $this->db->plimit($limit + 1, $offset);
107 }
108
109 dol_syslog("API Rest request");
110 $result = $this->db->query($sql);
111
112 if ($result) {
113 $num = $this->db->num_rows($result);
114 $min = min($num, ($limit <= 0 ? $num : $limit));
115 for ($i = 0; $i < $min; $i++) {
116 $obj = $this->db->fetch_object($result);
117 $account = new Account($this->db);
118 if ($account->fetch($obj->rowid) > 0) {
119 $account->balance = $account->solde(1); // 1=Exclude future operation date
120 $list[] = $this->_filterObjectProperties($this->_cleanObjectDatas($account), $properties);
121 }
122 }
123 } else {
124 throw new RestException(503, 'Error when retrieving list of accounts: ' . $this->db->lasterror());
125 }
126
127 return $list;
128 }
129
138 public function get($id)
139 {
140 if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
141 throw new RestException(403);
142 }
143
144 $account = new Account($this->db);
145 $result = $account->fetch($id);
146 if (!$result) {
147 throw new RestException(404, 'account not found');
148 }
149
150 return $this->_cleanObjectDatas($account);
151 }
152
161 public function post($request_data = null)
162 {
163 if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
164 throw new RestException(403);
165 }
166 // Check mandatory fields
167 $this->_validate($request_data);
168
169 $account = new Account($this->db);
170 // Date of the initial balance (required to create an account).
171 $account->date_solde = dol_now();
172 foreach ($request_data as $field => $value) {
173 if ($field === 'caller') {
174 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
175 $account->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
176 continue;
177 }
178
179 $account->$field = $this->_checkValForAPI($field, $value, $account);
180 }
181
182 if ($account->create(DolibarrApiAccess::$user) < 0) {
183 throw new RestException(500, 'Error creating bank account', array_merge(array($account->error), $account->errors));
184 }
185 return $account->id;
186 }
187
212 public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0, $cheque_number = "")
213 {
214 if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
215 throw new RestException(403);
216 }
217
218 require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
219
220 $accountfrom = new Account($this->db);
221 $resultAccountFrom = $accountfrom->fetch($bankaccount_from_id);
222
223 if ($resultAccountFrom === 0) {
224 throw new RestException(404, 'The BankAccount for bankaccount_from_id provided does not exist.');
225 }
226
227 $accountto = new Account($this->db);
228 $resultAccountTo = $accountto->fetch($bankaccount_to_id);
229
230 if ($resultAccountTo === 0) {
231 throw new RestException(404, 'The BankAccount for bankaccount_to_id provided does not exist.');
232 }
233
234 if ($accountto->currency_code == $accountfrom->currency_code) {
235 $amount_to = $amount;
236 } else {
237 if (!$amount_to || empty($amount_to)) {
238 throw new RestException(422, 'You must provide amount_to value since bankaccount_from and bankaccount_to does not share the same currency.');
239 }
240 }
241
242 if ($amount_to < 0) {
243 throw new RestException(422, 'You must provide a positive value for amount.');
244 }
245
246 if ($accountto->id == $accountfrom->id) {
247 throw new RestException(422, 'bankaccount_from_id and bankaccount_to_id must be different !');
248 }
249
250 $this->db->begin();
251
252 $error = 0;
253 $bank_line_id_from = 0;
254 $bank_line_id_to = 0;
255 $result = 0;
256 $user = DolibarrApiAccess::$user;
257
258 // By default, electronic transfer from bank to bank
259 $typefrom = 'PRE';
260 $typeto = 'VIR';
261
262 if ($accountto->type == Account::TYPE_CASH || $accountfrom->type == Account::TYPE_CASH) {
263 // This is transfer of change
264 $typefrom = 'LIQ';
265 $typeto = 'LIQ';
266 }
267
268 // Clean data
269 $description = sanitizeVal($description, 'alphanohtml');
270 $cheque_number = sanitizeVal($cheque_number, 'alphanohtml');
271
276 if (!$error) {
277 $bank_line_id_from = $accountfrom->addline((int) $date, $typefrom, $description, -1 * (float) price2num($amount), '', 0, $user, $cheque_number);
278 }
279 if (!($bank_line_id_from > 0)) {
280 $error++;
281 }
282
283 if (!$error) {
284 $bank_line_id_to = $accountto->addline((int) $date, $typeto, $description, (float) price2num($amount_to), '', 0, $user, $cheque_number);
285 }
286 if (!($bank_line_id_to > 0)) {
287 $error++;
288 }
289
294 $url = DOL_URL_ROOT . '/compta/bank/line.php?rowid=';
295 $label = '(banktransfert)';
296 $type = 'banktransfert';
297
298 if (!$error) {
299 $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, $url, $label, $type);
300 }
301 if (!($result > 0)) {
302 $error++;
303 }
304
305 if (!$error) {
306 $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, $url, $label, $type);
307 }
308 if (!($result > 0)) {
309 $error++;
310 }
311
312 if (!$error) {
313 $this->db->commit();
314
315 return array(
316 'success' => array(
317 'code' => 201,
318 'message' => 'Internal wire transfer created successfully.',
319 'bank_id_from' => $bank_line_id_from,
320 'bank_id_to' => $bank_line_id_to,
321 )
322 );
323 } else {
324 $this->db->rollback();
325 throw new RestException(500, $accountfrom->errorsToString() . ' ' . $accountto->errorsToString());
326 }
327 }
328
338 public function put($id, $request_data = null)
339 {
340 if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
341 throw new RestException(403);
342 }
343
344 $account = new Account($this->db);
345 $result = $account->fetch($id);
346 if (!$result) {
347 throw new RestException(404, 'account not found');
348 }
349
350 foreach ($request_data as $field => $value) {
351 if ($field == 'id') {
352 continue;
353 }
354 if ($field === 'caller') {
355 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
356 $account->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
357 continue;
358 }
359
360 if ($field == 'array_options' && is_array($value)) {
361 foreach ($value as $index => $val) {
362 $account->array_options[$index] = $this->_checkValExtrafieldsForAPI($index, $val, $account);
363 }
364 continue;
365 }
366 $account->$field = $this->_checkValForAPI($field, $value, $account);
367 }
368
369 if ($account->update(DolibarrApiAccess::$user) > 0) {
370 return $this->get($id);
371 } else {
372 throw new RestException(500, $account->errorsToString());
373 }
374 }
375
384 public function delete($id)
385 {
386 if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) {
387 throw new RestException(403);
388 }
389 $account = new Account($this->db);
390 $result = $account->fetch($id);
391 if (!$result) {
392 throw new RestException(404, 'account not found');
393 }
394
395 if ($account->delete(DolibarrApiAccess::$user) < 0) {
396 throw new RestException(500, 'error when deleting account');
397 }
398
399 return array(
400 'success' => array(
401 'code' => 200,
402 'message' => 'account deleted'
403 )
404 );
405 }
406
415 private function _validate($data)
416 {
417 if ($data === null) {
418 $data = array();
419 }
420 $account = array();
421 foreach (BankAccounts::$FIELDS as $field) {
422 if (!isset($data[$field])) {
423 throw new RestException(400, "$field field missing");
424 }
425 $account[$field] = $data[$field];
426 }
427 return $account;
428 }
429
430 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
440 protected function _cleanObjectDatas($object)
441 {
442 // phpcs:enable
443 $object = parent::_cleanObjectDatas($object);
444
445 unset($object->rowid);
446
447 return $object;
448 }
449
463 public function getLines($id, $sqlfilters = '')
464 {
465 $list = array();
466
467 if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
468 throw new RestException(403);
469 }
470
471 $account = new Account($this->db);
472 $result = $account->fetch($id);
473 if (!$result) {
474 throw new RestException(404, 'account not found');
475 }
476
477 $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "bank ";
478 $sql .= " WHERE fk_account = " . ((int) $id);
479
480 // Add sql filters
481 if ($sqlfilters) {
482 $errormessage = '';
483 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
484 if ($errormessage) {
485 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
486 }
487 }
488
489 $sql .= " ORDER BY rowid";
490
491 $result = $this->db->query($sql);
492
493 if ($result) {
494 $num = $this->db->num_rows($result);
495 //$min = min($num, ($limit <= 0 ? $num : $limit));
496 for ($i = 0; $i < $num; $i++) {
497 $obj = $this->db->fetch_object($result);
498 $accountLine = new AccountLine($this->db);
499 if ($accountLine->fetch($obj->rowid) > 0) {
500 $list[] = $this->_cleanObjectDatas($accountLine);
501 }
502 }
503 } else {
504 throw new RestException(503, 'Error when retrieving list of account lines: ' . $this->db->lasterror());
505 }
506
507 return $list;
508 }
509
529 public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '', $accountancycode = '', $datev = null, $num_releve = '')
530 {
531 if (!DolibarrApiAccess::$user->hasRight('banque', 'modifier')) {
532 throw new RestException(403);
533 }
534
535 $account = new Account($this->db);
536 $result = $account->fetch($id);
537 if (!$result) {
538 throw new RestException(404, 'account not found');
539 }
540
541 $type = sanitizeVal($type);
542 $label = sanitizeVal($label);
543 $cheque_number = sanitizeVal($cheque_number);
544 $cheque_writer = sanitizeVal($cheque_writer);
545 $cheque_bank = sanitizeVal($cheque_bank);
546 $accountancycode = sanitizeVal($accountancycode);
547 $num_releve = sanitizeVal($num_releve);
548
549 $result = $account->addline(
550 (int) $date,
551 $type,
552 $label,
553 $amount,
554 $cheque_number,
555 $category,
556 DolibarrApiAccess::$user,
557 $cheque_writer,
558 $cheque_bank,
559 $accountancycode,
560 (int) $datev,
561 $num_releve
562 );
563 if ($result < 0) {
564 throw new RestException(503, 'Error when adding line to account: ' . $account->errorsToString());
565 }
566 return $result;
567 }
568
582 public function addLink($id, $line_id, $url_id, $url, $label, $type)
583 {
584 if (!DolibarrApiAccess::$user->hasRight('banque', 'modifier')) {
585 throw new RestException(403);
586 }
587
588 $account = new Account($this->db);
589 $result = $account->fetch($id);
590 if (!$result) {
591 throw new RestException(404, 'account not found');
592 }
593
594 $accountLine = new AccountLine($this->db);
595 $result = $accountLine->fetch($line_id);
596 if (!$result) {
597 throw new RestException(404, 'account line not found');
598 }
599
600 if ($accountLine->fk_account != $id) {
601 throw new RestException(400, 'Line does not belong to this account');
602 }
603
604 $url = sanitizeVal($url);
605 $label = sanitizeVal($label);
606 $type = sanitizeVal($type);
607
608 $result = $account->add_url_line($line_id, $url_id, $url, $label, $type);
609 if ($result < 0) {
610 throw new RestException(503, 'Error when adding link to account line: ' . $account->errorsToString());
611 }
612 return $result;
613 }
614
628 public function getLinks($id, $line_id)
629 {
630 if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
631 throw new RestException(403);
632 }
633
634 $account = new Account($this->db);
635 $result = $account->fetch($id);
636 if (!$result) {
637 throw new RestException(404, 'account not found');
638 }
639
640 $links = $account->get_url($line_id); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
641 foreach ($links as &$link) {
642 unset($link[0], $link[1], $link[2], $link[3]); // Remove the numeric keys
643 }
644
645 return $links;
646 }
647
657 public function getDetailAccountLine($line_id)
658 {
659 if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
660 throw new RestException(403);
661 }
662
663 $accountLine = new AccountLine($this->db);
664 $result = $accountLine->fetch($line_id);
665 if (!$result) {
666 throw new RestException(404, 'account Line not found');
667 }
668
669 return $this->_cleanObjectDatas($accountLine);
670 }
671
682 public function updateLine($id, $line_id, $label)
683 {
684 if (!DolibarrApiAccess::$user->hasRight('banque', 'modifier')) {
685 throw new RestException(403);
686 }
687
688 $account = new Account($this->db);
689 $result = $account->fetch($id);
690 if (!$result) {
691 throw new RestException(404, 'account not found');
692 }
693
694 $accountLine = new AccountLine($this->db);
695 $result = $accountLine->fetch($line_id);
696 if (!$result) {
697 throw new RestException(404, 'account line not found');
698 }
699
700 if ($accountLine->fk_account != $id) {
701 throw new RestException(400, 'Line does not belong to this account');
702 }
703
704 $accountLine->label = sanitizeVal($label);
705
706 $result = $accountLine->updateLabel();
707 if ($result < 0) {
708 throw new RestException(503, 'Error when updating link to account line: ' . $accountLine->errorsToString());
709 }
710 return $accountLine->id;
711 }
712
724 public function deleteLine($id, $line_id)
725 {
726 if (!DolibarrApiAccess::$user->hasRight('banque', 'modifier')) {
727 throw new RestException(403);
728 }
729
730 $account = new Account($this->db);
731 $result = $account->fetch($id);
732 if (!$result) {
733 throw new RestException(404, 'account not found');
734 }
735
736 $accountLine = new AccountLine($this->db);
737 $result = $accountLine->fetch($line_id);
738 if (!$result) {
739 throw new RestException(404, 'account line not found');
740 }
741
742 if ($accountLine->fk_account != $id) {
743 throw new RestException(400, 'Line does not belong to this account');
744 }
745
746 if ($accountLine->delete(DolibarrApiAccess::$user) < 0) {
747 throw new RestException(500, 'error when deleting account line');
748 }
749
750 return array(
751 'success' => array(
752 'code' => 200,
753 'message' => "account line $line_id deleted"
754 )
755 );
756 }
757
784 public function reconcile($id, $num_releve, $lines, $conciliated = 1, $catid = 0)
785 {
786 global $langs;
787
788 if (!DolibarrApiAccess::$user->hasRight('banque', 'lire') || !DolibarrApiAccess::$user->hasRight('banque', 'consolidate')) {
789 throw new RestException(403);
790 }
791
792 $account = new Account($this->db);
793 $result = $account->fetch($id);
794 if ($result <= 0) {
795 throw new RestException(404, 'account not found');
796 }
797 if (!DolibarrApi::_checkAccessToResource('banque', $account->id, 'bank_account&bank_account')) {
798 throw new RestException(403, 'Access to this bank account not allowed for login '.DolibarrApiAccess::$user->login);
799 }
800 if ($account->canBeConciliated() <= 0) {
801 throw new RestException(400, 'Account can not be reconciled (reconciliation disabled, cash account or closed account)');
802 }
803
804 $num_releve = trim(sanitizeVal($num_releve));
805 if ($num_releve === '' || dol_strlen($num_releve) > 50) {
806 throw new RestException(400, 'num_releve field missing or longer than 50 characters');
807 }
808 if (getDolGlobalString('BANK_STATEMENT_REGEX_RULE') && !preg_match('/'.getDolGlobalString('BANK_STATEMENT_REGEX_RULE').'/', $num_releve)) {
809 $langs->load("errors");
810 throw new RestException(400, $langs->transnoentitiesnoconv("ErrorBankStatementNameMustFollowRegex", getDolGlobalString('BANK_STATEMENT_REGEX_RULE')));
811 }
812 if (!is_array($lines) || empty($lines)) {
813 throw new RestException(400, 'lines field missing or empty');
814 }
815 $conciliated = empty($conciliated) ? 0 : 1;
816 $catid = (int) $catid;
817 if ($catid > 0) {
818 $bankcateg = new BankCateg($this->db);
819 if ($bankcateg->fetch($catid) <= 0 || empty($bankcateg->id)) {
820 throw new RestException(400, 'Bank category '.$catid.' not found');
821 }
822 }
823 $categorie = new Categorie($this->db);
824
825 // Check every line before the first write
826 $lineids = array();
827 $toupdate = array();
828 foreach (array_unique(array_map('intval', $lines)) as $line_id) {
829 $accountLine = new AccountLine($this->db);
830 if ($line_id <= 0 || $accountLine->fetch($line_id) <= 0) {
831 throw new RestException(404, 'account line '.$line_id.' not found');
832 }
833 if ($accountLine->fk_account != $id) {
834 throw new RestException(400, 'Line '.$line_id.' does not belong to this account');
835 }
836 if ($accountLine->rappro && (string) $accountLine->num_releve !== $num_releve) {
837 throw new RestException(409, 'Line '.$line_id.' is already reconciled with statement '.$accountLine->num_releve.', cannot reconcile it with '.$num_releve);
838 }
839 $lineids[] = $line_id;
840 if (!$accountLine->rappro) {
841 // update_conciliation() inserts the category link without checking it already exists
842 $linecat = 0;
843 if ($catid > 0) {
844 $linecats = $categorie->containing($line_id, Categorie::TYPE_BANK_LINE, 'id');
845 if (!is_array($linecats)) {
846 throw new RestException(503, 'Error when reading categories of account line '.$line_id);
847 }
848 $linecat = in_array($catid, $linecats) ? 0 : $catid;
849 }
850 $toupdate[] = array($accountLine, $linecat);
851 }
852 }
853
854 $this->db->begin();
855 foreach ($toupdate as list($accountLine, $linecat)) {
856 $accountLine->num_releve = $num_releve;
857 if ($accountLine->update_conciliation(DolibarrApiAccess::$user, $linecat, $conciliated) < 0) {
858 $errors = array_merge(array($accountLine->error, $this->db->lasterror()), $accountLine->errors);
859 $this->db->rollback();
860 throw new RestException(503, 'Error when reconciling account line '.$accountLine->id, $errors);
861 }
862 }
863 if (!$this->db->commit()) {
864 throw new RestException(503, 'Error when reconciling account lines: '.$this->db->lasterror());
865 }
866
867 return array(
868 'num_releve' => $num_releve,
869 'conciliated' => $conciliated,
870 'lines' => $lineids
871 );
872 }
873
883 public function getBalance($id)
884 {
885 if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) {
886 throw new RestException(403);
887 }
888
889 $account = new Account($this->db);
890 $result = $account->fetch($id);
891
892 if (!$result) {
893 throw new RestException(404, 'account not found');
894 }
895
896 $balance = $account->solde(1); //1=Exclude future operation date (this is to exclude input made in advance and have real account sold)
897
898 return $balance;
899 }
900}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage bank accounts.
const TYPE_CASH
Cash account.
Class to manage bank transaction lines.
post($request_data=null)
Create account object.
addLink($id, $line_id, $url_id, $url, $label, $type)
Add a link to an account line.
put($id, $request_data=null)
Update account.
_validate($data)
Validate fields before creating an object.
getLinks($id, $line_id)
Get the list of links for a line of the account.
transfer($bankaccount_from_id=0, $bankaccount_to_id=0, $date=null, $description="", $amount=0.0, $amount_to=0.0, $cheque_number="")
Create an internal wire transfer between two bank accounts.
__construct()
Constructor.
getBalance($id)
Get the current account balance.
addLine($id, $date, $type, $label, $amount, $category=0, $cheque_number='', $cheque_writer='', $cheque_bank='', $accountancycode='', $datev=null, $num_releve='')
Add a line to an account.
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $category=0, $sqlfilters='', $properties='')
Get the list of accounts.
getDetailAccountLine($line_id)
Get the detail of a given line of the bank account.
getLines($id, $sqlfilters='')
Get the list of lines of the account.
deleteLine($id, $line_id)
Delete an account line.
reconcile($id, $num_releve, $lines, $conciliated=1, $catid=0)
Reconcile account lines with a bank statement.
_cleanObjectDatas($object)
Clean sensible object datas @phpstan-template T.
updateLine($id, $line_id, $label)
Update an account line.
Class to manage bank categories.
Class to manage categories.
Class for API REST v1.
Definition api.class.php:35
_checkValExtrafieldsForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $parenttableforentity='')
Check access by user to a given resource.
dol_now($mode='gmt')
Return date for now.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
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.