dolibarr 21.0.0-alpha
intracommreport.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) ---Put here your own copyright and developer email---
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
31{
32 global $langs, $conf;
33
34 // global $db;
35 // $extrafields = new ExtraFields($db);
36 // $extrafields->fetch_name_optionals_label('intracommreport');
37
38 $langs->load("intracommreport");
39
40 $h = 0;
41 $head = array();
42
43 $head[$h][0] = dol_buildpath("/intracommreport/admin/setup.php", 1);
44 $head[$h][1] = $langs->trans("Settings");
45 $head[$h][2] = 'settings';
46 $h++;
47
48 /*
49 $head[$h][0] = dol_buildpath("/intracommreport/admin/intracommreport_extrafields.php", 1);
50 $head[$h][1] = $langs->trans("ExtraFields");
51 $nbExtrafields = is_countable($extrafields->attributes['intracommreport']['label']) ? count($extrafields->attributes['intracommreport']['label']) : 0;
52 if ($nbExtrafields > 0) {
53 $head[$h][1] .= ' <span class="badge">' . $nbExtrafields . '</span>';
54 }
55 $head[$h][2] = 'intracommreport_extrafields';
56 $h++;
57 */
58
59 // Show more tabs from modules
60 // Entries must be declared in modules descriptor with line
61 //$this->tabs = array(
62 // 'entity:+tabname:Title:@intracommreport:/intracommreport/mypage.php?id=__ID__'
63 //); // to add new tab
64 //$this->tabs = array(
65 // 'entity:-tabname:Title:@intracommreport:/intracommreport/mypage.php?id=__ID__'
66 //); // to remove a tab
67 complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport');
68
69 complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport', 'remove');
70
71 return $head;
72}
73
74
82{
83 global $db, $langs, $conf;
84
85 $langs->load("mymodule@mymodule");
86
87 $showtabofpagecontact = 0;
88 $showtabofpagenote = 0;
89 $showtabofpagedocument = 0;
90 $showtabofpageagenda = 0;
91
92 $h = 0;
93 $head = array();
94
95 $head[$h][0] = dol_buildpath("/intracommreport/card.php", 1).'?id='.$object->id;
96 $head[$h][1] = $langs->trans("IntraCommReport");
97 $head[$h][2] = 'card';
98 $h++;
99
100 if ($showtabofpagecontact) {
101 $head[$h][0] = dol_buildpath("/intracommreport/contact.php", 1).'?id='.$object->id;
102 $head[$h][1] = $langs->trans("Contacts");
103 $head[$h][2] = 'contact';
104 $h++;
105 }
106
107 if ($showtabofpagenote) {
108 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
109 $nbNote = 0;
110 if (!empty($object->note_private)) {
111 $nbNote++;
112 }
113 if (!empty($object->note_public)) {
114 $nbNote++;
115 }
116 $head[$h][0] = dol_buildpath('/intracommreport/note.php', 1).'?id='.$object->id;
117 $head[$h][1] = $langs->trans('Notes');
118 if ($nbNote > 0) {
119 $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
120 }
121 $head[$h][2] = 'note';
122 $h++;
123 }
124 }
125
126 if ($showtabofpagedocument) {
127 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
128 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
129 $upload_dir = $conf->mymodule->dir_output."/intracommreport/".dol_sanitizeFileName($object->ref);
130 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
131 $nbLinks = Link::count($db, $object->element, $object->id);
132 $head[$h][0] = dol_buildpath("/mymodule/document.php", 1).'?id='.$object->id;
133 $head[$h][1] = $langs->trans('Documents');
134 if (($nbFiles + $nbLinks) > 0) {
135 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
136 }
137 $head[$h][2] = 'document';
138 $h++;
139 }
140
141 if ($showtabofpageagenda) {
142 $head[$h][0] = dol_buildpath("/mymodule/agenda.php", 1).'?id='.$object->id;
143 $head[$h][1] = $langs->trans("Events");
144 $head[$h][2] = 'agenda';
145 $h++;
146 }
147
148 // Show more tabs from modules
149 // Entries must be declared in modules descriptor with line
150 //$this->tabs = array(
151 // 'entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
152 //); // to add new tab
153 //$this->tabs = array(
154 // 'entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
155 //); // to remove a tab
156 complete_head_from_modules($conf, $langs, $object, $head, $h, 'intracommreport@mymodule');
157
158 complete_head_from_modules($conf, $langs, $object, $head, $h, 'intracommreport@mymodule', 'remove');
159
160 return $head;
161}
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
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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).
intracommreportPrepareHead($object)
Prepare array of tabs for IntraCommReport.
intracommreportAdminPrepareHead()
Prepare admin pages header.