dolibarr 20.0.0
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 *
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("workstation");
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = dol_buildpath("/workstation/workstation_card.php", 1).'?id='.$object->id;
41 $head[$h][1] = $langs->trans("Card");
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_buildpath('/workstation/workstation_note.php', 1).'?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->workstation->dir_output."/workstation/".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_buildpath("/workstation/workstation_document.php", 1).'?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_buildpath("/workstation/workstation_agenda.php", 1).'?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:@workstation:/workstation/mypage.php?id=__ID__'
84 //); // to add new tab
85 //$this->tabs = array(
86 // 'entity:-tabname:Title:@workstation:/workstation/mypage.php?id=__ID__'
87 //); // to remove a tab
88 complete_head_from_modules($conf, $langs, $object, $head, $h, 'workstation');
89
90 complete_head_from_modules($conf, $langs, $object, $head, $h, 'workstation', '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_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 dolibarr global constant string value.
workstationPrepareHead($object)
Prepare array of tabs for Workstation.