24use Luracast\Restler\RestException;
26require_once DOL_DOCUMENT_ROOT.
'/main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/cstate.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/cregion.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/ccountry.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/hrm/class/establishment.class.php';
40 private $translations =
null;
67 public function getOrderingMethods($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
71 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
72 throw new RestException(401);
75 $sql =
"SELECT rowid, code, libelle as label, module";
76 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_method as t";
77 $sql .=
" WHERE t.active = ".((int) $active);
83 throw new RestException(503,
'Error when validating parameter sqlfilters -> '.$errormessage);
88 $sql .= $this->db->order($sortfield, $sortorder);
94 $offset = $limit * $page;
96 $sql .= $this->db->plimit($limit, $offset);
99 $result = $this->db->query($sql);
102 $num = $this->db->num_rows($result);
103 $min = min($num, ($limit <= 0 ? $num : $limit));
104 for ($i = 0; $i < $min; $i++) {
105 $list[] = $this->db->fetch_object($result);
108 throw new RestException(400, $this->db->lasterror());
129 public function getOrderingOrigins($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
133 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
134 throw new RestException(401);
137 $sql =
"SELECT rowid, code, label, module";
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_reason as t";
139 $sql .=
" WHERE t.active = ".((int) $active);
145 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
150 $sql .= $this->db->order($sortfield, $sortorder);
156 $offset = $limit * $page;
158 $sql .= $this->db->plimit($limit, $offset);
161 $result = $this->db->query($sql);
164 $num = $this->db->num_rows($result);
165 $min = min($num, ($limit <= 0 ? $num : $limit));
166 for ($i = 0; $i < $min; $i++) {
167 $list[] = $this->db->fetch_object($result);
170 throw new RestException(400, $this->db->lasterror());
192 public function getPaymentTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
196 if (!DolibarrApiAccess::$user->hasRight(
'propal',
'lire') && !DolibarrApiAccess::$user->hasRight(
'commande',
'lire') && !DolibarrApiAccess::$user->hasRight(
'facture',
'lire')) {
197 throw new RestException(401);
200 $sql =
"SELECT id, code, type, libelle as label, module";
201 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement as t";
202 $sql .=
" WHERE t.entity IN (".getEntity(
'c_paiement').
")";
203 $sql .=
" AND t.active = ".((int) $active);
209 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
214 $sql .= $this->db->order($sortfield, $sortorder);
220 $offset = $limit * $page;
222 $sql .= $this->db->plimit($limit, $offset);
225 $result = $this->db->query($sql);
228 $num = $this->db->num_rows($result);
229 $min = min($num, ($limit <= 0 ? $num : $limit));
230 for ($i = 0; $i < $min; $i++) {
231 $list[] = $this->db->fetch_object($result);
234 throw new RestException(400, $this->db->lasterror());
257 public function getListOfRegions($sortfield =
"code_region", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
263 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_regions as t";
264 $sql .=
" WHERE 1 = 1";
266 $sql .=
" AND t.fk_pays = ".((int) $country);
272 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
274 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
275 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
278 $sql .= $this->db->order($sortfield, $sortorder);
284 $offset = $limit * $page;
286 $sql .= $this->db->plimit($limit, $offset);
289 $result = $this->db->query($sql);
292 $num = $this->db->num_rows($result);
293 $min = min($num, ($limit <= 0 ? $num : $limit));
294 for ($i = 0; $i < $min; $i++) {
295 $obj = $this->db->fetch_object($result);
296 $region =
new Cregion($this->db);
297 if ($region->fetch($obj->rowid) > 0) {
298 if (empty($filter) || stripos($region->name, $filter) !==
false) {
304 throw new RestException(503,
'Error when retrieving list of regions');
361 public function getListOfStates($sortfield =
"code_departement", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
367 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_departements as t";
369 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as d ON t.fk_region = d.code_region";
371 $sql .=
" WHERE 1 = 1";
373 $sql .=
" AND d.fk_pays = ".((int) $country);
380 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
384 $sql .= $this->db->order($sortfield, $sortorder);
390 $offset = $limit * $page;
392 $sql .= $this->db->plimit($limit, $offset);
395 $result = $this->db->query($sql);
398 $num = $this->db->num_rows($result);
399 $min = min($num, ($limit <= 0 ? $num : $limit));
400 for ($i = 0; $i < $min; $i++) {
401 $obj = $this->db->fetch_object($result);
402 $state =
new Cstate($this->db);
403 if ($state->fetch($obj->rowid) > 0) {
404 if (empty($filter) || stripos($state->label, $filter) !==
false) {
410 throw new RestException(503,
'Error when retrieving list of states');
467 public function getListOfCountries($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $filter =
'', $lang =
'', $sqlfilters =
'')
473 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"c_country as t";
474 $sql .=
" WHERE 1 = 1";
480 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
484 $sql .= $this->db->order($sortfield, $sortorder);
490 $offset = $limit * $page;
492 $sql .= $this->db->plimit($limit, $offset);
495 $result = $this->db->query($sql);
498 $num = $this->db->num_rows($result);
499 $min = min($num, ($limit <= 0 ? $num : $limit));
500 for ($i = 0; $i < $min; $i++) {
501 $obj = $this->db->fetch_object($result);
503 if ($country->fetch($obj->rowid) > 0) {
508 if (empty($filter) || stripos($country->label, $filter) !==
false) {
514 throw new RestException(503,
'Error when retrieving list of countries');
579 $region =
new Cregion($this->db);
581 $result = $region->fetch($id, $code);
583 throw new RestException(503,
'Error when retrieving region : '.$region->error);
584 } elseif ($result == 0) {
585 throw new RestException(404,
'Region not found');
602 $state =
new Cstate($this->db);
604 $result = $state->fetch($id, $code);
606 throw new RestException(503,
'Error when retrieving state : '.$state->error);
607 } elseif ($result == 0) {
608 throw new RestException(404,
'State not found');
629 $result = $country->fetch($id, $code, $iso);
632 throw new RestException(503,
'Error when retrieving country : '.$country->error);
633 } elseif ($result == 0) {
634 throw new RestException(404,
'Country not found');
658 public function getAvailability($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
662 if (!DolibarrApiAccess::$user->hasRight(
'commande',
'lire')) {
663 throw new RestException(401);
666 $sql =
"SELECT rowid, code, label";
667 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_availability as t";
668 $sql .=
" WHERE t.active = ".((int) $active);
674 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
679 $sql .= $this->db->order($sortfield, $sortorder);
685 $offset = $limit * $page;
687 $sql .= $this->db->plimit($limit, $offset);
690 $result = $this->db->query($sql);
693 $num = $this->db->num_rows($result);
694 $min = min($num, ($limit <= 0 ? $num : $limit));
695 for ($i = 0; $i < $min; $i++) {
696 $list[] = $this->db->fetch_object($result);
699 throw new RestException(400, $this->db->lasterror());
715 $object = parent::_cleanObjectDatas($object);
717 unset($object->error);
718 unset($object->errors);
732 private function translateLabel($object, $lang, $prefix =
'Country', $dict = array(
'dict'))
736 if ($this->translations ==
null || $this->translations->getDefaultLang() !== $lang) {
738 $this->translations =
new Translate(
'', $conf);
739 $this->translations->setDefaultLang($lang);
740 $this->translations->loadLangs($dict);
743 $key = $prefix.$object->code;
745 $translation = $this->translations->trans($key);
746 if ($translation != $key) {
747 $object->label = html_entity_decode($translation);
770 public function getListOfEventTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $sqlfilters =
'')
774 $sql =
"SELECT id, code, type, libelle as label, module";
775 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as t";
776 $sql .=
" WHERE t.active = ".((int) $active);
778 $sql .=
" AND t.type LIKE '%".$this->db->escape($type).
"%'";
781 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
788 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
793 $sql .= $this->db->order($sortfield, $sortorder);
799 $offset = $limit * $page;
801 $sql .= $this->db->plimit($limit, $offset);
804 $result = $this->db->query($sql);
807 $num = $this->db->num_rows($result);
808 $min = min($num, ($limit <= 0 ? $num : $limit));
809 for ($i = 0; $i < $min; $i++) {
810 $list[] = $this->db->fetch_object($result);
813 throw new RestException(503,
'Error when retrieving list of events types : '.$this->db->lasterror());
836 public function getListOfExpenseReportsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $sqlfilters =
'')
840 $sql =
"SELECT id, code, label, accountancy_code, active, module, position";
841 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees as t";
842 $sql .=
" WHERE t.active = ".((int) $active);
844 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
851 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
856 $sql .= $this->db->order($sortfield, $sortorder);
862 $offset = $limit * $page;
864 $sql .= $this->db->plimit($limit, $offset);
867 $result = $this->db->query($sql);
870 $num = $this->db->num_rows($result);
871 $min = min($num, ($limit <= 0 ? $num : $limit));
872 for ($i = 0; $i < $min; $i++) {
873 $list[] = $this->db->fetch_object($result);
876 throw new RestException(503,
'Error when retrieving list of expense report types : '.$this->db->lasterror());
901 public function getListOfContactTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
905 $sql =
"SELECT rowid, code, element as type, libelle as label, source, module, position";
906 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact as t";
907 $sql .=
" WHERE t.active = ".((int) $active);
909 $sql .=
" AND type LIKE '%".$this->db->escape($type).
"%'";
912 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
919 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
924 $sql .= $this->db->order($sortfield, $sortorder);
930 $offset = $limit * $page;
932 $sql .= $this->db->plimit($limit, $offset);
935 $result = $this->db->query($sql);
938 $num = $this->db->num_rows($result);
939 $min = min($num, ($limit <= 0 ? $num : $limit));
940 for ($i = 0; $i < $min; $i++) {
941 $contact_type = $this->db->fetch_object($result);
942 $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"));
943 $list[] = $contact_type;
946 throw new RestException(503,
'Error when retrieving list of contacts types : '.$this->db->lasterror());
969 public function getListOfCivilities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
973 $sql =
"SELECT rowid, code, label, module";
974 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_civility as t";
975 $sql .=
" WHERE t.active = ".((int) $active);
977 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
984 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
989 $sql .= $this->db->order($sortfield, $sortorder);
995 $offset = $limit * $page;
997 $sql .= $this->db->plimit($limit, $offset);
1000 $result = $this->db->query($sql);
1003 $num = $this->db->num_rows($result);
1004 $min = min($num, ($limit <= 0 ? $num : $limit));
1005 for ($i = 0; $i < $min; $i++) {
1006 $civility = $this->db->fetch_object($result);
1007 $this->
translateLabel($civility, $lang,
'Civility', array(
'dict'));
1008 $list[] = $civility;
1011 throw new RestException(503,
'Error when retrieving list of civility : '.$this->db->lasterror());
1033 public function getListOfCurrencies($multicurrency = 0, $sortfield =
"code_iso", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1036 $sql =
"SELECT t.code_iso, t.label, t.unicode";
1037 if (!empty($multicurrency)) {
1038 $sql .=
" , cr.date_sync, cr.rate ";
1040 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_currencies as t";
1041 if (!empty($multicurrency)) {
1042 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency as m ON m.code=t.code_iso";
1043 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
1045 $sql .=
" WHERE t.active = ".((int) $active);
1046 if (!empty($multicurrency)) {
1047 $sql .=
" AND m.entity IN (".getEntity(
'multicurrency').
")";
1048 if (!empty($multicurrency) && $multicurrency != 2) {
1049 $sql .=
" AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.
"multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
1057 if ($errormessage) {
1058 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1063 $sql .= $this->db->order($sortfield, $sortorder);
1069 $offset = $limit * $page;
1071 $sql .= $this->db->plimit($limit, $offset);
1074 $result = $this->db->query($sql);
1077 $num = $this->db->num_rows($result);
1078 $min = min($num, ($limit <= 0 ? $num : $limit));
1079 for ($i = 0; $i < $min; $i++) {
1080 $list[] = $this->db->fetch_object($result);
1083 throw new RestException(503,
'Error when retrieving list of currency : '.$this->db->lasterror());
1106 if (!DolibarrApiAccess::$user->admin) {
1107 throw new RestException(401,
'Only an admin user can get list of extrafields');
1110 if ($type ==
'thirdparty') {
1113 if ($type ==
'contact') {
1114 $type =
'socpeople';
1117 $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";
1118 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1119 $sql .=
" WHERE t.entity IN (".getEntity(
'extrafields').
")";
1120 if (!empty($type)) {
1121 $sql .=
" AND t.elementtype = '".$this->db->escape($type).
"'";
1127 if ($errormessage) {
1128 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1132 $sql .= $this->db->order($sortfield, $sortorder);
1134 $resql = $this->db->query($sql);
1136 if ($this->db->num_rows($resql)) {
1137 while ($tab = $this->db->fetch_object($resql)) {
1139 $list[$tab->elementtype][$tab->name][
'type'] = $tab->type;
1140 $list[$tab->elementtype][$tab->name][
'label'] = $tab->label;
1141 $list[$tab->elementtype][$tab->name][
'size'] = $tab->size;
1142 $list[$tab->elementtype][$tab->name][
'elementtype'] = $tab->elementtype;
1143 $list[$tab->elementtype][$tab->name][
'default'] = $tab->fielddefault;
1144 $list[$tab->elementtype][$tab->name][
'computed'] = $tab->fieldcomputed;
1145 $list[$tab->elementtype][$tab->name][
'unique'] = $tab->fieldunique;
1146 $list[$tab->elementtype][$tab->name][
'required'] = $tab->fieldrequired;
1147 $list[$tab->elementtype][$tab->name][
'param'] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1148 $list[$tab->elementtype][$tab->name][
'pos'] = $tab->pos;
1149 $list[$tab->elementtype][$tab->name][
'alwayseditable'] = $tab->alwayseditable;
1150 $list[$tab->elementtype][$tab->name][
'perms'] = $tab->perms;
1151 $list[$tab->elementtype][$tab->name][
'list'] = $tab->list;
1155 throw new RestException(503,
'Error when retrieving list of extra fields : '.$this->db->lasterror());
1158 if (!count($list)) {
1159 throw new RestException(404,
'No extrafield found');
1183 public function getListOfTowns($sortfield =
"zip,town", $sortorder =
'ASC', $limit = 100, $page = 0, $zipcode =
'', $town =
'', $active = 1, $sqlfilters =
'')
1187 $sql =
"SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
1188 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ziptown as t";
1189 $sql .=
" WHERE t.active = ".((int) $active);
1191 $sql .=
" AND t.zip LIKE '%".$this->db->escape($zipcode).
"%'";
1194 $sql .=
" AND t.town LIKE '%".$this->db->escape($town).
"%'";
1200 if ($errormessage) {
1201 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1206 $sql .= $this->db->order($sortfield, $sortorder);
1212 $offset = $limit * $page;
1214 $sql .= $this->db->plimit($limit, $offset);
1217 $result = $this->db->query($sql);
1220 $num = $this->db->num_rows($result);
1221 $min = min($num, ($limit <= 0 ? $num : $limit));
1222 for ($i = 0; $i < $min; $i++) {
1223 $list[] = $this->db->fetch_object($result);
1226 throw new RestException(503,
'Error when retrieving list of towns : '.$this->db->lasterror());
1248 public function getPaymentTerms($sortfield =
"sortorder", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1252 if (!DolibarrApiAccess::$user->hasRight(
'propal',
'lire') && !DolibarrApiAccess::$user->hasRight(
'commande',
'lire') && !DolibarrApiAccess::$user->hasRight(
'facture',
'lire')) {
1253 throw new RestException(401);
1256 $sql =
"SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
1257 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
1258 $sql .=
" WHERE t.entity IN (".getEntity(
'c_payment_term').
")";
1259 $sql .=
" AND t.active = ".((int) $active);
1264 if ($errormessage) {
1265 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1270 $sql .= $this->db->order($sortfield, $sortorder);
1276 $offset = $limit * $page;
1278 $sql .= $this->db->plimit($limit, $offset);
1281 $result = $this->db->query($sql);
1284 $num = $this->db->num_rows($result);
1285 $min = min($num, ($limit <= 0 ? $num : $limit));
1286 for ($i = 0; $i < $min; $i++) {
1287 $list[] = $this->db->fetch_object($result);
1290 throw new RestException(400, $this->db->lasterror());
1311 public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1315 $sql =
"SELECT rowid as id, code, libelle as label, description, tracking, module";
1316 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as t";
1317 $sql .=
" WHERE t.entity IN (".getEntity(
'c_shipment_mode').
")";
1318 $sql .=
" AND t.active = ".((int) $active);
1323 if ($errormessage) {
1324 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1335 $offset = $limit * $page;
1337 $sql .= $this->db->plimit($limit, $offset);
1340 $result = $this->db->query($sql);
1343 $num = $this->db->num_rows($result);
1344 $min = min($num, ($limit <= 0 ? $num : $limit));
1345 for ($i = 0; $i < $min; $i++) {
1346 $method = $this->db->fetch_object($result);
1351 throw new RestException(400, $this->db->lasterror());
1372 public function getListOfMeasuringUnits($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1376 $sql =
"SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
1377 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_units as t";
1378 $sql .=
" WHERE t.active = ".((int) $active);
1383 if ($errormessage) {
1384 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1389 $sql .= $this->db->order($sortfield, $sortorder);
1395 $offset = $limit * $page;
1397 $sql .= $this->db->plimit($limit, $offset);
1400 $result = $this->db->query($sql);
1403 $num = $this->db->num_rows($result);
1404 $min = min($num, ($limit <= 0 ? $num : $limit));
1405 for ($i = 0; $i < $min; $i++) {
1406 $list[] = $this->db->fetch_object($result);
1409 throw new RestException(503,
'Error when retrieving list of measuring units: '.$this->db->lasterror());
1431 public function getListOfLegalForm($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters =
'')
1435 $sql =
"SELECT t.rowid, t.code, t.fk_pays, t.libelle, t.isvatexempted, t.active, t.module, t.position";
1436 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_forme_juridique as t";
1437 $sql .=
" WHERE t.active = ".((int) $active);
1439 $sql .=
" AND t.fk_pays = ".((int) $country);
1445 if ($errormessage) {
1446 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1451 $sql .= $this->db->order($sortfield, $sortorder);
1457 $offset = $limit * $page;
1459 $sql .= $this->db->plimit($limit, $offset);
1462 $result = $this->db->query($sql);
1465 $num = $this->db->num_rows($result);
1466 $min = min($num, ($limit <= 0 ? $num : $limit));
1467 for ($i = 0; $i < $min; $i++) {
1468 $list[] = $this->db->fetch_object($result);
1471 throw new RestException(503,
'Error when retrieving list of legal form: '.$this->db->lasterror());
1492 public function getListOfStaff($sortfield =
"id", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1496 $sql =
"SELECT t.id, t.code, t.libelle, t.active, t.module";
1497 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_effectif as t";
1498 $sql .=
" WHERE t.active = ".((int) $active);
1503 if ($errormessage) {
1504 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1509 $sql .= $this->db->order($sortfield, $sortorder);
1515 $offset = $limit * $page;
1517 $sql .= $this->db->plimit($limit, $offset);
1520 $result = $this->db->query($sql);
1523 $num = $this->db->num_rows($result);
1524 $min = min($num, ($limit <= 0 ? $num : $limit));
1525 for ($i = 0; $i < $min; $i++) {
1526 $list[] = $this->db->fetch_object($result);
1529 throw new RestException(503,
'Error when retrieving list of staff: '.$this->db->lasterror());
1550 public function getListOfsocialNetworks($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1554 if (!isModEnabled(
'socialnetworks')) {
1555 throw new RestException(400,
'API not available: this dictionary is not enabled by setup');
1560 $sql =
"SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active";
1561 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_socialnetworks as t";
1562 $sql .=
" WHERE t.entity IN (".getEntity(
'c_socialnetworks').
")";
1563 $sql .=
" AND t.active = ".((int) $active);
1568 if ($errormessage) {
1569 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1574 $sql .= $this->db->order($sortfield, $sortorder);
1580 $offset = $limit * $page;
1582 $sql .= $this->db->plimit($limit, $offset);
1585 $result = $this->db->query($sql);
1588 $num = $this->db->num_rows($result);
1589 $min = min($num, ($limit <= 0 ? $num : $limit));
1590 for ($i = 0; $i < $min; $i++) {
1591 $list[] = $this->db->fetch_object($result);
1594 throw new RestException(503,
'Error when retrieving list of social networks: '.$this->db->lasterror());
1616 public function getTicketsCategories($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1620 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1621 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category as t";
1622 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_category').
")";
1623 $sql .=
" AND t.active = ".((int) $active);
1628 if ($errormessage) {
1629 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1634 $sql .= $this->db->order($sortfield, $sortorder);
1640 $offset = $limit * $page;
1642 $sql .= $this->db->plimit($limit, $offset);
1645 $result = $this->db->query($sql);
1648 $num = $this->db->num_rows($result);
1649 $min = min($num, ($limit <= 0 ? $num : $limit));
1650 for ($i = 0; $i < $min; $i++) {
1651 $category = $this->db->fetch_object($result);
1652 $this->
translateLabel($category, $lang,
'TicketCategoryShort', array(
'ticket'));
1653 $list[] = $category;
1656 throw new RestException(503,
'Error when retrieving list of ticket categories : '.$this->db->lasterror());
1678 public function getTicketsSeverities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1682 $sql =
"SELECT rowid, code, pos, label, use_default, color, description";
1683 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity as t";
1684 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_severity').
")";
1685 $sql .=
" AND t.active = ".((int) $active);
1690 if ($errormessage) {
1691 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1696 $sql .= $this->db->order($sortfield, $sortorder);
1702 $offset = $limit * $page;
1704 $sql .= $this->db->plimit($limit, $offset);
1707 $result = $this->db->query($sql);
1710 $num = $this->db->num_rows($result);
1711 $min = min($num, ($limit <= 0 ? $num : $limit));
1712 for ($i = 0; $i < $min; $i++) {
1713 $severity = $this->db->fetch_object($result);
1714 $this->
translateLabel($severity, $lang,
'TicketSeverityShort', array(
'ticket'));
1715 $list[] = $severity;
1718 throw new RestException(503,
'Error when retrieving list of ticket severities : '.$this->db->lasterror());
1740 public function getTicketsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1744 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1745 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type as t";
1746 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_type').
")";
1747 $sql .=
" AND t.active = ".((int) $active);
1753 if ($errormessage) {
1754 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1759 $sql .= $this->db->order($sortfield, $sortorder);
1765 $offset = $limit * $page;
1767 $sql .= $this->db->plimit($limit, $offset);
1770 $result = $this->db->query($sql);
1773 $num = $this->db->num_rows($result);
1774 $min = min($num, ($limit <= 0 ? $num : $limit));
1775 for ($i = 0; $i < $min; $i++) {
1776 $type =$this->db->fetch_object($result);
1777 $this->
translateLabel($type, $lang,
'TicketTypeShort', array(
'ticket'));
1781 throw new RestException(503,
'Error when retrieving list of ticket types : '.$this->db->lasterror());
1803 public function getListOfIncoterms($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1807 $sql =
"SELECT rowid, code, active";
1808 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_incoterms as t";
1809 $sql .=
" WHERE 1=1";
1815 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1817 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1818 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1822 $sql .= $this->db->order($sortfield, $sortorder);
1828 $offset = $limit * $page;
1830 $sql .= $this->db->plimit($limit, $offset);
1833 $result = $this->db->query($sql);
1836 $num = $this->db->num_rows($result);
1837 $min = min($num, ($limit <= 0 ? $num : $limit));
1838 for ($i = 0; $i < $min; $i++) {
1839 $type =$this->db->fetch_object($result);
1843 throw new RestException(503,
'Error when retrieving list of incoterm types : '.$this->db->lasterror());
1860 global $conf, $mysoc;
1862 if (!DolibarrApiAccess::$user->admin
1863 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
1864 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');
1867 unset($mysoc->pays);
1868 unset($mysoc->note);
1871 unset($mysoc->lines);
1873 unset($mysoc->effectif);
1874 unset($mysoc->effectif_id);
1875 unset($mysoc->forme_juridique_code);
1876 unset($mysoc->forme_juridique);
1877 unset($mysoc->mode_reglement_supplier_id);
1878 unset($mysoc->cond_reglement_supplier_id);
1879 unset($mysoc->transport_mode_supplier_id);
1880 unset($mysoc->fk_prospectlevel);
1882 unset($mysoc->total_ht);
1883 unset($mysoc->total_tva);
1884 unset($mysoc->total_localtax1);
1885 unset($mysoc->total_localtax2);
1886 unset($mysoc->total_ttc);
1888 unset($mysoc->lastname);
1889 unset($mysoc->firstname);
1890 unset($mysoc->civility_id);
1892 unset($mysoc->client);
1893 unset($mysoc->prospect);
1894 unset($mysoc->fournisseur);
1895 unset($mysoc->contact_id);
1897 unset($mysoc->fk_incoterms);
1898 unset($mysoc->label_incoterms);
1899 unset($mysoc->location_incoterms);
1919 $sql =
"SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status";
1920 $sql .=
" FROM ".MAIN_DB_PREFIX.
"establishment as e";
1921 $sql .=
" WHERE e.entity IN (".getEntity(
'establishment').
')';
1926 $result = $this->db->query($sql);
1929 $num = $this->db->num_rows($result);
1930 $min = min($num, ($limit <= 0 ? $num : $limit));
1931 for ($i = 0; $i < $min; $i++) {
1932 $list[] = $this->db->fetch_object($result);
1935 throw new RestException(503,
'Error when retrieving list of establishments : '.$this->db->lasterror());
1955 $result = $establishment->fetch($id);
1957 throw new RestException(503,
'Error when retrieving establishment : '.$establishment->error);
1958 } elseif ($result == 0) {
1959 throw new RestException(404,
'Establishment not found');
1982 if (!DolibarrApiAccess::$user->admin
1984 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');
1987 if (!preg_match(
'/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
1988 throw new RestException(404,
'Error Bad or unknown value for constantname');
1991 throw new RestException(403,
'Forbidden. This parameter cant be read with APIs');
2012 global $langs, $conf;
2014 if (!DolibarrApiAccess::$user->admin
2015 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK)) {
2016 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');
2019 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2020 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
2022 $langs->load(
"admin");
2024 $outexpectedchecksum =
'';
2025 $outcurrentchecksum =
'';
2028 $file_list = array(
'missing' => array(),
'updated' => array());
2031 $xmlshortfile =
dol_sanitizeFileName(
GETPOST(
'xmlshortfile',
'alpha') ?
GETPOST(
'xmlshortfile',
'alpha') :
'filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ?
'' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).
'.xml'.(empty($conf->global->MAIN_FILECHECK_LOCAL_EXT) ?
'' : $conf->global->MAIN_FILECHECK_LOCAL_EXT));
2032 $xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
2034 $xmlremote = ($target ==
'default' ?
'' : $target);
2035 if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
2036 $xmlremote = $conf->global->MAIN_FILECHECK_URL;
2038 $param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
2039 if (empty($xmlremote) && !empty($conf->global->$param)) {
2040 $xmlremote = $conf->global->$param;
2042 if (empty($xmlremote)) {
2043 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
2045 if ($xmlremote && !preg_match(
'/^https?:\/\//i', $xmlremote)) {
2046 $langs->load(
"errors");
2047 throw new RestException(500, $langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote));
2049 if ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
2050 $langs->load(
"errors");
2051 throw new RestException(500, $langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'));
2054 if ($target ==
'local') {
2056 $xml = simplexml_load_file($xmlfile);
2058 throw new RestException(500, $langs->trans(
'XmlNotFound').
': '.$xmlfile);
2061 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
2064 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404') {
2065 $xmlfile = $xmlarray[
'content'];
2067 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
2069 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
2070 throw new RestException(500, $errormsg);
2075 $checksumconcat = array();
2076 $file_list = array();
2080 if (is_object($xml->dolibarr_constants[0])) {
2083 $out .=
'<div class="div-table-responsive-no-min">';
2084 $out .=
'<table class="noborder">';
2085 $out .=
'<tr class="liste_titre">';
2086 $out .=
'<td>#</td>';
2087 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
2088 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
2089 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
2090 $out .=
'</tr>'.
"\n";
2093 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
2094 $constname = $constant[
'name'];
2095 $constvalue = (string) $constant;
2096 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
2099 if ($constname && $conf->global->$constname !=
'') {
2100 $value = $conf->global->$constname;
2102 $valueforchecksum = (empty($value) ?
'0' : $value);
2104 $checksumconcat[] = $valueforchecksum;
2107 $out .=
'<tr class="oddeven">';
2108 $out .=
'<td>'.$i.
'</td>'.
"\n";
2109 $out .=
'<td>'.$constname.
'</td>'.
"\n";
2110 $out .=
'<td class="center">'.$constvalue.
'</td>'.
"\n";
2111 $out .=
'<td class="center">'.$valueforchecksum.
'</td>'.
"\n";
2116 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2125 if (is_object($xml->dolibarr_htdocs_dir[0])) {
2126 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
2129 $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)$';
2130 $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)$';
2131 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
2134 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
2136 foreach ($scanfiles as $keyfile => $valfile) {
2137 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
2138 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
2139 $md5newfile = @md5_file($valfile[
'fullname']);
2140 $file_list[
'added'][] = array(
'filename'=>$tmprelativefilename,
'md5'=>$md5newfile);
2147 $out .=
'<div class="div-table-responsive-no-min">';
2148 $out .=
'<table class="noborder">';
2149 $out .=
'<tr class="liste_titre">';
2150 $out .=
'<td>#</td>';
2151 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2152 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2153 $out .=
'</tr>'.
"\n";
2154 $tmpfilelist =
dol_sort_array($file_list[
'missing'],
'filename');
2155 if (is_array($tmpfilelist) && count($tmpfilelist)) {
2157 foreach ($tmpfilelist as $file) {
2159 $out .=
'<tr class="oddeven">';
2160 $out .=
'<td>'.$i.
'</td>'.
"\n";
2161 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2162 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2166 $out .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2177 $out .=
'<div class="div-table-responsive-no-min">';
2178 $out .=
'<table class="noborder">';
2179 $out .=
'<tr class="liste_titre">';
2180 $out .=
'<td>#</td>';
2181 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2182 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2183 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2184 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2185 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2186 $out .=
'</tr>'.
"\n";
2187 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
2188 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
2190 foreach ($tmpfilelist2 as $file) {
2192 $out .=
'<tr class="oddeven">';
2193 $out .=
'<td>'.$i.
'</td>'.
"\n";
2194 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2195 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2196 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2197 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2198 $totalsize += $size;
2199 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2200 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2203 $out .=
'<tr class="liste_total">';
2204 $out .=
'<td></td>'.
"\n";
2205 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2206 $out .=
'<td align="center"></td>'.
"\n";
2207 $out .=
'<td align="center"></td>'.
"\n";
2208 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2209 $out .=
'<td class="right"></td>'.
"\n";
2212 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2223 $out .=
'<div class="div-table-responsive-no-min">';
2224 $out .=
'<table class="noborder">';
2225 $out .=
'<tr class="liste_titre">';
2226 $out .=
'<td>#</td>';
2227 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2228 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2229 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2230 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2231 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2232 $out .=
'</tr>'.
"\n";
2234 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
2236 foreach ($tmpfilelist3 as $file) {
2238 $out .=
'<tr class="oddeven">';
2239 $out .=
'<td>'.$i.
'</td>'.
"\n";
2240 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2241 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2242 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2243 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2244 $totalsize += $size;
2245 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2246 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2249 $out .=
'<tr class="liste_total">';
2250 $out .=
'<td></td>'.
"\n";
2251 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2252 $out .=
'<td align="center"></td>'.
"\n";
2253 $out .=
'<td align="center"></td>'.
"\n";
2254 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2255 $out .=
'<td class="right"></td>'.
"\n";
2258 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2265 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
2271 throw new RestException(500,
'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
2276 asort($checksumconcat);
2277 $checksumget = md5(join(
',', $checksumconcat));
2278 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
2280 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
2281 if ($checksumget == $checksumtoget) {
2282 if (count($file_list[
'added'])) {
2283 $resultcode =
'warning';
2284 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
2286 $outcurrentchecksum = $checksumget;
2289 $resultcomment =
'Success';
2291 $outcurrentchecksum = $checksumget;
2294 $resultcode =
'error';
2295 $resultcomment =
'Error';
2297 $outcurrentchecksum = $checksumget;
2300 throw new RestException(404,
'No signature file known');
2303 return array(
'resultcode'=>$resultcode,
'resultcomment'=>$resultcomment,
'expectedchecksum'=> $outexpectedchecksum,
'currentchecksum'=> $outcurrentchecksum,
'out'=>$out);
2320 if (!DolibarrApiAccess::$user->admin
2321 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES)) {
2322 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');
2325 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).