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.
'/ticket/class/ticket.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/knowledgemanagement/class/knowledgerecord.class.php';
49 const TYPE_PRODUCT =
'product';
50 const TYPE_SUPPLIER =
'supplier';
51 const TYPE_CUSTOMER =
'customer';
52 const TYPE_MEMBER =
'member';
53 const TYPE_CONTACT =
'contact';
54 const TYPE_USER =
'user';
55 const TYPE_PROJECT =
'project';
56 const TYPE_ACCOUNT =
'bank_account';
57 const TYPE_BANK_LINE =
'bank_line';
58 const TYPE_WAREHOUSE =
'warehouse';
59 const TYPE_ACTIONCOMM =
'actioncomm';
60 const TYPE_WEBSITE_PAGE =
'website_page';
61 const TYPE_TICKET =
'ticket';
62 const TYPE_KNOWLEDGEMANAGEMENT =
'knowledgemanagement';
67 public $picto =
'category';
73 protected $MAP_ID = array(
87 'knowledgemanagement' => 13
95 public static $MAP_ID_TO_CODE = array(
107 11 =>
'website_page',
109 13 =>
'knowledgemanagement'
117 public $MAP_CAT_FK = array(
120 'contact' =>
'socpeople',
121 'bank_account' =>
'account',
129 public $MAP_CAT_TABLE = array(
130 'customer' =>
'societe',
131 'supplier' =>
'fournisseur',
132 'bank_account'=>
'account',
140 public $MAP_OBJ_CLASS = array(
141 'product' =>
'Product',
142 'customer' =>
'Societe',
143 'supplier' =>
'Fournisseur',
144 'member' =>
'Adherent',
145 'contact' =>
'Contact',
147 'account' =>
'Account',
148 'bank_account' =>
'Account',
149 'project' =>
'Project',
150 'warehouse'=>
'Entrepot',
151 'actioncomm' =>
'ActionComm',
152 'website_page' =>
'WebsitePage',
153 'ticket' =>
'Ticket',
154 'knowledgemanagement' =>
'KnowledgeRecord'
162 public static $MAP_TYPE_TITLE_AREA = array(
163 'product' =>
'ProductsCategoriesArea',
164 'customer' =>
'CustomersCategoriesArea',
165 'supplier' =>
'SuppliersCategoriesArea',
166 'member' =>
'MembersCategoriesArea',
167 'contact' =>
'ContactsCategoriesArea',
168 'user' =>
'UsersCategoriesArea',
169 'account' =>
'AccountsCategoriesArea',
170 'bank_account' =>
'AccountsCategoriesArea',
171 'project' =>
'ProjectsCategoriesArea',
172 'warehouse'=>
'StocksCategoriesArea',
173 'actioncomm' =>
'ActioncommCategoriesArea',
174 'website_page' =>
'WebsitePageCategoriesArea'
181 public $MAP_OBJ_TABLE = array(
182 'customer' =>
'societe',
183 'supplier' =>
'societe',
184 'member' =>
'adherent',
185 'contact' =>
'socpeople',
186 'account' =>
'bank_account',
187 'project' =>
'projet',
188 'warehouse'=>
'entrepot',
189 'knowledgemanagement' =>
'knowledgemanagement_knowledgerecord'
195 public $element =
'category';
200 public $table_element =
'categorie';
254 public $cats = array();
259 public $motherof = array();
264 public $childs = array();
278 if (is_object($hookmanager)) {
279 $hookmanager->initHooks(array(
'category'));
280 $parameters = array();
281 $reshook = $hookmanager->executeHooks(
'constructCategory', $parameters, $this);
282 if ($reshook >= 0 && !empty($hookmanager->resArray)) {
283 foreach ($hookmanager->resArray as $mapList) {
284 $mapId = $mapList[
'id'];
285 $mapCode = $mapList[
'code'];
286 self::$MAP_ID_TO_CODE[$mapId] = $mapCode;
287 $this->MAP_ID[$mapCode] = $mapId;
288 $this->MAP_CAT_FK[$mapCode] = $mapList[
'cat_fk'];
289 $this->MAP_CAT_TABLE[$mapCode] = $mapList[
'cat_table'];
290 $this->MAP_OBJ_CLASS[$mapCode] = $mapList[
'obj_class'];
291 $this->MAP_OBJ_TABLE[$mapCode] = $mapList[
'obj_table'];
306 foreach ($this->MAP_ID as $mapCode => $mapId) {
310 'cat_fk' => (empty($this->MAP_CAT_FK[$mapCode]) ? $mapCode : $this->MAP_CAT_FK[$mapCode]),
311 'cat_table' => (empty($this->MAP_CAT_TABLE[$mapCode]) ? $mapCode : $this->MAP_CAT_TABLE[$mapCode]),
312 'obj_class' => (empty($this->MAP_OBJ_CLASS[$mapCode]) ? $mapCode : $this->MAP_OBJ_CLASS[$mapCode]),
313 'obj_table' => (empty($this->MAP_OBJ_TABLE[$mapCode]) ? $mapCode : $this->MAP_OBJ_TABLE[$mapCode])
329 public function fetch($id, $label =
'', $type = null, $ref_ext =
'')
334 if (empty($id) && empty($label) && empty($ref_ext)) {
335 $this->error =
"No category to search for";
338 if (!is_null($type) && !is_numeric($type)) {
339 $type = $this->MAP_ID[$type];
342 $sql =
"SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext";
343 $sql .=
", date_creation, tms, fk_user_creat, fk_user_modif";
344 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie";
346 $sql .=
" WHERE rowid = ".((int) $id);
347 } elseif (!empty($ref_ext)) {
348 $sql .=
" WHERE ref_ext LIKE '".$this->db->escape($ref_ext).
"'";
350 $sql .=
" WHERE label = '".$this->db->escape($label).
"' AND entity IN (".
getEntity(
'category').
")";
351 if (!is_null($type)) {
352 $sql .=
" AND type = ".((int) $type);
356 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
359 if ($this->
db->num_rows(
$resql) > 0) {
360 $res = $this->
db->fetch_array(
$resql);
362 $this->
id = $res[
'rowid'];
364 $this->fk_parent = (int) $res[
'fk_parent'];
365 $this->label = $res[
'label'];
367 $this->color = $res[
'color'];
368 $this->socid = (int) $res[
'fk_soc'];
369 $this->visible = (int) $res[
'visible'];
370 $this->
type = (int) $res[
'type'];
371 $this->ref_ext = $res[
'ref_ext'];
372 $this->entity = (int) $res[
'entity'];
373 $this->date_creation = $this->
db->jdate($res[
'date_creation']);
374 $this->date_modification = $this->
db->jdate($res[
'tms']);
375 $this->user_creation_id = (int) $res[
'fk_user_creat'];
376 $this->user_modification_id = (int) $res[
'fk_user_modif'];
377 $this->user_creation = (int) $res[
'fk_user_creat'];
378 $this->user_modification = (int) $res[
'fk_user_modif'];
387 if (!empty($conf->global->MAIN_MULTILANGS)) {
393 $this->error =
"No category found";
398 $this->error = $this->
db->lasterror;
399 $this->errors[] = $this->
db->lasterror;
415 global $conf, $langs, $hookmanager;
416 $langs->load(
'categories');
420 if (!is_numeric($type)) {
421 $type = $this->MAP_ID[$type];
426 dol_syslog(get_class($this).
'::create', LOG_DEBUG);
429 $this->label = trim($this->label);
431 $this->color = trim($this->color);
432 $this->import_key = trim($this->import_key);
433 $this->ref_ext = trim($this->ref_ext);
434 if (empty($this->visible)) {
437 $this->fk_parent = ($this->fk_parent !=
"" ? intval($this->fk_parent) : 0);
440 $this->error = $langs->trans(
"ImpossibleAddCat", $this->label);
441 $this->error .=
" : ".$langs->trans(
"CategoryExistsAtSameLevel");
448 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie (";
449 $sql .=
"fk_parent,";
451 $sql .=
" description,";
453 if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
458 $sql .=
" import_key,";
461 $sql .=
" date_creation,";
462 $sql .=
" fk_user_creat";
463 $sql .=
") VALUES (";
464 $sql .= (int) $this->fk_parent.
",";
465 $sql .=
"'".$this->db->escape($this->label).
"', ";
466 $sql .=
"'".$this->db->escape($this->
description).
"', ";
467 $sql .=
"'".$this->db->escape($this->color).
"', ";
468 if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
469 $sql .= ($this->socid > 0 ? $this->socid :
'null').
", ";
471 $sql .=
"'".$this->db->escape($this->visible).
"', ";
472 $sql .= ((int) $type).
", ";
473 $sql .= (!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
'null').
", ";
474 $sql .= (!empty($this->ref_ext) ?
"'".$this->db->escape($this->ref_ext).
"'" :
'null').
", ";
475 $sql .= (int) $conf->entity.
", ";
476 $sql .=
"'".$this->db->idate($now).
"', ";
477 $sql .= (int) $user->id;
480 $res = $this->db->query($sql);
482 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"categorie");
499 $result = $this->
call_trigger(
'CATEGORY_CREATE', $user);
510 $this->
db->rollback();
514 $this->
db->rollback();
518 $this->error = $this->
db->error();
519 $this->
db->rollback();
534 global $conf, $langs, $hookmanager;
539 $this->label = trim($this->label);
541 $this->ref_ext = trim($this->ref_ext);
542 $this->fk_parent = ($this->fk_parent !=
"" ? intval($this->fk_parent) : 0);
543 $this->visible = ($this->visible !=
"" ? intval($this->visible) : 0);
546 $this->error = $langs->trans(
"ImpossibleUpdateCat");
547 $this->error .=
" : ".$langs->trans(
"CategoryExistsAtSameLevel");
553 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"categorie";
554 $sql .=
" SET label = '".$this->db->escape($this->label).
"',";
555 $sql .=
" description = '".$this->db->escape($this->
description).
"',";
556 $sql .=
" ref_ext = '".$this->db->escape($this->ref_ext).
"',";
557 $sql .=
" color = '".$this->db->escape($this->color).
"'";
558 if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
559 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->socid :
'null');
561 $sql .=
", visible = ".(int) $this->visible;
562 $sql .=
", fk_parent = ".(int) $this->fk_parent;
563 $sql .=
", fk_user_modif = ".(int) $user->id;
564 $sql .=
" WHERE rowid = ".((int) $this->id);
566 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
567 if ($this->
db->query($sql)) {
580 $result = $this->
call_trigger(
'CATEGORY_MODIFY', $user);
582 $error++; $this->
db->rollback();
return -1;
591 $this->
db->rollback();
604 public function delete($user, $notrigger = 0)
606 global $conf, $langs;
611 $this->fk_parent = ($this->fk_parent !=
"" ? intval($this->fk_parent) : 0);
617 if (!$error && !$notrigger) {
619 $result = $this->
call_trigger(
'CATEGORY_DELETE', $user);
628 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"categorie";
629 $sql .=
" SET fk_parent = ".((int) $this->fk_parent);
630 $sql .=
" WHERE fk_parent = ".((int) $this->
id);
632 if (!$this->
db->query($sql)) {
633 $this->error = $this->
db->lasterror();
638 $arraydelete = array(
639 'categorie_account' =>
'fk_categorie',
640 'categorie_actioncomm' =>
'fk_categorie',
641 'categorie_contact' =>
'fk_categorie',
642 'categorie_fournisseur' =>
'fk_categorie',
643 'categorie_knowledgemanagement' => array(
'field' =>
'fk_categorie',
'enabled' =>
isModEnabled(
'knowledgemanagement')),
644 'categorie_member' =>
'fk_categorie',
645 'categorie_user' =>
'fk_categorie',
646 'categorie_product' =>
'fk_categorie',
647 'categorie_project' =>
'fk_categorie',
648 'categorie_societe' =>
'fk_categorie',
649 'categorie_ticket' => array(
'field' =>
'fk_categorie',
'enabled' =>
isModEnabled(
'ticket')),
650 'categorie_warehouse' =>
'fk_categorie',
651 'categorie_website_page' => array(
'field' =>
'fk_categorie',
'enabled' =>
isModEnabled(
'website')),
652 'bank_class' =>
'fk_categ',
653 'categorie_lang' =>
'fk_category',
654 'categorie' =>
'rowid',
656 foreach ($arraydelete as $key => $value) {
657 if (is_array($value)) {
658 if (empty($value[
'enabled'])) {
661 $value = $value[
'field'];
663 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$key;
664 $sql .=
" WHERE ".$value.
" = ".((int) $this->
id);
665 if (!$this->
db->query($sql)) {
666 $this->errors[] = $this->
db->lasterror();
667 dol_syslog(
"Error sql=".$sql.
" ".$this->error, LOG_ERR);
677 dol_syslog(get_class($this).
"::delete erreur ".$this->error, LOG_ERR);
685 $this->
db->rollback();
701 global $user, $langs, $conf;
705 if ($this->
id == -1) {
710 $type = $obj->element;
715 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
716 $sql .=
" (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
")";
717 $sql .=
" VALUES (".((int) $this->
id).
", ".((int) $obj->id).
")";
719 dol_syslog(get_class($this).
'::add_type', LOG_DEBUG);
720 if ($this->
db->query($sql)) {
721 if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
722 $sql =
'SELECT fk_parent FROM '.MAIN_DB_PREFIX.
'categorie';
723 $sql .=
" WHERE rowid = ".((int) $this->
id);
725 dol_syslog(get_class($this).
"::add_type", LOG_DEBUG);
728 if ($this->
db->num_rows(
$resql) > 0) {
729 $objparent = $this->
db->fetch_object(
$resql);
731 if (!empty($objparent->fk_parent)) {
733 $cat->id = $objparent->fk_parent;
734 if (!$cat->containsObject($type, $obj->id)) {
735 $result = $cat->add_type($obj, $type);
737 $this->error = $cat->error;
745 $this->error = $this->
db->lasterror();
749 $this->
db->rollback();
755 $this->context = array(
'linkto'=>$obj);
766 $this->
db->rollback();
770 $this->
db->rollback();
771 if ($this->
db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
772 $this->error = $this->
db->lasterrno();
775 $this->error = $this->
db->lasterror();
793 global $user, $langs, $conf;
798 if ($type ==
'societe') {
800 dol_syslog(get_class($this).
"::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING);
801 } elseif ($type ==
'fournisseur') {
803 dol_syslog(get_class($this).
"::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING);
808 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
809 $sql .=
" WHERE fk_categorie = ".((int) $this->
id);
810 $sql .=
" AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".((
int) $obj->id);
812 dol_syslog(get_class($this).
'::del_type', LOG_DEBUG);
813 if ($this->
db->query($sql)) {
815 $this->context = array(
'unlinkoff'=>$obj);
816 $result = $this->
call_trigger(
'CATEGORY_UNLINK', $user);
826 $this->
db->rollback();
830 $this->
db->rollback();
831 $this->error = $this->
db->lasterror();
848 public function getObjectsInCateg($type, $onlyids = 0, $limit = 0, $offset = 0, $sortfield =
'', $sortorder =
'ASC')
854 $classnameforobj = $this->MAP_OBJ_CLASS[$type];
855 $obj =
new $classnameforobj($this->
db);
857 $sql =
"SELECT c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]);
858 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]).
" as c";
859 $sql .=
", ".MAIN_DB_PREFIX.(empty($this->MAP_OBJ_TABLE[$type]) ? $type : $this->MAP_OBJ_TABLE[$type]).
" as o";
860 $sql .=
" WHERE o.entity IN (".getEntity($obj->element).
")";
861 $sql .=
" AND c.fk_categorie = ".((int) $this->
id);
862 $sql .=
" AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = o.rowid";
864 if (($type ==
'customer' || $type ==
'supplier') && $user->socid > 0) {
865 $sql .=
" AND o.rowid = ".((int) $user->socid);
867 if ($limit > 0 || $offset > 0) {
868 $sql .= $this->
db->plimit($limit + 1, $offset);
870 $sql .= $this->
db->order($sortfield, $sortorder);
872 dol_syslog(get_class($this).
"::getObjectsInCateg", LOG_DEBUG);
875 while ($rec = $this->
db->fetch_array(
$resql)) {
877 $objs[] = $rec[
'fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])];
879 $classnameforobj = $this->MAP_OBJ_CLASS[$type];
881 $obj =
new $classnameforobj($this->
db);
882 $obj->fetch($rec[
'fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]);
889 $this->error = $this->
db->error().
' sql='.$sql;
904 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
905 $sql .=
" WHERE fk_categorie = ".((int) $this->
id).
" AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".((
int) $object_id);
906 dol_syslog(get_class($this).
"::containsObject", LOG_DEBUG);
909 return $this->
db->fetch_object(
$resql)->nb;
911 $this->error = $this->
db->error().
' sql='.$sql;
927 public function getListForItem($id, $type =
'customer', $sortfield =
"s.rowid", $sortorder =
'ASC', $limit = 0, $page = 0)
931 $categories = array();
936 $subcol_name =
"fk_".$type;
937 if ($type ==
"customer") {
938 $sub_type =
"societe";
939 $subcol_name =
"fk_soc";
941 if ($type ==
"supplier") {
942 $sub_type =
"fournisseur";
943 $subcol_name =
"fk_soc";
945 if ($type ==
"contact") {
946 $subcol_name =
"fk_socpeople";
949 $idoftype = array_search($type, self::$MAP_ID_TO_CODE);
951 $sql =
"SELECT s.rowid";
952 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as s, ".MAIN_DB_PREFIX.
"categorie_".$sub_type.
" as sub";
953 $sql .=
' WHERE s.entity IN ('.getEntity(
'category').
')';
954 $sql .=
' AND s.type='.((int) $idoftype);
955 $sql .=
' AND s.rowid = sub.fk_categorie';
956 $sql .=
" AND sub.".$subcol_name.
" = ".((int) $id);
958 $sql .= $this->
db->order($sortfield, $sortorder);
961 $nbtotalofrecords =
'';
962 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
963 $result = $this->
db->query($sql);
964 $nbtotalofrecords = $this->
db->num_rows($result);
965 if (($page * $limit) > $nbtotalofrecords) {
975 $offset = $limit * $page;
977 $sql .= $this->
db->plimit($limit + 1, $offset);
980 $result = $this->
db->query($sql);
983 $num = $this->
db->num_rows($result);
984 $min = min($num, ($limit <= 0 ? $num : $limit));
986 $obj = $this->
db->fetch_object($result);
988 if ($category_static->fetch($obj->rowid)) {
989 $categories[$i][
'id'] = $category_static->id;
990 $categories[$i][
'fk_parent'] = $category_static->fk_parent;
991 $categories[$i][
'label'] = $category_static->label;
992 $categories[$i][
'description'] = $category_static->description;
993 $categories[$i][
'color'] = $category_static->color;
994 $categories[$i][
'socid'] = $category_static->socid;
995 $categories[$i][
'ref_ext'] = $category_static->ref_ext;
996 $categories[$i][
'visible'] = $category_static->visible;
997 $categories[$i][
'type'] = $category_static->type;
998 $categories[$i][
'entity'] = $category_static->entity;
999 $categories[$i][
'array_options'] = $category_static->array_options;
1002 if (!empty($conf->global->MAIN_MULTILANGS) && isset($category_static->multilangs)) {
1003 $categories[$i][
'multilangs'] = $category_static->multilangs;
1009 $this->error = $this->
db->lasterror();
1012 if (!count($categories)) {
1028 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1029 $sql .=
" WHERE fk_parent = ".((int) $this->
id);
1030 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1032 $res = $this->
db->query($sql);
1035 while ($rec = $this->
db->fetch_array($res)) {
1037 $cat->fetch($rec[
'rowid']);
1056 $this->motherof = array();
1059 $sql =
"SELECT fk_parent as id_parent, rowid as id_son";
1060 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie";
1061 $sql .=
" WHERE fk_parent != 0";
1062 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1064 dol_syslog(get_class($this).
"::load_motherof", LOG_DEBUG);
1067 while ($obj = $this->
db->fetch_object(
$resql)) {
1068 $this->motherof[$obj->id_son] = $obj->id_parent;
1100 global $conf, $langs;
1102 if (!is_numeric($type)) {
1103 $type = $this->MAP_ID[$type];
1105 if (is_null($type)) {
1106 $this->error =
'BadValueForParameterType';
1110 if (is_string($markafterid)) {
1111 $markafterid = explode(
',', $markafterid);
1112 } elseif (is_numeric($markafterid)) {
1113 if ($markafterid > 0) {
1114 $markafterid = array($markafterid);
1116 $markafterid = array();
1118 } elseif (!is_array($markafterid)) {
1119 $markafterid = array();
1122 $this->cats = array();
1126 $current_lang = $langs->getDefaultLang();
1129 $sql =
"SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible";
1130 if (!empty($conf->global->MAIN_MULTILANGS)) {
1131 $sql .=
", t.label as label_trans, t.description as description_trans";
1133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as c";
1134 if (!empty($conf->global->MAIN_MULTILANGS)) {
1135 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->
db->escape($current_lang).
"'";
1137 $sql .=
" WHERE c.entity IN (".getEntity(
'category').
")";
1138 $sql .=
" AND c.type = ".(int) $type;
1140 dol_syslog(get_class($this).
"::get_full_arbo get category list", LOG_DEBUG);
1144 while ($obj = $this->
db->fetch_object(
$resql)) {
1145 $this->cats[$obj->rowid][
'rowid'] = $obj->rowid;
1146 $this->cats[$obj->rowid][
'id'] = $obj->rowid;
1147 $this->cats[$obj->rowid][
'fk_parent'] = $obj->fk_parent;
1148 $this->cats[$obj->rowid][
'label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label;
1149 $this->cats[$obj->rowid][
'description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description;
1150 $this->cats[$obj->rowid][
'color'] = $obj->color;
1151 $this->cats[$obj->rowid][
'visible'] = $obj->visible;
1152 $this->cats[$obj->rowid][
'ref_ext'] = $obj->ref_ext;
1161 dol_syslog(get_class($this).
"::get_full_arbo call to buildPathFromId", LOG_DEBUG);
1162 foreach ($this->cats as $key => $val) {
1168 if (count($markafterid) > 0) {
1169 $keyfiltercatid =
'('.implode(
'|', $markafterid).
')';
1172 $keyfilter1 =
'^'.$keyfiltercatid.
'$';
1173 $keyfilter2 =
'_'.$keyfiltercatid.
'$';
1174 $keyfilter3 =
'^'.$keyfiltercatid.
'_';
1175 $keyfilter4 =
'_'.$keyfiltercatid.
'_';
1176 foreach ($this->cats as $key => $val) {
1177 $test = (preg_match(
'/'.$keyfilter1.
'/', $val[
'fullpath']) || preg_match(
'/'.$keyfilter2.
'/', $val[
'fullpath'])
1178 || preg_match(
'/'.$keyfilter3.
'/', $val[
'fullpath']) || preg_match(
'/'.$keyfilter4.
'/', $val[
'fullpath']));
1180 if (($test && !$include) || (!$test && $include)) {
1181 unset($this->cats[$key]);
1186 dol_syslog(get_class($this).
"::get_full_arbo dol_sort_array", LOG_DEBUG);
1187 $this->cats =
dol_sort_array($this->cats,
'fulllabel',
'asc',
true,
false);
1208 if (!empty($this->cats[$id_categ][
'fullpath'])) {
1210 dol_syslog(get_class($this).
"::buildPathFromId fullpath and fulllabel already defined", LOG_WARNING);
1220 $this->cats[$id_categ][
'fullpath'] =
'_'.$id_categ;
1221 $this->cats[$id_categ][
'fulllabel'] = $this->cats[$id_categ][
'label'];
1222 $i = 0; $cursor_categ = $id_categ;
1224 while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) {
1226 $this->cats[$id_categ][
'fullpath'] =
'_'.$this->motherof[$cursor_categ].$this->cats[$id_categ][
'fullpath'];
1227 $this->cats[$id_categ][
'fulllabel'] = (empty($this->cats[$this->motherof[$cursor_categ]]) ?
'NotFound' : $this->cats[$this->motherof[$cursor_categ]][
'label']).
' >> '.$this->cats[$id_categ][
'fulllabel'];
1230 $cursor_categ = $this->motherof[$cursor_categ];
1235 $nbunderscore = substr_count($this->cats[$id_categ][
'fullpath'],
'_');
1236 $this->cats[$id_categ][
'level'] = ($nbunderscore ? $nbunderscore : null);
1251 foreach ($this->cats as $key => $val) {
1252 print
'id: '.$this->cats[$key][
'id'];
1253 print
' label: '.$this->cats[$key][
'label'];
1254 print
' mother: '.$this->cats[$key][
'fk_parent'];
1256 print
' fullpath: '.$this->cats[$key][
'fullpath'];
1257 print
' fulllabel: '.$this->cats[$key][
'fulllabel'];
1274 if (!is_numeric($type)) {
1275 $type = $this->MAP_ID[$type];
1278 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1279 $sql .=
" WHERE entity IN (".getEntity(
'category').
")";
1280 if (!is_null($type)) {
1281 $sql .=
" AND type = ".(int) $type;
1284 $sql .=
" AND fk_parent = 0";
1287 $res = $this->
db->query($sql);
1290 while ($rec = $this->
db->fetch_array($res)) {
1292 $cat->fetch($rec[
'rowid']);
1293 $cats[$rec[
'rowid']] = $cat;
1324 $type = $this->type;
1326 if (!is_numeric($type)) {
1327 $type = $this->MAP_ID[$type];
1333 $sql =
"SELECT c.rowid";
1334 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as c ";
1335 $sql .=
" WHERE c.entity IN (".getEntity(
'category').
")";
1336 $sql .=
" AND c.type = ".((int) $type);
1337 $sql .=
" AND c.fk_parent = ".((int) $this->fk_parent);
1338 $sql .=
" AND c.label = '".$this->db->escape($this->label).
"'";
1340 dol_syslog(get_class($this).
"::already_exists", LOG_DEBUG);
1343 if ($this->
db->num_rows(
$resql) > 0) {
1344 $obj = $this->
db->fetch_array(
$resql);
1350 if ($obj[0] > 0 && $obj[0] != $this->
id) {
1351 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);
1355 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);
1358 $this->error = $this->
db->error();
1375 public function print_all_ways($sep =
'>>', $url =
'', $nocolor = 0, $addpicto = 0)
1381 foreach ($allways as $way) {
1385 foreach ($way as $cat) {
1388 if (empty($nocolor)) {
1389 $forced_color =
'colortoreplace';
1390 if ($i == count($way)) {
1392 $forced_color =
'categtextwhite';
1395 $forced_color =
'categtextblack';
1402 $link =
'<a href="'.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$cat->id.
'&type='.$cat->type.
'" class="'.$forced_color.
'">';
1404 $w[] = $link.(($addpicto && $i == 1) ?
img_object(
'',
'category',
'class="paddingright"') :
'').$cat->label.$linkend;
1405 } elseif ($url ==
'none') {
1406 $link =
'<span class="'.$forced_color.
'">';
1407 $linkend =
'</span>';
1408 $w[] = $link.(($addpicto && $i == 1) ?
img_object(
'',
'category',
'class="paddingright"') :
'').$cat->label.$linkend;
1410 $w[] =
'<a class="'.$forced_color.
'" href="'.DOL_URL_ROOT.
'/'.$url.
'?catid='.$cat->id.
'">'.($addpicto ?
img_object(
'',
'category') :
'').$cat->label.
'</a>';
1413 $newcategwithpath = preg_replace(
'/colortoreplace/', $forced_color, implode(
'<span class="inline-block valignmiddle paddingleft paddingright '.$forced_color.
'">'.$sep.
'</span>', $w));
1415 $ways[] = $newcategwithpath;
1433 $sql =
"SELECT fk_parent FROM ".MAIN_DB_PREFIX.
"categorie";
1434 $sql .=
" WHERE rowid = ".((int) $this->
id);
1436 $res = $this->
db->query($sql);
1439 while ($rec = $this->
db->fetch_array($res)) {
1440 if ($rec[
'fk_parent'] > 0) {
1442 $cat->fetch($rec[
'fk_parent']);
1466 if (!empty($parents)) {
1467 foreach ($parents as $parent) {
1468 $allways = $parent->get_all_ways();
1469 foreach ($allways as $way) {
1477 if (count($ways) == 0) {
1478 $ways[0][0] = $this;
1498 if (is_numeric($type)) {
1499 $type = Categorie::$MAP_ID_TO_CODE[$type];
1502 if ($type === Categorie::TYPE_BANK_LINE) {
1504 $sql =
"SELECT c.label, c.rowid";
1505 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_class as a, ".MAIN_DB_PREFIX.
"bank_categ as c";
1506 $sql .=
" WHERE a.lineid=".((int) $id).
" AND a.fk_categ = c.rowid";
1507 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
1508 $sql .=
" ORDER BY c.label";
1510 $res = $this->
db->query($sql);
1512 while ($obj = $this->
db->fetch_object($res)) {
1513 if ($mode ==
'id') {
1514 $cats[] = $obj->rowid;
1515 } elseif ($mode ==
'label') {
1516 $cats[] = $obj->label;
1519 $cat->id = $obj->rowid;
1520 $cat->label = $obj->label;
1529 $sql =
"SELECT ct.fk_categorie, c.label, c.rowid";
1530 $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";
1531 $sql .=
" WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".(
int) $id;
1535 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
1537 $res = $this->
db->query($sql);
1539 while ($obj = $this->
db->fetch_object($res)) {
1540 if ($mode ==
'id') {
1541 $cats[] = $obj->rowid;
1542 } elseif ($mode ==
'label') {
1543 $cats[] = $obj->label;
1546 $cat->fetch($obj->fk_categorie);
1570 public function rechercher($id, $nom, $type, $exact =
false, $case =
false)
1573 if (is_numeric($type)) {
1574 dol_syslog(__METHOD__.
': using numeric types is deprecated.', LOG_WARNING);
1580 if (is_numeric($type)) {
1582 $map_type = array_flip($this->MAP_ID);
1583 $type = $map_type[$type];
1584 dol_syslog(get_class($this).
"::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING);
1588 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1589 $sql .=
" WHERE type = ".((int) $this->MAP_ID[$type]);
1590 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1593 $nom =
'%'.$this->db->escape(str_replace(
'*',
'%', $nom)).
'%';
1596 $sql .=
" AND label LIKE '".$this->db->escape($nom).
"'";
1598 $sql .=
" AND label LIKE BINARY '".$this->db->escape($nom).
"'";
1602 $sql .=
" AND rowid = ".((int) $id);
1605 $res = $this->
db->query($sql);
1607 while ($rec = $this->
db->fetch_array($res)) {
1609 $cat->fetch($rec[
'rowid']);
1615 $this->error = $this->
db->error().
' sql='.$sql;
1630 public function getNomUrl($withpicto = 0, $option =
'', $maxlength = 0, $moreparam =
'')
1632 global $langs, $hookmanager;
1635 $label = $langs->trans(
"ShowCategory").
': '.($this->
ref ? $this->
ref : $this->label);
1638 $forced_color =
'categtextwhite';
1641 $forced_color =
'categtextblack';
1645 $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.
'">';
1648 $picto =
'category';
1652 $result .= ($link.img_object($label, $picto,
'class="classfortooltip"').$linkend);
1654 if ($withpicto && $withpicto != 2) {
1657 if ($withpicto != 2) {
1658 $result .= $link.dol_trunc(($this->
ref ? $this->
ref : $this->label), $maxlength).$linkend;
1661 $hookmanager->initHooks(array($this->element .
'dao'));
1662 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1663 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1665 $result = $hookmanager->resPrint;
1667 $result .= $hookmanager->resPrint;
1684 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1686 $dir = $sdir.
'/'.
get_exdir($this->
id, 2, 0, 0, $this,
'category').$this->id.
"/";
1689 if (!file_exists($dir)) {
1693 if (file_exists($dir)) {
1694 if (is_array($file[
'name']) && count($file[
'name']) > 0) {
1695 $nbfile = count($file[
'name']);
1696 for ($i = 0; $i <= $nbfile; $i++) {
1697 $originImage = $dir.$file[
'name'][$i];
1702 if (file_exists($originImage)) {
1708 $originImage = $dir.$file[
'name'];
1713 if (file_exists($originImage)) {
1732 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1737 $dirthumb = $dir.
'thumbs/';
1739 if (file_exists($dir)) {
1740 $handle = opendir($dir);
1741 if (is_resource($handle)) {
1742 while (($file = readdir($handle)) !==
false) {
1743 if (
dol_is_file($dir.$file) && preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) {
1748 $photo_vignette =
'';
1749 if (preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) {
1750 $photo_vignette = preg_replace(
'/'.$regs[0].
'/i',
'', $photo).
'_small'.$regs[0];
1755 $obj[
'photo'] = $photo;
1756 if ($photo_vignette && is_file($dirthumb.$photo_vignette)) {
1757 $obj[
'photo_vignette'] =
'thumbs/'.$photo_vignette;
1759 $obj[
'photo_vignette'] =
"";
1762 $tabobj[$nbphoto - 1] = $obj;
1765 if ($nbmax && $nbphoto >= $nbmax) {
1788 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1790 $dir = dirname($file).
'/';
1791 $dirthumb = $dir.
'/thumbs/';
1792 $filename = preg_replace(
'/'.preg_quote($dir,
'/').
'/i',
'', $file);
1798 if (preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) {
1799 $photo_vignette = preg_replace(
'/'.$regs[0].
'/i',
'', $filename).
'_small'.$regs[0];
1800 if (file_exists($dirthumb.$photo_vignette)) {
1816 $infoImg = getimagesize($file);
1817 $this->imgWidth = $infoImg[0];
1818 $this->imgHeight = $infoImg[1];
1832 $langs_available = $langs->get_available_languages();
1833 $current_lang = $langs->getDefaultLang();
1835 foreach ($langs_available as $key => $value) {
1836 $sql =
"SELECT rowid";
1837 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_lang";
1838 $sql .=
" WHERE fk_category=".((int) $this->
id);
1839 $sql .=
" AND lang = '".$this->db->escape($key).
"'";
1841 $result = $this->
db->query($sql);
1843 if ($key == $current_lang) {
1844 if ($this->
db->num_rows($result)) {
1845 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"categorie_lang";
1846 $sql2 .=
" SET label = '".$this->db->escape($this->label).
"',";
1847 $sql2 .=
" description = '".$this->db->escape($this->
description).
"'";
1848 $sql2 .=
" WHERE fk_category = ".((int) $this->
id).
" AND lang = '".$this->
db->escape($key).
"'";
1850 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_lang (fk_category, lang, label, description)";
1851 $sql2 .=
" VALUES(".((int) $this->
id).
", '".$this->
db->escape($key).
"', '".$this->
db->escape($this->label).
"'";
1852 $sql2 .=
", '".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"')";
1854 dol_syslog(get_class($this).
'::setMultiLangs', LOG_DEBUG);
1855 if (!$this->
db->query($sql2)) {
1856 $this->error = $this->
db->lasterror();
1859 } elseif (isset($this->multilangs[
"$key"])) {
1860 if ($this->
db->num_rows($result)) {
1861 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"categorie_lang";
1862 $sql2 .=
" SET label='".$this->db->escape($this->multilangs[
"$key"][
"label"]).
"',";
1863 $sql2 .=
" description='".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"'";
1864 $sql2 .=
" WHERE fk_category=".((int) $this->
id).
" AND lang='".$this->
db->escape($key).
"'";
1866 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_lang (fk_category, lang, label, description)";
1867 $sql2 .=
" VALUES(".((int) $this->
id).
", '".$this->
db->escape($key).
"', '".$this->
db->escape($this->multilangs[
"$key"][
"label"]).
"'";
1868 $sql2 .=
",'".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"')";
1872 if ($this->multilangs[
"$key"][
"label"] || $this->multilangs[
"$key"][
"description"] || $this->multilangs[
"$key"][
"note"]) {
1873 dol_syslog(get_class($this).
'::setMultiLangs', LOG_DEBUG);
1875 if (!$this->
db->query($sql2)) {
1876 $this->error = $this->
db->lasterror();
1883 $result = $this->
call_trigger(
'CATEGORY_SET_MULTILANGS', $user);
1885 $this->error = $this->
db->lasterror();
1902 $current_lang = $langs->getDefaultLang();
1904 $sql =
"SELECT lang, label, description";
1905 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_lang";
1906 $sql .=
" WHERE fk_category=".((int) $this->
id);
1908 $result = $this->
db->query($sql);
1910 while ($obj = $this->
db->fetch_object($result)) {
1912 if ($obj->lang == $current_lang) {
1913 $this->label = $obj->label;
1916 $this->multilangs[
"$obj->lang"][
"label"] = $obj->label;
1917 $this->multilangs[
"$obj->lang"][
"description"] = $obj->description;
1921 $this->error = $langs->trans(
"Error").
" : ".$this->
db->error().
" - ".$sql;
1947 dol_syslog(get_class($this).
"::initAsSpecimen");
1951 $this->fk_parent = 0;
1952 $this->label =
'SPECIMEN';
1953 $this->specimen = 1;
1956 $this->
type = self::TYPE_PRODUCT;
1985 if ($type ==
'bank_account') {
1989 return " LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_".$type.
" as cp ON ".$rowIdName.
" = cp.fk_".$type;
2002 if ($type ==
'bank_account') {
2005 if ($type ==
'customer') {
2008 if ($type ==
'supplier') {
2009 $type =
'fournisseur';
2012 if (empty($searchList) && !is_array($searchList)) {
2016 $searchCategorySqlList = array();
2017 foreach ($searchList as $searchCategory) {
2018 if (intval($searchCategory) == -2) {
2019 $searchCategorySqlList[] =
" cp.fk_categorie IS NULL";
2020 } elseif (intval($searchCategory) > 0) {
2021 $searchCategorySqlList[] =
" ".$rowIdName.
" IN (SELECT fk_".$type.
" FROM ".MAIN_DB_PREFIX.
"categorie_".$type.
" WHERE fk_categorie = ".((int) $searchCategory).
")";
2025 if (!empty($searchCategorySqlList)) {
2026 return " AND (".implode(
' AND ', $searchCategorySqlList).
")";
2039 dol_syslog(get_class($this).
"::count_all_categories", LOG_DEBUG);
2040 $sql =
"SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX.
"categorie";
2041 $sql .=
" WHERE entity IN (".getEntity(
'category').
")";
2043 $res = $this->
db->query($sql);
2045 $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.
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
create($user)
Add category into database.
debug_cats()
Display content of $this->cats.
$conf db
API class for accounts.
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...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
add_type($obj, $type= '')
Link an object to the category.
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.
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.
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. ...
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...
getLibStatut($mode)
Return label of contact status.
__construct($db)
Constructor.
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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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 *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
liste_photos($dir, $nbmax=0)
Return tableau de toutes les photos de la categorie.
buildPathFromId($id_categ, $protection=1000)
For category id_categ and its childs available in this->cats, define property fullpath and fulllabel...
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
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
initAsSpecimen()
Initialise an instance with random values.
sanitizeVal($out= '', $check= 'alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
getObjectsInCateg($type, $onlyids=0, $limit=0, $offset=0, $sortfield= '', $sortorder= 'ASC')
Return list of fetched instance of elements having this category.