dolibarr 24.0.0-beta
quickmemo_memo.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 John BOTELLA
3 * Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
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("quickmemo");
36
37 $showtabofpagecontact = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_CONTACT');
38 $showtabofpagenote = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_NOTE');
39 $showtabofpagedocument = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_DOCUMENT');
40 $showtabofpageagenda = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_AGENDA');
41
42 $h = 0;
43 $head = array();
44
45 $head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_card.php", 1), ['id' => $object->id]);
46 $head[$h][1] = $langs->trans("Memo");
47 $head[$h][2] = 'card';
48 $h++;
49
50 if ($showtabofpagecontact) {
51 $head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_contact.php", 1), ['id' => $object->id]);
52 $head[$h][1] = $langs->trans("Contacts");
53 $head[$h][2] = 'contact';
54 $h++;
55 }
56
57 if ($showtabofpagenote) {
58 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
59 $nbNote = 0;
60 if (!empty($object->note_private)) {
61 $nbNote++;
62 }
63 if (!empty($object->note_public)) {
64 $nbNote++;
65 }
66 $head[$h][0] = dolBuildUrl(dol_buildpath('/quickmemo/memo_note.php', 1), ['id' => $object->id]);
67 $head[$h][1] = $langs->trans('Notes');
68 if ($nbNote > 0) {
69 $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
70 }
71 $head[$h][2] = 'note';
72 $h++;
73 }
74 }
75
76 if ($showtabofpagedocument) {
77 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
78 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
79 $upload_dir = $conf->quickmemo->dir_output."/memo/".dol_sanitizeFileName($object->ref);
80 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
81 $nbLinks = Link::count($db, $object->element, $object->id);
82 $head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_document.php", 1), ['id' => $object->id]);
83 $head[$h][1] = $langs->trans('Documents');
84 if (($nbFiles + $nbLinks) > 0) {
85 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
86 }
87 $head[$h][2] = 'document';
88 $h++;
89 }
90
91 if ($showtabofpageagenda) {
92 $head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/memo_agenda.php", 1), ['id' => $object->id]);
93 $head[$h][1] = $langs->trans("Events");
94 $head[$h][2] = 'agenda';
95 $h++;
96 }
97
98 // Show more tabs from modules
99 // Entries must be declared in modules descriptor with line
100 //$this->tabs = array(
101 // 'entity:+tabname:Title:@quickmemo:/quickmemo/mypage.php?id=__ID__'
102 //); // to add new tab
103 //$this->tabs = array(
104 // 'entity:-tabname:Title:@quickmemo:/quickmemo/mypage.php?id=__ID__'
105 //); // to remove a tab
106 complete_head_from_modules($conf, $langs, $object, $head, $h, 'memo@quickmemo');
107
108 complete_head_from_modules($conf, $langs, $object, $head, $h, 'memo@quickmemo', 'remove');
109
110 return $head;
111}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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:64
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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).
memoPrepareHead($object)
Prepare array of tabs for Memo.