dolibarr 18.0.6
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 (empty($conf->global->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) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
50 $head[$h][2] = 'contact';
51 $h++;
52 }
53
54 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
55 $nbNote = 0;
56 if (!empty($object->note_private)) $nbNote++;
57 if (!empty($object->note_public)) $nbNote++;
58 $head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_note.php', 1).'?id='.$object->id;
59 $head[$h][1] = $langs->trans('Notes');
60 if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
61 $head[$h][2] = 'note';
62 $h++;
63 }
64
65 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
66 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
67 $upload_dir = $conf->stocktransfer->dir_output."/stocktransfer/".dol_sanitizeFileName($object->ref);
68 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
69 $nbLinks = Link::count($db, $object->element, $object->id);
70 $head[$h][0] = dol_buildpath("/product/stock/stocktransfer/stocktransfer_document.php", 1).'?id='.$object->id;
71 $head[$h][1] = $langs->trans('Documents');
72 if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
73 $head[$h][2] = 'document';
74 $h++;
75
76 $head[$h][0] = dol_buildpath("/product/stock/stocktransfer/stocktransfer_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:@stocktransfer:/stocktransfer/mypage.php?id=__ID__'
85 //); // to add new tab
86 //$this->tabs = array(
87 // 'entity:-tabname:Title:@stocktransfer:/stocktransfer/mypage.php?id=__ID__'
88 //); // to remove a tab
89 complete_head_from_modules($conf, $langs, $object, $head, $h, 'stocktransfer@stocktransfer');
90
91 complete_head_from_modules($conf, $langs, $object, $head, $h, 'stocktransfer@stocktransfer', 'remove');
92
93 return $head;
94}
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).
stocktransferPrepareHead($object)
Prepare array of tabs for StockTransfer.