18 use Luracast\Restler\RestException;
21 require_once DOL_DOCUMENT_ROOT.
'/core/lib/multicurrency.lib.php';
51 public function index($sortfield =
"t.rowid", $sortorder =
'ASC', $sqlfilters =
'')
57 $sql =
"SELECT t.rowid";
58 $sql .=
" FROM ".$this->db->prefix().
"multicurrency as t";
59 $sql .=
' WHERE 1 = 1';
64 throw new RestException(503,
'Error when validating parameter sqlfilters -> '.$errormessage);
66 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
67 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
70 $sql .= $this->
db->order($sortfield, $sortorder);
75 $offset = $limit * $page;
77 $sql .= $this->
db->plimit($limit + 1, $offset);
80 $result = $this->
db->query($sql);
83 $num = $this->
db->num_rows($result);
84 $min = min($num, ($limit <= 0 ? $num : $limit));
86 $obj = $this->
db->fetch_object($result);
88 if ($multicurrency_static->fetch($obj->rowid)) {
94 throw new RestException(503,
'Error when retrieve currencies list : '.$this->
db->lasterror());
96 if (!count($obj_ret)) {
97 throw new RestException(404,
'No currencies found');
113 $object = parent::_cleanObjectDatas($object);
116 foreach ($object as $key => $value) {
118 if ($key ==
"id" || $key ==
"code" || $key ==
"rate" || $key ==
"date_sync")
120 unset($object->$key);
_checkFilters($sqlfilters, &$error='')
Return if a $sqlfilters parameter is valid.
index($sortfield="t.rowid", $sortorder='ASC', $sqlfilters='')
Get a list of currencies.
__construct()
Constructor.
_cleanObjectDatas($object)
Clean sensible object datas.
$conf db
API class for accounts.