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