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);
81 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
83 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
84 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
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());
130 public function getOrderingOrigins($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
134 if (!DolibarrApiAccess::$user->rights->commande->lire) {
135 throw new RestException(401);
138 $sql =
"SELECT rowid, code, label, module";
139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_input_reason as t";
140 $sql .=
" WHERE t.active = ".((int) $active);
145 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
147 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
148 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
152 $sql .= $this->
db->order($sortfield, $sortorder);
158 $offset = $limit * $page;
160 $sql .= $this->
db->plimit($limit, $offset);
163 $result = $this->
db->query($sql);
166 $num = $this->
db->num_rows($result);
167 $min = min($num, ($limit <= 0 ? $num : $limit));
168 for ($i = 0; $i < $min; $i++) {
169 $list[] = $this->
db->fetch_object($result);
172 throw new RestException(400, $this->
db->lasterror());
194 public function getPaymentTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
198 if (!DolibarrApiAccess::$user->rights->propal->lire && !DolibarrApiAccess::$user->rights->commande->lire && !DolibarrApiAccess::$user->rights->facture->lire) {
199 throw new RestException(401);
202 $sql =
"SELECT id, code, type, libelle as label, module";
203 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement as t";
204 $sql .=
" WHERE t.entity IN (".getEntity(
'c_paiement').
")";
205 $sql .=
" AND t.active = ".((int) $active);
210 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
212 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
213 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
217 $sql .= $this->
db->order($sortfield, $sortorder);
223 $offset = $limit * $page;
225 $sql .= $this->
db->plimit($limit, $offset);
228 $result = $this->
db->query($sql);
231 $num = $this->
db->num_rows($result);
232 $min = min($num, ($limit <= 0 ? $num : $limit));
233 for ($i = 0; $i < $min; $i++) {
234 $list[] = $this->
db->fetch_object($result);
237 throw new RestException(400, $this->
db->lasterror());
263 public function getListOfStates($sortfield =
"code_departement", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $filter =
'', $sqlfilters =
'')
269 $sql =
"SELECT t.rowid FROM ".MAIN_DB_PREFIX.
"c_departements as t";
271 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions as d ON t.fk_region = d.code_region";
273 $sql .=
" WHERE 1 = 1";
275 $sql .=
" AND d.fk_pays = ".((int) $country);
281 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
283 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
284 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
287 $sql .= $this->
db->order($sortfield, $sortorder);
293 $offset = $limit * $page;
295 $sql .= $this->
db->plimit($limit, $offset);
298 $result = $this->
db->query($sql);
301 $num = $this->
db->num_rows($result);
302 $min = min($num, ($limit <= 0 ? $num : $limit));
303 for ($i = 0; $i < $min; $i++) {
304 $obj = $this->
db->fetch_object($result);
306 if ($state->fetch($obj->rowid) > 0) {
307 if (empty($filter) || stripos($state->label, $filter) !==
false) {
313 throw new RestException(503,
'Error when retrieving list of states');
370 public function getListOfCountries($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $filter =
'', $lang =
'', $sqlfilters =
'')
376 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"c_country as t";
377 $sql .=
" WHERE 1 = 1";
382 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
384 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
385 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
388 $sql .= $this->
db->order($sortfield, $sortorder);
394 $offset = $limit * $page;
396 $sql .= $this->
db->plimit($limit, $offset);
399 $result = $this->
db->query($sql);
402 $num = $this->
db->num_rows($result);
403 $min = min($num, ($limit <= 0 ? $num : $limit));
404 for ($i = 0; $i < $min; $i++) {
405 $obj = $this->
db->fetch_object($result);
407 if ($country->fetch($obj->rowid) > 0) {
412 if (empty($filter) || stripos($country->label, $filter) !==
false) {
418 throw new RestException(503,
'Error when retrieving list of countries');
488 $result = $state->fetch($id, $code);
490 throw new RestException(503,
'Error when retrieving state : '.$state->error);
491 } elseif ($result == 0) {
492 throw new RestException(404,
'State not found');
514 $result = $country->fetch($id, $code, $iso);
517 throw new RestException(503,
'Error when retrieving country : '.$country->error);
518 } elseif ($result == 0) {
519 throw new RestException(404,
'Country not found');
543 public function getAvailability($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
547 if (!DolibarrApiAccess::$user->rights->commande->lire) {
548 throw new RestException(401);
551 $sql =
"SELECT rowid, code, label";
552 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_availability as t";
553 $sql .=
" WHERE t.active = ".((int) $active);
558 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
560 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
561 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
565 $sql .= $this->
db->order($sortfield, $sortorder);
571 $offset = $limit * $page;
573 $sql .= $this->
db->plimit($limit, $offset);
576 $result = $this->
db->query($sql);
579 $num = $this->
db->num_rows($result);
580 $min = min($num, ($limit <= 0 ? $num : $limit));
581 for ($i = 0; $i < $min; $i++) {
582 $list[] = $this->
db->fetch_object($result);
585 throw new RestException(400, $this->
db->lasterror());
601 $object = parent::_cleanObjectDatas($object);
603 unset($object->error);
604 unset($object->errors);
622 if ($this->translations ==
null || $this->translations->getDefaultLang() !== $lang) {
624 $this->translations =
new Translate(
'', $conf);
625 $this->translations->setDefaultLang($lang);
626 $this->translations->load(
'dict');
629 $key = $prefix.$object->code;
631 $translation = $this->translations->trans($key);
632 if ($translation != $key) {
633 $object->label = html_entity_decode($translation);
657 public function getListOfEventTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $sqlfilters =
'')
661 $sql =
"SELECT id, code, type, libelle as label, module";
662 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as t";
663 $sql .=
" WHERE t.active = ".((int) $active);
665 $sql .=
" AND t.type LIKE '%".$this->db->escape($type).
"%'";
668 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
674 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
676 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
677 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
681 $sql .= $this->
db->order($sortfield, $sortorder);
687 $offset = $limit * $page;
689 $sql .= $this->
db->plimit($limit, $offset);
692 $result = $this->
db->query($sql);
695 $num = $this->
db->num_rows($result);
696 $min = min($num, ($limit <= 0 ? $num : $limit));
697 for ($i = 0; $i < $min; $i++) {
698 $list[] = $this->
db->fetch_object($result);
701 throw new RestException(503,
'Error when retrieving list of events types : '.$this->
db->lasterror());
724 public function getListOfExpenseReportsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $sqlfilters =
'')
728 $sql =
"SELECT id, code, label, accountancy_code, active, module, position";
729 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees as t";
730 $sql .=
" WHERE t.active = ".((int) $active);
732 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
738 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
740 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
741 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
745 $sql .= $this->
db->order($sortfield, $sortorder);
751 $offset = $limit * $page;
753 $sql .= $this->
db->plimit($limit, $offset);
756 $result = $this->
db->query($sql);
759 $num = $this->
db->num_rows($result);
760 $min = min($num, ($limit <= 0 ? $num : $limit));
761 for ($i = 0; $i < $min; $i++) {
762 $list[] = $this->
db->fetch_object($result);
765 throw new RestException(503,
'Error when retrieving list of expense report types : '.$this->
db->lasterror());
789 public function getListOfContactTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $sqlfilters =
'')
793 $sql =
"SELECT rowid, code, element as type, libelle as label, source, module, position";
794 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact as t";
795 $sql .=
" WHERE t.active = ".((int) $active);
797 $sql .=
" AND type LIKE '%".$this->db->escape($type).
"%'";
800 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
806 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
808 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
809 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
813 $sql .= $this->
db->order($sortfield, $sortorder);
819 $offset = $limit * $page;
821 $sql .= $this->
db->plimit($limit, $offset);
824 $result = $this->
db->query($sql);
827 $num = $this->
db->num_rows($result);
828 $min = min($num, ($limit <= 0 ? $num : $limit));
829 for ($i = 0; $i < $min; $i++) {
830 $list[] = $this->
db->fetch_object($result);
833 throw new RestException(503,
'Error when retrieving list of contacts types : '.$this->
db->lasterror());
855 public function getListOfCivilities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $sqlfilters =
'')
859 $sql =
"SELECT rowid, code, label, module";
860 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_civility as t";
861 $sql .=
" WHERE t.active = ".((int) $active);
863 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
869 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
871 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
872 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
876 $sql .= $this->
db->order($sortfield, $sortorder);
882 $offset = $limit * $page;
884 $sql .= $this->
db->plimit($limit, $offset);
887 $result = $this->
db->query($sql);
890 $num = $this->
db->num_rows($result);
891 $min = min($num, ($limit <= 0 ? $num : $limit));
892 for ($i = 0; $i < $min; $i++) {
893 $list[] = $this->
db->fetch_object($result);
896 throw new RestException(503,
'Error when retrieving list of civility : '.$this->
db->lasterror());
918 public function getListOfCurrencies($multicurrency = 0, $sortfield =
"code_iso", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
921 $sql =
"SELECT t.code_iso, t.label, t.unicode";
922 if (!empty($multicurrency)) {
923 $sql .=
" , cr.date_sync, cr.rate ";
925 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_currencies as t";
926 if (!empty($multicurrency)) {
927 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency as m ON m.code=t.code_iso";
928 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
930 $sql .=
" WHERE t.active = ".((int) $active);
931 if (!empty($multicurrency)) {
932 $sql .=
" AND m.entity IN (".getEntity(
'multicurrency').
")";
933 if (!empty($multicurrency) && $multicurrency != 2) {
934 $sql .=
" AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.
"multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
942 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
944 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
945 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
949 $sql .= $this->
db->order($sortfield, $sortorder);
955 $offset = $limit * $page;
957 $sql .= $this->
db->plimit($limit, $offset);
960 $result = $this->
db->query($sql);
963 $num = $this->
db->num_rows($result);
964 $min = min($num, ($limit <= 0 ? $num : $limit));
965 for ($i = 0; $i < $min; $i++) {
966 $list[] = $this->
db->fetch_object($result);
969 throw new RestException(503,
'Error when retrieving list of currency : '.$this->
db->lasterror());
992 if (!DolibarrApiAccess::$user->admin) {
993 throw new RestException(401,
'Only an admin user can get list of extrafields');
996 if ($type ==
'thirdparty') {
999 if ($type ==
'contact') {
1000 $type =
'socpeople';
1003 $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";
1004 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1005 $sql .=
" WHERE t.entity IN (".getEntity(
'extrafields').
")";
1006 if (!empty($type)) {
1007 $sql .=
" AND t.elementtype = '".$this->db->escape($type).
"'";
1013 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1015 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1016 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1019 $sql .= $this->
db->order($sortfield, $sortorder);
1024 while ($tab = $this->
db->fetch_object(
$resql)) {
1026 $list[$tab->elementtype][$tab->name][
'type'] = $tab->type;
1027 $list[$tab->elementtype][$tab->name][
'label'] = $tab->label;
1028 $list[$tab->elementtype][$tab->name][
'size'] = $tab->size;
1029 $list[$tab->elementtype][$tab->name][
'elementtype'] = $tab->elementtype;
1030 $list[$tab->elementtype][$tab->name][
'default'] = $tab->fielddefault;
1031 $list[$tab->elementtype][$tab->name][
'computed'] = $tab->fieldcomputed;
1032 $list[$tab->elementtype][$tab->name][
'unique'] = $tab->fieldunique;
1033 $list[$tab->elementtype][$tab->name][
'required'] = $tab->fieldrequired;
1034 $list[$tab->elementtype][$tab->name][
'param'] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1035 $list[$tab->elementtype][$tab->name][
'pos'] = $tab->pos;
1036 $list[$tab->elementtype][$tab->name][
'alwayseditable'] = $tab->alwayseditable;
1037 $list[$tab->elementtype][$tab->name][
'perms'] = $tab->perms;
1038 $list[$tab->elementtype][$tab->name][
'list'] = $tab->list;
1042 throw new RestException(503,
'Error when retrieving list of extra fields : '.$this->
db->lasterror());
1045 if (!count($list)) {
1046 throw new RestException(404,
'No extrafield found');
1070 public function getListOfTowns($sortfield =
"zip,town", $sortorder =
'ASC', $limit = 100, $page = 0, $zipcode =
'', $town =
'', $active = 1, $sqlfilters =
'')
1074 $sql =
"SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
1075 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ziptown as t";
1076 $sql .=
" WHERE t.active = ".((int) $active);
1078 $sql .=
" AND t.zip LIKE '%".$this->db->escape($zipcode).
"%'";
1081 $sql .=
" AND t.town LIKE '%".$this->db->escape($town).
"%'";
1087 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1089 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1090 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1094 $sql .= $this->
db->order($sortfield, $sortorder);
1100 $offset = $limit * $page;
1102 $sql .= $this->
db->plimit($limit, $offset);
1105 $result = $this->
db->query($sql);
1108 $num = $this->
db->num_rows($result);
1109 $min = min($num, ($limit <= 0 ? $num : $limit));
1110 for ($i = 0; $i < $min; $i++) {
1111 $list[] = $this->
db->fetch_object($result);
1114 throw new RestException(503,
'Error when retrieving list of towns : '.$this->
db->lasterror());
1136 public function getPaymentTerms($sortfield =
"sortorder", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1140 if (!DolibarrApiAccess::$user->rights->propal->lire && !DolibarrApiAccess::$user->rights->commande->lire && !DolibarrApiAccess::$user->rights->facture->lire) {
1141 throw new RestException(401);
1144 $sql =
"SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
1145 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
1146 $sql .=
" WHERE t.entity IN (".getEntity(
'c_payment_term').
")";
1147 $sql .=
" AND t.active = ".((int) $active);
1152 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1154 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1155 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1159 $sql .= $this->
db->order($sortfield, $sortorder);
1165 $offset = $limit * $page;
1167 $sql .= $this->
db->plimit($limit, $offset);
1170 $result = $this->
db->query($sql);
1173 $num = $this->
db->num_rows($result);
1174 $min = min($num, ($limit <= 0 ? $num : $limit));
1175 for ($i = 0; $i < $min; $i++) {
1176 $list[] = $this->
db->fetch_object($result);
1179 throw new RestException(400, $this->
db->lasterror());
1203 $sql =
"SELECT rowid as id, code, libelle as label, description, tracking, module";
1204 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as t";
1205 $sql .=
" WHERE t.entity IN (".getEntity(
'c_shipment_mode').
")";
1206 $sql .=
" AND t.active = ".((int) $active);
1211 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1213 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1214 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1224 $offset = $limit * $page;
1226 $sql .= $this->
db->plimit($limit, $offset);
1229 $result = $this->
db->query($sql);
1232 $num = $this->
db->num_rows($result);
1233 $min = min($num, ($limit <= 0 ? $num : $limit));
1234 for ($i = 0; $i < $min; $i++) {
1235 $list[] = $this->
db->fetch_object($result);
1238 throw new RestException(400, $this->
db->lasterror());
1259 public function getListOfMeasuringUnits($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1263 $sql =
"SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
1264 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_units as t";
1265 $sql .=
" WHERE t.active = ".((int) $active);
1270 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1272 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1273 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1277 $sql .= $this->
db->order($sortfield, $sortorder);
1283 $offset = $limit * $page;
1285 $sql .= $this->
db->plimit($limit, $offset);
1288 $result = $this->
db->query($sql);
1291 $num = $this->
db->num_rows($result);
1292 $min = min($num, ($limit <= 0 ? $num : $limit));
1293 for ($i = 0; $i < $min; $i++) {
1294 $list[] = $this->
db->fetch_object($result);
1297 throw new RestException(503,
'Error when retrieving list of measuring units: '.$this->
db->lasterror());
1319 public function getListOfLegalForm($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters =
'')
1323 $sql =
"SELECT t.rowid, t.code, t.fk_pays, t.libelle, t.isvatexempted, t.active, t.module, t.position";
1324 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_forme_juridique as t";
1325 $sql .=
" WHERE t.active = ".((int) $active);
1327 $sql .=
" AND t.fk_pays = ".((int) $country);
1333 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1335 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1336 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1340 $sql .= $this->
db->order($sortfield, $sortorder);
1346 $offset = $limit * $page;
1348 $sql .= $this->
db->plimit($limit, $offset);
1351 $result = $this->
db->query($sql);
1354 $num = $this->
db->num_rows($result);
1355 $min = min($num, ($limit <= 0 ? $num : $limit));
1356 for ($i = 0; $i < $min; $i++) {
1357 $list[] = $this->
db->fetch_object($result);
1360 throw new RestException(503,
'Error when retrieving list of legal form: '.$this->
db->lasterror());
1381 public function getListOfStaff($sortfield =
"id", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1385 $sql =
"SELECT t.id, t.code, t.libelle, t.active, t.module";
1386 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_effectif as t";
1387 $sql .=
" WHERE t.active = ".((int) $active);
1392 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1394 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1395 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1399 $sql .= $this->
db->order($sortfield, $sortorder);
1405 $offset = $limit * $page;
1407 $sql .= $this->
db->plimit($limit, $offset);
1410 $result = $this->
db->query($sql);
1413 $num = $this->
db->num_rows($result);
1414 $min = min($num, ($limit <= 0 ? $num : $limit));
1415 for ($i = 0; $i < $min; $i++) {
1416 $list[] = $this->
db->fetch_object($result);
1419 throw new RestException(503,
'Error when retrieving list of staff: '.$this->
db->lasterror());
1440 public function getListOfsocialNetworks($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1444 if (empty($conf->socialnetworks->enabled)) {
1445 throw new RestException(400,
'API not available: this dictionary is not enabled by setup');
1450 $sql =
"SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active";
1451 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_socialnetworks as t";
1452 $sql .=
" WHERE t.entity IN (".getEntity(
'c_socialnetworks').
")";
1453 $sql .=
" AND t.active = ".((int) $active);
1458 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1460 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1461 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1465 $sql .= $this->
db->order($sortfield, $sortorder);
1471 $offset = $limit * $page;
1473 $sql .= $this->
db->plimit($limit, $offset);
1476 $result = $this->
db->query($sql);
1479 $num = $this->
db->num_rows($result);
1480 $min = min($num, ($limit <= 0 ? $num : $limit));
1481 for ($i = 0; $i < $min; $i++) {
1482 $list[] = $this->
db->fetch_object($result);
1485 throw new RestException(503,
'Error when retrieving list of social networks: '.$this->
db->lasterror());
1506 public function getTicketsCategories($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1510 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1511 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category as t";
1512 $sql .=
" WHERE t.active = ".((int) $active);
1517 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1519 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1520 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1524 $sql .= $this->
db->order($sortfield, $sortorder);
1530 $offset = $limit * $page;
1532 $sql .= $this->
db->plimit($limit, $offset);
1535 $result = $this->
db->query($sql);
1538 $num = $this->
db->num_rows($result);
1539 $min = min($num, ($limit <= 0 ? $num : $limit));
1540 for ($i = 0; $i < $min; $i++) {
1541 $list[] = $this->
db->fetch_object($result);
1544 throw new RestException(503,
'Error when retrieving list of ticket categories : '.$this->
db->lasterror());
1565 public function getTicketsSeverities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1569 $sql =
"SELECT rowid, code, pos, label, use_default, color, description";
1570 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity as t";
1571 $sql .=
" WHERE t.active = ".((int) $active);
1576 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1578 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1579 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1583 $sql .= $this->
db->order($sortfield, $sortorder);
1589 $offset = $limit * $page;
1591 $sql .= $this->
db->plimit($limit, $offset);
1594 $result = $this->
db->query($sql);
1597 $num = $this->
db->num_rows($result);
1598 $min = min($num, ($limit <= 0 ? $num : $limit));
1599 for ($i = 0; $i < $min; $i++) {
1600 $list[] = $this->
db->fetch_object($result);
1603 throw new RestException(503,
'Error when retrieving list of ticket severities : '.$this->
db->lasterror());
1624 public function getTicketsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1628 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1629 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type as t";
1630 $sql .=
" WHERE t.active = ".(int) $active;
1637 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1639 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1640 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1644 $sql .= $this->
db->order($sortfield, $sortorder);
1650 $offset = $limit * $page;
1652 $sql .= $this->
db->plimit($limit, $offset);
1655 $result = $this->
db->query($sql);
1658 $num = $this->
db->num_rows($result);
1659 $min = min($num, ($limit <= 0 ? $num : $limit));
1660 for ($i = 0; $i < $min; $i++) {
1661 $list[] = $this->
db->fetch_object($result);
1664 throw new RestException(503,
'Error when retrieving list of ticket types : '.$this->
db->lasterror());
1681 global $conf, $mysoc;
1683 if (!DolibarrApiAccess::$user->admin
1684 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
1685 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');
1688 unset($mysoc->skype);
1689 unset($mysoc->twitter);
1690 unset($mysoc->facebook);
1691 unset($mysoc->linkedin);
1693 unset($mysoc->pays);
1694 unset($mysoc->note);
1697 unset($mysoc->lines);
1699 unset($mysoc->effectif);
1700 unset($mysoc->effectif_id);
1701 unset($mysoc->forme_juridique_code);
1702 unset($mysoc->forme_juridique);
1703 unset($mysoc->mode_reglement_supplier_id);
1704 unset($mysoc->cond_reglement_supplier_id);
1705 unset($mysoc->transport_mode_supplier_id);
1706 unset($mysoc->fk_prospectlevel);
1708 unset($mysoc->total_ht);
1709 unset($mysoc->total_tva);
1710 unset($mysoc->total_localtax1);
1711 unset($mysoc->total_localtax2);
1712 unset($mysoc->total_ttc);
1714 unset($mysoc->lastname);
1715 unset($mysoc->firstname);
1716 unset($mysoc->civility_id);
1718 unset($mysoc->client);
1719 unset($mysoc->prospect);
1720 unset($mysoc->fournisseur);
1721 unset($mysoc->contact_id);
1723 unset($mysoc->fk_incoterms);
1724 unset($mysoc->label_incoterms);
1725 unset($mysoc->location_incoterms);
1745 $sql =
"SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status";
1746 $sql .=
" FROM ".MAIN_DB_PREFIX.
"establishment as e";
1747 $sql .=
" WHERE e.entity IN (".getEntity(
'establishment').
')';
1752 $result = $this->
db->query($sql);
1755 $num = $this->
db->num_rows($result);
1756 $min = min($num, ($limit <= 0 ? $num : $limit));
1757 for ($i = 0; $i < $min; $i++) {
1758 $list[] = $this->
db->fetch_object($result);
1761 throw new RestException(503,
'Error when retrieving list of establishments : '.$this->
db->lasterror());
1781 $result = $establishment->fetch($id);
1783 throw new RestException(503,
'Error when retrieving establishment : '.$establishment->error);
1784 } elseif ($result == 0) {
1785 throw new RestException(404,
'Establishment not found');
1808 if (!DolibarrApiAccess::$user->admin
1809 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ)) {
1810 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');
1813 if (!preg_match(
'/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
1814 throw new RestException(404,
'Error Bad or unknown value for constantname');
1817 throw new RestException(403,
'Forbidden. This parameter cant be read with APIs');
1820 return $conf->global->$constantname;
1838 global $langs, $conf;
1840 if (!DolibarrApiAccess::$user->admin
1841 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK)) {
1842 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');
1845 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1846 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
1848 $langs->load(
"admin");
1850 $outexpectedchecksum =
'';
1851 $outcurrentchecksum =
'';
1854 $file_list = array(
'missing' => array(),
'updated' => array());
1857 $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));
1858 $xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
1860 $xmlremote = ($target ==
'default' ?
'' : $target);
1861 if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
1862 $xmlremote = $conf->global->MAIN_FILECHECK_URL;
1864 $param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
1865 if (empty($xmlremote) && !empty($conf->global->$param)) {
1866 $xmlremote = $conf->global->$param;
1868 if (empty($xmlremote)) {
1869 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
1871 if ($xmlremote && !preg_match(
'/^https?:\/\//i', $xmlremote)) {
1872 $langs->load(
"errors");
1873 throw new RestException(500, $langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote));
1875 if ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
1876 $langs->load(
"errors");
1877 throw new RestException(500, $langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'));
1880 if ($target ==
'local') {
1882 $xml = simplexml_load_file($xmlfile);
1884 throw new RestException(500, $langs->trans(
'XmlNotFound').
': '.$xmlfile);
1887 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1890 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404') {
1891 $xmlfile = $xmlarray[
'content'];
1893 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
1895 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
1896 throw new RestException(500, $errormsg);
1901 $checksumconcat = array();
1902 $file_list = array();
1906 if (is_object($xml->dolibarr_constants[0])) {
1909 $out .=
'<div class="div-table-responsive-no-min">';
1910 $out .=
'<table class="noborder">';
1911 $out .=
'<tr class="liste_titre">';
1912 $out .=
'<td>#</td>';
1913 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
1914 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
1915 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
1916 $out .=
'</tr>'.
"\n";
1919 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
1920 $constname = $constant[
'name'];
1921 $constvalue = (string) $constant;
1922 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
1925 if ($constname && $conf->global->$constname !=
'') {
1926 $value = $conf->global->$constname;
1928 $valueforchecksum = (empty($value) ?
'0' : $value);
1930 $checksumconcat[] = $valueforchecksum;
1933 $out .=
'<tr class="oddeven">';
1934 $out .=
'<td>'.$i.
'</td>'.
"\n";
1935 $out .=
'<td>'.$constname.
'</td>'.
"\n";
1936 $out .=
'<td class="center">'.$constvalue.
'</td>'.
"\n";
1937 $out .=
'<td class="center">'.$valueforchecksum.
'</td>'.
"\n";
1942 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1951 if (is_object($xml->dolibarr_htdocs_dir[0])) {
1952 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
1955 $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)$';
1956 $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)$';
1957 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
1960 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
1962 foreach ($scanfiles as $keyfile => $valfile) {
1963 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
1964 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
1965 $md5newfile = @md5_file($valfile[
'fullname']);
1966 $file_list[
'added'][] = array(
'filename'=>$tmprelativefilename,
'md5'=>$md5newfile);
1973 $out .=
'<div class="div-table-responsive-no-min">';
1974 $out .=
'<table class="noborder">';
1975 $out .=
'<tr class="liste_titre">';
1976 $out .=
'<td>#</td>';
1977 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
1978 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
1979 $out .=
'</tr>'.
"\n";
1980 $tmpfilelist =
dol_sort_array($file_list[
'missing'],
'filename');
1981 if (is_array($tmpfilelist) && count($tmpfilelist)) {
1983 foreach ($tmpfilelist as $file) {
1985 $out .=
'<tr class="oddeven">';
1986 $out .=
'<td>'.$i.
'</td>'.
"\n";
1987 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
1988 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
1992 $out .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2003 $out .=
'<div class="div-table-responsive-no-min">';
2004 $out .=
'<table class="noborder">';
2005 $out .=
'<tr class="liste_titre">';
2006 $out .=
'<td>#</td>';
2007 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2008 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2009 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2010 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2011 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2012 $out .=
'</tr>'.
"\n";
2013 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
2014 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
2016 foreach ($tmpfilelist2 as $file) {
2018 $out .=
'<tr class="oddeven">';
2019 $out .=
'<td>'.$i.
'</td>'.
"\n";
2020 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2021 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2022 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2023 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2024 $totalsize += $size;
2025 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2026 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2029 $out .=
'<tr class="liste_total">';
2030 $out .=
'<td></td>'.
"\n";
2031 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2032 $out .=
'<td align="center"></td>'.
"\n";
2033 $out .=
'<td align="center"></td>'.
"\n";
2034 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2035 $out .=
'<td class="right"></td>'.
"\n";
2038 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2049 $out .=
'<div class="div-table-responsive-no-min">';
2050 $out .=
'<table class="noborder">';
2051 $out .=
'<tr class="liste_titre">';
2052 $out .=
'<td>#</td>';
2053 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2054 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2055 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2056 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2057 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2058 $out .=
'</tr>'.
"\n";
2060 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
2062 foreach ($tmpfilelist3 as $file) {
2064 $out .=
'<tr class="oddeven">';
2065 $out .=
'<td>'.$i.
'</td>'.
"\n";
2066 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2067 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2068 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2069 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2070 $totalsize += $size;
2071 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2072 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2075 $out .=
'<tr class="liste_total">';
2076 $out .=
'<td></td>'.
"\n";
2077 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2078 $out .=
'<td align="center"></td>'.
"\n";
2079 $out .=
'<td align="center"></td>'.
"\n";
2080 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2081 $out .=
'<td class="right"></td>'.
"\n";
2084 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2091 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
2097 throw new RestException(500,
'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
2102 asort($checksumconcat);
2103 $checksumget = md5(join(
',', $checksumconcat));
2104 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
2106 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
2107 if ($checksumget == $checksumtoget) {
2108 if (count($file_list[
'added'])) {
2109 $resultcode =
'warning';
2110 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
2112 $outcurrentchecksum = $checksumget;
2115 $resultcomment =
'Success';
2117 $outcurrentchecksum = $checksumget;
2120 $resultcode =
'error';
2121 $resultcomment =
'Error';
2123 $outcurrentchecksum = $checksumget;
2126 throw new RestException(404,
'No signature file known');
2129 return array(
'resultcode'=>$resultcode,
'resultcomment'=>$resultcomment,
'expectedchecksum'=> $outexpectedchecksum,
'currentchecksum'=> $outcurrentchecksum,
'out'=>$out);
2146 if (!DolibarrApiAccess::$user->admin
2147 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES)) {
2148 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');
2151 sort($conf->modules);