24 use Luracast\Restler\RestException;
26 require_once DOL_DOCUMENT_ROOT.
'/main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/cstate.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/ccountry.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/hrm/class/establishment.class.php';
39 private $translations =
null;
66 public function getOrderingMethods($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
70 if (!DolibarrApiAccess::$user->rights->commande->lire) {
71 throw new RestException(401);
74 $sql =
"SELECT rowid, code, libelle as label, module";
75 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_method as t";
76 $sql .=
" WHERE t.active = ".((int) $active);
82 throw new RestException(503,
'Error when validating parameter sqlfilters -> '.$errormessage);
87 $sql .= $this->
db->order($sortfield, $sortorder);
93 $offset = $limit * $page;
95 $sql .= $this->
db->plimit($limit, $offset);
98 $result = $this->
db->query($sql);
101 $num = $this->
db->num_rows($result);
102 $min = min($num, ($limit <= 0 ? $num : $limit));
103 for ($i = 0; $i < $min; $i++) {
104 $list[] = $this->
db->fetch_object($result);
107 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->rights->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->rights->propal->lire && !DolibarrApiAccess::$user->rights->commande->lire && !DolibarrApiAccess::$user->rights->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());
260 public function getListOfStates($sortfield =
"code_departement", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
266 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_departements as t";
268 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as d ON t.fk_region = d.code_region";
270 $sql .=
" WHERE 1 = 1";
272 $sql .=
" AND d.fk_pays = ".((int) $country);
279 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
283 $sql .= $this->
db->order($sortfield, $sortorder);
289 $offset = $limit * $page;
291 $sql .= $this->
db->plimit($limit, $offset);
294 $result = $this->
db->query($sql);
297 $num = $this->
db->num_rows($result);
298 $min = min($num, ($limit <= 0 ? $num : $limit));
299 for ($i = 0; $i < $min; $i++) {
300 $obj = $this->
db->fetch_object($result);
302 if ($state->fetch($obj->rowid) > 0) {
303 if (empty($filter) || stripos($state->label, $filter) !==
false) {
309 throw new RestException(503,
'Error when retrieving list of states');
366 public function getListOfCountries($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $filter =
'', $lang =
'', $sqlfilters =
'')
372 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"c_country as t";
373 $sql .=
" WHERE 1 = 1";
379 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
383 $sql .= $this->
db->order($sortfield, $sortorder);
389 $offset = $limit * $page;
391 $sql .= $this->
db->plimit($limit, $offset);
394 $result = $this->
db->query($sql);
397 $num = $this->
db->num_rows($result);
398 $min = min($num, ($limit <= 0 ? $num : $limit));
399 for ($i = 0; $i < $min; $i++) {
400 $obj = $this->
db->fetch_object($result);
402 if ($country->fetch($obj->rowid) > 0) {
407 if (empty($filter) || stripos($country->label, $filter) !==
false) {
413 throw new RestException(503,
'Error when retrieving list of countries');
483 $result = $state->fetch($id, $code);
485 throw new RestException(503,
'Error when retrieving state : '.$state->error);
486 } elseif ($result == 0) {
487 throw new RestException(404,
'State not found');
509 $result = $country->fetch($id, $code, $iso);
512 throw new RestException(503,
'Error when retrieving country : '.$country->error);
513 } elseif ($result == 0) {
514 throw new RestException(404,
'Country not found');
538 public function getAvailability($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
542 if (!DolibarrApiAccess::$user->rights->commande->lire) {
543 throw new RestException(401);
546 $sql =
"SELECT rowid, code, label";
547 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_availability as t";
548 $sql .=
" WHERE t.active = ".((int) $active);
554 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
559 $sql .= $this->
db->order($sortfield, $sortorder);
565 $offset = $limit * $page;
567 $sql .= $this->
db->plimit($limit, $offset);
570 $result = $this->
db->query($sql);
573 $num = $this->
db->num_rows($result);
574 $min = min($num, ($limit <= 0 ? $num : $limit));
575 for ($i = 0; $i < $min; $i++) {
576 $list[] = $this->
db->fetch_object($result);
579 throw new RestException(400, $this->
db->lasterror());
595 $object = parent::_cleanObjectDatas($object);
597 unset($object->error);
598 unset($object->errors);
612 private function translateLabel($object, $lang, $prefix =
'Country', $dict = array(
'dict'))
616 if ($this->translations ==
null || $this->translations->getDefaultLang() !== $lang) {
618 $this->translations =
new Translate(
'', $conf);
619 $this->translations->setDefaultLang($lang);
620 $this->translations->loadLangs($dict);
623 $key = $prefix.$object->code;
625 $translation = $this->translations->trans($key);
626 if ($translation != $key) {
627 $object->label = html_entity_decode($translation);
650 public function getListOfEventTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $sqlfilters =
'')
654 $sql =
"SELECT id, code, type, libelle as label, module";
655 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as t";
656 $sql .=
" WHERE t.active = ".((int) $active);
658 $sql .=
" AND t.type LIKE '%".$this->db->escape($type).
"%'";
661 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
668 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
673 $sql .= $this->
db->order($sortfield, $sortorder);
679 $offset = $limit * $page;
681 $sql .= $this->
db->plimit($limit, $offset);
684 $result = $this->
db->query($sql);
687 $num = $this->
db->num_rows($result);
688 $min = min($num, ($limit <= 0 ? $num : $limit));
689 for ($i = 0; $i < $min; $i++) {
690 $list[] = $this->
db->fetch_object($result);
693 throw new RestException(503,
'Error when retrieving list of events types : '.$this->
db->lasterror());
716 public function getListOfExpenseReportsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $sqlfilters =
'')
720 $sql =
"SELECT id, code, label, accountancy_code, active, module, position";
721 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees as t";
722 $sql .=
" WHERE t.active = ".((int) $active);
724 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
731 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
736 $sql .= $this->
db->order($sortfield, $sortorder);
742 $offset = $limit * $page;
744 $sql .= $this->
db->plimit($limit, $offset);
747 $result = $this->
db->query($sql);
750 $num = $this->
db->num_rows($result);
751 $min = min($num, ($limit <= 0 ? $num : $limit));
752 for ($i = 0; $i < $min; $i++) {
753 $list[] = $this->
db->fetch_object($result);
756 throw new RestException(503,
'Error when retrieving list of expense report types : '.$this->
db->lasterror());
781 public function getListOfContactTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
785 $sql =
"SELECT rowid, code, element as type, libelle as label, source, module, position";
786 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact as t";
787 $sql .=
" WHERE t.active = ".((int) $active);
789 $sql .=
" AND type LIKE '%".$this->db->escape($type).
"%'";
792 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
799 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
804 $sql .= $this->
db->order($sortfield, $sortorder);
810 $offset = $limit * $page;
812 $sql .= $this->
db->plimit($limit, $offset);
815 $result = $this->
db->query($sql);
818 $num = $this->
db->num_rows($result);
819 $min = min($num, ($limit <= 0 ? $num : $limit));
820 for ($i = 0; $i < $min; $i++) {
821 $contact_type = $this->
db->fetch_object($result);
822 $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"));
823 $list[] = $contact_type;
826 throw new RestException(503,
'Error when retrieving list of contacts types : '.$this->
db->lasterror());
849 public function getListOfCivilities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
853 $sql =
"SELECT rowid, code, label, module";
854 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_civility as t";
855 $sql .=
" WHERE t.active = ".((int) $active);
857 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
864 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
869 $sql .= $this->
db->order($sortfield, $sortorder);
875 $offset = $limit * $page;
877 $sql .= $this->
db->plimit($limit, $offset);
880 $result = $this->
db->query($sql);
883 $num = $this->
db->num_rows($result);
884 $min = min($num, ($limit <= 0 ? $num : $limit));
885 for ($i = 0; $i < $min; $i++) {
886 $civility = $this->
db->fetch_object($result);
887 $this->
translateLabel($civility, $lang,
'Civility', array(
'dict'));
891 throw new RestException(503,
'Error when retrieving list of civility : '.$this->
db->lasterror());
913 public function getListOfCurrencies($multicurrency = 0, $sortfield =
"code_iso", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
916 $sql =
"SELECT t.code_iso, t.label, t.unicode";
917 if (!empty($multicurrency)) {
918 $sql .=
" , cr.date_sync, cr.rate ";
920 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_currencies as t";
921 if (!empty($multicurrency)) {
922 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency as m ON m.code=t.code_iso";
923 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
925 $sql .=
" WHERE t.active = ".((int) $active);
926 if (!empty($multicurrency)) {
927 $sql .=
" AND m.entity IN (".getEntity(
'multicurrency').
")";
928 if (!empty($multicurrency) && $multicurrency != 2) {
929 $sql .=
" AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.
"multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
938 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
943 $sql .= $this->
db->order($sortfield, $sortorder);
949 $offset = $limit * $page;
951 $sql .= $this->
db->plimit($limit, $offset);
954 $result = $this->
db->query($sql);
957 $num = $this->
db->num_rows($result);
958 $min = min($num, ($limit <= 0 ? $num : $limit));
959 for ($i = 0; $i < $min; $i++) {
960 $list[] = $this->
db->fetch_object($result);
963 throw new RestException(503,
'Error when retrieving list of currency : '.$this->
db->lasterror());
986 if (!DolibarrApiAccess::$user->admin) {
987 throw new RestException(401,
'Only an admin user can get list of extrafields');
990 if ($type ==
'thirdparty') {
993 if ($type ==
'contact') {
997 $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";
998 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
999 $sql .=
" WHERE t.entity IN (".getEntity(
'extrafields').
")";
1000 if (!empty($type)) {
1001 $sql .=
" AND t.elementtype = '".$this->db->escape($type).
"'";
1007 if ($errormessage) {
1008 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1012 $sql .= $this->
db->order($sortfield, $sortorder);
1017 while ($tab = $this->
db->fetch_object(
$resql)) {
1019 $list[$tab->elementtype][$tab->name][
'type'] = $tab->type;
1020 $list[$tab->elementtype][$tab->name][
'label'] = $tab->label;
1021 $list[$tab->elementtype][$tab->name][
'size'] = $tab->size;
1022 $list[$tab->elementtype][$tab->name][
'elementtype'] = $tab->elementtype;
1023 $list[$tab->elementtype][$tab->name][
'default'] = $tab->fielddefault;
1024 $list[$tab->elementtype][$tab->name][
'computed'] = $tab->fieldcomputed;
1025 $list[$tab->elementtype][$tab->name][
'unique'] = $tab->fieldunique;
1026 $list[$tab->elementtype][$tab->name][
'required'] = $tab->fieldrequired;
1027 $list[$tab->elementtype][$tab->name][
'param'] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1028 $list[$tab->elementtype][$tab->name][
'pos'] = $tab->pos;
1029 $list[$tab->elementtype][$tab->name][
'alwayseditable'] = $tab->alwayseditable;
1030 $list[$tab->elementtype][$tab->name][
'perms'] = $tab->perms;
1031 $list[$tab->elementtype][$tab->name][
'list'] = $tab->list;
1035 throw new RestException(503,
'Error when retrieving list of extra fields : '.$this->
db->lasterror());
1038 if (!count($list)) {
1039 throw new RestException(404,
'No extrafield found');
1063 public function getListOfTowns($sortfield =
"zip,town", $sortorder =
'ASC', $limit = 100, $page = 0, $zipcode =
'', $town =
'', $active = 1, $sqlfilters =
'')
1067 $sql =
"SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
1068 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ziptown as t";
1069 $sql .=
" WHERE t.active = ".((int) $active);
1071 $sql .=
" AND t.zip LIKE '%".$this->db->escape($zipcode).
"%'";
1074 $sql .=
" AND t.town LIKE '%".$this->db->escape($town).
"%'";
1080 if ($errormessage) {
1081 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1086 $sql .= $this->
db->order($sortfield, $sortorder);
1092 $offset = $limit * $page;
1094 $sql .= $this->
db->plimit($limit, $offset);
1097 $result = $this->
db->query($sql);
1100 $num = $this->
db->num_rows($result);
1101 $min = min($num, ($limit <= 0 ? $num : $limit));
1102 for ($i = 0; $i < $min; $i++) {
1103 $list[] = $this->
db->fetch_object($result);
1106 throw new RestException(503,
'Error when retrieving list of towns : '.$this->
db->lasterror());
1128 public function getPaymentTerms($sortfield =
"sortorder", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1132 if (!DolibarrApiAccess::$user->rights->propal->lire && !DolibarrApiAccess::$user->rights->commande->lire && !DolibarrApiAccess::$user->rights->facture->lire) {
1133 throw new RestException(401);
1136 $sql =
"SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
1137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
1138 $sql .=
" WHERE t.entity IN (".getEntity(
'c_payment_term').
")";
1139 $sql .=
" AND t.active = ".((int) $active);
1144 if ($errormessage) {
1145 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1150 $sql .= $this->
db->order($sortfield, $sortorder);
1156 $offset = $limit * $page;
1158 $sql .= $this->
db->plimit($limit, $offset);
1161 $result = $this->
db->query($sql);
1164 $num = $this->
db->num_rows($result);
1165 $min = min($num, ($limit <= 0 ? $num : $limit));
1166 for ($i = 0; $i < $min; $i++) {
1167 $list[] = $this->
db->fetch_object($result);
1170 throw new RestException(400, $this->
db->lasterror());
1191 public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1195 $sql =
"SELECT rowid as id, code, libelle as label, description, tracking, module";
1196 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as t";
1197 $sql .=
" WHERE t.entity IN (".getEntity(
'c_shipment_mode').
")";
1198 $sql .=
" AND t.active = ".((int) $active);
1203 if ($errormessage) {
1204 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1215 $offset = $limit * $page;
1217 $sql .= $this->
db->plimit($limit, $offset);
1220 $result = $this->
db->query($sql);
1223 $num = $this->
db->num_rows($result);
1224 $min = min($num, ($limit <= 0 ? $num : $limit));
1225 for ($i = 0; $i < $min; $i++) {
1226 $method = $this->
db->fetch_object($result);
1231 throw new RestException(400, $this->
db->lasterror());
1252 public function getListOfMeasuringUnits($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1256 $sql =
"SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
1257 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_units as t";
1258 $sql .=
" WHERE t.active = ".((int) $active);
1263 if ($errormessage) {
1264 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1269 $sql .= $this->
db->order($sortfield, $sortorder);
1275 $offset = $limit * $page;
1277 $sql .= $this->
db->plimit($limit, $offset);
1280 $result = $this->
db->query($sql);
1283 $num = $this->
db->num_rows($result);
1284 $min = min($num, ($limit <= 0 ? $num : $limit));
1285 for ($i = 0; $i < $min; $i++) {
1286 $list[] = $this->
db->fetch_object($result);
1289 throw new RestException(503,
'Error when retrieving list of measuring units: '.$this->
db->lasterror());
1311 public function getListOfLegalForm($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters =
'')
1315 $sql =
"SELECT t.rowid, t.code, t.fk_pays, t.libelle, t.isvatexempted, t.active, t.module, t.position";
1316 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_forme_juridique as t";
1317 $sql .=
" WHERE t.active = ".((int) $active);
1319 $sql .=
" AND t.fk_pays = ".((int) $country);
1325 if ($errormessage) {
1326 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1331 $sql .= $this->
db->order($sortfield, $sortorder);
1337 $offset = $limit * $page;
1339 $sql .= $this->
db->plimit($limit, $offset);
1342 $result = $this->
db->query($sql);
1345 $num = $this->
db->num_rows($result);
1346 $min = min($num, ($limit <= 0 ? $num : $limit));
1347 for ($i = 0; $i < $min; $i++) {
1348 $list[] = $this->
db->fetch_object($result);
1351 throw new RestException(503,
'Error when retrieving list of legal form: '.$this->
db->lasterror());
1372 public function getListOfStaff($sortfield =
"id", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1376 $sql =
"SELECT t.id, t.code, t.libelle, t.active, t.module";
1377 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_effectif 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 staff: '.$this->
db->lasterror());
1430 public function getListOfsocialNetworks($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1435 throw new RestException(400,
'API not available: this dictionary is not enabled by setup');
1440 $sql =
"SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active";
1441 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_socialnetworks as t";
1442 $sql .=
" WHERE t.entity IN (".getEntity(
'c_socialnetworks').
")";
1443 $sql .=
" AND t.active = ".((int) $active);
1448 if ($errormessage) {
1449 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1454 $sql .= $this->
db->order($sortfield, $sortorder);
1460 $offset = $limit * $page;
1462 $sql .= $this->
db->plimit($limit, $offset);
1465 $result = $this->
db->query($sql);
1468 $num = $this->
db->num_rows($result);
1469 $min = min($num, ($limit <= 0 ? $num : $limit));
1470 for ($i = 0; $i < $min; $i++) {
1471 $list[] = $this->
db->fetch_object($result);
1474 throw new RestException(503,
'Error when retrieving list of social networks: '.$this->
db->lasterror());
1496 public function getTicketsCategories($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1500 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1501 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category as t";
1502 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_category').
")";
1503 $sql .=
" AND t.active = ".((int) $active);
1508 if ($errormessage) {
1509 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1514 $sql .= $this->
db->order($sortfield, $sortorder);
1520 $offset = $limit * $page;
1522 $sql .= $this->
db->plimit($limit, $offset);
1525 $result = $this->
db->query($sql);
1528 $num = $this->
db->num_rows($result);
1529 $min = min($num, ($limit <= 0 ? $num : $limit));
1530 for ($i = 0; $i < $min; $i++) {
1531 $category = $this->
db->fetch_object($result);
1532 $this->
translateLabel($category, $lang,
'TicketCategoryShort', array(
'ticket'));
1533 $list[] = $category;
1536 throw new RestException(503,
'Error when retrieving list of ticket categories : '.$this->
db->lasterror());
1558 public function getTicketsSeverities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1562 $sql =
"SELECT rowid, code, pos, label, use_default, color, description";
1563 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity as t";
1564 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_severity').
")";
1565 $sql .=
" AND t.active = ".((int) $active);
1570 if ($errormessage) {
1571 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1576 $sql .= $this->
db->order($sortfield, $sortorder);
1582 $offset = $limit * $page;
1584 $sql .= $this->
db->plimit($limit, $offset);
1587 $result = $this->
db->query($sql);
1590 $num = $this->
db->num_rows($result);
1591 $min = min($num, ($limit <= 0 ? $num : $limit));
1592 for ($i = 0; $i < $min; $i++) {
1593 $severity = $this->
db->fetch_object($result);
1594 $this->
translateLabel($severity, $lang,
'TicketSeverityShort', array(
'ticket'));
1595 $list[] = $severity;
1598 throw new RestException(503,
'Error when retrieving list of ticket severities : '.$this->
db->lasterror());
1620 public function getTicketsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1624 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1625 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type as t";
1626 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_type').
")";
1627 $sql .=
" AND t.active = ".((int) $active);
1633 if ($errormessage) {
1634 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1639 $sql .= $this->
db->order($sortfield, $sortorder);
1645 $offset = $limit * $page;
1647 $sql .= $this->
db->plimit($limit, $offset);
1650 $result = $this->
db->query($sql);
1653 $num = $this->
db->num_rows($result);
1654 $min = min($num, ($limit <= 0 ? $num : $limit));
1655 for ($i = 0; $i < $min; $i++) {
1656 $type =$this->
db->fetch_object($result);
1657 $this->
translateLabel($type, $lang,
'TicketTypeShort', array(
'ticket'));
1661 throw new RestException(503,
'Error when retrieving list of ticket types : '.$this->
db->lasterror());
1678 global $conf, $mysoc;
1680 if (!DolibarrApiAccess::$user->admin
1681 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
1682 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');
1685 unset($mysoc->skype);
1686 unset($mysoc->twitter);
1687 unset($mysoc->facebook);
1688 unset($mysoc->linkedin);
1690 unset($mysoc->pays);
1691 unset($mysoc->note);
1694 unset($mysoc->lines);
1696 unset($mysoc->effectif);
1697 unset($mysoc->effectif_id);
1698 unset($mysoc->forme_juridique_code);
1699 unset($mysoc->forme_juridique);
1700 unset($mysoc->mode_reglement_supplier_id);
1701 unset($mysoc->cond_reglement_supplier_id);
1702 unset($mysoc->transport_mode_supplier_id);
1703 unset($mysoc->fk_prospectlevel);
1705 unset($mysoc->total_ht);
1706 unset($mysoc->total_tva);
1707 unset($mysoc->total_localtax1);
1708 unset($mysoc->total_localtax2);
1709 unset($mysoc->total_ttc);
1711 unset($mysoc->lastname);
1712 unset($mysoc->firstname);
1713 unset($mysoc->civility_id);
1715 unset($mysoc->client);
1716 unset($mysoc->prospect);
1717 unset($mysoc->fournisseur);
1718 unset($mysoc->contact_id);
1720 unset($mysoc->fk_incoterms);
1721 unset($mysoc->label_incoterms);
1722 unset($mysoc->location_incoterms);
1742 $sql =
"SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status";
1743 $sql .=
" FROM ".MAIN_DB_PREFIX.
"establishment as e";
1744 $sql .=
" WHERE e.entity IN (".getEntity(
'establishment').
')';
1749 $result = $this->
db->query($sql);
1752 $num = $this->
db->num_rows($result);
1753 $min = min($num, ($limit <= 0 ? $num : $limit));
1754 for ($i = 0; $i < $min; $i++) {
1755 $list[] = $this->
db->fetch_object($result);
1758 throw new RestException(503,
'Error when retrieving list of establishments : '.$this->
db->lasterror());
1778 $result = $establishment->fetch($id);
1780 throw new RestException(503,
'Error when retrieving establishment : '.$establishment->error);
1781 } elseif ($result == 0) {
1782 throw new RestException(404,
'Establishment not found');
1805 if (!DolibarrApiAccess::$user->admin
1806 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ)) {
1807 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');
1810 if (!preg_match(
'/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
1811 throw new RestException(404,
'Error Bad or unknown value for constantname');
1814 throw new RestException(403,
'Forbidden. This parameter cant be read with APIs');
1817 return $conf->global->$constantname;
1835 global $langs, $conf;
1837 if (!DolibarrApiAccess::$user->admin
1838 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK)) {
1839 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');
1842 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1843 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
1845 $langs->load(
"admin");
1847 $outexpectedchecksum =
'';
1848 $outcurrentchecksum =
'';
1851 $file_list = array(
'missing' => array(),
'updated' => array());
1854 $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));
1855 $xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
1857 $xmlremote = ($target ==
'default' ?
'' : $target);
1858 if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
1859 $xmlremote = $conf->global->MAIN_FILECHECK_URL;
1861 $param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
1862 if (empty($xmlremote) && !empty($conf->global->$param)) {
1863 $xmlremote = $conf->global->$param;
1865 if (empty($xmlremote)) {
1866 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
1868 if ($xmlremote && !preg_match(
'/^https?:\/\//i', $xmlremote)) {
1869 $langs->load(
"errors");
1870 throw new RestException(500, $langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote));
1872 if ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
1873 $langs->load(
"errors");
1874 throw new RestException(500, $langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'));
1877 if ($target ==
'local') {
1879 $xml = simplexml_load_file($xmlfile);
1881 throw new RestException(500, $langs->trans(
'XmlNotFound').
': '.$xmlfile);
1884 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1887 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404') {
1888 $xmlfile = $xmlarray[
'content'];
1890 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
1892 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
1893 throw new RestException(500, $errormsg);
1898 $checksumconcat = array();
1899 $file_list = array();
1903 if (is_object($xml->dolibarr_constants[0])) {
1906 $out .=
'<div class="div-table-responsive-no-min">';
1907 $out .=
'<table class="noborder">';
1908 $out .=
'<tr class="liste_titre">';
1909 $out .=
'<td>#</td>';
1910 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
1911 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
1912 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
1913 $out .=
'</tr>'.
"\n";
1916 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
1917 $constname = $constant[
'name'];
1918 $constvalue = (string) $constant;
1919 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
1922 if ($constname && $conf->global->$constname !=
'') {
1923 $value = $conf->global->$constname;
1925 $valueforchecksum = (empty($value) ?
'0' : $value);
1927 $checksumconcat[] = $valueforchecksum;
1930 $out .=
'<tr class="oddeven">';
1931 $out .=
'<td>'.$i.
'</td>'.
"\n";
1932 $out .=
'<td>'.$constname.
'</td>'.
"\n";
1933 $out .=
'<td class="center">'.$constvalue.
'</td>'.
"\n";
1934 $out .=
'<td class="center">'.$valueforchecksum.
'</td>'.
"\n";
1939 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1948 if (is_object($xml->dolibarr_htdocs_dir[0])) {
1949 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
1952 $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)$';
1953 $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)$';
1954 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
1957 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
1959 foreach ($scanfiles as $keyfile => $valfile) {
1960 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
1961 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
1962 $md5newfile = @md5_file($valfile[
'fullname']);
1963 $file_list[
'added'][] = array(
'filename'=>$tmprelativefilename,
'md5'=>$md5newfile);
1970 $out .=
'<div class="div-table-responsive-no-min">';
1971 $out .=
'<table class="noborder">';
1972 $out .=
'<tr class="liste_titre">';
1973 $out .=
'<td>#</td>';
1974 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
1975 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
1976 $out .=
'</tr>'.
"\n";
1977 $tmpfilelist =
dol_sort_array($file_list[
'missing'],
'filename');
1978 if (is_array($tmpfilelist) && count($tmpfilelist)) {
1980 foreach ($tmpfilelist as $file) {
1982 $out .=
'<tr class="oddeven">';
1983 $out .=
'<td>'.$i.
'</td>'.
"\n";
1984 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
1985 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
1989 $out .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2000 $out .=
'<div class="div-table-responsive-no-min">';
2001 $out .=
'<table class="noborder">';
2002 $out .=
'<tr class="liste_titre">';
2003 $out .=
'<td>#</td>';
2004 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2005 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2006 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2007 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2008 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2009 $out .=
'</tr>'.
"\n";
2010 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
2011 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
2013 foreach ($tmpfilelist2 as $file) {
2015 $out .=
'<tr class="oddeven">';
2016 $out .=
'<td>'.$i.
'</td>'.
"\n";
2017 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2018 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2019 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2020 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2021 $totalsize += $size;
2022 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2023 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2026 $out .=
'<tr class="liste_total">';
2027 $out .=
'<td></td>'.
"\n";
2028 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2029 $out .=
'<td align="center"></td>'.
"\n";
2030 $out .=
'<td align="center"></td>'.
"\n";
2031 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2032 $out .=
'<td class="right"></td>'.
"\n";
2035 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2046 $out .=
'<div class="div-table-responsive-no-min">';
2047 $out .=
'<table class="noborder">';
2048 $out .=
'<tr class="liste_titre">';
2049 $out .=
'<td>#</td>';
2050 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2051 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2052 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2053 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2054 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2055 $out .=
'</tr>'.
"\n";
2057 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
2059 foreach ($tmpfilelist3 as $file) {
2061 $out .=
'<tr class="oddeven">';
2062 $out .=
'<td>'.$i.
'</td>'.
"\n";
2063 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2064 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2065 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2066 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2067 $totalsize += $size;
2068 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2069 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2072 $out .=
'<tr class="liste_total">';
2073 $out .=
'<td></td>'.
"\n";
2074 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2075 $out .=
'<td align="center"></td>'.
"\n";
2076 $out .=
'<td align="center"></td>'.
"\n";
2077 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2078 $out .=
'<td class="right"></td>'.
"\n";
2081 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2088 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
2094 throw new RestException(500,
'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
2099 asort($checksumconcat);
2100 $checksumget = md5(join(
',', $checksumconcat));
2101 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
2103 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
2104 if ($checksumget == $checksumtoget) {
2105 if (count($file_list[
'added'])) {
2106 $resultcode =
'warning';
2107 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
2109 $outcurrentchecksum = $checksumget;
2112 $resultcomment =
'Success';
2114 $outcurrentchecksum = $checksumget;
2117 $resultcode =
'error';
2118 $resultcomment =
'Error';
2120 $outcurrentchecksum = $checksumget;
2123 throw new RestException(404,
'No signature file known');
2126 return array(
'resultcode'=>$resultcode,
'resultcomment'=>$resultcomment,
'expectedchecksum'=> $outexpectedchecksum,
'currentchecksum'=> $outcurrentchecksum,
'out'=>$out);
2143 if (!DolibarrApiAccess::$user->admin
2144 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES)) {
2145 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');
2148 sort($conf->modules);
Class to manage dictionary Countries (used by imports)
Class to manage dictionary States (used by imports)
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.
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.
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.
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.
getListOfCountries($sortfield="code", $sortorder='ASC', $limit=100, $page=0, $filter='', $lang='', $sqlfilters='')
Get the list of countries.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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, &$error='')
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.
isModEnabled($module)
Is Dolibarr module enabled.
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).
$conf db
API class for accounts.