dolibarr 21.0.0-alpha
knowledgemanagement_knowledgerecord.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021-2024 Frédéric France <frederic.france@free.fr>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
32{
33 global $db, $langs, $conf;
34
35 $langs->load("knowledgemanagement");
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_card.php?id='.$object->id;
41 $head[$h][1] = $langs->trans("KnowledgeRecord");
42 $head[$h][2] = 'card';
43 $h++;
44
45 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
46 $nbNote = 0;
47 if (!empty($object->note_private)) {
48 $nbNote++;
49 }
50 if (!empty($object->note_public)) {
51 $nbNote++;
52 }
53 $head[$h][0] = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_note.php?id='.$object->id;
54 $head[$h][1] = $langs->trans('Notes');
55 if ($nbNote > 0) {
56 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
57 }
58 $head[$h][2] = 'note';
59 $h++;
60 }
61
62 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
63 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
64 $upload_dir = $conf->knowledgemanagement->dir_output."/knowledgerecord/".dol_sanitizeFileName($object->ref);
65 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
66 $nbLinks = Link::count($db, $object->element, $object->id);
67 $head[$h][0] = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_document.php?id='.$object->id;
68 $head[$h][1] = $langs->trans('Documents');
69 if (($nbFiles + $nbLinks) > 0) {
70 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
71 }
72 $head[$h][2] = 'document';
73 $h++;
74
75 $head[$h][0] = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_agenda.php?id='.$object->id;
76 $head[$h][1] = $langs->trans("Events");
77 $head[$h][2] = 'agenda';
78 $h++;
79
80 // Show more tabs from modules
81 // Entries must be declared in modules descriptor with line
82 //$this->tabs = array(
83 // 'entity:+tabname:Title:@knowledgemanagement:/knowledgemanagement/mypage.php?id=__ID__'
84 //); // to add new tab
85 //$this->tabs = array(
86 // 'entity:-tabname:Title:@knowledgemanagement:/knowledgemanagement/mypage.php?id=__ID__'
87 //); // to remove a tab
88 complete_head_from_modules($conf, $langs, $object, $head, $h, 'knowledgerecord@knowledgemanagement');
89
90 complete_head_from_modules($conf, $langs, $object, $head, $h, 'knowledgerecord@knowledgemanagement', 'remove');
91
92 return $head;
93}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.
Definition files.lib.php:63
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
knowledgerecordPrepareHead($object)
Prepare array of tabs for KnowledgeRecord.