24use Luracast\Restler\RestException;
26require_once DOL_DOCUMENT_ROOT.
'/main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/api/class/api.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/cstate.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/cregion.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/ccountry.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/hrm/class/establishment.class.php';
41 private $translations =
null;
68 public function getOrderingMethods($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
72 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
73 throw new RestException(401);
76 $sql =
"SELECT rowid, code, libelle as label, module";
77 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_method as t";
78 $sql .=
" WHERE t.active = ".((int) $active);
84 throw new RestException(503,
'Error when validating parameter sqlfilters -> '.$errormessage);
89 $sql .= $this->db->order($sortfield, $sortorder);
95 $offset = $limit * $page;
97 $sql .= $this->db->plimit($limit, $offset);
100 $result = $this->db->query($sql);
103 $num = $this->db->num_rows($result);
104 $min = min($num, ($limit <= 0 ? $num : $limit));
105 for ($i = 0; $i < $min; $i++) {
106 $list[] = $this->db->fetch_object($result);
109 throw new RestException(400, $this->db->lasterror());
130 public function getOrderingOrigins($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
134 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
135 throw new RestException(401);
138 $sql =
"SELECT rowid, code, label, module";
139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_reason as t";
140 $sql .=
" WHERE t.active = ".((int) $active);
146 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
151 $sql .= $this->db->order($sortfield, $sortorder);
157 $offset = $limit * $page;
159 $sql .= $this->db->plimit($limit, $offset);
162 $result = $this->db->query($sql);
165 $num = $this->db->num_rows($result);
166 $min = min($num, ($limit <= 0 ? $num : $limit));
167 for ($i = 0; $i < $min; $i++) {
168 $list[] = $this->db->fetch_object($result);
171 throw new RestException(400, $this->db->lasterror());
193 public function getPaymentTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
197 if (!DolibarrApiAccess::$user->hasRight(
'propal',
'lire') && !DolibarrApiAccess::$user->hasRight(
'commande',
'lire') && !DolibarrApiAccess::$user->hasRight(
'facture',
'lire')) {
198 throw new RestException(401);
201 $sql =
"SELECT id, code, type, libelle as label, module";
202 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement as t";
203 $sql .=
" WHERE t.entity IN (".getEntity(
'c_paiement').
")";
204 $sql .=
" AND t.active = ".((int) $active);
210 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
215 $sql .= $this->db->order($sortfield, $sortorder);
221 $offset = $limit * $page;
223 $sql .= $this->db->plimit($limit, $offset);
226 $result = $this->db->query($sql);
229 $num = $this->db->num_rows($result);
230 $min = min($num, ($limit <= 0 ? $num : $limit));
231 for ($i = 0; $i < $min; $i++) {
232 $list[] = $this->db->fetch_object($result);
235 throw new RestException(400, $this->db->lasterror());
258 public function getListOfRegions($sortfield =
"code_region", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
264 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_regions as t";
265 $sql .=
" WHERE 1 = 1";
267 $sql .=
" AND t.fk_pays = ".((int) $country);
273 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
275 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
276 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
279 $sql .= $this->db->order($sortfield, $sortorder);
285 $offset = $limit * $page;
287 $sql .= $this->db->plimit($limit, $offset);
290 $result = $this->db->query($sql);
293 $num = $this->db->num_rows($result);
294 $min = min($num, ($limit <= 0 ? $num : $limit));
295 for ($i = 0; $i < $min; $i++) {
296 $obj = $this->db->fetch_object($result);
297 $region =
new Cregion($this->db);
298 if ($region->fetch($obj->rowid) > 0) {
299 if (empty($filter) || stripos($region->name, $filter) !==
false) {
305 throw new RestException(503,
'Error when retrieving list of regions');
362 public function getListOfStates($sortfield =
"code_departement", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
368 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_departements as t";
370 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as d ON t.fk_region = d.code_region";
372 $sql .=
" WHERE 1 = 1";
374 $sql .=
" AND d.fk_pays = ".((int) $country);
381 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
385 $sql .= $this->db->order($sortfield, $sortorder);
391 $offset = $limit * $page;
393 $sql .= $this->db->plimit($limit, $offset);
396 $result = $this->db->query($sql);
399 $num = $this->db->num_rows($result);
400 $min = min($num, ($limit <= 0 ? $num : $limit));
401 for ($i = 0; $i < $min; $i++) {
402 $obj = $this->db->fetch_object($result);
403 $state =
new Cstate($this->db);
404 if ($state->fetch($obj->rowid) > 0) {
405 if (empty($filter) || stripos($state->label, $filter) !==
false) {
411 throw new RestException(503,
'Error when retrieving list of states');
468 public function getListOfCountries($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $filter =
'', $lang =
'', $sqlfilters =
'')
474 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"c_country as t";
475 $sql .=
" WHERE 1 = 1";
481 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
485 $sql .= $this->db->order($sortfield, $sortorder);
491 $offset = $limit * $page;
493 $sql .= $this->db->plimit($limit, $offset);
496 $result = $this->db->query($sql);
499 $num = $this->db->num_rows($result);
500 $min = min($num, ($limit <= 0 ? $num : $limit));
501 for ($i = 0; $i < $min; $i++) {
502 $obj = $this->db->fetch_object($result);
504 if ($country->fetch($obj->rowid) > 0) {
509 if (empty($filter) || stripos($country->label, $filter) !==
false) {
515 throw new RestException(503,
'Error when retrieving list of countries');
580 $region =
new Cregion($this->db);
582 $result = $region->fetch($id, $code);
584 throw new RestException(503,
'Error when retrieving region : '.$region->error);
585 } elseif ($result == 0) {
586 throw new RestException(404,
'Region not found');
603 $state =
new Cstate($this->db);
605 $result = $state->fetch($id, $code);
607 throw new RestException(503,
'Error when retrieving state : '.$state->error);
608 } elseif ($result == 0) {
609 throw new RestException(404,
'State not found');
630 $result = $country->fetch($id, $code, $iso);
633 throw new RestException(503,
'Error when retrieving country : '.$country->error);
634 } elseif ($result == 0) {
635 throw new RestException(404,
'Country not found');
659 public function getAvailability($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
663 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
664 throw new RestException(401);
667 $sql =
"SELECT rowid, code, label";
668 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_availability as t";
669 $sql .=
" WHERE t.active = ".((int) $active);
675 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
680 $sql .= $this->db->order($sortfield, $sortorder);
686 $offset = $limit * $page;
688 $sql .= $this->db->plimit($limit, $offset);
691 $result = $this->db->query($sql);
694 $num = $this->db->num_rows($result);
695 $min = min($num, ($limit <= 0 ? $num : $limit));
696 for ($i = 0; $i < $min; $i++) {
697 $list[] = $this->db->fetch_object($result);
700 throw new RestException(400, $this->db->lasterror());
716 $object = parent::_cleanObjectDatas($object);
718 unset($object->error);
719 unset($object->errors);
733 private function translateLabel($object, $lang, $prefix =
'Country', $dict = array(
'dict'))
737 if ($this->translations ==
null || $this->translations->getDefaultLang() !== $lang) {
739 $this->translations =
new Translate(
'', $conf);
740 $this->translations->setDefaultLang($lang);
741 $this->translations->loadLangs($dict);
744 $key = $prefix.$object->code;
746 $translation = $this->translations->trans($key);
747 if ($translation != $key) {
748 $object->label = html_entity_decode($translation);
771 public function getListOfEventTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $sqlfilters =
'')
775 $sql =
"SELECT id, code, type, libelle as label, module";
776 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as t";
777 $sql .=
" WHERE t.active = ".((int) $active);
779 $sql .=
" AND t.type LIKE '%".$this->db->escape($type).
"%'";
782 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
789 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
794 $sql .= $this->db->order($sortfield, $sortorder);
800 $offset = $limit * $page;
802 $sql .= $this->db->plimit($limit, $offset);
805 $result = $this->db->query($sql);
808 $num = $this->db->num_rows($result);
809 $min = min($num, ($limit <= 0 ? $num : $limit));
810 for ($i = 0; $i < $min; $i++) {
811 $list[] = $this->db->fetch_object($result);
814 throw new RestException(503,
'Error when retrieving list of events types : '.$this->db->lasterror());
837 public function getListOfExpenseReportsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $sqlfilters =
'')
841 $sql =
"SELECT id, code, label, accountancy_code, active, module, position";
842 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees as t";
843 $sql .=
" WHERE t.active = ".((int) $active);
845 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
852 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
857 $sql .= $this->db->order($sortfield, $sortorder);
863 $offset = $limit * $page;
865 $sql .= $this->db->plimit($limit, $offset);
868 $result = $this->db->query($sql);
871 $num = $this->db->num_rows($result);
872 $min = min($num, ($limit <= 0 ? $num : $limit));
873 for ($i = 0; $i < $min; $i++) {
874 $list[] = $this->db->fetch_object($result);
877 throw new RestException(503,
'Error when retrieving list of expense report types : '.$this->db->lasterror());
902 public function getListOfContactTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
906 $sql =
"SELECT rowid, code, element as type, libelle as label, source, module, position";
907 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact as t";
908 $sql .=
" WHERE t.active = ".((int) $active);
910 $sql .=
" AND type LIKE '%".$this->db->escape($type).
"%'";
913 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
920 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
925 $sql .= $this->db->order($sortfield, $sortorder);
931 $offset = $limit * $page;
933 $sql .= $this->db->plimit($limit, $offset);
936 $result = $this->db->query($sql);
939 $num = $this->db->num_rows($result);
940 $min = min($num, ($limit <= 0 ? $num : $limit));
941 for ($i = 0; $i < $min; $i++) {
942 $contact_type = $this->db->fetch_object($result);
943 $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"));
944 $list[] = $contact_type;
947 throw new RestException(503,
'Error when retrieving list of contacts types : '.$this->db->lasterror());
970 public function getListOfCivilities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
974 $sql =
"SELECT rowid, code, label, module";
975 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_civility as t";
976 $sql .=
" WHERE t.active = ".((int) $active);
978 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
985 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
990 $sql .= $this->db->order($sortfield, $sortorder);
996 $offset = $limit * $page;
998 $sql .= $this->db->plimit($limit, $offset);
1001 $result = $this->db->query($sql);
1004 $num = $this->db->num_rows($result);
1005 $min = min($num, ($limit <= 0 ? $num : $limit));
1006 for ($i = 0; $i < $min; $i++) {
1007 $civility = $this->db->fetch_object($result);
1008 $this->
translateLabel($civility, $lang,
'Civility', array(
'dict'));
1009 $list[] = $civility;
1012 throw new RestException(503,
'Error when retrieving list of civility : '.$this->db->lasterror());
1034 public function getListOfCurrencies($multicurrency = 0, $sortfield =
"code_iso", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1037 $sql =
"SELECT t.code_iso, t.label, t.unicode";
1038 if (!empty($multicurrency)) {
1039 $sql .=
" , cr.date_sync, cr.rate ";
1041 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_currencies as t";
1042 if (!empty($multicurrency)) {
1043 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency as m ON m.code=t.code_iso";
1044 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
1046 $sql .=
" WHERE t.active = ".((int) $active);
1047 if (!empty($multicurrency)) {
1048 $sql .=
" AND m.entity IN (".getEntity(
'multicurrency').
")";
1049 if (!empty($multicurrency) && $multicurrency != 2) {
1050 $sql .=
" AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.
"multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
1058 if ($errormessage) {
1059 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1064 $sql .= $this->db->order($sortfield, $sortorder);
1070 $offset = $limit * $page;
1072 $sql .= $this->db->plimit($limit, $offset);
1075 $result = $this->db->query($sql);
1078 $num = $this->db->num_rows($result);
1079 $min = min($num, ($limit <= 0 ? $num : $limit));
1080 for ($i = 0; $i < $min; $i++) {
1081 $list[] = $this->db->fetch_object($result);
1084 throw new RestException(503,
'Error when retrieving list of currency : '.$this->db->lasterror());
1107 if (!DolibarrApiAccess::$user->admin) {
1108 throw new RestException(401,
'Only an admin user can get list of extrafields');
1111 if ($type ==
'thirdparty') {
1114 if ($type ==
'contact') {
1115 $type =
'socpeople';
1118 $sql =
"SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed";
1119 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1120 $sql .=
" WHERE t.entity IN (".getEntity(
'extrafields').
")";
1121 if (!empty($type)) {
1122 $sql .=
" AND t.elementtype = '".$this->db->escape($type).
"'";
1128 if ($errormessage) {
1129 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1133 $sql .= $this->db->order($sortfield, $sortorder);
1135 $resql = $this->db->query($sql);
1137 if ($this->db->num_rows($resql)) {
1138 while ($tab = $this->db->fetch_object($resql)) {
1140 $list[$tab->elementtype][$tab->name][
'type'] = $tab->type;
1141 $list[$tab->elementtype][$tab->name][
'label'] = $tab->label;
1142 $list[$tab->elementtype][$tab->name][
'size'] = $tab->size;
1143 $list[$tab->elementtype][$tab->name][
'elementtype'] = $tab->elementtype;
1144 $list[$tab->elementtype][$tab->name][
'default'] = $tab->fielddefault;
1145 $list[$tab->elementtype][$tab->name][
'computed'] = $tab->fieldcomputed;
1146 $list[$tab->elementtype][$tab->name][
'unique'] = $tab->fieldunique;
1147 $list[$tab->elementtype][$tab->name][
'required'] = $tab->fieldrequired;
1148 $list[$tab->elementtype][$tab->name][
'param'] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1149 $list[$tab->elementtype][$tab->name][
'pos'] = $tab->pos;
1150 $list[$tab->elementtype][$tab->name][
'alwayseditable'] = $tab->alwayseditable;
1151 $list[$tab->elementtype][$tab->name][
'perms'] = $tab->perms;
1152 $list[$tab->elementtype][$tab->name][
'list'] = $tab->list;
1156 throw new RestException(503,
'Error when retrieving list of extra fields : '.$this->db->lasterror());
1180 public function getListOfTowns($sortfield =
"zip,town", $sortorder =
'ASC', $limit = 100, $page = 0, $zipcode =
'', $town =
'', $active = 1, $sqlfilters =
'')
1184 $sql =
"SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
1185 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ziptown as t";
1186 $sql .=
" WHERE t.active = ".((int) $active);
1188 $sql .=
" AND t.zip LIKE '%".$this->db->escape($zipcode).
"%'";
1191 $sql .=
" AND t.town LIKE '%".$this->db->escape($town).
"%'";
1197 if ($errormessage) {
1198 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1203 $sql .= $this->db->order($sortfield, $sortorder);
1209 $offset = $limit * $page;
1211 $sql .= $this->db->plimit($limit, $offset);
1214 $result = $this->db->query($sql);
1217 $num = $this->db->num_rows($result);
1218 $min = min($num, ($limit <= 0 ? $num : $limit));
1219 for ($i = 0; $i < $min; $i++) {
1220 $list[] = $this->db->fetch_object($result);
1223 throw new RestException(503,
'Error when retrieving list of towns : '.$this->db->lasterror());
1245 public function getPaymentTerms($sortfield =
"sortorder", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1249 if (!DolibarrApiAccess::$user->hasRight(
'propal',
'lire') && !DolibarrApiAccess::$user->hasRight(
'commande',
'lire') && !DolibarrApiAccess::$user->hasRight(
'facture',
'lire')) {
1250 throw new RestException(401);
1253 $sql =
"SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
1254 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
1255 $sql .=
" WHERE t.entity IN (".getEntity(
'c_payment_term').
")";
1256 $sql .=
" AND t.active = ".((int) $active);
1261 if ($errormessage) {
1262 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1267 $sql .= $this->db->order($sortfield, $sortorder);
1273 $offset = $limit * $page;
1275 $sql .= $this->db->plimit($limit, $offset);
1278 $result = $this->db->query($sql);
1281 $num = $this->db->num_rows($result);
1282 $min = min($num, ($limit <= 0 ? $num : $limit));
1283 for ($i = 0; $i < $min; $i++) {
1284 $list[] = $this->db->fetch_object($result);
1287 throw new RestException(400, $this->db->lasterror());
1308 public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1312 $sql =
"SELECT rowid as id, code, libelle as label, description, tracking, module";
1313 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as t";
1314 $sql .=
" WHERE t.entity IN (".getEntity(
'c_shipment_mode').
")";
1315 $sql .=
" AND t.active = ".((int) $active);
1320 if ($errormessage) {
1321 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1332 $offset = $limit * $page;
1334 $sql .= $this->db->plimit($limit, $offset);
1337 $result = $this->db->query($sql);
1340 $num = $this->db->num_rows($result);
1341 $min = min($num, ($limit <= 0 ? $num : $limit));
1342 for ($i = 0; $i < $min; $i++) {
1343 $method = $this->db->fetch_object($result);
1348 throw new RestException(400, $this->db->lasterror());
1369 public function getListOfMeasuringUnits($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1373 $sql =
"SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
1374 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_units as t";
1375 $sql .=
" WHERE t.active = ".((int) $active);
1380 if ($errormessage) {
1381 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1386 $sql .= $this->db->order($sortfield, $sortorder);
1392 $offset = $limit * $page;
1394 $sql .= $this->db->plimit($limit, $offset);
1397 $result = $this->db->query($sql);
1400 $num = $this->db->num_rows($result);
1401 $min = min($num, ($limit <= 0 ? $num : $limit));
1402 for ($i = 0; $i < $min; $i++) {
1403 $list[] = $this->db->fetch_object($result);
1406 throw new RestException(503,
'Error when retrieving list of measuring units: '.$this->db->lasterror());
1428 public function getListOfLegalForm($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters =
'')
1432 $sql =
"SELECT t.rowid, t.code, t.fk_pays, t.libelle, t.isvatexempted, t.active, t.module, t.position";
1433 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_forme_juridique as t";
1434 $sql .=
" WHERE t.active = ".((int) $active);
1436 $sql .=
" AND t.fk_pays = ".((int) $country);
1442 if ($errormessage) {
1443 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1448 $sql .= $this->db->order($sortfield, $sortorder);
1454 $offset = $limit * $page;
1456 $sql .= $this->db->plimit($limit, $offset);
1459 $result = $this->db->query($sql);
1462 $num = $this->db->num_rows($result);
1463 $min = min($num, ($limit <= 0 ? $num : $limit));
1464 for ($i = 0; $i < $min; $i++) {
1465 $list[] = $this->db->fetch_object($result);
1468 throw new RestException(503,
'Error when retrieving list of legal form: '.$this->db->lasterror());
1489 public function getListOfStaff($sortfield =
"id", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1493 $sql =
"SELECT t.id, t.code, t.libelle, t.active, t.module";
1494 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_effectif as t";
1495 $sql .=
" WHERE t.active = ".((int) $active);
1500 if ($errormessage) {
1501 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1506 $sql .= $this->db->order($sortfield, $sortorder);
1512 $offset = $limit * $page;
1514 $sql .= $this->db->plimit($limit, $offset);
1517 $result = $this->db->query($sql);
1520 $num = $this->db->num_rows($result);
1521 $min = min($num, ($limit <= 0 ? $num : $limit));
1522 for ($i = 0; $i < $min; $i++) {
1523 $list[] = $this->db->fetch_object($result);
1526 throw new RestException(503,
'Error when retrieving list of staff: '.$this->db->lasterror());
1547 public function getListOfsocialNetworks($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1551 if (!isModEnabled(
'socialnetworks')) {
1552 throw new RestException(400,
'API not available: this dictionary is not enabled by setup');
1557 $sql =
"SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active";
1558 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_socialnetworks as t";
1559 $sql .=
" WHERE t.entity IN (".getEntity(
'c_socialnetworks').
")";
1560 $sql .=
" AND t.active = ".((int) $active);
1565 if ($errormessage) {
1566 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1571 $sql .= $this->db->order($sortfield, $sortorder);
1577 $offset = $limit * $page;
1579 $sql .= $this->db->plimit($limit, $offset);
1582 $result = $this->db->query($sql);
1585 $num = $this->db->num_rows($result);
1586 $min = min($num, ($limit <= 0 ? $num : $limit));
1587 for ($i = 0; $i < $min; $i++) {
1588 $list[] = $this->db->fetch_object($result);
1591 throw new RestException(503,
'Error when retrieving list of social networks: '.$this->db->lasterror());
1613 public function getTicketsCategories($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1617 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1618 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category as t";
1619 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_category').
")";
1620 $sql .=
" AND t.active = ".((int) $active);
1625 if ($errormessage) {
1626 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1631 $sql .= $this->db->order($sortfield, $sortorder);
1637 $offset = $limit * $page;
1639 $sql .= $this->db->plimit($limit, $offset);
1642 $result = $this->db->query($sql);
1645 $num = $this->db->num_rows($result);
1646 $min = min($num, ($limit <= 0 ? $num : $limit));
1647 for ($i = 0; $i < $min; $i++) {
1648 $category = $this->db->fetch_object($result);
1649 $this->
translateLabel($category, $lang,
'TicketCategoryShort', array(
'ticket'));
1650 $list[] = $category;
1653 throw new RestException(503,
'Error when retrieving list of ticket categories : '.$this->db->lasterror());
1675 public function getTicketsSeverities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1679 $sql =
"SELECT rowid, code, pos, label, use_default, color, description";
1680 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity as t";
1681 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_severity').
")";
1682 $sql .=
" AND t.active = ".((int) $active);
1687 if ($errormessage) {
1688 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1693 $sql .= $this->db->order($sortfield, $sortorder);
1699 $offset = $limit * $page;
1701 $sql .= $this->db->plimit($limit, $offset);
1704 $result = $this->db->query($sql);
1707 $num = $this->db->num_rows($result);
1708 $min = min($num, ($limit <= 0 ? $num : $limit));
1709 for ($i = 0; $i < $min; $i++) {
1710 $severity = $this->db->fetch_object($result);
1711 $this->
translateLabel($severity, $lang,
'TicketSeverityShort', array(
'ticket'));
1712 $list[] = $severity;
1715 throw new RestException(503,
'Error when retrieving list of ticket severities : '.$this->db->lasterror());
1737 public function getTicketsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1741 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1742 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type as t";
1743 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_type').
")";
1744 $sql .=
" AND t.active = ".((int) $active);
1750 if ($errormessage) {
1751 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1756 $sql .= $this->db->order($sortfield, $sortorder);
1762 $offset = $limit * $page;
1764 $sql .= $this->db->plimit($limit, $offset);
1767 $result = $this->db->query($sql);
1770 $num = $this->db->num_rows($result);
1771 $min = min($num, ($limit <= 0 ? $num : $limit));
1772 for ($i = 0; $i < $min; $i++) {
1773 $type =$this->db->fetch_object($result);
1774 $this->
translateLabel($type, $lang,
'TicketTypeShort', array(
'ticket'));
1778 throw new RestException(503,
'Error when retrieving list of ticket types : '.$this->db->lasterror());
1800 public function getListOfIncoterms($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1804 $sql =
"SELECT rowid, code, active";
1805 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_incoterms as t";
1806 $sql .=
" WHERE 1=1";
1812 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1814 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1815 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1819 $sql .= $this->db->order($sortfield, $sortorder);
1825 $offset = $limit * $page;
1827 $sql .= $this->db->plimit($limit, $offset);
1830 $result = $this->db->query($sql);
1833 $num = $this->db->num_rows($result);
1834 $min = min($num, ($limit <= 0 ? $num : $limit));
1835 for ($i = 0; $i < $min; $i++) {
1836 $type =$this->db->fetch_object($result);
1840 throw new RestException(503,
'Error when retrieving list of incoterm types : '.$this->db->lasterror());
1857 global $conf, $mysoc;
1859 if (!DolibarrApiAccess::$user->admin
1860 && (!
getDolGlobalString(
'API_LOGINS_ALLOWED_FOR_GET_COMPANY') || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
1861 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');
1864 unset($mysoc->pays);
1865 unset($mysoc->note);
1868 unset($mysoc->lines);
1870 unset($mysoc->effectif);
1871 unset($mysoc->effectif_id);
1872 unset($mysoc->forme_juridique_code);
1873 unset($mysoc->forme_juridique);
1874 unset($mysoc->mode_reglement_supplier_id);
1875 unset($mysoc->cond_reglement_supplier_id);
1876 unset($mysoc->transport_mode_supplier_id);
1877 unset($mysoc->fk_prospectlevel);
1879 unset($mysoc->total_ht);
1880 unset($mysoc->total_tva);
1881 unset($mysoc->total_localtax1);
1882 unset($mysoc->total_localtax2);
1883 unset($mysoc->total_ttc);
1885 unset($mysoc->lastname);
1886 unset($mysoc->firstname);
1887 unset($mysoc->civility_id);
1889 unset($mysoc->client);
1890 unset($mysoc->prospect);
1891 unset($mysoc->fournisseur);
1892 unset($mysoc->contact_id);
1894 unset($mysoc->fk_incoterms);
1895 unset($mysoc->label_incoterms);
1896 unset($mysoc->location_incoterms);
1916 $sql =
"SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status";
1917 $sql .=
" FROM ".MAIN_DB_PREFIX.
"establishment as e";
1918 $sql .=
" WHERE e.entity IN (".getEntity(
'establishment').
')';
1923 $result = $this->db->query($sql);
1926 $num = $this->db->num_rows($result);
1927 $min = min($num, ($limit <= 0 ? $num : $limit));
1928 for ($i = 0; $i < $min; $i++) {
1929 $list[] = $this->db->fetch_object($result);
1932 throw new RestException(503,
'Error when retrieving list of establishments : '.$this->db->lasterror());
1952 $result = $establishment->fetch($id);
1954 throw new RestException(503,
'Error when retrieving establishment : '.$establishment->error);
1955 } elseif ($result == 0) {
1956 throw new RestException(404,
'Establishment not found');
1979 if (!DolibarrApiAccess::$user->admin
1981 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');
1984 if (!preg_match(
'/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
1985 throw new RestException(404,
'Error Bad or unknown value for constantname');
1988 throw new RestException(403,
'Forbidden. This parameter cant be read with APIs');
2009 global $langs, $conf;
2011 if (!DolibarrApiAccess::$user->admin
2012 && (!
getDolGlobalString(
'API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK') || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK)) {
2013 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');
2016 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2017 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
2019 $langs->load(
"admin");
2021 $outexpectedchecksum =
'';
2022 $outcurrentchecksum =
'';
2025 $file_list = array(
'missing' => array(),
'updated' => array());
2029 $xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
2031 $xmlremote = ($target ==
'default' ?
'' : $target);
2033 $xmlremote = $conf->global->MAIN_FILECHECK_URL;
2035 $param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
2039 if (empty($xmlremote)) {
2040 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
2042 if ($xmlremote && !preg_match(
'/^https?:\/\//i', $xmlremote)) {
2043 $langs->load(
"errors");
2044 throw new RestException(500, $langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote));
2046 if ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
2047 $langs->load(
"errors");
2048 throw new RestException(500, $langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'));
2051 if (LIBXML_VERSION < 20900) {
2054 libxml_disable_entity_loader(
true);
2057 if ($target ==
'local') {
2059 $xml = simplexml_load_file($xmlfile);
2061 throw new RestException(500, $langs->trans(
'XmlNotFound').
': '.$xmlfile);
2064 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
2067 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404') {
2068 $xmlfile = $xmlarray[
'content'];
2070 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
2072 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
2073 throw new RestException(500, $errormsg);
2078 $checksumconcat = array();
2079 $file_list = array();
2083 if (is_object($xml->dolibarr_constants[0])) {
2086 $out .=
'<div class="div-table-responsive-no-min">';
2087 $out .=
'<table class="noborder">';
2088 $out .=
'<tr class="liste_titre">';
2089 $out .=
'<td>#</td>';
2090 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
2091 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
2092 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
2093 $out .=
'</tr>'.
"\n";
2096 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
2097 $constname = $constant[
'name'];
2098 $constvalue = (string) $constant;
2099 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
2105 $valueforchecksum = (empty($value) ?
'0' : $value);
2107 $checksumconcat[] = $valueforchecksum;
2110 $out .=
'<tr class="oddeven">';
2111 $out .=
'<td>'.$i.
'</td>'.
"\n";
2112 $out .=
'<td>'.$constname.
'</td>'.
"\n";
2113 $out .=
'<td class="center">'.$constvalue.
'</td>'.
"\n";
2114 $out .=
'<td class="center">'.$valueforchecksum.
'</td>'.
"\n";
2119 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2128 if (is_object($xml->dolibarr_htdocs_dir[0])) {
2129 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
2132 $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)$';
2133 $regextoexclude =
'('.($includecustom ?
'' :
'custom|').
'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$';
2134 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
2137 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
2139 foreach ($scanfiles as $keyfile => $valfile) {
2140 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
2141 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
2142 $md5newfile = @md5_file($valfile[
'fullname']);
2143 $file_list[
'added'][] = array(
'filename'=>$tmprelativefilename,
'md5'=>$md5newfile);
2150 $out .=
'<div class="div-table-responsive-no-min">';
2151 $out .=
'<table class="noborder">';
2152 $out .=
'<tr class="liste_titre">';
2153 $out .=
'<td>#</td>';
2154 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2155 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2156 $out .=
'</tr>'.
"\n";
2157 $tmpfilelist =
dol_sort_array($file_list[
'missing'],
'filename');
2158 if (is_array($tmpfilelist) && count($tmpfilelist)) {
2160 foreach ($tmpfilelist as $file) {
2162 $out .=
'<tr class="oddeven">';
2163 $out .=
'<td>'.$i.
'</td>'.
"\n";
2164 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2165 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2169 $out .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2180 $out .=
'<div class="div-table-responsive-no-min">';
2181 $out .=
'<table class="noborder">';
2182 $out .=
'<tr class="liste_titre">';
2183 $out .=
'<td>#</td>';
2184 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2185 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2186 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2187 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2188 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2189 $out .=
'</tr>'.
"\n";
2190 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
2191 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
2193 foreach ($tmpfilelist2 as $file) {
2195 $out .=
'<tr class="oddeven">';
2196 $out .=
'<td>'.$i.
'</td>'.
"\n";
2197 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2198 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2199 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2200 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2201 $totalsize += $size;
2202 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2203 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2206 $out .=
'<tr class="liste_total">';
2207 $out .=
'<td></td>'.
"\n";
2208 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2209 $out .=
'<td align="center"></td>'.
"\n";
2210 $out .=
'<td align="center"></td>'.
"\n";
2211 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2212 $out .=
'<td class="right"></td>'.
"\n";
2215 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2226 $out .=
'<div class="div-table-responsive-no-min">';
2227 $out .=
'<table class="noborder">';
2228 $out .=
'<tr class="liste_titre">';
2229 $out .=
'<td>#</td>';
2230 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2231 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2232 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2233 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2234 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2235 $out .=
'</tr>'.
"\n";
2237 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
2239 foreach ($tmpfilelist3 as $file) {
2241 $out .=
'<tr class="oddeven">';
2242 $out .=
'<td>'.$i.
'</td>'.
"\n";
2243 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2244 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2245 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2246 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2247 $totalsize += $size;
2248 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2249 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2252 $out .=
'<tr class="liste_total">';
2253 $out .=
'<td></td>'.
"\n";
2254 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2255 $out .=
'<td align="center"></td>'.
"\n";
2256 $out .=
'<td align="center"></td>'.
"\n";
2257 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2258 $out .=
'<td class="right"></td>'.
"\n";
2261 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2268 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
2274 throw new RestException(500,
'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
2279 asort($checksumconcat);
2280 $checksumget = md5(join(
',', $checksumconcat));
2281 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
2283 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
2284 if ($checksumget == $checksumtoget) {
2285 if (count($file_list[
'added'])) {
2286 $resultcode =
'warning';
2287 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
2289 $outcurrentchecksum = $checksumget;
2292 $resultcomment =
'Success';
2294 $outcurrentchecksum = $checksumget;
2297 $resultcode =
'error';
2298 $resultcomment =
'Error';
2300 $outcurrentchecksum = $checksumget;
2303 throw new RestException(404,
'No signature file known');
2306 return array(
'resultcode'=>$resultcode,
'resultcomment'=>$resultcomment,
'expectedchecksum'=> $outexpectedchecksum,
'currentchecksum'=> $outcurrentchecksum,
'out'=>$out);
2323 if (!DolibarrApiAccess::$user->admin
2324 && (!
getDolGlobalString(
'API_LOGINS_ALLOWED_FOR_GET_MODULES') || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES)) {
2325 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');
2328 sort($conf->modules);
Class to manage dictionary Countries (used by imports)
Class to manage dictionary Regions.
Class to manage dictionary States (used by imports)
_checkFilters($sqlfilters, &$error='')
Return if a $sqlfilters parameter is valid Function no more used.
Class to manage establishments.
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.
getListOfExtrafields($sortfield="t.pos", $sortorder='ASC', $type='', $sqlfilters='')
Get the list of extra fields.
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.
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.
getListOfExpenseReportsTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $module='', $active=1, $sqlfilters='')
Get the list of Expense Report types.
__construct()
Constructor.
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.
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.
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.
getListOfIncoterms($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $lang='', $sqlfilters='')
Get the list of incoterms.
getCompany()
Get properties of company.
getPaymentTypes($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $active=1, $sqlfilters='')
Get the list of payments types.
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.
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.
_fetchCcountry($id, $code='', $iso='', $lang='')
Get country.
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.
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($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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).