35 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
47 const TYPE_PRODUCT =
'product';
48 const TYPE_SUPPLIER =
'supplier';
49 const TYPE_CUSTOMER =
'customer';
50 const TYPE_MEMBER =
'member';
51 const TYPE_CONTACT =
'contact';
52 const TYPE_USER =
'user';
53 const TYPE_PROJECT =
'project';
54 const TYPE_ACCOUNT =
'bank_account';
55 const TYPE_BANK_LINE =
'bank_line';
56 const TYPE_WAREHOUSE =
'warehouse';
57 const TYPE_ACTIONCOMM =
'actioncomm';
58 const TYPE_WEBSITE_PAGE =
'website_page';
63 public $picto =
'category';
69 protected $MAP_ID = array(
89 public static $MAP_ID_TO_CODE = array(
109 protected $MAP_CAT_FK = array(
112 'contact' =>
'socpeople',
113 'bank_account' =>
'account',
121 protected $MAP_CAT_TABLE = array(
122 'customer' =>
'societe',
123 'supplier' =>
'fournisseur',
124 'bank_account'=>
'account',
132 protected $MAP_OBJ_CLASS = array(
133 'product' =>
'Product',
134 'customer' =>
'Societe',
135 'supplier' =>
'Fournisseur',
136 'member' =>
'Adherent',
137 'contact' =>
'Contact',
139 'account' =>
'Account',
140 'bank_account' =>
'Account',
141 'project' =>
'Project',
142 'warehouse'=>
'Entrepot',
143 'actioncomm' =>
'ActionComm',
144 'website_page' =>
'WebsitePage'
152 public static $MAP_TYPE_TITLE_AREA = array(
153 'product' =>
'ProductsCategoriesArea',
154 'customer' =>
'CustomersCategoriesArea',
155 'supplier' =>
'SuppliersCategoriesArea',
156 'member' =>
'MembersCategoriesArea',
157 'contact' =>
'ContactsCategoriesArea',
158 'user' =>
'UsersCategoriesArea',
159 'account' =>
'AccountsCategoriesArea',
160 'bank_account' =>
'AccountsCategoriesArea',
161 'project' =>
'ProjectsCategoriesArea',
162 'warehouse'=>
'StocksCategoriesArea',
163 'actioncomm' =>
'ActioncommCategoriesArea',
164 'website_page' =>
'WebsitePageCategoriesArea'
172 protected $MAP_OBJ_TABLE = array(
173 'customer' =>
'societe',
174 'supplier' =>
'societe',
175 'member' =>
'adherent',
176 'contact' =>
'socpeople',
177 'account' =>
'bank_account',
178 'project' =>
'projet',
179 'warehouse'=>
'entrepot'
185 public $element =
'category';
190 public $table_element =
'categorie';
243 public $cats = array();
248 public $motherof = array();
261 if (is_object($hookmanager)) {
262 $hookmanager->initHooks(array(
'category'));
263 $parameters = array();
264 $reshook = $hookmanager->executeHooks(
'constructCategory', $parameters, $this);
265 if ($reshook >= 0 && !empty($hookmanager->resArray)) {
266 $mapList = $hookmanager->resArray;
267 $mapId = $mapList[
'id'];
268 $mapCode = $mapList[
'code'];
269 self::$MAP_ID_TO_CODE[$mapId] = $mapCode;
270 $this->MAP_ID[$mapCode] = $mapId;
271 $this->MAP_CAT_FK[$mapCode] = $mapList[
'cat_fk'];
272 $this->MAP_CAT_TABLE[$mapCode] = $mapList[
'cat_table'];
273 $this->MAP_OBJ_CLASS[$mapCode] = $mapList[
'obj_class'];
274 $this->MAP_OBJ_TABLE[$mapCode] = $mapList[
'obj_table'];
288 foreach ($this->MAP_ID as $mapCode => $mapId) {
292 'cat_fk' => (empty($this->MAP_CAT_FK[$mapCode]) ? $mapCode : $this->MAP_CAT_FK[$mapCode]),
293 'cat_table' => (empty($this->MAP_CAT_TABLE[$mapCode]) ? $mapCode : $this->MAP_CAT_TABLE[$mapCode]),
294 'obj_class' => (empty($this->MAP_OBJ_CLASS[$mapCode]) ? $mapCode : $this->MAP_OBJ_CLASS[$mapCode]),
295 'obj_table' => (empty($this->MAP_OBJ_TABLE[$mapCode]) ? $mapCode : $this->MAP_OBJ_TABLE[$mapCode])
311 public function fetch($id, $label =
'', $type = null, $ref_ext =
'')
316 if (empty($id) && empty($label) && empty($ref_ext))
return -1;
317 if (!is_null($type) && !is_numeric($type)) $type = $this->MAP_ID[$type];
319 $sql =
"SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext";
320 $sql .=
", date_creation, tms, fk_user_creat, fk_user_modif";
321 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie";
323 $sql .=
" WHERE rowid = ".$id;
324 } elseif (!empty($ref_ext)) {
325 $sql .=
" WHERE ref_ext LIKE '".$this->db->escape($ref_ext).
"'";
327 $sql .=
" WHERE label = '".$this->db->escape($label).
"' AND entity IN (".
getEntity(
'category').
")";
328 if (!is_null($type)) $sql .=
" AND type = ".((int) $type);
331 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
334 if ($this->
db->num_rows(
$resql) > 0) {
335 $res = $this->
db->fetch_array(
$resql);
337 $this->
id = $res[
'rowid'];
339 $this->fk_parent = (int) $res[
'fk_parent'];
340 $this->label = $res[
'label'];
342 $this->color = $res[
'color'];
343 $this->socid = (int) $res[
'fk_soc'];
344 $this->visible = (int) $res[
'visible'];
345 $this->
type = (int) $res[
'type'];
346 $this->ref_ext = $res[
'ref_ext'];
347 $this->entity = (int) $res[
'entity'];
348 $this->date_creation = $this->
db->jdate($res[
'date_creation']);
349 $this->date_modification = $this->
db->jdate($res[
'tms']);
350 $this->user_creation = (int) $res[
'fk_user_creat'];
351 $this->user_modification = (int) $res[
'fk_user_modif'];
360 if (!empty($conf->global->MAIN_MULTILANGS)) $this->
getMultiLangs();
383 global $conf, $langs, $hookmanager;
384 $langs->load(
'categories');
388 if (!is_numeric($type)) $type = $this->MAP_ID[$type];
392 dol_syslog(get_class($this).
'::create', LOG_DEBUG);
395 $this->label = trim($this->label);
397 $this->color = trim($this->color);
398 $this->import_key = trim($this->import_key);
399 $this->ref_ext = trim($this->ref_ext);
400 if (empty($this->visible)) $this->visible = 0;
401 $this->fk_parent = ($this->fk_parent !=
"" ? intval($this->fk_parent) : 0);
404 $this->error = $langs->trans(
"ImpossibleAddCat", $this->label);
405 $this->error .=
" : ".$langs->trans(
"CategoryExistsAtSameLevel");
412 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie (";
413 $sql .=
"fk_parent,";
415 $sql .=
" description,";
417 if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
422 $sql .=
" import_key,";
425 $sql .=
" date_creation,";
426 $sql .=
" fk_user_creat";
427 $sql .=
") VALUES (";
428 $sql .= (int) $this->fk_parent.
",";
429 $sql .=
"'".$this->db->escape($this->label).
"', ";
430 $sql .=
"'".$this->db->escape($this->
description).
"', ";
431 $sql .=
"'".$this->db->escape($this->color).
"', ";
432 if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
433 $sql .= ($this->socid > 0 ? $this->socid :
'null').
", ";
435 $sql .=
"'".$this->db->escape($this->visible).
"', ";
436 $sql .= $this->
db->escape($type).
", ";
437 $sql .= (!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
'null').
", ";
438 $sql .= (!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
'null').
", ";
439 $sql .= (int) $conf->entity.
", ";
440 $sql .=
"'".$this->db->idate($now).
"', ";
441 $sql .= (int) $user->id;
444 $res = $this->db->query($sql);
446 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"categorie");
463 $result = $this->
call_trigger(
'CATEGORY_CREATE', $user);
464 if ($result < 0) { $error++; }
472 $this->
db->rollback();
476 $this->
db->rollback();
480 $this->error = $this->
db->error();
481 $this->
db->rollback();
496 global $conf, $langs, $hookmanager;
501 $this->label = trim($this->label);
503 $this->ref_ext = trim($this->ref_ext);
504 $this->fk_parent = ($this->fk_parent !=
"" ? intval($this->fk_parent) : 0);
505 $this->visible = ($this->visible !=
"" ? intval($this->visible) : 0);
508 $this->error = $langs->trans(
"ImpossibleUpdateCat");
509 $this->error .=
" : ".$langs->trans(
"CategoryExistsAtSameLevel");
515 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"categorie";
516 $sql .=
" SET label = '".$this->db->escape($this->label).
"',";
517 $sql .=
" description = '".$this->db->escape($this->
description).
"',";
518 $sql .=
" ref_ext = '".$this->db->escape($this->ref_ext).
"',";
519 $sql .=
" color = '".$this->db->escape($this->color).
"'";
520 if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
521 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->socid :
'null');
523 $sql .=
", visible = ".(int) $this->visible;
524 $sql .=
", fk_parent = ".(int) $this->fk_parent;
525 $sql .=
", fk_user_modif = ".(int) $user->id;
526 $sql .=
" WHERE rowid = ".$this->id;
528 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
529 if ($this->
db->query($sql)) {
542 $result = $this->
call_trigger(
'CATEGORY_MODIFY', $user);
543 if ($result < 0) { $error++; $this->
db->rollback();
return -1; }
551 $this->
db->rollback();
564 public function delete($user, $notrigger = 0)
566 global $conf, $langs;
571 $this->fk_parent = ($this->fk_parent !=
"" ? intval($this->fk_parent) : 0);
577 if (!$error && !$notrigger) {
579 $result = $this->
call_trigger(
'CATEGORY_DELETE', $user);
580 if ($result < 0) $error++;
586 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"categorie";
587 $sql .=
" SET fk_parent = ".$this->fk_parent;
588 $sql .=
" WHERE fk_parent = ".$this->id;
590 if (!$this->
db->query($sql)) {
591 $this->error = $this->
db->lasterror();
596 $arraydelete = array(
597 'categorie_societe' =>
'fk_categorie',
598 'categorie_fournisseur' =>
'fk_categorie',
599 'categorie_product' =>
'fk_categorie',
600 'categorie_member' =>
'fk_categorie',
601 'categorie_contact' =>
'fk_categorie',
602 'categorie_account' =>
'fk_categorie',
603 'bank_class' =>
'fk_categ',
604 'categorie_lang' =>
'fk_category',
605 'categorie' =>
'rowid',
607 foreach ($arraydelete as $key => $value) {
608 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$key;
609 $sql .=
" WHERE ".$value.
" = ".$this->id;
610 if (!$this->
db->query($sql)) {
611 $this->errors[] = $this->
db->lasterror();
612 dol_syslog(
"Error sql=".$sql.
" ".$this->error, LOG_ERR);
622 dol_syslog(get_class($this).
"::delete erreur ".$this->error, LOG_ERR);
630 $this->
db->rollback();
646 global $user, $langs, $conf;
650 if ($this->
id == -1)
return -2;
652 if (empty($type)) $type = $obj->element;
656 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
657 $sql .=
" (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
")";
658 $sql .=
" VALUES (".$this->id.
", ".$obj->id.
")";
660 dol_syslog(get_class($this).
'::add_type', LOG_DEBUG);
661 if ($this->
db->query($sql)) {
662 if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
663 $sql =
'SELECT fk_parent FROM '.MAIN_DB_PREFIX.
'categorie';
664 $sql .=
" WHERE rowid = ".$this->id;
666 dol_syslog(get_class($this).
"::add_type", LOG_DEBUG);
669 if ($this->
db->num_rows(
$resql) > 0) {
670 $objparent = $this->
db->fetch_object(
$resql);
672 if (!empty($objparent->fk_parent)) {
674 $cat->id = $objparent->fk_parent;
675 if (!$cat->containsObject($type, $obj->id)) {
676 $result = $cat->add_type($obj, $type);
678 $this->error = $cat->error;
686 $this->error = $this->
db->lasterror();
690 $this->
db->rollback();
698 $this->context = array(
'linkto'=>$obj);
700 if ($result < 0) { $error++; }
707 $this->
db->rollback();
711 $this->
db->rollback();
712 if ($this->
db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
713 $this->error = $this->
db->lasterrno();
716 $this->error = $this->
db->lasterror();
734 global $user, $langs, $conf;
739 if ($type ==
'societe') {
741 dol_syslog(get_class($this).
"::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING);
742 } elseif ($type ==
'fournisseur') {
744 dol_syslog(get_class($this).
"::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING);
749 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
750 $sql .=
" WHERE fk_categorie = ".$this->id;
751 $sql .=
" AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".$obj->id;
753 dol_syslog(get_class($this).
'::del_type', LOG_DEBUG);
754 if ($this->
db->query($sql)) {
756 $this->context = array(
'unlinkoff'=>$obj);
757 $result = $this->
call_trigger(
'CATEGORY_UNLINK', $user);
758 if ($result < 0) { $error++; }
765 $this->
db->rollback();
769 $this->
db->rollback();
770 $this->error = $this->
db->lasterror();
787 public function getObjectsInCateg($type, $onlyids = 0, $limit = 0, $offset = 0, $sortfield =
'', $sortorder =
'ASC')
793 $classnameforobj = $this->MAP_OBJ_CLASS[$type];
794 $obj =
new $classnameforobj($this->
db);
796 $sql =
"SELECT c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]);
797 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]).
" as c";
798 $sql .=
", ".MAIN_DB_PREFIX.(empty($this->MAP_OBJ_TABLE[$type]) ? $type : $this->MAP_OBJ_TABLE[$type]).
" as o";
799 $sql .=
" WHERE o.entity IN (".getEntity($obj->element).
")";
800 $sql .=
" AND c.fk_categorie = ".$this->id;
801 $sql .=
" AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = o.rowid";
803 if (($type ==
'customer' || $type ==
'supplier') && $user->socid > 0) {
804 $sql .=
" AND o.rowid = ".$user->socid;
806 if ($limit > 0 || $offset > 0) $sql .= $this->
db->plimit($limit + 1, $offset);
807 $sql .= $this->
db->order($sortfield, $sortorder);
809 dol_syslog(get_class($this).
"::getObjectsInCateg", LOG_DEBUG);
812 while ($rec = $this->
db->fetch_array(
$resql)) {
814 $objs[] = $rec[
'fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])];
816 $classnameforobj = $this->MAP_OBJ_CLASS[$type];
818 $obj =
new $classnameforobj($this->
db);
819 $obj->fetch($rec[
'fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]);
826 $this->error = $this->
db->error().
' sql='.$sql;
841 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
842 $sql .=
" WHERE fk_categorie = ".$this->id.
" AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".$object_id;
843 dol_syslog(get_class($this).
"::containsObject", LOG_DEBUG);
846 return $this->
db->fetch_object(
$resql)->nb;
848 $this->error = $this->
db->error().
' sql='.$sql;
864 public function getListForItem($id, $type =
'customer', $sortfield =
"s.rowid", $sortorder =
'ASC', $limit = 0, $page = 0)
868 $categories = array();
871 $subcol_name =
"fk_".$type;
872 if ($type ==
"customer") {
873 $sub_type =
"societe";
874 $subcol_name =
"fk_soc";
876 if ($type ==
"supplier") {
877 $sub_type =
"fournisseur";
878 $subcol_name =
"fk_soc";
880 if ($type ==
"contact") {
881 $subcol_name =
"fk_socpeople";
884 $idoftype = array_search($type, self::$MAP_ID_TO_CODE);
886 $sql =
"SELECT s.rowid";
887 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as s";
888 $sql .=
" , ".MAIN_DB_PREFIX.
"categorie_".$sub_type.
" as sub ";
889 $sql .=
' WHERE s.entity IN ('.getEntity(
'category').
')';
890 $sql .=
' AND s.type='.$idoftype;
891 $sql .=
' AND s.rowid = sub.fk_categorie';
892 $sql .=
' AND sub.'.$subcol_name.
' = '.$id;
894 $sql .= $this->
db->order($sortfield, $sortorder);
897 $nbtotalofrecords =
'';
898 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
899 $result = $this->
db->query($sql);
900 $nbtotalofrecords = $this->
db->num_rows($result);
901 if (($page * $limit) > $nbtotalofrecords) {
911 $offset = $limit * $page;
913 $sql .= $this->
db->plimit($limit + 1, $offset);
916 $result = $this->
db->query($sql);
919 $num = $this->
db->num_rows($result);
920 $min = min($num, ($limit <= 0 ? $num : $limit));
922 $obj = $this->
db->fetch_object($result);
924 if ($category_static->fetch($obj->rowid)) {
925 $categories[$i][
'id'] = $category_static->id;
926 $categories[$i][
'fk_parent'] = $category_static->fk_parent;
927 $categories[$i][
'label'] = $category_static->label;
928 $categories[$i][
'description'] = $category_static->description;
929 $categories[$i][
'color'] = $category_static->color;
930 $categories[$i][
'socid'] = $category_static->socid;
931 $categories[$i][
'ref_ext'] = $category_static->ref_ext;
932 $categories[$i][
'visible'] = $category_static->visible;
933 $categories[$i][
'type'] = $category_static->type;
934 $categories[$i][
'entity'] = $category_static->entity;
935 $categories[$i][
'array_options'] = $category_static->array_options;
938 if (!empty($conf->global->MAIN_MULTILANGS)) {
939 $categories[$i][
'multilangs'] = $category_static->multilangs;
945 $this->error = $this->
db->lasterror();
948 if (!count($categories)) {
964 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
965 $sql .=
" WHERE fk_parent = ".$this->id;
966 $sql .=
" AND entity IN (".getEntity(
'category').
")";
968 $res = $this->
db->query($sql);
971 while ($rec = $this->
db->fetch_array($res)) {
973 $cat->fetch($rec[
'rowid']);
992 $this->motherof = array();
995 $sql =
"SELECT fk_parent as id_parent, rowid as id_son";
996 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie";
997 $sql .=
" WHERE fk_parent != 0";
998 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1000 dol_syslog(get_class($this).
"::load_motherof", LOG_DEBUG);
1003 while ($obj = $this->
db->fetch_object(
$resql)) {
1004 $this->motherof[$obj->id_son] = $obj->id_parent;
1036 global $conf, $langs;
1038 if (!is_numeric($type)) $type = $this->MAP_ID[$type];
1039 if (is_null($type)) {
1040 $this->error =
'BadValueForParameterType';
1044 if (is_string($markafterid)) {
1045 $markafterid = explode(
',', $markafterid);
1046 } elseif (is_numeric($markafterid)) {
1047 if ($markafterid > 0) {
1048 $markafterid = array($markafterid);
1050 $markafterid = array();
1052 } elseif (!is_array($markafterid)) {
1053 $markafterid = array();
1056 $this->cats = array();
1060 $current_lang = $langs->getDefaultLang();
1063 $sql =
"SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible";
1064 if (!empty($conf->global->MAIN_MULTILANGS)) $sql .=
", t.label as label_trans, t.description as description_trans";
1065 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as c";
1066 if (!empty($conf->global->MAIN_MULTILANGS)) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->
db->escape($current_lang).
"'";
1067 $sql .=
" WHERE c.entity IN (".getEntity(
'category').
")";
1068 $sql .=
" AND c.type = ".(int) $type;
1070 dol_syslog(get_class($this).
"::get_full_arbo get category list", LOG_DEBUG);
1074 while ($obj = $this->
db->fetch_object(
$resql)) {
1075 $this->cats[$obj->rowid][
'rowid'] = $obj->rowid;
1076 $this->cats[$obj->rowid][
'id'] = $obj->rowid;
1077 $this->cats[$obj->rowid][
'fk_parent'] = $obj->fk_parent;
1078 $this->cats[$obj->rowid][
'label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label;
1079 $this->cats[$obj->rowid][
'description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description;
1080 $this->cats[$obj->rowid][
'color'] = $obj->color;
1081 $this->cats[$obj->rowid][
'visible'] = $obj->visible;
1082 $this->cats[$obj->rowid][
'ref_ext'] = $obj->ref_ext;
1091 dol_syslog(get_class($this).
"::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG);
1092 foreach ($this->cats as $key => $val) {
1098 if (count($markafterid) > 0) {
1099 $keyfiltercatid =
'('.implode(
'|', $markafterid).
')';
1102 $keyfilter1 =
'^'.$keyfiltercatid.
'$';
1103 $keyfilter2 =
'_'.$keyfiltercatid.
'$';
1104 $keyfilter3 =
'^'.$keyfiltercatid.
'_';
1105 $keyfilter4 =
'_'.$keyfiltercatid.
'_';
1106 foreach ($this->cats as $key => $val) {
1107 $test = (preg_match(
'/'.$keyfilter1.
'/', $val[
'fullpath']) || preg_match(
'/'.$keyfilter2.
'/', $val[
'fullpath'])
1108 || preg_match(
'/'.$keyfilter3.
'/', $val[
'fullpath']) || preg_match(
'/'.$keyfilter4.
'/', $val[
'fullpath']));
1110 if (($test && !$include) || (!$test && $include)) {
1111 unset($this->cats[$key]);
1116 dol_syslog(get_class($this).
"::get_full_arbo dol_sort_array", LOG_DEBUG);
1117 $this->cats =
dol_sort_array($this->cats,
'fulllabel',
'asc',
true,
false);
1138 dol_syslog(get_class($this).
"::build_path_from_id_categ id_categ=".$id_categ.
" protection=".$protection, LOG_DEBUG);
1140 if (!empty($this->cats[$id_categ][
'fullpath'])) {
1142 dol_syslog(get_class($this).
"::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
1152 $this->cats[$id_categ][
'fullpath'] =
'_'.$id_categ;
1153 $this->cats[$id_categ][
'fulllabel'] = $this->cats[$id_categ][
'label'];
1154 $i = 0; $cursor_categ = $id_categ;
1156 while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) {
1158 $this->cats[$id_categ][
'fullpath'] =
'_'.$this->motherof[$cursor_categ].$this->cats[$id_categ][
'fullpath'];
1159 $this->cats[$id_categ][
'fulllabel'] = $this->cats[$this->motherof[$cursor_categ]][
'label'].
' >> '.$this->cats[$id_categ][
'fulllabel'];
1161 $i++; $cursor_categ = $this->motherof[$cursor_categ];
1166 $nbunderscore = substr_count($this->cats[$id_categ][
'fullpath'],
'_');
1167 $this->cats[$id_categ][
'level'] = ($nbunderscore ? $nbunderscore : null);
1182 foreach ($this->cats as $key => $val) {
1183 print 'id: '.$this->cats[$key][
'id'];
1184 print ' label: '.$this->cats[$key][
'label'];
1185 print ' mother: '.$this->cats[$key][
'fk_parent'];
1187 print ' fullpath: '.$this->cats[$key][
'fullpath'];
1188 print ' fulllabel: '.$this->cats[$key][
'fulllabel'];
1205 if (!is_numeric($type)) $type = $this->MAP_ID[$type];
1207 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1208 $sql .=
" WHERE entity IN (".getEntity(
'category').
")";
1209 if (!is_null($type))
1210 $sql .=
" AND type = ".(int) $type;
1212 $sql .=
" AND fk_parent = 0";
1214 $res = $this->
db->query($sql);
1217 while ($rec = $this->
db->fetch_array($res)) {
1219 $cat->fetch($rec[
'rowid']);
1220 $cats[$rec[
'rowid']] = $cat;
1251 $type = $this->type;
1253 if (!is_numeric($type)) $type = $this->MAP_ID[$type];
1258 $sql =
"SELECT c.rowid";
1259 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as c ";
1260 $sql .=
" WHERE c.entity IN (".getEntity(
'category').
")";
1261 $sql .=
" AND c.type = ".$type;
1262 $sql .=
" AND c.fk_parent = ".$this->fk_parent;
1263 $sql .=
" AND c.label = '".$this->db->escape($this->label).
"'";
1265 dol_syslog(get_class($this).
"::already_exists", LOG_DEBUG);
1268 if ($this->
db->num_rows(
$resql) > 0) {
1269 $obj = $this->
db->fetch_array(
$resql);
1275 if ($obj[0] > 0 && $obj[0] != $this->
id) {
1276 dol_syslog(get_class($this).
"::already_exists category with name=".$this->label.
" and parent ".$this->fk_parent.
" exists: rowid=".$obj[0].
" current_id=".$this->id, LOG_DEBUG);
1280 dol_syslog(get_class($this).
"::already_exists no category with same name=".$this->label.
" and same parent ".$this->fk_parent.
" than category id=".$this->id, LOG_DEBUG);
1283 $this->error = $this->
db->error();
1300 public function print_all_ways($sep =
' >> ', $url =
'', $nocolor = 0, $addpicto = 0)
1306 foreach ($allways as $way) {
1310 foreach ($way as $cat) {
1313 if (empty($nocolor)) {
1314 $forced_color =
'toreplace';
1315 if ($i == count($way)) {
1317 $forced_color =
'categtextwhite';
1319 if (
colorIsLight($cat->color)) $forced_color =
'categtextblack';
1325 $link =
'<a href="'.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$cat->id.
'&type='.$cat->type.
'" class="'.$forced_color.
'">';
1327 $w[] = $link.($addpicto ?
img_object(
'',
'category',
'class="paddingright"') :
'').$cat->label.$linkend;
1328 } elseif ($url ==
'none') {
1329 $link =
'<span class="'.$forced_color.
'">';
1330 $linkend =
'</span>';
1331 $w[] = $link.($addpicto ?
img_object(
'',
'category',
'class="paddingright"') :
'').$cat->label.$linkend;
1333 $w[] =
'<a class="'.$forced_color.
'" href="'.DOL_URL_ROOT.
'/'.$url.
'?catid='.$cat->id.
'">'.($addpicto ?
img_object(
'',
'category') :
'').$cat->label.
'</a>';
1336 $newcategwithpath = preg_replace(
'/toreplace/', $forced_color, implode($sep, $w));
1338 $ways[] = $newcategwithpath;
1356 $sql =
"SELECT fk_parent FROM ".MAIN_DB_PREFIX.
"categorie";
1357 $sql .=
" WHERE rowid = ".$this->id;
1359 $res = $this->
db->query($sql);
1362 while ($rec = $this->
db->fetch_array($res)) {
1363 if ($rec[
'fk_parent'] > 0) {
1365 $cat->fetch($rec[
'fk_parent']);
1389 if (!empty($parents)) {
1390 foreach ($parents as $parent) {
1391 $allways = $parent->get_all_ways();
1392 foreach ($allways as $way) {
1400 if (count($ways) == 0)
1401 $ways[0][0] = $this;
1420 if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type];
1422 if ($type === Categorie::TYPE_BANK_LINE) {
1424 $sql =
"SELECT c.label, c.rowid";
1425 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_class as a, ".MAIN_DB_PREFIX.
"bank_categ as c";
1426 $sql .=
" WHERE a.lineid=".$id.
" AND a.fk_categ = c.rowid";
1427 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
1428 $sql .=
" ORDER BY c.label";
1430 $res = $this->
db->query($sql);
1432 while ($obj = $this->
db->fetch_object($res)) {
1433 if ($mode ==
'id') {
1434 $cats[] = $obj->rowid;
1435 } elseif ($mode ==
'label') {
1436 $cats[] = $obj->label;
1439 $cat->id = $obj->rowid;
1440 $cat->label = $obj->label;
1449 $sql =
"SELECT ct.fk_categorie, c.label, c.rowid";
1450 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]).
" as ct, ".MAIN_DB_PREFIX.
"categorie as c";
1451 $sql .=
" WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".(
int) $id.
" AND c.type = ".$this->MAP_ID[$type];
1452 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
1454 $res = $this->
db->query($sql);
1456 while ($obj = $this->
db->fetch_object($res)) {
1457 if ($mode ==
'id') {
1458 $cats[] = $obj->rowid;
1459 } elseif ($mode ==
'label') {
1460 $cats[] = $obj->label;
1463 $cat->fetch($obj->fk_categorie);
1488 public function rechercher($id, $nom, $type, $exact =
false, $case =
false)
1491 if (is_numeric($type)) {
1492 dol_syslog(__METHOD__.
': using numeric types is deprecated.', LOG_WARNING);
1498 if (is_numeric($type)) {
1500 $map_type = array_flip($this->MAP_ID);
1501 $type = $map_type[$type];
1502 dol_syslog(get_class($this).
"::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING);
1506 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1507 $sql .=
" WHERE type = ".$this->MAP_ID[$type];
1508 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1511 $nom =
'%'.str_replace(
'*',
'%', $nom).
'%';
1513 $sql .=
" AND label LIKE '".$this->db->escape($nom).
"'";
1514 else $sql .=
" AND label LIKE BINARY '".$this->db->escape($nom).
"'";
1517 $sql .=
" AND rowid = '".$id.
"'";
1520 $res = $this->
db->query($sql);
1522 while ($rec = $this->
db->fetch_array($res)) {
1524 $cat->fetch($rec[
'rowid']);
1530 $this->error = $this->
db->error().
' sql='.$sql;
1545 public function getNomUrl($withpicto = 0, $option =
'', $maxlength = 0, $moreparam =
'')
1550 $label = $langs->trans(
"ShowCategory").
': '.($this->ref ? $this->ref : $this->label);
1553 $forced_color =
'categtextwhite';
1555 if (
colorIsLight($this->color)) $forced_color =
'categtextblack';
1558 $link =
'<a href="'.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$this->
id.
'&type='.$this->
type.$moreparam.
'&backtopage='.urlencode(
$_SERVER[
'PHP_SELF'].($moreparam ?
'?'.$moreparam :
'')).
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip '.$forced_color.
'">';
1561 $picto =
'category';
1564 if ($withpicto) $result .= ($link.img_object($label, $picto,
'class="classfortooltip"').$linkend);
1565 if ($withpicto && $withpicto != 2) $result .=
' ';
1566 if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend;
1582 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1584 $dir = $sdir.
'/'.
get_exdir($this->
id, 2, 0, 0, $this,
'category').$this->id.
"/";
1587 if (!file_exists($dir)) {
1591 if (file_exists($dir)) {
1592 if (is_array($file[
'name']) && count($file[
'name']) > 0) {
1593 $nbfile = count($file[
'name']);
1594 for ($i = 0; $i <= $nbfile; $i++) {
1595 $originImage = $dir.$file[
'name'][$i];
1600 if (file_exists($originImage)) {
1606 $originImage = $dir.$file[
'name'];
1611 if (file_exists($originImage)) {
1630 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1635 $dirthumb = $dir.
'thumbs/';
1637 if (file_exists($dir)) {
1638 $handle = opendir($dir);
1639 if (is_resource($handle)) {
1640 while (($file = readdir($handle)) !==
false) {
1641 if (
dol_is_file($dir.$file) && preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) {
1646 $photo_vignette =
'';
1647 if (preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) {
1648 $photo_vignette = preg_replace(
'/'.$regs[0].
'/i',
'', $photo).
'_small'.$regs[0];
1653 $obj[
'photo'] = $photo;
1654 if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj[
'photo_vignette'] =
'thumbs/'.$photo_vignette;
1655 else $obj[
'photo_vignette'] =
"";
1657 $tabobj[$nbphoto - 1] = $obj;
1660 if ($nbmax && $nbphoto >= $nbmax)
break;
1681 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1683 $dir = dirname($file).
'/';
1684 $dirthumb = $dir.
'/thumbs/';
1685 $filename = preg_replace(
'/'.preg_quote($dir,
'/').
'/i',
'', $file);
1691 if (preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) {
1692 $photo_vignette = preg_replace(
'/'.$regs[0].
'/i',
'', $filename).
'_small'.$regs[0];
1693 if (file_exists($dirthumb.$photo_vignette)) {
1709 $infoImg = getimagesize($file);
1710 $this->imgWidth = $infoImg[0];
1711 $this->imgHeight = $infoImg[1];
1725 $langs_available = $langs->get_available_languages();
1726 $current_lang = $langs->getDefaultLang();
1728 foreach ($langs_available as $key => $value) {
1729 $sql =
"SELECT rowid";
1730 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_lang";
1731 $sql .=
" WHERE fk_category=".$this->id;
1732 $sql .=
" AND lang='".$key.
"'";
1734 $result = $this->
db->query($sql);
1736 if ($key == $current_lang) {
1737 if ($this->
db->num_rows($result)) {
1738 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"categorie_lang";
1739 $sql2 .=
" SET label='".$this->db->escape($this->label).
"',";
1740 $sql2 .=
" description='".$this->db->escape($this->
description).
"'";
1741 $sql2 .=
" WHERE fk_category=".$this->id.
" AND lang='".$this->
db->escape($key).
"'";
1743 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_lang (fk_category, lang, label, description)";
1744 $sql2 .=
" VALUES(".$this->id.
",'".$key.
"','".$this->
db->escape($this->label);
1745 $sql2 .=
"','".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"')";
1747 dol_syslog(get_class($this).
'::setMultiLangs', LOG_DEBUG);
1748 if (!$this->
db->query($sql2)) {
1749 $this->error = $this->
db->lasterror();
1752 } elseif (isset($this->multilangs[
"$key"])) {
1753 if ($this->
db->num_rows($result)) {
1754 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"categorie_lang";
1755 $sql2 .=
" SET label='".$this->db->escape($this->multilangs[
"$key"][
"label"]).
"',";
1756 $sql2 .=
" description='".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"'";
1757 $sql2 .=
" WHERE fk_category=".$this->id.
" AND lang='".$this->
db->escape($key).
"'";
1759 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_lang (fk_category, lang, label, description)";
1760 $sql2 .=
" VALUES(".$this->id.
",'".$key.
"','".$this->
db->escape($this->multilangs[
"$key"][
"label"]);
1761 $sql2 .=
"','".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"')";
1765 if ($this->multilangs[
"$key"][
"label"] || $this->multilangs[
"$key"][
"description"] || $this->multilangs[
"$key"][
"note"])
1766 dol_syslog(get_class($this).
'::setMultiLangs', LOG_DEBUG);
1767 if (!$this->
db->query($sql2)) {
1768 $this->error = $this->
db->lasterror();
1775 $result = $this->
call_trigger(
'CATEGORY_SET_MULTILANGS', $user);
1777 $this->error = $this->
db->lasterror();
1794 $current_lang = $langs->getDefaultLang();
1796 $sql =
"SELECT lang, label, description";
1797 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_lang";
1798 $sql .=
" WHERE fk_category=".$this->id;
1800 $result = $this->
db->query($sql);
1802 while ($obj = $this->
db->fetch_object($result)) {
1804 if ($obj->lang == $current_lang) {
1805 $this->label = $obj->label;
1808 $this->multilangs[
"$obj->lang"][
"label"] = $obj->label;
1809 $this->multilangs[
"$obj->lang"][
"description"] = $obj->description;
1813 $this->error = $langs->trans(
"Error").
" : ".$this->
db->error().
" - ".$sql;
1839 dol_syslog(get_class($this).
"::initAsSpecimen");
1843 $this->fk_parent = 0;
1844 $this->label =
'SPECIMEN';
1845 $this->specimen = 1;
1848 $this->
type = self::TYPE_PRODUCT;
1877 if ($type ==
'bank_account') $type =
'account';
1879 return " LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_".$type.
" as cp ON ".$rowIdName.
" = cp.fk_".$type;
1892 if ($type ==
'bank_account') $type =
'account';
1894 if (empty($searchList) && !is_array($searchList)) {
1898 $searchCategorySqlList = array();
1899 foreach ($searchList as $searchCategory) {
1900 if (intval($searchCategory) == -2) {
1901 $searchCategorySqlList[] =
" cp.fk_categorie IS NULL";
1902 } elseif (intval($searchCategory) > 0) {
1903 $searchCategorySqlList[] =
" ".$rowIdName.
" IN (SELECT fk_".$type.
" FROM ".MAIN_DB_PREFIX.
"categorie_".$type.
" WHERE fk_categorie = ".((int) $searchCategory).
")";
1907 if (!empty($searchCategorySqlList)) {
1908 return " AND (".implode(
' AND ', $searchCategorySqlList).
")";
1921 dol_syslog(get_class($this).
"::count_all_categories", LOG_DEBUG);
1922 $sql =
"SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX.
"categorie";
1923 $sql .=
" WHERE entity IN (".getEntity(
'category').
")";
1925 $res = $this->
db->query($sql);
1927 $obj = $this->
db->fetch_object($res);
getMultiLangs()
Load array this->multilangs.
static replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
fetch($id, $label= '', $type=null, $ref_ext= '')
Load category into memory from database.
containing($id, $type, $mode= 'object')
Return list of categories (object instances or labels) linked to element of id $id and type $type Sho...
addThumbs($file)
Build thumb.
create($user)
Add category into database.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
debug_cats()
Display content of $this->cats.
get_filles()
Return direct childs id of a category into an array.
add_photo($sdir, $file)
Deplace fichier uploade sous le nom $files dans le repertoire sdir.
setMultiLangs($user)
Update ou cree les traductions des infos produits.
dol_now($mode= 'auto')
Return date for now.
update(User $user)
Update category.
getListForItem($id, $type= 'customer', $sortfield="s.rowid", $sortorder= 'ASC', $limit=0, $page=0)
List categories of an element id.
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
get_image_size($file)
Load size of image file.
static getFilterSelectQuery($type, $rowIdName, $searchList)
Return the addtional SQL SELECT query for filtering a list by a category.
delete_photo($file)
Efface la photo de la categorie et sa vignette.
static getFilterJoinQuery($type, $rowIdName)
Return the addtional SQL JOIN query for filtering a list by a category.
get_all_ways()
Returns in a table all possible paths to get to the category starting with the major categories repre...
add_type($obj, $type= '')
Link an object to the category.
$conf db
API class for accounts.
get_all_categories($type=null, $parent=false)
Returns all categories.
insertExtraFields($trigger= '', $userused=null)
Add/Update all extra fields values for the current object.
del_type($obj, $type)
Delete object from category.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
build_path_from_id_categ($id_categ, $protection=1000)
For category id_categ and its childs available in this->cats, define property fullpath and fulllabel...
get_main_categories($type=null)
Returns the top level categories (which are not child)
containsObject($type, $object_id)
Check for the presence of an object in a category.
get_full_arbo($type, $markafterid=0, $include=0)
Rebuilding the category tree as an array Return an array of table('id','id_mere',...) trie selon arbre et avec: id = id de la categorie id_mere = id de la categorie mere id_children = tableau des id enfant label = nom de la categorie fulllabel = nom avec chemin complet de la categorie fullpath = chemin complet compose des id.
print_all_ways($sep= '>> ', $url= '', $nocolor=0, $addpicto=0)
Returns the path of the category, with the names of the categories separated by $sep (" >> " by defau...
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
getNomUrl($withpicto=0, $option= '', $maxlength=0, $moreparam= '')
Return name and link of category (with picto) Use ->id, ->ref, ->label, ->color.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
getLibStatut($mode)
Return label of contact status.
__construct($db)
Constructor.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
deleteExtraFields()
Delete all extra fields values for the current object.
load_motherof()
Load the array this->motherof that is array(id_son=>id_parent, ...)
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles= 'addedfile', $upload_dir= '')
Make control on an uploaded file from an GUI page and move it to final destination.
dol_is_file($pathoffile)
Return if path is a file.
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
countNbOfCategories()
Count all categories.
print
Draft customers invoices.
get_meres()
Returns an array containing the list of parent categories.
getMapList()
Get map list.
call_trigger($triggerName, $user)
Call trigger based on this instance.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
liste_photos($dir, $nbmax=0)
Return tableau de toutes les photos de la categorie.
colorIsLight($stringcolor)
Return true if the color is light.
rechercher($id, $nom, $type, $exact=false, $case=false)
Returns categories whose id or name match add wildcards in the name unless $exact = true...
already_exists()
Check if no category with same label already exists for this cat's parent or root and for this cat's ...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
initAsSpecimen()
Initialise an instance with random values.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
getObjectsInCateg($type, $onlyids=0, $limit=0, $offset=0, $sortfield= '', $sortorder= 'ASC')
Return list of fetched instance of elements having this category.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...