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