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'];
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();
702 global $user, $langs, $conf;
706 if ($this->
id == -1) {
711 $type = $obj->element;
714 dol_syslog(get_class($this).
'::add_type', LOG_DEBUG);
718 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
719 $sql .=
" (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
")";
720 $sql .=
" VALUES (".((int) $this->
id).
", ".((int) $obj->id).
")";
722 if ($this->
db->query($sql)) {
723 if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
724 $sql =
'SELECT fk_parent FROM '.MAIN_DB_PREFIX.
'categorie';
725 $sql .=
" WHERE rowid = ".((int) $this->
id);
727 dol_syslog(get_class($this).
"::add_type", LOG_DEBUG);
730 if ($this->
db->num_rows(
$resql) > 0) {
731 $objparent = $this->
db->fetch_object(
$resql);
733 if (!empty($objparent->fk_parent)) {
735 $cat->id = $objparent->fk_parent;
736 if (!$cat->containsObject($type, $obj->id)) {
737 $result = $cat->add_type($obj, $type);
739 $this->error = $cat->error;
747 $this->error = $this->
db->lasterror();
751 $this->
db->rollback();
757 $this->context = array(
'linkto'=>$obj);
768 $this->
db->rollback();
772 $this->
db->rollback();
773 if ($this->
db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
774 $this->error = $this->
db->lasterrno();
777 $this->error = $this->
db->lasterror();
795 global $user, $langs, $conf;
800 if ($type ==
'societe') {
802 dol_syslog(get_class($this).
"::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING);
803 } elseif ($type ==
'fournisseur') {
805 dol_syslog(get_class($this).
"::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING);
810 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
811 $sql .=
" WHERE fk_categorie = ".((int) $this->
id);
812 $sql .=
" AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".((
int) $obj->id);
814 dol_syslog(get_class($this).
'::del_type', LOG_DEBUG);
815 if ($this->
db->query($sql)) {
817 $this->context = array(
'unlinkoff'=>$obj);
818 $result = $this->
call_trigger(
'CATEGORY_UNLINK', $user);
828 $this->
db->rollback();
832 $this->
db->rollback();
833 $this->error = $this->
db->lasterror();
850 public function getObjectsInCateg($type, $onlyids = 0, $limit = 0, $offset = 0, $sortfield =
'', $sortorder =
'ASC')
856 $classnameforobj = $this->MAP_OBJ_CLASS[$type];
857 $obj =
new $classnameforobj($this->
db);
859 $sql =
"SELECT c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]);
860 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]).
" as c";
861 $sql .=
", ".MAIN_DB_PREFIX.(empty($this->MAP_OBJ_TABLE[$type]) ? $type : $this->MAP_OBJ_TABLE[$type]).
" as o";
862 $sql .=
" WHERE o.entity IN (".getEntity($obj->element).
")";
863 $sql .=
" AND c.fk_categorie = ".((int) $this->
id);
864 $sql .=
" AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = o.rowid";
866 if (($type ==
'customer' || $type ==
'supplier') && $user->socid > 0) {
867 $sql .=
" AND o.rowid = ".((int) $user->socid);
869 if ($limit > 0 || $offset > 0) {
870 $sql .= $this->
db->plimit($limit + 1, $offset);
872 $sql .= $this->
db->order($sortfield, $sortorder);
874 dol_syslog(get_class($this).
"::getObjectsInCateg", LOG_DEBUG);
877 while ($rec = $this->
db->fetch_array(
$resql)) {
879 $objs[] = $rec[
'fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])];
881 $classnameforobj = $this->MAP_OBJ_CLASS[$type];
883 $obj =
new $classnameforobj($this->
db);
884 $obj->fetch($rec[
'fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]);
891 $this->error = $this->
db->error().
' sql='.$sql;
906 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
907 $sql .=
" WHERE fk_categorie = ".((int) $this->
id).
" AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".((
int) $object_id);
908 dol_syslog(get_class($this).
"::containsObject", LOG_DEBUG);
911 return $this->
db->fetch_object(
$resql)->nb;
913 $this->error = $this->
db->error().
' sql='.$sql;
929 public function getListForItem($id, $type =
'customer', $sortfield =
"s.rowid", $sortorder =
'ASC', $limit = 0, $page = 0)
933 $categories = array();
938 $subcol_name =
"fk_".$type;
939 if ($type ==
"customer") {
940 $sub_type =
"societe";
941 $subcol_name =
"fk_soc";
943 if ($type ==
"supplier") {
944 $sub_type =
"fournisseur";
945 $subcol_name =
"fk_soc";
947 if ($type ==
"contact") {
948 $subcol_name =
"fk_socpeople";
951 $idoftype = array_search($type, self::$MAP_ID_TO_CODE);
953 $sql =
"SELECT s.rowid";
954 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as s, ".MAIN_DB_PREFIX.
"categorie_".$sub_type.
" as sub";
955 $sql .=
' WHERE s.entity IN ('.getEntity(
'category').
')';
956 $sql .=
' AND s.type='.((int) $idoftype);
957 $sql .=
' AND s.rowid = sub.fk_categorie';
958 $sql .=
" AND sub.".$subcol_name.
" = ".((int) $id);
960 $sql .= $this->
db->order($sortfield, $sortorder);
964 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
965 $result = $this->
db->query($sql);
977 $offset = $limit * $page;
979 $sql .= $this->
db->plimit($limit + 1, $offset);
982 $result = $this->
db->query($sql);
985 $num = $this->
db->num_rows($result);
986 $min = min($num, ($limit <= 0 ? $num : $limit));
988 $obj = $this->
db->fetch_object($result);
990 if ($category_static->fetch($obj->rowid)) {
991 $categories[$i][
'id'] = $category_static->id;
992 $categories[$i][
'fk_parent'] = $category_static->fk_parent;
993 $categories[$i][
'label'] = $category_static->label;
994 $categories[$i][
'description'] = $category_static->description;
995 $categories[$i][
'color'] = $category_static->color;
996 $categories[$i][
'socid'] = $category_static->socid;
997 $categories[$i][
'ref_ext'] = $category_static->ref_ext;
998 $categories[$i][
'visible'] = $category_static->visible;
999 $categories[$i][
'type'] = $category_static->type;
1000 $categories[$i][
'entity'] = $category_static->entity;
1001 $categories[$i][
'array_options'] = $category_static->array_options;
1004 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && isset($category_static->multilangs)) {
1005 $categories[$i][
'multilangs'] = $category_static->multilangs;
1011 $this->error = $this->
db->lasterror();
1014 if (!count($categories)) {
1030 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1031 $sql .=
" WHERE fk_parent = ".((int) $this->
id);
1032 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1034 $res = $this->
db->query($sql);
1037 while ($rec = $this->
db->fetch_array($res)) {
1039 $cat->fetch($rec[
'rowid']);
1058 $this->motherof = array();
1061 $sql =
"SELECT fk_parent as id_parent, rowid as id_son";
1062 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie";
1063 $sql .=
" WHERE fk_parent != 0";
1064 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1066 dol_syslog(get_class($this).
"::load_motherof", LOG_DEBUG);
1069 while ($obj = $this->
db->fetch_object(
$resql)) {
1070 $this->motherof[$obj->id_son] = $obj->id_parent;
1102 global $conf, $langs;
1104 if (!is_numeric($type)) {
1105 $type = $this->MAP_ID[$type];
1107 if (is_null($type)) {
1108 $this->error =
'BadValueForParameterType';
1112 if (is_string($markafterid)) {
1113 $markafterid = explode(
',', $markafterid);
1114 } elseif (is_numeric($markafterid)) {
1115 if ($markafterid > 0) {
1116 $markafterid = array($markafterid);
1118 $markafterid = array();
1120 } elseif (!is_array($markafterid)) {
1121 $markafterid = array();
1124 $this->cats = array();
1128 $current_lang = $langs->getDefaultLang();
1131 $sql =
"SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible";
1133 $sql .=
", t.label as label_trans, t.description as description_trans";
1135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as c";
1137 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->
db->escape($current_lang).
"'";
1139 $sql .=
" WHERE c.entity IN (".getEntity(
'category').
")";
1140 $sql .=
" AND c.type = ".(int) $type;
1142 dol_syslog(get_class($this).
"::get_full_arbo get category list", LOG_DEBUG);
1146 while ($obj = $this->
db->fetch_object(
$resql)) {
1147 $this->cats[$obj->rowid][
'rowid'] = $obj->rowid;
1148 $this->cats[$obj->rowid][
'id'] = $obj->rowid;
1149 $this->cats[$obj->rowid][
'fk_parent'] = $obj->fk_parent;
1150 $this->cats[$obj->rowid][
'label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label;
1151 $this->cats[$obj->rowid][
'description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description;
1152 $this->cats[$obj->rowid][
'color'] = $obj->color;
1153 $this->cats[$obj->rowid][
'visible'] = $obj->visible;
1154 $this->cats[$obj->rowid][
'ref_ext'] = $obj->ref_ext;
1155 $this->cats[$obj->rowid][
'picto'] =
'category';
1164 dol_syslog(get_class($this).
"::get_full_arbo call to buildPathFromId", LOG_DEBUG);
1165 foreach ($this->cats as $key => $val) {
1171 if (count($markafterid) > 0) {
1172 $keyfiltercatid =
'('.implode(
'|', $markafterid).
')';
1175 $keyfilter1 =
'^'.$keyfiltercatid.
'$';
1176 $keyfilter2 =
'_'.$keyfiltercatid.
'$';
1177 $keyfilter3 =
'^'.$keyfiltercatid.
'_';
1178 $keyfilter4 =
'_'.$keyfiltercatid.
'_';
1179 foreach ($this->cats as $key => $val) {
1180 $test = (preg_match(
'/'.$keyfilter1.
'/', $val[
'fullpath']) || preg_match(
'/'.$keyfilter2.
'/', $val[
'fullpath'])
1181 || preg_match(
'/'.$keyfilter3.
'/', $val[
'fullpath']) || preg_match(
'/'.$keyfilter4.
'/', $val[
'fullpath']));
1183 if (($test && !$include) || (!$test && $include)) {
1184 unset($this->cats[$key]);
1189 dol_syslog(get_class($this).
"::get_full_arbo dol_sort_array", LOG_DEBUG);
1190 $this->cats =
dol_sort_array($this->cats,
'fulllabel',
'asc',
true,
false);
1211 if (!empty($this->cats[$id_categ][
'fullpath'])) {
1213 dol_syslog(get_class($this).
"::buildPathFromId fullpath and fulllabel already defined", LOG_WARNING);
1223 $this->cats[$id_categ][
'fullpath'] =
'_'.$id_categ;
1224 $this->cats[$id_categ][
'fulllabel'] = $this->cats[$id_categ][
'label'];
1225 $i = 0; $cursor_categ = $id_categ;
1227 while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) {
1229 $this->cats[$id_categ][
'fullpath'] =
'_'.$this->motherof[$cursor_categ].$this->cats[$id_categ][
'fullpath'];
1230 $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'];
1233 $cursor_categ = $this->motherof[$cursor_categ];
1238 $nbunderscore = substr_count($this->cats[$id_categ][
'fullpath'],
'_');
1239 $this->cats[$id_categ][
'level'] = ($nbunderscore ? $nbunderscore :
null);
1254 foreach ($this->cats as $key => $val) {
1255 print
'id: '.$this->cats[$key][
'id'];
1256 print
' label: '.$this->cats[$key][
'label'];
1257 print
' mother: '.$this->cats[$key][
'fk_parent'];
1259 print
' fullpath: '.$this->cats[$key][
'fullpath'];
1260 print
' fulllabel: '.$this->cats[$key][
'fulllabel'];
1277 if (!is_numeric($type)) {
1278 $type = $this->MAP_ID[$type];
1281 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1282 $sql .=
" WHERE entity IN (".getEntity(
'category').
")";
1283 if (!is_null($type)) {
1284 $sql .=
" AND type = ".(int) $type;
1287 $sql .=
" AND fk_parent = 0";
1290 $res = $this->
db->query($sql);
1293 while ($rec = $this->
db->fetch_array($res)) {
1295 $cat->fetch($rec[
'rowid']);
1296 $cats[$rec[
'rowid']] = $cat;
1327 $type = $this->type;
1329 if (!is_numeric($type)) {
1330 $type = $this->MAP_ID[$type];
1336 $sql =
"SELECT c.rowid";
1337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie as c ";
1338 $sql .=
" WHERE c.entity IN (".getEntity(
'category').
")";
1339 $sql .=
" AND c.type = ".((int) $type);
1340 $sql .=
" AND c.fk_parent = ".((int) $this->fk_parent);
1341 $sql .=
" AND c.label = '".$this->db->escape($this->label).
"'";
1343 dol_syslog(get_class($this).
"::already_exists", LOG_DEBUG);
1346 if ($this->
db->num_rows(
$resql) > 0) {
1347 $obj = $this->
db->fetch_array(
$resql);
1353 if ($obj[0] > 0 && $obj[0] != $this->
id) {
1354 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);
1358 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);
1361 $this->error = $this->
db->error();
1378 public function print_all_ways($sep =
'>>', $url =
'', $nocolor = 0, $addpicto = 0)
1384 foreach ($allways as $way) {
1388 foreach ($way as $cat) {
1391 if (empty($nocolor)) {
1392 $forced_color =
'colortoreplace';
1393 if ($i == count($way)) {
1395 $forced_color =
'categtextwhite';
1398 $forced_color =
'categtextblack';
1405 $link =
'<a href="'.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$cat->id.
'&type='.$cat->type.
'" class="'.$forced_color.
'">';
1407 $w[] = $link.(($addpicto && $i == 1) ?
img_object(
'',
'category',
'class="paddingright"') :
'').$cat->label.$linkend;
1408 } elseif ($url ==
'none') {
1409 $link =
'<span class="'.$forced_color.
'">';
1410 $linkend =
'</span>';
1411 $w[] = $link.(($addpicto && $i == 1) ?
img_object(
'',
'category',
'class="paddingright"') :
'').$cat->label.$linkend;
1413 $w[] =
'<a class="'.$forced_color.
'" href="'.DOL_URL_ROOT.
'/'.$url.
'?catid='.$cat->id.
'">'.($addpicto ?
img_object(
'',
'category') :
'').$cat->label.
'</a>';
1416 $newcategwithpath = preg_replace(
'/colortoreplace/', $forced_color, implode(
'<span class="inline-block valignmiddle paddingleft paddingright '.$forced_color.
'">'.$sep.
'</span>', $w));
1418 $ways[] = $newcategwithpath;
1436 $sql =
"SELECT fk_parent FROM ".MAIN_DB_PREFIX.
"categorie";
1437 $sql .=
" WHERE rowid = ".((int) $this->
id);
1439 $res = $this->
db->query($sql);
1442 while ($rec = $this->
db->fetch_array($res)) {
1443 if ($rec[
'fk_parent'] > 0) {
1445 $cat->fetch($rec[
'fk_parent']);
1469 if (!empty($parents)) {
1470 foreach ($parents as $parent) {
1471 $allways = $parent->get_all_ways();
1472 foreach ($allways as $way) {
1480 if (count($ways) == 0) {
1481 $ways[0][0] = $this;
1501 if (is_numeric($type)) {
1502 $type = Categorie::$MAP_ID_TO_CODE[$type];
1505 if ($type === Categorie::TYPE_BANK_LINE) {
1507 $sql =
"SELECT c.label, c.rowid";
1508 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_class as a, ".MAIN_DB_PREFIX.
"bank_categ as c";
1509 $sql .=
" WHERE a.lineid=".((int) $id).
" AND a.fk_categ = c.rowid";
1510 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
1511 $sql .=
" ORDER BY c.label";
1513 $res = $this->
db->query($sql);
1515 while ($obj = $this->
db->fetch_object($res)) {
1516 if ($mode ==
'id') {
1517 $cats[] = $obj->rowid;
1518 } elseif ($mode ==
'label') {
1519 $cats[] = $obj->label;
1522 $cat->id = $obj->rowid;
1523 $cat->label = $obj->label;
1532 $sql =
"SELECT ct.fk_categorie, c.label, c.rowid";
1533 $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";
1534 $sql .=
" WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).
" = ".(
int) $id;
1538 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
1540 $res = $this->
db->query($sql);
1542 while ($obj = $this->
db->fetch_object($res)) {
1543 if ($mode ==
'id') {
1544 $cats[] = $obj->rowid;
1545 } elseif ($mode ==
'label') {
1546 $cats[] = $obj->label;
1549 $cat->fetch($obj->fk_categorie);
1573 public function rechercher($id, $nom, $type, $exact =
false, $case =
false)
1576 if (is_numeric($type)) {
1577 dol_syslog(__METHOD__.
': using numeric types is deprecated.', LOG_WARNING);
1583 if (is_numeric($type)) {
1585 $map_type = array_flip($this->MAP_ID);
1586 $type = $map_type[$type];
1587 dol_syslog(get_class($this).
"::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING);
1591 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"categorie";
1592 $sql .=
" WHERE type = ".((int) $this->MAP_ID[$type]);
1593 $sql .=
" AND entity IN (".getEntity(
'category').
")";
1596 $nom =
'%'.$this->db->escape(str_replace(
'*',
'%', $nom)).
'%';
1599 $sql .=
" AND label LIKE '".$this->db->escape($nom).
"'";
1601 $sql .=
" AND label LIKE BINARY '".$this->db->escape($nom).
"'";
1605 $sql .=
" AND rowid = ".((int) $id);
1608 $res = $this->
db->query($sql);
1610 while ($rec = $this->
db->fetch_array($res)) {
1612 $cat->fetch($rec[
'rowid']);
1618 $this->error = $this->
db->error().
' sql='.$sql;
1633 public function getNomUrl($withpicto = 0, $option =
'', $maxlength = 0, $moreparam =
'')
1635 global $langs, $hookmanager;
1638 $label = $langs->trans(
"ShowCategory").
': '.($this->
ref ? $this->
ref : $this->label);
1641 $forced_color =
'categtextwhite';
1644 $forced_color =
'categtextblack';
1648 $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.
'">';
1651 $picto =
'category';
1655 $result .= ($link.img_object($label, $picto,
'class="classfortooltip"').$linkend);
1657 if ($withpicto && $withpicto != 2) {
1660 if ($withpicto != 2) {
1661 $result .= $link.dol_trunc(($this->
ref ? $this->
ref : $this->label), $maxlength).$linkend;
1664 $hookmanager->initHooks(array($this->element .
'dao'));
1665 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1666 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1668 $result = $hookmanager->resPrint;
1670 $result .= $hookmanager->resPrint;
1687 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1689 $dir = $sdir.
'/'.
get_exdir($this->
id, 2, 0, 0, $this,
'category').$this->id.
"/";
1692 if (!file_exists($dir)) {
1696 if (file_exists($dir)) {
1697 if (is_array($file[
'name']) && count($file[
'name']) > 0) {
1698 $nbfile = count($file[
'name']);
1699 for ($i = 0; $i <= $nbfile; $i++) {
1700 $originImage = $dir.$file[
'name'][$i];
1705 if (file_exists($originImage)) {
1711 $originImage = $dir.$file[
'name'];
1716 if (file_exists($originImage)) {
1735 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1740 $dirthumb = $dir.
'thumbs/';
1742 if (file_exists($dir)) {
1743 $handle = opendir($dir);
1744 if (is_resource($handle)) {
1745 while (($file = readdir($handle)) !==
false) {
1746 if (
dol_is_file($dir.$file) && preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) {
1751 $photo_vignette =
'';
1752 if (preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) {
1753 $photo_vignette = preg_replace(
'/'.$regs[0].
'/i',
'', $photo).
'_small'.$regs[0];
1758 $obj[
'photo'] = $photo;
1759 if ($photo_vignette && is_file($dirthumb.$photo_vignette)) {
1760 $obj[
'photo_vignette'] =
'thumbs/'.$photo_vignette;
1762 $obj[
'photo_vignette'] =
"";
1765 $tabobj[$nbphoto - 1] = $obj;
1768 if ($nbmax && $nbphoto >= $nbmax) {
1791 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1793 $dir = dirname($file).
'/';
1794 $dirthumb = $dir.
'/thumbs/';
1795 $filename = preg_replace(
'/'.preg_quote($dir,
'/').
'/i',
'', $file);
1801 if (preg_match(
'/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) {
1802 $photo_vignette = preg_replace(
'/'.$regs[0].
'/i',
'', $filename).
'_small'.$regs[0];
1803 if (file_exists($dirthumb.$photo_vignette)) {
1819 $infoImg = getimagesize($file);
1820 $this->imgWidth = $infoImg[0];
1821 $this->imgHeight = $infoImg[1];
1835 $langs_available = $langs->get_available_languages();
1836 $current_lang = $langs->getDefaultLang();
1838 foreach ($langs_available as $key => $value) {
1839 $sql =
"SELECT rowid";
1840 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_lang";
1841 $sql .=
" WHERE fk_category=".((int) $this->
id);
1842 $sql .=
" AND lang = '".$this->db->escape($key).
"'";
1844 $result = $this->
db->query($sql);
1846 if ($key == $current_lang) {
1847 if ($this->
db->num_rows($result)) {
1848 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"categorie_lang";
1849 $sql2 .=
" SET label = '".$this->db->escape($this->label).
"',";
1850 $sql2 .=
" description = '".$this->db->escape($this->
description).
"'";
1851 $sql2 .=
" WHERE fk_category = ".((int) $this->
id).
" AND lang = '".$this->
db->escape($key).
"'";
1853 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_lang (fk_category, lang, label, description)";
1854 $sql2 .=
" VALUES(".((int) $this->
id).
", '".$this->
db->escape($key).
"', '".$this->
db->escape($this->label).
"'";
1855 $sql2 .=
", '".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"')";
1857 dol_syslog(get_class($this).
'::setMultiLangs', LOG_DEBUG);
1858 if (!$this->
db->query($sql2)) {
1859 $this->error = $this->
db->lasterror();
1862 } elseif (isset($this->multilangs[
"$key"])) {
1863 if ($this->
db->num_rows($result)) {
1864 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"categorie_lang";
1865 $sql2 .=
" SET label='".$this->db->escape($this->multilangs[
"$key"][
"label"]).
"',";
1866 $sql2 .=
" description='".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"'";
1867 $sql2 .=
" WHERE fk_category=".((int) $this->
id).
" AND lang='".$this->
db->escape($key).
"'";
1869 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie_lang (fk_category, lang, label, description)";
1870 $sql2 .=
" VALUES(".((int) $this->
id).
", '".$this->
db->escape($key).
"', '".$this->
db->escape($this->multilangs[
"$key"][
"label"]).
"'";
1871 $sql2 .=
",'".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"')";
1875 if ($this->multilangs[
"$key"][
"label"] || $this->multilangs[
"$key"][
"description"] || $this->multilangs[
"$key"][
"note"]) {
1876 dol_syslog(get_class($this).
'::setMultiLangs', LOG_DEBUG);
1878 if (!$this->
db->query($sql2)) {
1879 $this->error = $this->
db->lasterror();
1886 $result = $this->
call_trigger(
'CATEGORY_SET_MULTILANGS', $user);
1888 $this->error = $this->
db->lasterror();
1905 $current_lang = $langs->getDefaultLang();
1907 $sql =
"SELECT lang, label, description";
1908 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_lang";
1909 $sql .=
" WHERE fk_category=".((int) $this->
id);
1911 $result = $this->
db->query($sql);
1913 while ($obj = $this->
db->fetch_object($result)) {
1915 if ($obj->lang == $current_lang) {
1916 $this->label = $obj->label;
1919 $this->multilangs[
"$obj->lang"][
"label"] = $obj->label;
1920 $this->multilangs[
"$obj->lang"][
"description"] = $obj->description;
1924 $this->error = $langs->trans(
"Error").
" : ".$this->
db->error().
" - ".$sql;
1950 dol_syslog(get_class($this).
"::initAsSpecimen");
1954 $this->fk_parent = 0;
1955 $this->label =
'SPECIMEN';
1956 $this->specimen = 1;
1959 $this->
type = self::TYPE_PRODUCT;
1989 if ($type ==
'bank_account') {
1993 return " LEFT JOIN ".MAIN_DB_PREFIX.
"categorie_".$type.
" as cp ON ".$rowIdName.
" = cp.fk_".$type;
2007 if ($type ==
'bank_account') {
2010 if ($type ==
'customer') {
2013 if ($type ==
'supplier') {
2014 $type =
'fournisseur';
2017 if (empty($searchList) && !is_array($searchList)) {
2021 $searchCategorySqlList = array();
2022 foreach ($searchList as $searchCategory) {
2023 if (intval($searchCategory) == -2) {
2024 $searchCategorySqlList[] =
" cp.fk_categorie IS NULL";
2025 } elseif (intval($searchCategory) > 0) {
2026 $searchCategorySqlList[] =
" ".$rowIdName.
" IN (SELECT fk_".$type.
" FROM ".MAIN_DB_PREFIX.
"categorie_".$type.
" WHERE fk_categorie = ".((int) $searchCategory).
")";
2030 if (!empty($searchCategorySqlList)) {
2031 return " AND (".implode(
' AND ', $searchCategorySqlList).
")";
2044 dol_syslog(get_class($this).
"::count_all_categories", LOG_DEBUG);
2045 $sql =
"SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX.
"categorie";
2046 $sql .=
" WHERE entity IN (".getEntity(
'category').
")";
2048 $res = $this->
db->query($sql);
2050 $obj = $this->
db->fetch_object($res);
Class to manage categories.
setMultiLangs($user)
Update ou cree les traductions des infos produits.
getListForItem($id, $type='customer', $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
List categories of an element id.
get_image_size($file)
Load size of image file.
load_motherof()
Load the array this->motherof that is array(id_son=>id_parent, ...)
debug_cats()
Display content of $this->cats.
getLibStatut($mode)
Return label of contact status.
delete_photo($file)
Efface la photo de la categorie et sa vignette.
containing($id, $type, $mode='object')
Return list of categories (object instances or labels) linked to element of id $id and type $type Sho...
countNbOfCategories()
Count all categories.
del_type($obj, $type)
Delete object from category.
buildPathFromId($id_categ, $protection=1000)
For category id_categ and its childs available in this->cats, define property fullpath and fulllabel.
static getFilterSelectQuery($type, $rowIdName, $searchList)
Return the addtional SQL SELECT query for filtering a list by a category.
rechercher($id, $nom, $type, $exact=false, $case=false)
Returns categories whose id or name match add wildcards in the name unless $exact = true.
getMultiLangs()
Load array this->multilangs.
already_exists()
Check if no category with same label already exists for this cat's parent or root and for this cat's ...
get_filles()
Return direct childs id of a category into an array.
initAsSpecimen()
Initialise an instance with random values.
get_all_categories($type=null, $parent=false)
Returns all categories.
static getFilterJoinQuery($type, $rowIdName)
Return the addtional SQL JOIN query for filtering a list by a category.
containsObject($type, $object_id)
Check for the presence of an object in a category.
get_main_categories($type=null)
Returns the top level categories (which are not child)
__construct($db)
Constructor.
getObjectsInCateg($type, $onlyids=0, $limit=0, $offset=0, $sortfield='', $sortorder='ASC')
Return list of fetched instance of elements having this category.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
getMapList()
Get map list.
get_full_arbo($type, $markafterid=0, $include=0)
Rebuilding the category tree as an array Return an array of table('id','id_mere',....
get_meres()
Returns an array containing the list of parent categories.
add_type($obj, $type='')
Link an object to the category.
create($user)
Add category into database.
update(User $user)
Update category.
liste_photos($dir, $nbmax=0)
Return tableau de toutes les photos de la categorie.
get_all_ways()
Returns in a table all possible paths to get to the category starting with the major categories repre...
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...
getNomUrl($withpicto=0, $option='', $maxlength=0, $moreparam='')
Return name and link of category (with picto) Use ->id, ->ref, ->label, ->color.
add_photo($sdir, $file)
Deplace fichier uploade sous le nom $file dans le repertoire sdir.
fetch($id, $label='', $type=null, $ref_ext='')
Load category into memory from database.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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...
deleteExtraFields()
Delete all extra fields values for the current object.
addThumbs($file)
Build thumb.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
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.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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.
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.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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...
colorIsLight($stringcolor)
Return true if the color is light.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$nbtotalofrecords
Count total nb of records.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db
API class for accounts.