27use Luracast\Restler\RestException;
29require_once DOL_DOCUMENT_ROOT.
'/main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/api/class/api.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/cstate.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/cregion.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/ccountry.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/hrm/class/establishment.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
49 private $translations =
null;
79 public function getListOfActionTriggers($sortfield =
"t.rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $elementtype =
'', $lang =
'', $sqlfilters =
'')
83 if ($elementtype ==
'thirdparty') {
84 $elementtype =
'societe';
86 if ($elementtype ==
'contact') {
87 $elementtype =
'socpeople';
90 $sql =
"SELECT t.rowid as id, t.elementtype, t.code, t.contexts, t.label, t.description, t.rang";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger as t";
93 if (!empty($elementtype)) {
94 $sql .=
" AND t.elementtype = '".$this->db->escape($elementtype).
"'";
101 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
105 $sql .= $this->db->order($sortfield, $sortorder);
111 $offset = $limit * $page;
113 $sql .= $this->db->plimit($limit, $offset);
116 $result = $this->db->query($sql);
118 $num = $this->db->num_rows($result);
119 $min = min($num, ($limit <= 0 ? $num : $limit));
120 for ($i = 0; $i < $min; $i++) {
121 $type = $this->db->fetch_object($result);
126 throw new RestException(503,
'Error when retrieving list of action triggers : '.$this->db->lasterror());
152 public function getOrderingMethods($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
156 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
157 throw new RestException(403);
160 $sql =
"SELECT rowid, code, libelle as label, module";
161 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_method as t";
162 $sql .=
" WHERE t.active = ".((int) $active);
168 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
173 $sql .= $this->db->order($sortfield, $sortorder);
179 $offset = $limit * $page;
181 $sql .= $this->db->plimit($limit, $offset);
184 $result = $this->db->query($sql);
187 $num = $this->db->num_rows($result);
188 $min = min($num, ($limit <= 0 ? $num : $limit));
189 for ($i = 0; $i < $min; $i++) {
190 $list[] = $this->db->fetch_object($result);
193 throw new RestException(503, $this->db->lasterror());
218 public function getOrderingOrigins($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
222 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
223 throw new RestException(403);
226 $sql =
"SELECT rowid, code, label, module";
227 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_reason as t";
228 $sql .=
" WHERE t.active = ".((int) $active);
234 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
239 $sql .= $this->db->order($sortfield, $sortorder);
245 $offset = $limit * $page;
247 $sql .= $this->db->plimit($limit, $offset);
250 $result = $this->db->query($sql);
253 $num = $this->db->num_rows($result);
254 $min = min($num, ($limit <= 0 ? $num : $limit));
255 for ($i = 0; $i < $min; $i++) {
256 $list[] = $this->db->fetch_object($result);
259 throw new RestException(503, $this->db->lasterror());
285 public function getPaymentTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
289 if (!DolibarrApiAccess::$user->hasRight(
'propal',
'lire') && !DolibarrApiAccess::$user->hasRight(
'commande',
'lire') && !DolibarrApiAccess::$user->hasRight(
'facture',
'lire')) {
290 throw new RestException(403);
293 $sql =
"SELECT id, code, type, libelle as label, module";
294 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement as t";
295 $sql .=
" WHERE t.entity IN (".getEntity(
'c_paiement').
")";
296 $sql .=
" AND t.active = ".((int) $active);
302 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
307 $sql .= $this->db->order($sortfield, $sortorder);
313 $offset = $limit * $page;
315 $sql .= $this->db->plimit($limit, $offset);
318 $result = $this->db->query($sql);
321 $num = $this->db->num_rows($result);
322 $min = min($num, ($limit <= 0 ? $num : $limit));
323 for ($i = 0; $i < $min; $i++) {
324 $list[] = $this->db->fetch_object($result);
327 throw new RestException(503, $this->db->lasterror());
353 public function getListOfRegions($sortfield =
"code_region", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
359 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_regions as t";
360 $sql .=
" WHERE 1 = 1";
362 $sql .=
" AND t.fk_pays = ".((int) $country);
369 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
373 $sql .= $this->db->order($sortfield, $sortorder);
379 $offset = $limit * $page;
381 $sql .= $this->db->plimit($limit, $offset);
384 $result = $this->db->query($sql);
387 $num = $this->db->num_rows($result);
388 $min = min($num, ($limit <= 0 ? $num : $limit));
389 for ($i = 0; $i < $min; $i++) {
390 $obj = $this->db->fetch_object($result);
391 $region =
new Cregion($this->db);
392 if ($region->fetch($obj->rowid) > 0) {
393 if (empty($filter) || stripos((
string) $region->name, $filter) !==
false) {
399 throw new RestException(503,
'Error when retrieving list of regions');
465 public function getListOfStates($sortfield =
"code_departement", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
471 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_departements as t";
473 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as d ON t.fk_region = d.code_region";
475 $sql .=
" WHERE 1 = 1";
477 $sql .=
" AND d.fk_pays = ".((int) $country);
484 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
488 $sql .= $this->db->order($sortfield, $sortorder);
494 $offset = $limit * $page;
496 $sql .= $this->db->plimit($limit, $offset);
499 $result = $this->db->query($sql);
502 $num = $this->db->num_rows($result);
503 $min = min($num, ($limit <= 0 ? $num : $limit));
504 for ($i = 0; $i < $min; $i++) {
505 $obj = $this->db->fetch_object($result);
506 $state =
new Cstate($this->db);
507 if ($state->fetch($obj->rowid) > 0) {
508 if (empty($filter) || stripos((
string) $state->label, $filter) !==
false) {
514 throw new RestException(503,
'Error when retrieving list of states');
580 public function getListOfCountries($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $filter =
'', $lang =
'', $sqlfilters =
'')
586 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"c_country as t";
587 $sql .=
" WHERE 1 = 1";
593 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
597 $sql .= $this->db->order($sortfield, $sortorder);
603 $offset = $limit * $page;
605 $sql .= $this->db->plimit($limit, $offset);
608 $result = $this->db->query($sql);
611 $num = $this->db->num_rows($result);
612 $min = min($num, ($limit <= 0 ? $num : $limit));
613 for ($i = 0; $i < $min; $i++) {
614 $obj = $this->db->fetch_object($result);
616 if ($country->fetch($obj->rowid) > 0) {
621 if (empty($filter) || stripos((
string) $country->label, $filter) !==
false) {
627 throw new RestException(503,
'Error when retrieving list of countries');
701 $region =
new Cregion($this->db);
703 $result = $region->fetch(
$id, (
int) $code);
705 throw new RestException(503,
'Error when retrieving region : '.$region->error);
706 } elseif ($result == 0) {
707 throw new RestException(404,
'Region not found');
726 $state =
new Cstate($this->db);
728 $result = $state->fetch(
$id, $code);
730 throw new RestException(503,
'Error when retrieving state : '.$state->error);
731 } elseif ($result == 0) {
732 throw new RestException(404,
'State not found');
755 $result = $country->fetch(
$id, $code, $iso);
758 throw new RestException(503,
'Error when retrieving country : '.$country->error);
759 } elseif ($result == 0) {
760 throw new RestException(404,
'Country not found');
788 public function getAvailability($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
792 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
793 throw new RestException(403);
796 $sql =
"SELECT rowid, code, label";
797 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_availability as t";
798 $sql .=
" WHERE t.active = ".((int) $active);
804 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
809 $sql .= $this->db->order($sortfield, $sortorder);
815 $offset = $limit * $page;
817 $sql .= $this->db->plimit($limit, $offset);
820 $result = $this->db->query($sql);
823 $num = $this->db->num_rows($result);
824 $min = min($num, ($limit <= 0 ? $num : $limit));
825 for ($i = 0; $i < $min; $i++) {
826 $list[] = $this->db->fetch_object($result);
829 throw new RestException(503, $this->db->lasterror());
869 if ($this->translations ==
null || $this->translations->getDefaultLang() !== $lang) {
871 $this->translations =
new Translate(
'', $conf);
872 $this->translations->setDefaultLang($lang);
873 $this->translations->loadLangs($dict);
876 $key = $prefix.$object->code;
878 $translation = $this->translations->trans($key);
879 if ($translation != $key) {
880 $object->label = html_entity_decode($translation);
906 public function getListOfEventTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $sqlfilters =
'')
910 $sql =
"SELECT id, code, type, libelle as label, module";
911 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as t";
912 $sql .=
" WHERE t.active = ".((int) $active);
914 $sql .=
" AND t.type LIKE '%".$this->db->escape($type).
"%'";
917 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
924 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
929 $sql .= $this->db->order($sortfield, $sortorder);
935 $offset = $limit * $page;
937 $sql .= $this->db->plimit($limit, $offset);
940 $result = $this->db->query($sql);
943 $num = $this->db->num_rows($result);
944 $min = min($num, ($limit <= 0 ? $num : $limit));
945 for ($i = 0; $i < $min; $i++) {
946 $list[] = $this->db->fetch_object($result);
949 throw new RestException(503,
'Error when retrieving list of events types : '.$this->db->lasterror());
975 public function getListOfExpenseReportsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $sqlfilters =
'')
979 if (!DolibarrApiAccess::$user->hasRight(
'expensereport',
'lire')) {
980 throw new RestException(403);
983 $sql =
"SELECT id, code, label, accountancy_code, active, module, position";
984 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees as t";
985 $sql .=
" WHERE t.active = ".((int) $active);
987 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
994 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
999 $sql .= $this->db->order($sortfield, $sortorder);
1005 $offset = $limit * $page;
1007 $sql .= $this->db->plimit($limit, $offset);
1010 $result = $this->db->query($sql);
1013 $num = $this->db->num_rows($result);
1014 $min = min($num, ($limit <= 0 ? $num : $limit));
1015 for ($i = 0; $i < $min; $i++) {
1016 $list[] = $this->db->fetch_object($result);
1019 throw new RestException(503,
'Error when retrieving list of expense report types : '.$this->db->lasterror());
1045 public function getListOfHolidayTypes($sortfield =
"sortorder", $sortorder =
'ASC', $limit = 100, $page = 0, $fk_country =
'', $active = 1, $lang =
'', $sqlfilters =
'')
1048 $langs->loadLangs(array(
'holiday'));
1050 if (!DolibarrApiAccess::$user->hasRight(
'holiday',
'read')) {
1051 throw new RestException(403);
1056 $sql =
"SELECT rowid, code, label, affect, delay, newbymonth, fk_country";
1057 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_holiday_types as t";
1058 $sql .=
" WHERE t.entity IN (".getEntity(
'c_holiday_types').
")";
1059 $sql .=
" AND t.active = ".((int) $active);
1061 $sql .=
" AND (t.fk_country = ".((int) $fk_country);
1062 $sql .=
" OR t.fk_country is null)";
1068 if ($errormessage) {
1069 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1073 $sql .= $this->db->order($sortfield, $sortorder);
1079 $offset = $limit * $page;
1081 $sql .= $this->db->plimit($limit, $offset);
1084 $result = $this->db->query($sql);
1087 $num = $this->db->num_rows($result);
1088 $min = min($num, ($limit <= 0 ? $num : $limit));
1089 for ($i = 0; $i < $min; $i++) {
1090 $holiday = $this->db->fetch_object($result);
1091 $tmplabel = $langs->trans($holiday->code);
1092 if ($tmplabel != $holiday->code) {
1093 $holiday->label = $tmplabel;
1099 throw new RestException(503,
'Error when retrieving list of holiday : '.$this->db->lasterror());
1125 public function getListOfPublicHolidays($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $fk_country =
'', $active = 1, $lang =
'', $sqlfilters =
'')
1128 $langs->loadLangs(array(
'hrm'));
1130 if (!DolibarrApiAccess::$user->hasRight(
'holiday',
'lire')) {
1131 throw new RestException(403);
1136 $sql =
"SELECT id, code, dayrule, day, month, year, fk_country, code as label";
1137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_hrm_public_holiday as t";
1138 $sql .=
" WHERE t.entity IN (".getEntity(
'c_hrm_public_holiday').
")";
1139 $sql .=
" AND t.active = ".((int) $active);
1141 $sql .=
" AND (t.fk_country = ".((int) $fk_country);
1142 $sql .=
" OR t.fk_country is null)";
1148 if ($errormessage) {
1149 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1153 $sql .= $this->db->order($sortfield, $sortorder);
1159 $offset = $limit * $page;
1161 $sql .= $this->db->plimit($limit, $offset);
1164 $result = $this->db->query($sql);
1167 $num = $this->db->num_rows($result);
1168 $min = min($num, ($limit <= 0 ? $num : $limit));
1169 for ($i = 0; $i < $min; $i++) {
1170 $holiday = $this->db->fetch_object($result);
1171 $tmplabel = $langs->trans($holiday->code);
1172 if ($tmplabel != $holiday->code) {
1173 $holiday->label = $tmplabel;
1179 throw new RestException(503,
'Error when retrieving list of public holiday : '.$this->db->lasterror());
1206 public function getListOfContactTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
1210 if ($type ==
'expedition' && !
getDolGlobalInt(
'SHIPPING_USE_ITS_OWN_CONTACTS')) {
1214 $sql =
"SELECT rowid, code, element as type, libelle as label, source, module, position";
1215 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact as t";
1216 $sql .=
" WHERE t.active = ".((int) $active);
1218 $sql .=
" AND t.element LIKE '%".$this->db->escape($type).
"%'";
1221 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
1227 if ($errormessage) {
1228 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1233 $sql .= $this->db->order($sortfield, $sortorder);
1239 $offset = $limit * $page;
1241 $sql .= $this->db->plimit($limit, $offset);
1244 $result = $this->db->query($sql);
1247 $num = $this->db->num_rows($result);
1248 $min = min($num, ($limit <= 0 ? $num : $limit));
1249 for ($i = 0; $i < $min; $i++) {
1250 $contact_type = $this->db->fetch_object($result);
1251 $this->
translateLabel($contact_type, $lang,
'TypeContact_'.$contact_type->type.
'_'.$contact_type->source.
'_', array(
"eventorganization",
"resource",
"projects",
"contracts",
"bills",
"orders",
"agenda",
"propal",
"stocks",
"supplier_proposal",
"interventions",
"sendings",
"ticket"));
1252 $list[] = $contact_type;
1255 throw new RestException(503,
'Error when retrieving list of contacts types : '.$this->db->lasterror());
1281 public function getListOfCivilities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
1285 $sql =
"SELECT rowid, code, label, module";
1286 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_civility as t";
1287 $sql .=
" WHERE t.active = ".((int) $active);
1289 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
1295 if ($errormessage) {
1296 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1301 $sql .= $this->db->order($sortfield, $sortorder);
1307 $offset = $limit * $page;
1309 $sql .= $this->db->plimit($limit, $offset);
1312 $result = $this->db->query($sql);
1315 $num = $this->db->num_rows($result);
1316 $min = min($num, ($limit <= 0 ? $num : $limit));
1317 for ($i = 0; $i < $min; $i++) {
1318 $civility = $this->db->fetch_object($result);
1319 $this->
translateLabel($civility, $lang,
'Civility', array(
'dict'));
1320 $list[] = $civility;
1323 throw new RestException(503,
'Error when retrieving list of civility : '.$this->db->lasterror());
1348 public function getListOfCurrencies($multicurrency = 0, $sortfield =
"code_iso", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1351 $sql =
"SELECT t.code_iso, t.label, t.unicode";
1352 if (!empty($multicurrency)) {
1353 $sql .=
" , cr.date_sync, cr.rate ";
1355 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_currencies as t";
1356 if (!empty($multicurrency)) {
1357 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency as m ON m.code=t.code_iso";
1358 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
1360 $sql .=
" WHERE t.active = ".((int) $active);
1361 if (!empty($multicurrency)) {
1362 $sql .=
" AND m.entity IN (".getEntity(
'multicurrency').
")";
1363 if (!empty($multicurrency) && $multicurrency != 2) {
1364 $sql .=
" AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.
"multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
1372 if ($errormessage) {
1373 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1378 $sql .= $this->db->order($sortfield, $sortorder);
1384 $offset = $limit * $page;
1386 $sql .= $this->db->plimit($limit, $offset);
1389 $result = $this->db->query($sql);
1392 $num = $this->db->num_rows($result);
1393 $min = min($num, ($limit <= 0 ? $num : $limit));
1394 for ($i = 0; $i < $min; $i++) {
1395 $list[] = $this->db->fetch_object($result);
1398 throw new RestException(503,
'Error when retrieving list of currency : '.$this->db->lasterror());
1420 public function getListOfExtrafields($sortfield =
"t.pos", $sortorder =
'ASC', $elementtype =
'', $sqlfilters =
'')
1424 if (!DolibarrApiAccess::$user->admin
1426 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_EXTRAFIELDS');
1429 if ($elementtype ==
'thirdparty') {
1430 $elementtype =
'societe';
1432 if ($elementtype ==
'contact') {
1433 $elementtype =
'socpeople';
1436 $sql =
"SELECT t.rowid as id, t.name, t.entity, t.elementtype, t.label, t.type, t.size, t.fieldcomputed, t.fielddefault,";
1437 $sql .=
" t.fieldunique, t.fieldrequired, t.perms, t.enabled, t.pos, t.alwayseditable, t.param, t.list, t.printable,";
1438 $sql .=
" t.totalizable, t.langs, t.help, t.css, t.cssview, t.csslist, t.fk_user_author, t.fk_user_modif, t.datec, t.tms";
1439 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1440 $sql .=
" WHERE t.entity IN (".getEntity(
'extrafields').
")";
1441 if (!empty($elementtype)) {
1442 $sql .=
" AND t.elementtype = '".$this->db->escape($elementtype).
"'";
1448 if ($errormessage) {
1449 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1453 $sql .= $this->db->order($sortfield, $sortorder);
1455 $resql = $this->db->query($sql);
1457 if ($this->db->num_rows($resql)) {
1458 while ($tab = $this->db->fetch_object($resql)) {
1460 $list[$tab->elementtype][$tab->name][
'id'] = $tab->id;
1461 $list[$tab->elementtype][$tab->name][
'type'] = $tab->type;
1462 $list[$tab->elementtype][$tab->name][
'label'] = $tab->label;
1463 $list[$tab->elementtype][$tab->name][
'size'] = $tab->size;
1464 $list[$tab->elementtype][$tab->name][
'elementtype'] = $tab->elementtype;
1465 $list[$tab->elementtype][$tab->name][
'default'] = $tab->fielddefault;
1466 $list[$tab->elementtype][$tab->name][
'computed'] = $tab->fieldcomputed;
1467 $list[$tab->elementtype][$tab->name][
'unique'] = $tab->fieldunique;
1468 $list[$tab->elementtype][$tab->name][
'required'] = $tab->fieldrequired;
1469 $list[$tab->elementtype][$tab->name][
'param'] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1470 $list[$tab->elementtype][$tab->name][
'pos'] = $tab->pos;
1471 $list[$tab->elementtype][$tab->name][
'alwayseditable'] = $tab->alwayseditable;
1472 $list[$tab->elementtype][$tab->name][
'perms'] = $tab->perms;
1473 $list[$tab->elementtype][$tab->name][
'list'] = $tab->list;
1474 $list[$tab->elementtype][$tab->name][
'printable'] = $tab->printable;
1475 $list[$tab->elementtype][$tab->name][
'totalizable'] = $tab->totalizable;
1476 $list[$tab->elementtype][$tab->name][
'langs'] = $tab->langs;
1477 $list[$tab->elementtype][$tab->name][
'help'] = $tab->help;
1478 $list[$tab->elementtype][$tab->name][
'css'] = $tab->css;
1479 $list[$tab->elementtype][$tab->name][
'cssview'] = $tab->cssview;
1480 $list[$tab->elementtype][$tab->name][
'csslist'] = $tab->csslist;
1481 $list[$tab->elementtype][$tab->name][
'fk_user_author'] = $tab->fk_user_author;
1482 $list[$tab->elementtype][$tab->name][
'fk_user_modif'] = $tab->fk_user_modif;
1483 $list[$tab->elementtype][$tab->name][
'datec'] = $tab->datec;
1484 $list[$tab->elementtype][$tab->name][
'tms'] = $tab->tms;
1488 throw new RestException(503,
'Error when retrieving list of extra fields : '.$this->db->lasterror());
1507 if (!DolibarrApiAccess::$user->admin) {
1508 throw new RestException(403,
'Only an admin user can delete an extrafield by attrname and elementtype');
1513 $result = $extrafields->fetch_name_optionals_label($elementtype,
false, $attrname);
1515 throw new RestException(404,
'Extrafield not found from attrname and elementtype');
1518 if (!$extrafields->delete($attrname, $elementtype)) {
1519 throw new RestException(500,
'Error when delete extrafield : '.$extrafields->error);
1525 'message' =>
'Extrafield deleted from attrname and elementtype'
1548 if (!DolibarrApiAccess::$user->admin) {
1549 throw new RestException(403,
'Only an admin user can get list of extrafields');
1552 if ($elementtype ==
'thirdparty') {
1553 $elementtype =
'societe';
1555 if ($elementtype ==
'contact') {
1556 $elementtype =
'socpeople';
1559 $sql =
"SELECT t.rowid as id, t.name, t.entity, t.elementtype, t.label, t.type, t.size, t.fieldcomputed, t.fielddefault,";
1560 $sql .=
" t.fieldunique, t.fieldrequired, t.perms, t.enabled, t.pos, t.alwayseditable, t.param, t.list, t.printable,";
1561 $sql .=
" t.totalizable, t.langs, t.help, t.css, t.cssview, t.csslist, t.fk_user_author, t.fk_user_modif, t.datec, t.tms";
1562 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1563 $sql .=
" WHERE t.entity IN (".getEntity(
'extrafields').
")";
1564 $sql .=
" AND t.elementtype = '".$this->db->escape($elementtype).
"'";
1565 $sql .=
" AND t.name = '".$this->db->escape($attrname).
"'";
1567 $resql = $this->db->query($sql);
1569 if ($this->db->num_rows($resql)) {
1570 while ($tab = $this->db->fetch_object($resql)) {
1572 $answer[$tab->elementtype][$tab->name][
'id'] = $tab->id;
1573 $answer[$tab->elementtype][$tab->name][
'type'] = $tab->type;
1574 $answer[$tab->elementtype][$tab->name][
'label'] = $tab->label;
1575 $answer[$tab->elementtype][$tab->name][
'size'] = $tab->size;
1576 $answer[$tab->elementtype][$tab->name][
'elementtype'] = $tab->elementtype;
1577 $answer[$tab->elementtype][$tab->name][
'default'] = $tab->fielddefault;
1578 $answer[$tab->elementtype][$tab->name][
'computed'] = $tab->fieldcomputed;
1579 $answer[$tab->elementtype][$tab->name][
'unique'] = $tab->fieldunique;
1580 $answer[$tab->elementtype][$tab->name][
'required'] = $tab->fieldrequired;
1581 $answer[$tab->elementtype][$tab->name][
'param'] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1582 $answer[$tab->elementtype][$tab->name][
'pos'] = $tab->pos;
1583 $answer[$tab->elementtype][$tab->name][
'alwayseditable'] = $tab->alwayseditable;
1584 $answer[$tab->elementtype][$tab->name][
'perms'] = $tab->perms;
1585 $answer[$tab->elementtype][$tab->name][
'list'] = $tab->list;
1586 $answer[$tab->elementtype][$tab->name][
'printable'] = $tab->printable;
1587 $answer[$tab->elementtype][$tab->name][
'totalizable'] = $tab->totalizable;
1588 $answer[$tab->elementtype][$tab->name][
'langs'] = $tab->langs;
1589 $answer[$tab->elementtype][$tab->name][
'help'] = $tab->help;
1590 $answer[$tab->elementtype][$tab->name][
'css'] = $tab->css;
1591 $answer[$tab->elementtype][$tab->name][
'cssview'] = $tab->cssview;
1592 $answer[$tab->elementtype][$tab->name][
'csslist'] = $tab->csslist;
1593 $answer[$tab->elementtype][$tab->name][
'fk_user_author'] = $tab->fk_user_author;
1594 $answer[$tab->elementtype][$tab->name][
'fk_user_modif'] = $tab->fk_user_modif;
1595 $answer[$tab->elementtype][$tab->name][
'datec'] = $tab->datec;
1596 $answer[$tab->elementtype][$tab->name][
'tms'] = $tab->tms;
1599 throw new RestException(404,
'Extrafield not found from attrname and elementtype');
1602 throw new RestException(503,
'Error when retrieving list of extra fields : '.$this->db->lasterror());
1624 if (!DolibarrApiAccess::$user->admin) {
1625 throw new RestException(403,
'Only an admin user can create an extrafield');
1630 $result = $extrafields->fetch_name_optionals_label($elementtype,
false, $attrname);
1632 throw new RestException(409,
'Duplicate extrafield already found from attrname and elementtype');
1638 foreach ($request_data as $field => $value) {
1639 $extrafields->$field = $this->
_checkValForAPI($field, $value, $extrafields);
1642 $entity = DolibarrApiAccess::$user->entity;
1643 if (empty($entity)) {
1650 if ($request_data[
'label']) {
1651 $label = $request_data[
'label'];
1653 throw new RestException(400,
"label field absent in json at root level");
1656 $alwayseditable = $request_data[
'alwayseditable'];
1657 $default_value = $request_data[
'default'];
1658 $totalizable = $request_data[
'totalizable'];
1659 $printable = $request_data[
'printable'];
1660 $required = $request_data[
'required'];
1661 $langfile = $request_data[
'langfile'];
1662 $computed = $request_data[
'computed'];
1663 $unique = $request_data[
'unique'];
1664 $param = $request_data[
'param'];
1665 $perms = $request_data[
'perms'];
1666 $size = $request_data[
'size'];
1667 $type = $request_data[
'type'];
1668 $list = $request_data[
'list'];
1669 $help = $request_data[
'help'];
1670 $pos = $request_data[
'pos'];
1671 $moreparams = array();
1673 if (0 > $extrafields->addExtraField($attrname, $label, $type, (
int) $pos, $size, $elementtype, (
int) $unique, (
int) $required, $default_value, $param, (
int) $alwayseditable, $perms, $list, $help, $computed, (
string) $entity, $langfile, (
string) $enabled, (
int) $totalizable, (
int) $printable, $moreparams)) {
1674 throw new RestException(500,
'Error creating extrafield', array_merge(array($extrafields->errno), $extrafields->errors));
1677 $sql =
"SELECT t.rowid as id";
1678 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1679 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
1680 $sql .=
" AND name = '".$this->db->escape($attrname).
"'";
1682 $resql = $this->db->query($sql);
1684 if ($this->db->num_rows($resql)) {
1685 $tab = $this->db->fetch_object($resql);
1686 $id = (int) $tab->id;
1713 if (!DolibarrApiAccess::$user->admin) {
1714 throw new RestException(403,
'Only an admin user can create an extrafield');
1719 $result = $extrafields->fetch_name_optionals_label($elementtype,
false, $attrname);
1721 throw new RestException(404,
'Extrafield not found from attrname and elementtype');
1724 foreach ($request_data as $field => $value) {
1725 $extrafields->$field = $this->
_checkValForAPI($field, $value, $extrafields);
1728 $entity = DolibarrApiAccess::$user->entity;
1729 if (empty($entity)) {
1735 if ($request_data[
'label']) {
1736 $label = $request_data[
'label'];
1738 throw new RestException(400,
"label field absent in json at root level");
1741 $alwayseditable = $request_data[
'alwayseditable'];
1742 $default_value = $request_data[
'default'];
1743 $totalizable = $request_data[
'totalizable'];
1744 $printable = $request_data[
'printable'];
1745 $required = $request_data[
'required'];
1746 $langfile = $request_data[
'langfile'];
1747 $computed = $request_data[
'computed'];
1748 $unique = $request_data[
'unique'];
1749 $param = $request_data[
'param'];
1750 $perms = $request_data[
'perms'];
1751 $size = $request_data[
'size'];
1752 $type = $request_data[
'type'];
1753 $list = $request_data[
'list'];
1754 $help = $request_data[
'help'];
1755 $pos = $request_data[
'pos'];
1756 $moreparams = array();
1758 if (0 > $extrafields->updateExtraField($attrname, $label, $type, (
int) $pos, $size, $elementtype, (
int) $unique, (
int) $required, $default_value, $param, (
int) $alwayseditable, $perms, $list, $help, $computed, (
string) $entity, $langfile, (
string) $enabled, (
int) $totalizable, (
int) $printable, $moreparams)) {
1759 throw new RestException(500,
'Error updating extrafield', array_merge(array($extrafields->errno), $extrafields->errors));
1762 $sql =
"SELECT t.rowid as id";
1763 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1764 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
1765 $sql .=
" AND name = '".$this->db->escape($attrname).
"'";
1767 $resql = $this->db->query($sql);
1769 if ($this->db->num_rows($resql)) {
1770 $tab = $this->db->fetch_object($resql);
1771 $id = (int) $tab->id;
1802 public function getListOfTowns($sortfield =
"zip,town", $sortorder =
'ASC', $limit = 100, $page = 0, $zipcode =
'', $town =
'', $active = 1, $sqlfilters =
'')
1806 $sql =
"SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
1807 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ziptown as t";
1808 $sql .=
" WHERE t.active = ".((int) $active);
1810 $sql .=
" AND t.zip LIKE '%".$this->db->escape($zipcode).
"%'";
1813 $sql .=
" AND t.town LIKE '%".$this->db->escape($town).
"%'";
1819 if ($errormessage) {
1820 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1825 $sql .= $this->db->order($sortfield, $sortorder);
1831 $offset = $limit * $page;
1833 $sql .= $this->db->plimit($limit, $offset);
1836 $result = $this->db->query($sql);
1839 $num = $this->db->num_rows($result);
1840 $min = min($num, ($limit <= 0 ? $num : $limit));
1841 for ($i = 0; $i < $min; $i++) {
1842 $list[] = $this->db->fetch_object($result);
1845 throw new RestException(503,
'Error when retrieving list of towns : '.$this->db->lasterror());
1871 public function getPaymentTerms($sortfield =
"sortorder", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1875 if (!DolibarrApiAccess::$user->hasRight(
'propal',
'lire') && !DolibarrApiAccess::$user->hasRight(
'commande',
'lire') && !DolibarrApiAccess::$user->hasRight(
'facture',
'lire')) {
1876 throw new RestException(403);
1879 $sql =
"SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
1880 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
1881 $sql .=
" WHERE t.entity IN (".getEntity(
'c_payment_term').
")";
1882 $sql .=
" AND t.active = ".((int) $active);
1887 if ($errormessage) {
1888 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1893 $sql .= $this->db->order($sortfield, $sortorder);
1899 $offset = $limit * $page;
1901 $sql .= $this->db->plimit($limit, $offset);
1904 $result = $this->db->query($sql);
1907 $num = $this->db->num_rows($result);
1908 $min = min($num, ($limit <= 0 ? $num : $limit));
1909 for ($i = 0; $i < $min; $i++) {
1910 $list[] = $this->db->fetch_object($result);
1913 throw new RestException(503, $this->db->lasterror());
1937 public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1941 $sql =
"SELECT rowid as id, code, libelle as label, description, tracking, module";
1942 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as t";
1943 $sql .=
" WHERE t.entity IN (".getEntity(
'c_shipment_mode').
")";
1944 $sql .=
" AND t.active = ".((int) $active);
1949 if ($errormessage) {
1950 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1961 $offset = $limit * $page;
1963 $sql .= $this->db->plimit($limit, $offset);
1966 $result = $this->db->query($sql);
1969 $num = $this->db->num_rows($result);
1970 $min = min($num, ($limit <= 0 ? $num : $limit));
1971 for ($i = 0; $i < $min; $i++) {
1972 $method = $this->db->fetch_object($result);
1977 throw new RestException(503, $this->db->lasterror());
2001 public function getListOfMeasuringUnits($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
2005 $sql =
"SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
2006 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_units as t";
2007 $sql .=
" WHERE t.active = ".((int) $active);
2012 if ($errormessage) {
2013 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2018 $sql .= $this->db->order($sortfield, $sortorder);
2024 $offset = $limit * $page;
2026 $sql .= $this->db->plimit($limit, $offset);
2029 $result = $this->db->query($sql);
2032 $num = $this->db->num_rows($result);
2033 $min = min($num, ($limit <= 0 ? $num : $limit));
2034 for ($i = 0; $i < $min; $i++) {
2035 $list[] = $this->db->fetch_object($result);
2038 throw new RestException(503,
'Error when retrieving list of measuring units: '.$this->db->lasterror());
2063 public function getListOfLegalForm($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters =
'')
2067 $sql =
"SELECT t.rowid, t.code, t.fk_pays, t.libelle, t.isvatexempted, t.active, t.module, t.position";
2068 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_forme_juridique as t";
2069 $sql .=
" WHERE t.active = ".((int) $active);
2071 $sql .=
" AND t.fk_pays = ".((int) $country);
2077 if ($errormessage) {
2078 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2083 $sql .= $this->db->order($sortfield, $sortorder);
2089 $offset = $limit * $page;
2091 $sql .= $this->db->plimit($limit, $offset);
2094 $result = $this->db->query($sql);
2097 $num = $this->db->num_rows($result);
2098 $min = min($num, ($limit <= 0 ? $num : $limit));
2099 for ($i = 0; $i < $min; $i++) {
2100 $list[] = $this->db->fetch_object($result);
2103 throw new RestException(503,
'Error when retrieving list of legal form: '.$this->db->lasterror());
2127 public function getListOfStaff($sortfield =
"id", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
2131 $sql =
"SELECT t.id, t.code, t.libelle, t.active, t.module";
2132 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_effectif as t";
2133 $sql .=
" WHERE t.active = ".((int) $active);
2138 if ($errormessage) {
2139 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2144 $sql .= $this->db->order($sortfield, $sortorder);
2150 $offset = $limit * $page;
2152 $sql .= $this->db->plimit($limit, $offset);
2155 $result = $this->db->query($sql);
2158 $num = $this->db->num_rows($result);
2159 $min = min($num, ($limit <= 0 ? $num : $limit));
2160 for ($i = 0; $i < $min; $i++) {
2161 $list[] = $this->db->fetch_object($result);
2164 throw new RestException(503,
'Error when retrieving list of staff: '.$this->db->lasterror());
2188 public function getListOfsocialNetworks($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
2193 throw new RestException(400,
'API not available: this dictionary is not enabled by setup');
2198 $sql =
"SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active";
2199 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_socialnetworks as t";
2200 $sql .=
" WHERE t.entity IN (".getEntity(
'c_socialnetworks').
")";
2201 $sql .=
" AND t.active = ".((int) $active);
2206 if ($errormessage) {
2207 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2212 $sql .= $this->db->order($sortfield, $sortorder);
2218 $offset = $limit * $page;
2220 $sql .= $this->db->plimit($limit, $offset);
2223 $result = $this->db->query($sql);
2226 $num = $this->db->num_rows($result);
2227 $min = min($num, ($limit <= 0 ? $num : $limit));
2228 for ($i = 0; $i < $min; $i++) {
2229 $list[] = $this->db->fetch_object($result);
2232 throw new RestException(503,
'Error when retrieving list of social networks: '.$this->db->lasterror());
2257 public function getTicketsCategories($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
2261 $sql =
"SELECT rowid, code, pos, label, use_default, description";
2262 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category as t";
2263 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_category').
")";
2264 $sql .=
" AND t.active = ".((int) $active);
2269 if ($errormessage) {
2270 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2275 $sql .= $this->db->order($sortfield, $sortorder);
2281 $offset = $limit * $page;
2283 $sql .= $this->db->plimit($limit, $offset);
2286 $result = $this->db->query($sql);
2289 $num = $this->db->num_rows($result);
2290 $min = min($num, ($limit <= 0 ? $num : $limit));
2291 for ($i = 0; $i < $min; $i++) {
2292 $category = $this->db->fetch_object($result);
2293 $this->
translateLabel($category, $lang,
'TicketCategoryShort', array(
'ticket'));
2294 $list[] = $category;
2297 throw new RestException(503,
'Error when retrieving list of ticket categories : '.$this->db->lasterror());
2322 public function getTicketsSeverities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
2326 $sql =
"SELECT rowid, code, pos, label, use_default, color, description";
2327 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity as t";
2328 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_severity').
")";
2329 $sql .=
" AND t.active = ".((int) $active);
2334 if ($errormessage) {
2335 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2340 $sql .= $this->db->order($sortfield, $sortorder);
2346 $offset = $limit * $page;
2348 $sql .= $this->db->plimit($limit, $offset);
2351 $result = $this->db->query($sql);
2354 $num = $this->db->num_rows($result);
2355 $min = min($num, ($limit <= 0 ? $num : $limit));
2356 for ($i = 0; $i < $min; $i++) {
2357 $severity = $this->db->fetch_object($result);
2358 $this->
translateLabel($severity, $lang,
'TicketSeverityShort', array(
'ticket'));
2359 $list[] = $severity;
2362 throw new RestException(503,
'Error when retrieving list of ticket severities : '.$this->db->lasterror());
2387 public function getTicketsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
2391 $sql =
"SELECT rowid, code, pos, label, use_default, description";
2392 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type as t";
2393 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_type').
")";
2394 $sql .=
" AND t.active = ".((int) $active);
2400 if ($errormessage) {
2401 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2406 $sql .= $this->db->order($sortfield, $sortorder);
2412 $offset = $limit * $page;
2414 $sql .= $this->db->plimit($limit, $offset);
2417 $result = $this->db->query($sql);
2420 $num = $this->db->num_rows($result);
2421 $min = min($num, ($limit <= 0 ? $num : $limit));
2422 for ($i = 0; $i < $min; $i++) {
2423 $type = $this->db->fetch_object($result);
2424 $this->
translateLabel($type, $lang,
'TicketTypeShort', array(
'ticket'));
2428 throw new RestException(503,
'Error when retrieving list of ticket types : '.$this->db->lasterror());
2453 public function getThirdpartiesTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
2457 $sql =
"SELECT id, code, libelle as label, fk_country, module, position";
2458 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_typent as t";
2459 $sql .=
" WHERE t.active = ".((int) $active);
2465 if ($errormessage) {
2466 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2471 $sql .= $this->db->order($sortfield, $sortorder);
2477 $offset = $limit * $page;
2479 $sql .= $this->db->plimit($limit, $offset);
2482 $result = $this->db->query($sql);
2485 $num = $this->db->num_rows($result);
2486 $min = min($num, ($limit <= 0 ? $num : $limit));
2487 for ($i = 0; $i < $min; $i++) {
2488 $type = $this->db->fetch_object($result);
2493 throw new RestException(503,
'Error when retrieving list of thirdparty types : '.$this->db->lasterror());
2517 public function getListOfIncoterms($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
2521 $sql =
"SELECT rowid, code, active";
2522 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_incoterms as t";
2523 $sql .=
" WHERE 1=1";
2529 if ($errormessage) {
2530 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2535 $sql .= $this->db->order($sortfield, $sortorder);
2541 $offset = $limit * $page;
2543 $sql .= $this->db->plimit($limit, $offset);
2546 $result = $this->db->query($sql);
2549 $num = $this->db->num_rows($result);
2550 $min = min($num, ($limit <= 0 ? $num : $limit));
2551 for ($i = 0; $i < $min; $i++) {
2552 $type = $this->db->fetch_object($result);
2556 throw new RestException(503,
'Error when retrieving list of incoterm types : '.$this->db->lasterror());
2580 public function getListOfVAT($sortfield =
"taux", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $fk_country = -1, $sqlfilters =
'')
2585 $sql =
"SELECT rowid, code, type_vat, active, fk_pays, taux, localtax1, localtax2, localtax1_type, localtax2_type, note";
2586 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
2587 $sql .=
" WHERE 1=1";
2593 if ($errormessage) {
2594 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
2598 $sql .=
" AND active = ".((int) $active);
2600 if ($fk_country == -1)
2601 $sql .=
" AND fk_pays =".((int)
$mysoc->country_id);
2604 $sql .=
" AND fk_pays =".((int) $fk_country);
2606 $sql .= $this->db->order($sortfield, $sortorder);
2612 $offset = $limit * $page;
2614 $sql .= $this->db->plimit($limit, $offset);
2617 $result = $this->db->query($sql);
2620 $num = $this->db->num_rows($result);
2621 $min = min($num, ($limit <= 0 ? $num : $limit));
2622 for ($i = 0; $i < $min; $i++) {
2623 $type = $this->db->fetch_object($result);
2627 throw new RestException(503,
'Error when retrieving list of vat types : '.$this->db->lasterror());
2648 if (!DolibarrApiAccess::$user->admin
2650 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_COMPANY');
2660 unset(
$mysoc->effectif_id);
2661 unset(
$mysoc->forme_juridique_code);
2662 unset(
$mysoc->forme_juridique);
2663 unset(
$mysoc->mode_reglement_supplier_id);
2664 unset(
$mysoc->cond_reglement_supplier_id);
2665 unset(
$mysoc->transport_mode_supplier_id);
2666 unset(
$mysoc->fk_prospectlevel);
2669 unset(
$mysoc->total_tva);
2670 unset(
$mysoc->total_localtax1);
2671 unset(
$mysoc->total_localtax2);
2672 unset(
$mysoc->total_ttc);
2675 unset(
$mysoc->firstname);
2676 unset(
$mysoc->civility_id);
2680 unset(
$mysoc->fournisseur);
2681 unset(
$mysoc->contact_id);
2683 unset(
$mysoc->fk_incoterms);
2684 unset(
$mysoc->label_incoterms);
2685 unset(
$mysoc->location_incoterms);
2707 $sql =
"SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status";
2708 $sql .=
" FROM ".MAIN_DB_PREFIX.
"establishment as e";
2709 $sql .=
" WHERE e.entity IN (".getEntity(
'establishment').
')';
2714 $result = $this->db->query($sql);
2717 $num = $this->db->num_rows($result);
2718 $min = min($num, ($limit <= 0 ? $num : $limit));
2719 for ($i = 0; $i < $min; $i++) {
2720 $list[] = $this->db->fetch_object($result);
2723 throw new RestException(503,
'Error when retrieving list of establishments : '.$this->db->lasterror());
2744 $result = $establishment->fetch(
$id);
2746 throw new RestException(503,
'Error when retrieving establishment : '.$establishment->error);
2747 } elseif ($result == 0) {
2748 throw new RestException(404,
'Establishment not found');
2771 if (!DolibarrApiAccess::$user->admin
2773 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_CONST_READ');
2776 if (!preg_match(
'/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
2777 throw new RestException(400,
'Error Bad or unknown value for constantname');
2780 throw new RestException(403,
'Forbidden. This parameter can not be read with APIs');
2805 if (!DolibarrApiAccess::$user->admin
2807 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_CONST_READ');
2810 $sql =
"select name, value";
2811 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2812 $sql .=
" WHERE entity IN (".getEntity(
'const').
')';
2814 $result = $this->db->query($sql);
2817 $num = $this->db->num_rows($result);
2818 for ($i = 0; $i < $num; $i++) {
2819 $obj = $this->db->fetch_object($result);
2822 $list[$obj->name] = $obj->value;
2826 throw new RestException(503,
'Error when retrieving list of const : '.$this->db->lasterror());
2848 global $langs, $conf;
2850 if (!DolibarrApiAccess::$user->admin
2852 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK');
2855 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2856 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
2858 $langs->load(
"admin");
2860 $outexpectedchecksum =
'';
2861 $outcurrentchecksum =
'';
2864 $file_list = array(
'missing' => array(),
'updated' => array());
2869 $xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
2870 if (!preg_match(
'/\.zip$/i', $xmlfile) &&
dol_is_file($xmlfile.
'.zip')) {
2875 $xmlremote = (($target ==
'default' || $target ==
'local') ?
'' : $target);
2879 $param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
2883 if (empty($xmlremote)) {
2884 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
2886 if ($xmlremote && !preg_match(
'/^https?:\/\//i', $xmlremote)) {
2887 $langs->load(
"errors");
2888 throw new RestException(500, $langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote));
2890 if ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
2891 $langs->load(
"errors");
2892 throw new RestException(500, $langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'));
2895 if (LIBXML_VERSION < 20900) {
2899 libxml_disable_entity_loader(
true);
2902 if ($target ==
'local') {
2904 $xml = simplexml_load_file($xmlfile);
2906 throw new RestException(500, $langs->trans(
'XmlNotFound').
': /install/'.$xmlshortfile);
2909 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
2912 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] != 400 && $xmlarray[
'http_code'] != 404) {
2913 $xmlfile = $xmlarray[
'content'];
2915 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NONET);
2917 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
2918 throw new RestException(500, $errormsg);
2923 $checksumconcat = array();
2924 $file_list = array();
2928 if (is_object($xml->dolibarr_constants[0])) {
2931 $out .=
'<div class="div-table-responsive-no-min">';
2932 $out .=
'<table class="noborder">';
2933 $out .=
'<tr class="liste_titre">';
2934 $out .=
'<td>#</td>';
2935 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
2936 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
2937 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
2938 $out .=
'</tr>'.
"\n";
2941 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
2942 $constname = $constant[
'name'];
2943 $constvalue = (string) $constant;
2944 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
2950 $valueforchecksum = (empty($value) ?
'0' : $value);
2952 $checksumconcat[] = $valueforchecksum;
2955 $out .=
'<tr class="oddeven">';
2956 $out .=
'<td>'.$i.
'</td>'.
"\n";
2957 $out .=
'<td>'.dol_escape_htmltag($constname).
'</td>'.
"\n";
2958 $out .=
'<td class="center">'.dol_escape_htmltag($constvalue).
'</td>'.
"\n";
2959 $out .=
'<td class="center">'.dol_escape_htmltag($valueforchecksum).
'</td>'.
"\n";
2964 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2973 if (is_object($xml->dolibarr_htdocs_dir[0])) {
2974 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
2977 $regextoinclude =
'\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|bak|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
2978 $regextoexclude =
'('.($includecustom ?
'' :
'custom|').
'documents|escpos-php\/doc|escpos-php\/example|escpos-php\/test|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$';
2979 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
2982 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
2983 '@phan-var-force array{insignature:string[],missing?:array<array{filename:string,expectedmd5:string,expectedsize:string}>,updated:array<array{filename:string,expectedmd5:string,expectedsize:string,md5:string}>} $file_list';
2985 foreach ($scanfiles as $keyfile => $valfile) {
2986 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
2987 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
2988 $md5newfile = @md5_file($valfile[
'fullname']);
2989 $file_list[
'added'][] = array(
'filename' => $tmprelativefilename,
'md5' => $md5newfile);
2996 $out .=
'<div class="div-table-responsive-no-min">';
2997 $out .=
'<table class="noborder">';
2998 $out .=
'<tr class="liste_titre">';
2999 $out .=
'<td>#</td>';
3000 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
3001 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
3002 $out .=
'</tr>'.
"\n";
3003 $tmpfilelist =
dol_sort_array($file_list[
'missing'],
'filename');
3004 if (is_array($tmpfilelist) && count($tmpfilelist)) {
3006 foreach ($tmpfilelist as $file) {
3008 $out .=
'<tr class="oddeven">';
3009 $out .=
'<td>'.$i.
'</td>'.
"\n";
3010 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
3011 $out .=
'<td class="center">'.(array_key_exists(
'expectedmd5', $file) ? $file[
'expectedmd5'] :
'').
'</td>'.
"\n";
3015 $out .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
3026 $out .=
'<div class="div-table-responsive-no-min">';
3027 $out .=
'<table class="noborder">';
3028 $out .=
'<tr class="liste_titre">';
3029 $out .=
'<td>#</td>';
3030 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
3031 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
3032 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
3033 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
3034 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
3035 $out .=
'</tr>'.
"\n";
3036 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
3037 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
3039 foreach ($tmpfilelist2 as $file) {
3041 $out .=
'<tr class="oddeven">';
3042 $out .=
'<td>'.$i.
'</td>'.
"\n";
3043 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
3044 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
3045 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
3046 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
3047 $totalsize += $size;
3048 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
3049 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
3052 $out .=
'<tr class="liste_total">';
3053 $out .=
'<td></td>'.
"\n";
3054 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
3055 $out .=
'<td align="center"></td>'.
"\n";
3056 $out .=
'<td align="center"></td>'.
"\n";
3057 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
3058 $out .=
'<td class="right"></td>'.
"\n";
3061 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
3072 $out .=
'<div class="div-table-responsive-no-min">';
3073 $out .=
'<table class="noborder">';
3074 $out .=
'<tr class="liste_titre">';
3075 $out .=
'<td>#</td>';
3076 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
3077 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
3078 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
3079 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
3080 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
3081 $out .=
'</tr>'.
"\n";
3083 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
3085 foreach ($tmpfilelist3 as $file) {
3087 $out .=
'<tr class="oddeven">';
3088 $out .=
'<td>'.$i.
'</td>'.
"\n";
3089 $out .=
'<td>'.dol_escape_htmltag($file[
'filename']).
'</td>'.
"\n";
3090 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
3091 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
3092 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
3093 $totalsize += $size;
3094 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
3095 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
3098 $out .=
'<tr class="liste_total">';
3099 $out .=
'<td></td>'.
"\n";
3100 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
3101 $out .=
'<td align="center"></td>'.
"\n";
3102 $out .=
'<td align="center"></td>'.
"\n";
3103 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
3104 $out .=
'<td class="right"></td>'.
"\n";
3107 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
3114 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
3120 throw new RestException(500,
'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
3125 asort($checksumconcat);
3126 $checksumget = md5(implode(
',', $checksumconcat));
3127 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
3129 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
3130 if ($checksumget == $checksumtoget) {
3131 if (count($file_list[
'added'])) {
3132 $resultcode =
'warning';
3133 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
3135 $outcurrentchecksum = $checksumget;
3138 $resultcomment =
'Success';
3140 $outcurrentchecksum = $checksumget;
3143 $resultcode =
'error';
3144 $resultcomment =
'Error';
3146 $outcurrentchecksum = $checksumget;
3149 throw new RestException(404,
'No signature file known');
3152 return array(
'resultcode' => $resultcode,
'resultcomment' => $resultcomment,
'expectedchecksum' => $outexpectedchecksum,
'currentchecksum' => $outcurrentchecksum,
'out' => $out);
3168 dol_syslog(
"Setup::getModules is DEPRECATED, use /api/index.php/setup/modules/status", LOG_INFO);
3171 if (!DolibarrApiAccess::$user->admin
3173 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_MODULES');
3176 sort($conf->modules);
3178 return $conf->modules;
3197 if (!DolibarrApiAccess::$user->admin
3199 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_MODULES');
3202 $filename = array();
3204 foreach ($modulesdir as $dir) {
3207 dol_syslog(
"Scan directory ".$dir.
" for module descriptor files (modXXX.class.php)");
3208 $handle = @opendir($dir);
3209 if (is_resource($handle)) {
3210 while (($file = readdir($handle)) !==
false) {
3212 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
3213 $modName = substr($file, 0,
dol_strlen($file) - 10);
3214 include_once $dir.$file;
3215 if (class_exists($modName)) {
3216 $objMod =
new $modName($db);
3217 $moduleName = strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
3219 $external = ((string) $moduleObject->isCoreOrExternalModule() ==
'external');
3221 $version = $objMod->version;
3222 if ($status !=
'all') {
3223 if ($status ==
'active' && $active ==
"") {
3225 } elseif ($status ==
'disabled' && $active == 1) {
3229 if ($origin !=
'all') {
3230 if ($origin ==
'external' && !$external) {
3232 } elseif ($origin ==
'core' && $external) {
3237 $filename[$moduleName] = array(
3238 'modName' => $modName,
3239 'origin' => $external ?
'external' :
'core',
3240 'active' => $active,
3241 'publisher' => $publisher,
3242 'version' => $version
3265 return $this->
_moduleOnOff($modulename, $state =
true);
3280 return $this->
_moduleOnOff($modulename, $state =
false);
3297 if (!DolibarrApiAccess::$user->admin
3299 throw new RestException(403,
'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_MODULES');
3303 foreach ($modulesdir as $dir) {
3304 $handle = @opendir($dir);
3305 if (is_resource($handle)) {
3306 while (($file = readdir($handle)) !==
false) {
3307 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
3309 if ($modulename == substr($file, 0,
dol_strlen($file) - 10)) {
3310 $modName = substr($file, 0,
dol_strlen($file) - 10);
3311 include_once $dir.$file;
3312 if (class_exists($modName)) {
3313 $objMod =
new $modName($db);
3316 activateModule($modulename);
3317 return array(
'result' =>
'success',
'message' =>
'Module '.$this->db->escape($modulename).
' activated');
3319 unActivateModule($modulename);
3320 return array(
'result' =>
'success',
'message' =>
'Module '.$this->db->escape($modulename).
' deactivated');
3328 throw new RestException(404,
'Module '.$this->db->escape($modulename).
' not found');
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Class to manage dictionary Countries (used by imports)
Class to manage dictionary Regions.
Class to manage dictionary States (used by imports)
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Class to manage establishments.
getExtrafields($attrname, $elementtype)
get Extrafield object
getShippingModes($limit=100, $page=0, $active=1, $lang='', $sqlfilters='')
Get the list of shipping methods.
getListOfContactTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $type='', $module='', $active=1, $lang='', $sqlfilters='')
Get the list of contacts types.
getTicketsCategories($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $lang='', $sqlfilters='')
Get the list of tickets categories.
getListOfMeasuringUnits($sortfield="rowid", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of measuring units.
_cleanObjectDatas($object)
Clean sensible object datas @phpstan-template T.
getListOfStaff($sortfield="id", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of staff.
getTicketsSeverities($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $lang='', $sqlfilters='')
Get the list of tickets severity.
translateLabel($object, $lang, $prefix='Country', $dict=array('dict'))
Translate the name of the object to the given language.
getCountryByISO($iso, $lang='')
Get country by Iso.
getCheckIntegrity($target)
Do a test of integrity for files and setup.
getListOfHolidayTypes($sortfield="sortorder", $sortorder='ASC', $limit=100, $page=0, $fk_country='', $active=1, $lang='', $sqlfilters='')
Get the list of holiday types.
getListOfExpenseReportsTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $module='', $active=1, $sqlfilters='')
Get the list of Expense Report types.
__construct()
Constructor.
getThirdpartiesTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $lang='', $sqlfilters='')
Get the list of thirdparties types.
getModulesList($status="active", $origin='all')
Get list of modules with status and origin.
getListOfTowns($sortfield="zip,town", $sortorder='ASC', $limit=100, $page=0, $zipcode='', $town='', $active=1, $sqlfilters='')
Get the list of towns.
getStateByCode($code)
Get state by Code.
getConfs()
Get all setup variables.
getListOfRegions($sortfield="code_region", $sortorder='ASC', $limit=100, $page=0, $country=0, $filter='', $sqlfilters='')
Get the list of regions.
getListOfEventTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $type='', $module='', $active=1, $sqlfilters='')
Get the list of events types.
getEstablishments()
Get the list of establishments.
getListOfLegalForm($sortfield="rowid", $sortorder='ASC', $limit=100, $page=0, $country=0, $active=1, $sqlfilters='')
Get the list of legal form of business.
getListOfCurrencies($multicurrency=0, $sortfield="code_iso", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of currencies.
getListOfPublicHolidays($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $fk_country='', $active=1, $lang='', $sqlfilters='')
Get the list of public holiday.
getListOfsocialNetworks($sortfield="rowid", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of social networks.
_fetchCstate($id, $code='')
Get state.
getEtablishmentByID($id)
Get establishment by ID.
getConf($constantname)
Get value of a setup variables.
updateExtrafields($attrname, $elementtype, $request_data=null)
Update Extrafield object.
deleteExtrafieldsFromNames($attrname, $elementtype)
Delete extrafield.
getListOfIncoterms($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $lang='', $sqlfilters='')
Get the list of incoterms.
getCompany()
Get properties of company.
_moduleOnOff($modulename, $state=false)
switch moduleOnOff
postExtrafields($attrname, $elementtype, $request_data=null)
Create Extrafield object.
getPaymentTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of payments types.
enableModules($modulename)
PUT enable module.
getCountryByID($id, $lang='')
Get country by ID.
_fetchCregion($id, $code='')
Get region.
getCountryByCode($code, $lang='')
Get country by Code.
getPaymentTerms($sortfield="sortorder", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of payments terms.
getOrderingOrigins($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of ordering origins.
getListOfActionTriggers($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $elementtype='', $lang='', $sqlfilters='')
Get the list of Action Triggers.
getListOfStates($sortfield="code_departement", $sortorder='ASC', $limit=100, $page=0, $country=0, $filter='', $sqlfilters='')
Get the list of states/provinces.
getOrderingMethods($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of ordering methods.
disableModules($modulename)
PUT enable module.
_fetchCcountry($id, $code='', $iso='', $lang='')
Get country.
getListOfExtrafields($sortfield="t.pos", $sortorder='ASC', $elementtype='', $sqlfilters='')
Get the list of extra fields.
getStateByID($id)
Get state by ID.
getAvailability($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of delivery times.
getTicketsTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $lang='', $sqlfilters='')
Get the list of tickets types.
getRegionByCode($code)
Get region by Code.
getListOfCountries($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $filter='', $lang='', $sqlfilters='')
Get the list of countries.
getListOfVAT($sortfield="taux", $sortorder='ASC', $limit=100, $page=0, $active=1, $fk_country=-1, $sqlfilters='')
Get the list of vat.
getRegionByID($id)
Get region by ID.
getListOfCivilities($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $module='', $active=1, $lang='', $sqlfilters='')
Get the list of civilities.
getModules()
Get list of enabled modules.
Class to manage translations.
getFilesUpdated(&$file_list, SimpleXMLElement $dir, $path='', $pathref='', &$checksumconcat=array())
Function to get list of updated or modified files.
dol_filemtime($pathoffile)
Return time of a file.
dol_filesize($pathoffile)
Return size of a file.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
jsonOrUnserialize($stringtodecode, $assoc=true)
Decode an encoded string.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1, $timeoutconnect=0, $timeoutresponse=0, $otherCurlOptions=array())
Function to get a content from an URL (use proxy if proxy defined).