dolibarr 19.0.3
stocktransfer_stocktransfer.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) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
31function stocktransferPrepareHead($object)
32{
33 global $db, $langs, $conf;
34
35 $langs->load("stocks");
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = dol_buildpath("/product/stock/stocktransfer/stocktransfer_card.php", 1).'?id='.$object->id;
41 $head[$h][1] = $langs->trans("Card");
42 $head[$h][2] = 'card';
43 $h++;
44
45 if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
46 $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
47 $head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_contact.php', 1).'?id='.$object->id;
48 $head[$h][1] = $langs->trans('ContactsAddresses');
49 if ($nbContact > 0) {
50 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
51 }
52 $head[$h][2] = 'contact';
53 $h++;
54 }
55
56 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
57 $nbNote = 0;
58 if (!empty($object->note_private)) {
59 $nbNote++;
60 }
61 if (!empty($object->note_public)) {
62 $nbNote++;
63 }
64 $head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_note.php', 1).'?id='.$object->id;
65 $head[$h][1] = $langs->trans('Notes');
66 if ($nbNote > 0) {
67 $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
68 }
69 $head[$h][2] = 'note';
70 $h++;
71 }
72
73 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
74 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
75 $upload_dir = $conf->stocktransfer->dir_output."/stocktransfer/".dol_sanitizeFileName($object->ref);
76 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
77 $nbLinks = Link::count($db, $object->element, $object->id);
78 $head[$h][0] = dol_buildpath("/product/stock/stocktransfer/stocktransfer_document.php", 1).'?id='.$object->id;
79 $head[$h][1] = $langs->trans('Documents');
80 if (($nbFiles + $nbLinks) > 0) {
81 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
82 }
83 $head[$h][2] = 'document';
84 $h++;
85
86 $head[$h][0] = dol_buildpath("/product/stock/stocktransfer/stocktransfer_agenda.php", 1).'?id='.$object->id;
87 $head[$h][1] = $langs->trans("Events");
88 $head[$h][2] = 'agenda';
89 $h++;
90
91 // Show more tabs from modules
92 // Entries must be declared in modules descriptor with line
93 //$this->tabs = array(
94 // 'entity:+tabname:Title:@stocktransfer:/stocktransfer/mypage.php?id=__ID__'
95 //); // to add new tab
96 //$this->tabs = array(
97 // 'entity:-tabname:Title:@stocktransfer:/stocktransfer/mypage.php?id=__ID__'
98 //); // to remove a tab
99 complete_head_from_modules($conf, $langs, $object, $head, $h, 'stocktransfer@stocktransfer');
100
101 complete_head_from_modules($conf, $langs, $object, $head, $h, 'stocktransfer@stocktransfer', 'remove');
102
103 return $head;
104}
dol_dir_list($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:62
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.
stocktransferPrepareHead($object)
Prepare array of tabs for StockTransfer.