27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 public $module =
'knowledgemanagement';
44 public $element =
'knowledgerecord';
49 public $table_element =
'knowledgemanagement_knowledgerecord';
54 public $picto =
'knowledgemanagement';
57 const STATUS_DRAFT = 0;
58 const STATUS_VALIDATED = 1;
59 const STATUS_CANCELED = 9;
93 public $fields = array(
94 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'visible' => 0,
'noteditable' => 1,
'index' => 1,
'css' =>
'left',
'comment' =>
"Id"),
95 'ref' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref',
'enabled' => 1,
'position' => 10,
'notnull' => 1,
'default' =>
'(PROV)',
'visible' => 5,
'index' => 1,
'searchall' => 1,
'comment' =>
"Reference of object",
"csslist" =>
"nowraponall",
"showoncombobox" => 1),
96 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'position' => 20,
'index' => 1),
97 'question' => array(
'type' =>
'text',
'label' =>
'Question',
'enabled' => 1,
'position' => 30,
'notnull' => 1,
'visible' => 1,
'searchall' => 1,
'csslist' =>
'tdoverflowmax300 small',
'copytoclipboard' => 1,
'tdcss' =>
'titlefieldcreate nowraponall'),
98 'lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Language',
'enabled' => 1,
'position' => 40,
'notnull' => 0,
'visible' => 1,
'tdcss' =>
'titlefieldcreate nowraponall',
"csslist" =>
"minwidth100 maxwidth200"),
99 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'visible' => -2,
'csslist' =>
'nowraponall'),
100 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'position' => 501,
'notnull' => 0,
'visible' => 2,),
101 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'position' => 600,
'notnull' => 0,
'visible' => 0,),
102 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserCreation',
'enabled' => 1,
'position' => 510,
'notnull' => 1,
'visible' => -2,
'foreignkey' =>
'user.rowid',),
103 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 511,
'notnull' => -1,
'visible' => -2,),
104 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'position' => 512,
'notnull' => 0,
'visible' => -2,),
105 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'visible' => -2,),
106 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'position' => 1010,
'notnull' => -1,
'visible' => 0,),
108 'fk_c_ticket_category' => array(
'type' =>
'integer:CTicketCategory:ticket/class/cticketcategory.class.php:0:(t.active:=:1):pos',
'label' =>
'SuggestedForTicketsInGroup',
'enabled' =>
'isModEnabled("ticket")',
'position' => 520,
'notnull' => 0,
'visible' => -1,
'help' =>
'YouCanLinkArticleToATicketCategory',
'csslist' =>
'minwidth200 tdoverflowmax250'),
109 'answer' => array(
'type' =>
'html',
'label' =>
'Solution',
'enabled' => 1,
'position' => 600,
'notnull' => 0,
'visible' => 3,
'searchall' => 1,
'csslist' =>
'tdoverflowmax300',
'copytoclipboard' => 1,
'tdcss' =>
'titlefieldcreate nowraponall'),
110 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
'visible' => 5,
'default' =>
'0',
'index' => 1,
'arrayofkeyval' => array(0 =>
'Draft', 1 =>
'Validated', 9 =>
'Obsolete'),),
126 public $last_main_doc;
130 public $fk_user_creat;
134 public $fk_user_modif;
138 public $fk_user_valid;
221 $this->ismultientitymanaged = 1;
222 $this->isextrafieldmanaged = 1;
225 $this->fields[
'rowid'][
'visible'] = 0;
227 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
228 $this->fields[
'entity'][
'enabled'] = 0;
232 foreach ($this->fields as $key => $val) {
233 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
234 unset($this->fields[$key]);
239 if (is_object($langs)) {
240 foreach ($this->fields as $key => $val) {
241 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
242 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
243 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
271 global $langs, $extrafields;
281 $result =
$object->fetchCommon($fromid);
282 if ($result > 0 && !empty(
$object->table_element_line)) {
296 if (property_exists(
$object,
'ref')) {
298 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
300 if (property_exists(
$object,
'question')) {
302 $object->question = empty($this->fields[
'question'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->question : $this->fields[
'question'][
'default'];
304 if (property_exists(
$object,
'status')) {
305 $object->status = self::STATUS_DRAFT;
307 if (property_exists(
$object,
'date_creation')) {
310 if (property_exists(
$object,
'date_modification')) {
311 $object->date_modification =
null;
315 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
316 $extrafields->fetch_name_optionals_label($this->table_element);
317 foreach (
$object->array_options as $key => $option) {
318 $shortkey = preg_replace(
'/options_/',
'', $key);
319 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
322 unset(
$object->array_options[$key]);
328 $object->context[
'createfromclone'] =
'createfromclone';
329 $result =
$object->createCommon($user);
333 $this->errors =
$object->errors;
345 if (property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
352 unset(
$object->context[
'createfromclone']);
359 $this->db->rollback();
371 public function fetch($id, $ref =
null)
374 if ($result > 0 && !empty($this->table_element_line)) {
387 $this->lines = array();
405 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
413 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
414 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
415 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
417 $sql .=
' WHERE 1 = 1';
421 if (is_array($filter)) {
423 if (count($filter) > 0) {
424 foreach ($filter as $key => $value) {
425 if ($key ==
't.rowid') {
426 $sqlwhere[] = $this->db->sanitize($key).
" = ".((int) $value);
427 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
428 $sqlwhere[] = $this->db->sanitize($key).
" = '".$this->db->idate((
int) $value).
"'";
429 } elseif (strpos($value,
'%') ===
false) {
430 $sqlwhere[] = $this->db->sanitize($key).
' IN ('.$this->db->sanitize($this->db->escape($value)).
')';
432 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
436 if (count($sqlwhere) > 0) {
437 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
447 $this->errors[] = $errormessage;
448 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
452 if (!empty($sortfield)) {
453 $sql .= $this->db->order($sortfield, $sortorder);
455 if (!empty($limit)) {
456 $sql .= $this->db->plimit($limit, $offset);
459 $resql = $this->db->query($sql);
461 $num = $this->db->num_rows($resql);
463 while ($i < ($limit ? min($limit, $num) : $num)) {
464 $obj = $this->db->fetch_object($resql);
466 $record =
new self($this->db);
467 $record->setVarsFromFetchObj($obj);
469 $records[$record->id] = $record;
473 $this->db->free($resql);
477 $this->errors[] =
'Error '.$this->db->lasterror();
478 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
503 public function delete(
User $user, $notrigger = 0)
508 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_knowledgemanagement WHERE fk_knowledgemanagement = ".((int) $this->
id);
509 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
510 $resql = $this->db->query($sql);
513 $this->error .= $this->db->lasterror();
519 $elements = array(
'categorie_knowledgemanagement');
520 foreach ($elements as $table) {
522 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$table;
523 $sql .=
" WHERE fk_knowledgemanagement = ".(int) $this->
id;
525 $result = $this->db->query($sql);
528 $this->errors[] = $this->db->lasterror();
537 if ($result > 0 && !empty($conf->knowledgemanagement->dir_output) && !empty($this->
ref)) {
538 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
540 if (file_exists($dir)) {
542 $this->errors[] =
'ErrorFailToDeleteDir';
561 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
578 global $conf, $langs;
580 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
585 if ($this->
status == self::STATUS_VALIDATED) {
586 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
603 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
606 $num = (string) $this->
ref;
608 $this->newref = $num;
612 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
613 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
614 $sql .=
" status = ".self::STATUS_VALIDATED;
615 if (!empty($this->fields[
'date_validation'])) {
616 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
618 if (!empty($this->fields[
'fk_user_valid'])) {
619 $sql .=
", fk_user_valid = ".((int) $user->id);
621 $sql .=
" WHERE rowid = ".((int) $this->
id);
623 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
624 $resql = $this->db->query($sql);
627 $this->error = $this->db->lasterror();
631 if (!$error && !$notrigger) {
633 $result = $this->call_trigger(
'KNOWLEDGERECORD_VALIDATE', $user);
642 $this->oldref = $this->ref;
645 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
647 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'knowledgerecord/".$this->db->escape($this->newref).
"'";
648 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'knowledgerecord/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
649 $resql = $this->db->query($sql);
652 $this->error = $this->db->lasterror();
654 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'knowledgerecord/".$this->db->escape($this->newref).
"'";
655 $sql .=
" WHERE filepath = 'knowledgerecord/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
656 $resql = $this->db->query($sql);
659 $this->error = $this->db->lasterror();
665 $dirsource = $conf->knowledgemanagement->dir_output.
'/knowledgerecord/'.$oldref;
666 $dirdest = $conf->knowledgemanagement->dir_output.
'/knowledgerecord/'.$newref;
667 if (!$error && file_exists($dirsource)) {
668 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
670 if (@rename($dirsource, $dirdest)) {
673 $listoffiles =
dol_dir_list($conf->knowledgemanagement->dir_output.
'/knowledgerecord/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
674 foreach ($listoffiles as $fileentry) {
675 $dirsource = $fileentry[
'name'];
676 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
677 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
678 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
679 @rename($dirsource, $dirdest);
689 $this->
status = self::STATUS_VALIDATED;
696 $this->db->rollback();
712 if ($this->
status <= self::STATUS_DRAFT) {
723 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'KNOWLEDGERECORD_UNVALIDATE');
733 public function cancel($user, $notrigger = 0)
736 if ($this->
status != self::STATUS_VALIDATED) {
747 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'KNOWLEDGERECORD_CANCEL');
757 public function reopen($user, $notrigger = 0)
760 if ($this->
status != self::STATUS_CANCELED) {
771 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'KNOWLEDGERECORD_REOPEN');
782 global $conf, $langs;
784 $langs->loadLangs([
'knowledgemanagement',
'languages']);
787 $nofetch = !empty($params[
'nofetch']);
789 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"KnowledgeRecord").
'</u>';
790 if (isset($this->
status)) {
791 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
793 $datas[
'label'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
794 $datas[
'question'] =
'<br><b>'.$langs->trans(
'Question').
':</b> '.$this->question;
795 $labellang = ($this->lang ? $langs->trans(
'Language_'.$this->lang) :
'');
796 $datas[
'lang'] =
'<br><b>'.$langs->trans(
'Language').
':</b> ' .
picto_from_langcode($this->lang,
'class="paddingrightonly saturatemedium opacitylow"') . $labellang;
799 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
800 $form =
new Form($this->db);
801 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1);
817 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
819 global $conf, $langs, $hookmanager;
821 if (!empty($conf->dol_no_mouse_hover)) {
829 'objecttype' => $this->element.($this->module ?
'@'.$this->module :
''),
833 $classfortooltip =
'classfortooltip';
836 $classfortooltip =
'classforajaxtooltip';
837 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
843 $url =
dol_buildpath(
'/knowledgemanagement/knowledgerecord_card.php', 1).
'?id='.$this->id;
845 if ($option !=
'nolink') {
847 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
848 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
849 $add_save_lastsearch_values = 1;
851 if ($add_save_lastsearch_values) {
852 $url .=
'&save_lastsearch_values=1';
857 if (empty($notooltip)) {
859 $label = $langs->trans(
"ShowKnowledgeRecord");
860 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
862 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
863 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
865 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
868 if ($option ==
'nolink') {
869 $linkstart =
'<span';
871 $linkstart =
'<a href="'.$url.
'"';
873 $linkstart .= $linkclose.
'>';
874 if ($option ==
'nolink') {
875 $linkend =
'</span>';
880 $result .= $linkstart;
882 if (empty($this->showphoto_on_popup)) {
884 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') : $dataparams.
' class="'.(($withpicto != 2) ?
'paddingright ' :
'').$classfortooltip.
'"'), 0, 0, $notooltip ? 0 : 1);
888 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
890 list($class, $module) = explode(
'@', $this->picto);
893 $filename = $filearray[0][
'name'];
894 if (!empty($filename)) {
895 $pospoint = strpos($filearray[0][
'name'],
'.');
897 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
899 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.
'" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div></div>';
901 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div>';
906 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
911 if ($withpicto != 2) {
912 $result .= $this->ref;
918 global $action, $hookmanager;
919 $hookmanager->initHooks(array(
'knowledgerecorddao'));
920 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
921 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
923 $result = $hookmanager->resPrint;
925 $result .= $hookmanager->resPrint;
953 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
956 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
957 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
958 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Obsolete');
959 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
960 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
961 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Obsolete');
964 $statusType =
'status'.$status;
965 if ($status == self::STATUS_VALIDATED) {
966 $statusType =
'status4';
968 if ($status == self::STATUS_CANCELED) {
969 $statusType =
'status6';
972 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
983 $sql =
'SELECT t.rowid, t.date_creation as datec, GREATEST(t.tms, kef.tms) as datem,';
984 $sql .=
' t.fk_user_creat, t.fk_user_modif';
985 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
986 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element.
"_extrafields as kef ON kef.fk_object = t.rowid";
987 $sql .=
' WHERE t.rowid = '.((int) $id);
988 $result = $this->db->query($sql);
990 if ($this->db->num_rows($result)) {
991 $obj = $this->db->fetch_object($result);
993 $this->
id = $obj->rowid;
995 $this->user_creation_id = $obj->fk_user_creat;
996 $this->user_modification_id = $obj->fk_user_modif;
997 $this->date_creation = $this->db->jdate($obj->datec);
998 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1001 $this->db->free($result);
1015 $this->question =
"ABCD";
1027 $this->lines = array();
1030 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_knowledgerecord:=:'.((
int) $this->
id).
')');
1032 if (is_numeric($result)) {
1033 $this->error = $objectline->error;
1034 $this->errors = $objectline->errors;
1037 $this->lines = $result;
1050 global $langs, $conf;
1051 $langs->load(
"knowledgemanagement");
1054 $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON =
'mod_knowledgerecord_standard';
1064 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1065 foreach ($dirmodels as $reldir) {
1066 $dir =
dol_buildpath($reldir.
"core/modules/knowledgemanagement/");
1069 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1077 if (class_exists($classname)) {
1078 $obj =
new $classname();
1079 '@phan-var-force ModeleNumRefKnowledgeRecord $obj';
1080 $numref = $obj->getNextValue($this);
1082 if ($numref !=
'' && $numref !=
'-1') {
1085 $this->error = $obj->error;
1090 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1094 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1110 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1112 global $conf, $langs;
1115 $includedocgeneration = 0;
1117 $langs->load(
"knowledgemanagement");
1120 $modele =
'standard_knowledgerecord';
1122 if (!empty($this->model_pdf)) {
1123 $modele = $this->model_pdf;
1129 $modelpath =
"core/modules/knowledgemanagement/doc/";
1131 if ($includedocgeneration && !empty($modele)) {
1132 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1147 global $conf, $langs;
1163 $this->db->commit();
1180 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1181 return parent::setCategoriesCommon($categories, Categorie::TYPE_KNOWLEDGEMANAGEMENT);
1193 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1195 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1196 $return .=
'<div class="info-box info-box-sm">';
1197 $return .=
'<span class="info-box-icon bg-infobox-action">';
1199 $return .=
'</span>';
1200 $return .=
'<div class="info-box-content">';
1201 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</span>';
1202 if ($selected >= 0) {
1203 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1205 if (property_exists($this,
'lang') && !empty($this->lang)) {
1207 $return .=
'<br>'.picto_from_langcode($this->lang,
'class="paddingrightonly saturatemedium opacitylow paddingrightonly"');
1209 if (property_exists($this,
'question')) {
1210 $return .=
'<div class="info-box-label tdoverflowmax150 classfortooltip" title="'.dolPrintHTMLForAttribute($this->question).
'">'.
dolGetFirstLineOfText($this->question).
'</div>';
1212 if (method_exists($this,
'getLibStatut')) {
1213 $return .=
'<div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1215 $return .=
'</div>';
1216 $return .=
'</div>';
1217 $return .=
'</div>';
1230 $this->nb = array();
1233 $sql =
"SELECT count(t.rowid) as nb";
1234 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1236 $resql = $this->db->query($sql);
1238 while ($obj = $this->db->fetch_object($resql)) {
1239 $this->nb[
"knowledgebase"] = $obj->nb;
1242 $this->db->free($resql);
1246 $this->error = $this->db->error();
1253require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1272 $this->isextrafieldmanaged = 0;
if(! $sortfield) if(! $sortorder) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class for KnowledgeRecord.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
fetch($id, $ref=null)
Load object in memory from the database.
validate($user, $notrigger=0)
Validate object.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
info($id)
Load the info information in the object.
cancel($user, $notrigger=0)
Set cancel status.
update(User $user, $notrigger=0)
Update object into database.
fetchLines()
Load object lines in memory from the database.
LibStatut($status, $mode=0)
Return the status.
create(User $user, $notrigger=0)
Create object into database.
getTooltipContentArray($params)
getTooltipContentArray
loadStateBoard()
Load indicators into this->nb for board.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
createFromClone(User $user, $fromid)
Clone an object into another one.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
setCategories($categories)
Sets object to supplied categories.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
getLinesArray()
Create an array of lines.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Return the label of the status.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
reopen($user, $notrigger=0)
Set back to validated status.
setDraft($user, $notrigger=0)
Set draft status.
Class KnowledgeRecordLine.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.