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');
485 $result = $state->fetch($id, $code);
487 throw new RestException(503,
'Error when retrieving state : '.$state->error);
488 } elseif ($result == 0) {
489 throw new RestException(404,
'State not found');
510 $result = $country->fetch($id, $code, $iso);
513 throw new RestException(503,
'Error when retrieving country : '.$country->error);
514 } elseif ($result == 0) {
515 throw new RestException(404,
'Country not found');
539 public function getAvailability($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
543 if (!DolibarrApiAccess::$user->rights->commande->lire) {
544 throw new RestException(401);
547 $sql =
"SELECT rowid, code, label";
548 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_availability as t";
549 $sql .=
" WHERE t.active = ".((int) $active);
554 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
556 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
557 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
561 $sql .= $this->
db->order($sortfield, $sortorder);
567 $offset = $limit * $page;
569 $sql .= $this->
db->plimit($limit, $offset);
572 $result = $this->
db->query($sql);
575 $num = $this->
db->num_rows($result);
576 $min = min($num, ($limit <= 0 ? $num : $limit));
577 for ($i = 0; $i < $min; $i++) {
578 $list[] = $this->
db->fetch_object($result);
581 throw new RestException(400, $this->
db->lasterror());
597 $object = parent::_cleanObjectDatas($object);
599 unset($object->error);
600 unset($object->errors);
614 private function translateLabel($object, $lang, $prefix =
'Country', $dict = array(
'dict'))
618 if ($this->translations ==
null || $this->translations->getDefaultLang() !== $lang) {
620 $this->translations =
new Translate(
'', $conf);
621 $this->translations->setDefaultLang($lang);
622 $this->translations->loadLangs($dict);
625 $key = $prefix.$object->code;
627 $translation = $this->translations->trans($key);
628 if ($translation != $key) {
629 $object->label = html_entity_decode($translation);
652 public function getListOfEventTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $sqlfilters =
'')
656 $sql =
"SELECT id, code, type, libelle as label, module";
657 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as t";
658 $sql .=
" WHERE t.active = ".((int) $active);
660 $sql .=
" AND t.type LIKE '%".$this->db->escape($type).
"%'";
663 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
669 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
671 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
672 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
676 $sql .= $this->
db->order($sortfield, $sortorder);
682 $offset = $limit * $page;
684 $sql .= $this->
db->plimit($limit, $offset);
687 $result = $this->
db->query($sql);
690 $num = $this->
db->num_rows($result);
691 $min = min($num, ($limit <= 0 ? $num : $limit));
692 for ($i = 0; $i < $min; $i++) {
693 $list[] = $this->
db->fetch_object($result);
696 throw new RestException(503,
'Error when retrieving list of events types : '.$this->
db->lasterror());
719 public function getListOfExpenseReportsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $sqlfilters =
'')
723 $sql =
"SELECT id, code, label, accountancy_code, active, module, position";
724 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees as t";
725 $sql .=
" WHERE t.active = ".((int) $active);
727 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
733 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
735 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
736 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
740 $sql .= $this->
db->order($sortfield, $sortorder);
746 $offset = $limit * $page;
748 $sql .= $this->
db->plimit($limit, $offset);
751 $result = $this->
db->query($sql);
754 $num = $this->
db->num_rows($result);
755 $min = min($num, ($limit <= 0 ? $num : $limit));
756 for ($i = 0; $i < $min; $i++) {
757 $list[] = $this->
db->fetch_object($result);
760 throw new RestException(503,
'Error when retrieving list of expense report types : '.$this->
db->lasterror());
785 public function getListOfContactTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $type =
'', $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
789 $sql =
"SELECT rowid, code, element as type, libelle as label, source, module, position";
790 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_contact as t";
791 $sql .=
" WHERE t.active = ".((int) $active);
793 $sql .=
" AND type LIKE '%".$this->db->escape($type).
"%'";
796 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
802 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
804 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
805 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
809 $sql .= $this->
db->order($sortfield, $sortorder);
815 $offset = $limit * $page;
817 $sql .= $this->
db->plimit($limit, $offset);
820 $result = $this->
db->query($sql);
823 $num = $this->
db->num_rows($result);
824 $min = min($num, ($limit <= 0 ? $num : $limit));
825 for ($i = 0; $i < $min; $i++) {
826 $contact_type = $this->
db->fetch_object($result);
827 $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"));
828 $list[] = $contact_type;
831 throw new RestException(503,
'Error when retrieving list of contacts types : '.$this->
db->lasterror());
854 public function getListOfCivilities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $module =
'', $active = 1, $lang =
'', $sqlfilters =
'')
858 $sql =
"SELECT rowid, code, label, module";
859 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_civility as t";
860 $sql .=
" WHERE t.active = ".((int) $active);
862 $sql .=
" AND t.module LIKE '%".$this->db->escape($module).
"%'";
868 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
870 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
871 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
875 $sql .= $this->
db->order($sortfield, $sortorder);
881 $offset = $limit * $page;
883 $sql .= $this->
db->plimit($limit, $offset);
886 $result = $this->
db->query($sql);
889 $num = $this->
db->num_rows($result);
890 $min = min($num, ($limit <= 0 ? $num : $limit));
891 for ($i = 0; $i < $min; $i++) {
892 $civility = $this->
db->fetch_object($result);
893 $this->
translateLabel($civility, $lang,
'Civility', array(
'dict'));
897 throw new RestException(503,
'Error when retrieving list of civility : '.$this->
db->lasterror());
919 public function getListOfCurrencies($multicurrency = 0, $sortfield =
"code_iso", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
922 $sql =
"SELECT t.code_iso, t.label, t.unicode";
923 if (!empty($multicurrency)) {
924 $sql .=
" , cr.date_sync, cr.rate ";
926 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_currencies as t";
927 if (!empty($multicurrency)) {
928 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency as m ON m.code=t.code_iso";
929 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
931 $sql .=
" WHERE t.active = ".((int) $active);
932 if (!empty($multicurrency)) {
933 $sql .=
" AND m.entity IN (".getEntity(
'multicurrency').
")";
934 if (!empty($multicurrency) && $multicurrency != 2) {
935 $sql .=
" AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.
"multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
943 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
945 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
946 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
950 $sql .= $this->
db->order($sortfield, $sortorder);
956 $offset = $limit * $page;
958 $sql .= $this->
db->plimit($limit, $offset);
961 $result = $this->
db->query($sql);
964 $num = $this->
db->num_rows($result);
965 $min = min($num, ($limit <= 0 ? $num : $limit));
966 for ($i = 0; $i < $min; $i++) {
967 $list[] = $this->
db->fetch_object($result);
970 throw new RestException(503,
'Error when retrieving list of currency : '.$this->
db->lasterror());
993 if (!DolibarrApiAccess::$user->admin) {
994 throw new RestException(401,
'Only an admin user can get list of extrafields');
997 if ($type ==
'thirdparty') {
1000 if ($type ==
'contact') {
1001 $type =
'socpeople';
1004 $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";
1005 $sql .=
" FROM ".MAIN_DB_PREFIX.
"extrafields as t";
1006 $sql .=
" WHERE t.entity IN (".getEntity(
'extrafields').
")";
1007 if (!empty($type)) {
1008 $sql .=
" AND t.elementtype = '".$this->db->escape($type).
"'";
1014 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1016 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1017 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1020 $sql .= $this->
db->order($sortfield, $sortorder);
1025 while ($tab = $this->
db->fetch_object(
$resql)) {
1027 $list[$tab->elementtype][$tab->name][
'type'] = $tab->type;
1028 $list[$tab->elementtype][$tab->name][
'label'] = $tab->label;
1029 $list[$tab->elementtype][$tab->name][
'size'] = $tab->size;
1030 $list[$tab->elementtype][$tab->name][
'elementtype'] = $tab->elementtype;
1031 $list[$tab->elementtype][$tab->name][
'default'] = $tab->fielddefault;
1032 $list[$tab->elementtype][$tab->name][
'computed'] = $tab->fieldcomputed;
1033 $list[$tab->elementtype][$tab->name][
'unique'] = $tab->fieldunique;
1034 $list[$tab->elementtype][$tab->name][
'required'] = $tab->fieldrequired;
1035 $list[$tab->elementtype][$tab->name][
'param'] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1036 $list[$tab->elementtype][$tab->name][
'pos'] = $tab->pos;
1037 $list[$tab->elementtype][$tab->name][
'alwayseditable'] = $tab->alwayseditable;
1038 $list[$tab->elementtype][$tab->name][
'perms'] = $tab->perms;
1039 $list[$tab->elementtype][$tab->name][
'list'] = $tab->list;
1043 throw new RestException(503,
'Error when retrieving list of extra fields : '.$this->
db->lasterror());
1046 if (!count($list)) {
1047 throw new RestException(404,
'No extrafield found');
1071 public function getListOfTowns($sortfield =
"zip,town", $sortorder =
'ASC', $limit = 100, $page = 0, $zipcode =
'', $town =
'', $active = 1, $sqlfilters =
'')
1075 $sql =
"SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
1076 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ziptown as t";
1077 $sql .=
" WHERE t.active = ".((int) $active);
1079 $sql .=
" AND t.zip LIKE '%".$this->db->escape($zipcode).
"%'";
1082 $sql .=
" AND t.town LIKE '%".$this->db->escape($town).
"%'";
1088 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1090 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1091 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1095 $sql .= $this->
db->order($sortfield, $sortorder);
1101 $offset = $limit * $page;
1103 $sql .= $this->
db->plimit($limit, $offset);
1106 $result = $this->
db->query($sql);
1109 $num = $this->
db->num_rows($result);
1110 $min = min($num, ($limit <= 0 ? $num : $limit));
1111 for ($i = 0; $i < $min; $i++) {
1112 $list[] = $this->
db->fetch_object($result);
1115 throw new RestException(503,
'Error when retrieving list of towns : '.$this->
db->lasterror());
1137 public function getPaymentTerms($sortfield =
"sortorder", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1141 if (!DolibarrApiAccess::$user->rights->propal->lire && !DolibarrApiAccess::$user->rights->commande->lire && !DolibarrApiAccess::$user->rights->facture->lire) {
1142 throw new RestException(401);
1145 $sql =
"SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
1146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
1147 $sql .=
" WHERE t.entity IN (".getEntity(
'c_payment_term').
")";
1148 $sql .=
" AND t.active = ".((int) $active);
1153 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1155 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1156 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1160 $sql .= $this->
db->order($sortfield, $sortorder);
1166 $offset = $limit * $page;
1168 $sql .= $this->
db->plimit($limit, $offset);
1171 $result = $this->
db->query($sql);
1174 $num = $this->
db->num_rows($result);
1175 $min = min($num, ($limit <= 0 ? $num : $limit));
1176 for ($i = 0; $i < $min; $i++) {
1177 $list[] = $this->
db->fetch_object($result);
1180 throw new RestException(400, $this->
db->lasterror());
1201 public function getShippingModes($limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1205 $sql =
"SELECT rowid as id, code, libelle as label, description, tracking, module";
1206 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode as t";
1207 $sql .=
" WHERE t.entity IN (".getEntity(
'c_shipment_mode').
")";
1208 $sql .=
" AND t.active = ".((int) $active);
1213 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1215 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1216 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1226 $offset = $limit * $page;
1228 $sql .= $this->
db->plimit($limit, $offset);
1231 $result = $this->
db->query($sql);
1234 $num = $this->
db->num_rows($result);
1235 $min = min($num, ($limit <= 0 ? $num : $limit));
1236 for ($i = 0; $i < $min; $i++) {
1237 $method = $this->
db->fetch_object($result);
1242 throw new RestException(400, $this->
db->lasterror());
1263 public function getListOfMeasuringUnits($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1267 $sql =
"SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
1268 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_units as t";
1269 $sql .=
" WHERE t.active = ".((int) $active);
1274 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1276 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1277 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1281 $sql .= $this->
db->order($sortfield, $sortorder);
1287 $offset = $limit * $page;
1289 $sql .= $this->
db->plimit($limit, $offset);
1292 $result = $this->
db->query($sql);
1295 $num = $this->
db->num_rows($result);
1296 $min = min($num, ($limit <= 0 ? $num : $limit));
1297 for ($i = 0; $i < $min; $i++) {
1298 $list[] = $this->
db->fetch_object($result);
1301 throw new RestException(503,
'Error when retrieving list of measuring units: '.$this->
db->lasterror());
1323 public function getListOfLegalForm($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters =
'')
1327 $sql =
"SELECT t.rowid, t.code, t.fk_pays, t.libelle, t.isvatexempted, t.active, t.module, t.position";
1328 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_forme_juridique as t";
1329 $sql .=
" WHERE t.active = ".((int) $active);
1331 $sql .=
" AND t.fk_pays = ".((int) $country);
1337 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1339 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1340 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1344 $sql .= $this->
db->order($sortfield, $sortorder);
1350 $offset = $limit * $page;
1352 $sql .= $this->
db->plimit($limit, $offset);
1355 $result = $this->
db->query($sql);
1358 $num = $this->
db->num_rows($result);
1359 $min = min($num, ($limit <= 0 ? $num : $limit));
1360 for ($i = 0; $i < $min; $i++) {
1361 $list[] = $this->
db->fetch_object($result);
1364 throw new RestException(503,
'Error when retrieving list of legal form: '.$this->
db->lasterror());
1385 public function getListOfStaff($sortfield =
"id", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1389 $sql =
"SELECT t.id, t.code, t.libelle, t.active, t.module";
1390 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_effectif as t";
1391 $sql .=
" WHERE t.active = ".((int) $active);
1396 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1398 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1399 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1403 $sql .= $this->
db->order($sortfield, $sortorder);
1409 $offset = $limit * $page;
1411 $sql .= $this->
db->plimit($limit, $offset);
1414 $result = $this->
db->query($sql);
1417 $num = $this->
db->num_rows($result);
1418 $min = min($num, ($limit <= 0 ? $num : $limit));
1419 for ($i = 0; $i < $min; $i++) {
1420 $list[] = $this->
db->fetch_object($result);
1423 throw new RestException(503,
'Error when retrieving list of staff: '.$this->
db->lasterror());
1444 public function getListOfsocialNetworks($sortfield =
"rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters =
'')
1449 throw new RestException(400,
'API not available: this dictionary is not enabled by setup');
1454 $sql =
"SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active";
1455 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_socialnetworks as t";
1456 $sql .=
" WHERE t.entity IN (".getEntity(
'c_socialnetworks').
")";
1457 $sql .=
" AND t.active = ".((int) $active);
1462 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1464 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1465 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1469 $sql .= $this->
db->order($sortfield, $sortorder);
1475 $offset = $limit * $page;
1477 $sql .= $this->
db->plimit($limit, $offset);
1480 $result = $this->
db->query($sql);
1483 $num = $this->
db->num_rows($result);
1484 $min = min($num, ($limit <= 0 ? $num : $limit));
1485 for ($i = 0; $i < $min; $i++) {
1486 $list[] = $this->
db->fetch_object($result);
1489 throw new RestException(503,
'Error when retrieving list of social networks: '.$this->
db->lasterror());
1511 public function getTicketsCategories($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1515 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1516 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_category as t";
1517 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_category').
")";
1518 $sql .=
" AND t.active = ".((int) $active);
1523 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1525 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1526 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1530 $sql .= $this->
db->order($sortfield, $sortorder);
1536 $offset = $limit * $page;
1538 $sql .= $this->
db->plimit($limit, $offset);
1541 $result = $this->
db->query($sql);
1544 $num = $this->
db->num_rows($result);
1545 $min = min($num, ($limit <= 0 ? $num : $limit));
1546 for ($i = 0; $i < $min; $i++) {
1547 $category = $this->
db->fetch_object($result);
1548 $this->
translateLabel($category, $lang,
'TicketCategoryShort', array(
'ticket'));
1549 $list[] = $category;
1552 throw new RestException(503,
'Error when retrieving list of ticket categories : '.$this->
db->lasterror());
1574 public function getTicketsSeverities($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1578 $sql =
"SELECT rowid, code, pos, label, use_default, color, description";
1579 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_severity as t";
1580 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_severity').
")";
1581 $sql .=
" AND t.active = ".((int) $active);
1586 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1588 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1589 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1593 $sql .= $this->
db->order($sortfield, $sortorder);
1599 $offset = $limit * $page;
1601 $sql .= $this->
db->plimit($limit, $offset);
1604 $result = $this->
db->query($sql);
1607 $num = $this->
db->num_rows($result);
1608 $min = min($num, ($limit <= 0 ? $num : $limit));
1609 for ($i = 0; $i < $min; $i++) {
1610 $severity = $this->
db->fetch_object($result);
1611 $this->
translateLabel($severity, $lang,
'TicketSeverityShort', array(
'ticket'));
1612 $list[] = $severity;
1615 throw new RestException(503,
'Error when retrieving list of ticket severities : '.$this->
db->lasterror());
1637 public function getTicketsTypes($sortfield =
"code", $sortorder =
'ASC', $limit = 100, $page = 0, $active = 1, $lang =
'', $sqlfilters =
'')
1641 $sql =
"SELECT rowid, code, pos, label, use_default, description";
1642 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_ticket_type as t";
1643 $sql .=
" WHERE t.entity IN (".getEntity(
'c_ticket_type').
")";
1644 $sql .=
" AND t.active = ".((int) $active);
1650 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
1652 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
1653 $sql .=
" AND (".preg_replace_callback(
'/'.$regexstring.
'/',
'DolibarrApi::_forge_criteria_callback', $sqlfilters).
")";
1657 $sql .= $this->
db->order($sortfield, $sortorder);
1663 $offset = $limit * $page;
1665 $sql .= $this->
db->plimit($limit, $offset);
1668 $result = $this->
db->query($sql);
1671 $num = $this->
db->num_rows($result);
1672 $min = min($num, ($limit <= 0 ? $num : $limit));
1673 for ($i = 0; $i < $min; $i++) {
1674 $type =$this->
db->fetch_object($result);
1675 $this->
translateLabel($type, $lang,
'TicketTypeShort', array(
'ticket'));
1679 throw new RestException(503,
'Error when retrieving list of ticket types : '.$this->
db->lasterror());
1696 global $conf, $mysoc;
1698 if (!DolibarrApiAccess::$user->admin
1699 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
1700 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');
1703 unset($mysoc->skype);
1704 unset($mysoc->twitter);
1705 unset($mysoc->facebook);
1706 unset($mysoc->linkedin);
1708 unset($mysoc->pays);
1709 unset($mysoc->note);
1712 unset($mysoc->lines);
1714 unset($mysoc->effectif);
1715 unset($mysoc->effectif_id);
1716 unset($mysoc->forme_juridique_code);
1717 unset($mysoc->forme_juridique);
1718 unset($mysoc->mode_reglement_supplier_id);
1719 unset($mysoc->cond_reglement_supplier_id);
1720 unset($mysoc->transport_mode_supplier_id);
1721 unset($mysoc->fk_prospectlevel);
1723 unset($mysoc->total_ht);
1724 unset($mysoc->total_tva);
1725 unset($mysoc->total_localtax1);
1726 unset($mysoc->total_localtax2);
1727 unset($mysoc->total_ttc);
1729 unset($mysoc->lastname);
1730 unset($mysoc->firstname);
1731 unset($mysoc->civility_id);
1733 unset($mysoc->client);
1734 unset($mysoc->prospect);
1735 unset($mysoc->fournisseur);
1736 unset($mysoc->contact_id);
1738 unset($mysoc->fk_incoterms);
1739 unset($mysoc->label_incoterms);
1740 unset($mysoc->location_incoterms);
1760 $sql =
"SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status";
1761 $sql .=
" FROM ".MAIN_DB_PREFIX.
"establishment as e";
1762 $sql .=
" WHERE e.entity IN (".getEntity(
'establishment').
')';
1767 $result = $this->
db->query($sql);
1770 $num = $this->
db->num_rows($result);
1771 $min = min($num, ($limit <= 0 ? $num : $limit));
1772 for ($i = 0; $i < $min; $i++) {
1773 $list[] = $this->
db->fetch_object($result);
1776 throw new RestException(503,
'Error when retrieving list of establishments : '.$this->
db->lasterror());
1796 $result = $establishment->fetch($id);
1798 throw new RestException(503,
'Error when retrieving establishment : '.$establishment->error);
1799 } elseif ($result == 0) {
1800 throw new RestException(404,
'Establishment not found');
1823 if (!DolibarrApiAccess::$user->admin
1825 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');
1828 if (!preg_match(
'/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) {
1829 throw new RestException(404,
'Error Bad or unknown value for constantname');
1832 throw new RestException(403,
'Forbidden. This parameter cant be read with APIs');
1853 global $langs, $conf;
1855 if (!DolibarrApiAccess::$user->admin
1856 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_INTEGRITY_CHECK)) {
1857 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');
1860 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1861 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
1863 $langs->load(
"admin");
1865 $outexpectedchecksum =
'';
1866 $outcurrentchecksum =
'';
1869 $file_list = array(
'missing' => array(),
'updated' => array());
1872 $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));
1873 $xmlfile = DOL_DOCUMENT_ROOT.
'/install/'.$xmlshortfile;
1875 $xmlremote = ($target ==
'default' ?
'' : $target);
1876 if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
1877 $xmlremote = $conf->global->MAIN_FILECHECK_URL;
1879 $param =
'MAIN_FILECHECK_URL_'.DOL_VERSION;
1880 if (empty($xmlremote) && !empty($conf->global->$param)) {
1881 $xmlremote = $conf->global->$param;
1883 if (empty($xmlremote)) {
1884 $xmlremote =
'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.
'.xml';
1886 if ($xmlremote && !preg_match(
'/^https?:\/\//i', $xmlremote)) {
1887 $langs->load(
"errors");
1888 throw new RestException(500, $langs->trans(
"ErrorURLMustStartWithHttp", $xmlremote));
1890 if ($xmlremote && !preg_match(
'/\.xml$/', $xmlremote)) {
1891 $langs->load(
"errors");
1892 throw new RestException(500, $langs->trans(
"ErrorURLMustEndWith", $xmlremote,
'.xml'));
1895 if ($target ==
'local') {
1897 $xml = simplexml_load_file($xmlfile);
1899 throw new RestException(500, $langs->trans(
'XmlNotFound').
': '.$xmlfile);
1902 $xmlarray =
getURLContent($xmlremote,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1905 if (!$xmlarray[
'curl_error_no'] && $xmlarray[
'http_code'] !=
'400' && $xmlarray[
'http_code'] !=
'404') {
1906 $xmlfile = $xmlarray[
'content'];
1908 $xml = simplexml_load_string($xmlfile,
'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
1910 $errormsg = $langs->trans(
'XmlNotFound').
': '.$xmlremote.
' - '.$xmlarray[
'http_code'].(($xmlarray[
'http_code'] == 400 && $xmlarray[
'content']) ?
' '.$xmlarray[
'content'] :
'').
' '.$xmlarray[
'curl_error_no'].
' '.$xmlarray[
'curl_error_msg'];
1911 throw new RestException(500, $errormsg);
1916 $checksumconcat = array();
1917 $file_list = array();
1921 if (is_object($xml->dolibarr_constants[0])) {
1924 $out .=
'<div class="div-table-responsive-no-min">';
1925 $out .=
'<table class="noborder">';
1926 $out .=
'<tr class="liste_titre">';
1927 $out .=
'<td>#</td>';
1928 $out .=
'<td>'.$langs->trans(
"Constant").
'</td>';
1929 $out .=
'<td class="center">'.$langs->trans(
"ExpectedValue").
'</td>';
1930 $out .=
'<td class="center">'.$langs->trans(
"Value").
'</td>';
1931 $out .=
'</tr>'.
"\n";
1934 foreach ($xml->dolibarr_constants[0]->constant as $constant) {
1935 $constname = $constant[
'name'];
1936 $constvalue = (string) $constant;
1937 $constvalue = (empty($constvalue) ?
'0' : $constvalue);
1940 if ($constname && $conf->global->$constname !=
'') {
1941 $value = $conf->global->$constname;
1943 $valueforchecksum = (empty($value) ?
'0' : $value);
1945 $checksumconcat[] = $valueforchecksum;
1948 $out .=
'<tr class="oddeven">';
1949 $out .=
'<td>'.$i.
'</td>'.
"\n";
1950 $out .=
'<td>'.$constname.
'</td>'.
"\n";
1951 $out .=
'<td class="center">'.$constvalue.
'</td>'.
"\n";
1952 $out .=
'<td class="center">'.$valueforchecksum.
'</td>'.
"\n";
1957 $out .=
'<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
1966 if (is_object($xml->dolibarr_htdocs_dir[0])) {
1967 $includecustom = (empty($xml->dolibarr_htdocs_dir[0][
'includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0][
'includecustom']);
1970 $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)$';
1971 $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)$';
1972 $scanfiles =
dol_dir_list(DOL_DOCUMENT_ROOT,
'files', 1, $regextoinclude, $regextoexclude);
1975 $ret =
getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0],
'', DOL_DOCUMENT_ROOT, $checksumconcat);
1977 foreach ($scanfiles as $keyfile => $valfile) {
1978 $tmprelativefilename = preg_replace(
'/^'.preg_quote(DOL_DOCUMENT_ROOT,
'/').
'/',
'', $valfile[
'fullname']);
1979 if (!in_array($tmprelativefilename, $file_list[
'insignature'])) {
1980 $md5newfile = @md5_file($valfile[
'fullname']);
1981 $file_list[
'added'][] = array(
'filename'=>$tmprelativefilename,
'md5'=>$md5newfile);
1988 $out .=
'<div class="div-table-responsive-no-min">';
1989 $out .=
'<table class="noborder">';
1990 $out .=
'<tr class="liste_titre">';
1991 $out .=
'<td>#</td>';
1992 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
1993 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
1994 $out .=
'</tr>'.
"\n";
1995 $tmpfilelist =
dol_sort_array($file_list[
'missing'],
'filename');
1996 if (is_array($tmpfilelist) && count($tmpfilelist)) {
1998 foreach ($tmpfilelist as $file) {
2000 $out .=
'<tr class="oddeven">';
2001 $out .=
'<td>'.$i.
'</td>'.
"\n";
2002 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2003 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2007 $out .=
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2018 $out .=
'<div class="div-table-responsive-no-min">';
2019 $out .=
'<table class="noborder">';
2020 $out .=
'<tr class="liste_titre">';
2021 $out .=
'<td>#</td>';
2022 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2023 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2024 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2025 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2026 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2027 $out .=
'</tr>'.
"\n";
2028 $tmpfilelist2 =
dol_sort_array($file_list[
'updated'],
'filename');
2029 if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
2031 foreach ($tmpfilelist2 as $file) {
2033 $out .=
'<tr class="oddeven">';
2034 $out .=
'<td>'.$i.
'</td>'.
"\n";
2035 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2036 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2037 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2038 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2039 $totalsize += $size;
2040 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2041 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2044 $out .=
'<tr class="liste_total">';
2045 $out .=
'<td></td>'.
"\n";
2046 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2047 $out .=
'<td align="center"></td>'.
"\n";
2048 $out .=
'<td align="center"></td>'.
"\n";
2049 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2050 $out .=
'<td class="right"></td>'.
"\n";
2053 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2064 $out .=
'<div class="div-table-responsive-no-min">';
2065 $out .=
'<table class="noborder">';
2066 $out .=
'<tr class="liste_titre">';
2067 $out .=
'<td>#</td>';
2068 $out .=
'<td>'.$langs->trans(
"Filename").
'</td>';
2069 $out .=
'<td class="center">'.$langs->trans(
"ExpectedChecksum").
'</td>';
2070 $out .=
'<td class="center">'.$langs->trans(
"CurrentChecksum").
'</td>';
2071 $out .=
'<td class="right">'.$langs->trans(
"Size").
'</td>';
2072 $out .=
'<td class="right">'.$langs->trans(
"DateModification").
'</td>';
2073 $out .=
'</tr>'.
"\n";
2075 if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
2077 foreach ($tmpfilelist3 as $file) {
2079 $out .=
'<tr class="oddeven">';
2080 $out .=
'<td>'.$i.
'</td>'.
"\n";
2081 $out .=
'<td>'.$file[
'filename'].
'</td>'.
"\n";
2082 $out .=
'<td class="center">'.$file[
'expectedmd5'].
'</td>'.
"\n";
2083 $out .=
'<td class="center">'.$file[
'md5'].
'</td>'.
"\n";
2084 $size =
dol_filesize(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']);
2085 $totalsize += $size;
2086 $out .=
'<td class="right">'.dol_print_size($size).
'</td>'.
"\n";
2087 $out .=
'<td class="right">'.dol_print_date(
dol_filemtime(DOL_DOCUMENT_ROOT.
'/'.$file[
'filename']),
'dayhour').
'</td>'.
"\n";
2090 $out .=
'<tr class="liste_total">';
2091 $out .=
'<td></td>'.
"\n";
2092 $out .=
'<td>'.$langs->trans(
"Total").
'</td>'.
"\n";
2093 $out .=
'<td align="center"></td>'.
"\n";
2094 $out .=
'<td align="center"></td>'.
"\n";
2095 $out .=
'<td class="right">'.dol_print_size($totalsize).
'</td>'.
"\n";
2096 $out .=
'<td class="right"></td>'.
"\n";
2099 $out .=
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2106 if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
2112 throw new RestException(500,
'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile);
2117 asort($checksumconcat);
2118 $checksumget = md5(join(
',', $checksumconcat));
2119 $checksumtoget = trim((
string) $xml->dolibarr_htdocs_dir_checksum);
2121 $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans(
"Unknown"));
2122 if ($checksumget == $checksumtoget) {
2123 if (count($file_list[
'added'])) {
2124 $resultcode =
'warning';
2125 $resultcomment =
'FileIntegrityIsOkButFilesWereAdded';
2127 $outcurrentchecksum = $checksumget;
2130 $resultcomment =
'Success';
2132 $outcurrentchecksum = $checksumget;
2135 $resultcode =
'error';
2136 $resultcomment =
'Error';
2138 $outcurrentchecksum = $checksumget;
2141 throw new RestException(404,
'No signature file known');
2144 return array(
'resultcode'=>$resultcode,
'resultcomment'=>$resultcomment,
'expectedchecksum'=> $outexpectedchecksum,
'currentchecksum'=> $outcurrentchecksum,
'out'=>$out);
2161 if (!DolibarrApiAccess::$user->admin
2162 && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_MODULES)) {
2163 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');
2166 sort($conf->modules);
Class to manage dictionary Countries (used by imports)
Class to manage dictionary States (used by imports)
_checkFilters($sqlfilters, &$error='')
Return if a $sqlfilters parameter is valid.
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.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.