dolibarr 21.0.0-alpha
supplier_proposal.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * or see https://www.gnu.org/
20 */
21
35{
36 global $db, $langs, $conf, $user;
37
38 // Load translation files required by the page
39 $langs->loadLangs(array("supplier_proposal", "compta"));
40
41 $h = 0;
42 $head = array();
43
44 $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$object->id;
45 $head[$h][1] = $langs->trans('CommRequests');
46 $head[$h][2] = 'comm';
47 $h++;
48
49 if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
50 $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
51 $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id;
52 $head[$h][1] = $langs->trans('ContactsAddresses');
53 if ($nbContact > 0) {
54 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
55 }
56 $head[$h][2] = 'contact';
57 $h++;
58 }
59
60 // Show more tabs from modules
61 // Entries must be declared in modules descriptor with line
62 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
63 // $this->tabs = array('entity:-tabname); to remove a tab
64 complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'add', 'core');
65
66 if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
67 $nbNote = 0;
68 if (!empty($object->note_private)) {
69 $nbNote++;
70 }
71 if (!empty($object->note_public)) {
72 $nbNote++;
73 }
74 $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
75 $head[$h][1] = $langs->trans('Notes');
76 if ($nbNote > 0) {
77 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
78 }
79 $head[$h][2] = 'note';
80 $h++;
81 }
82
83 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
84 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
85 $upload_dir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref);
86 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
87 $nbLinks = Link::count($db, $object->element, $object->id);
88 $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
89 $head[$h][1] = $langs->trans('Documents');
90 if (($nbFiles + $nbLinks) > 0) {
91 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
92 }
93 $head[$h][2] = 'document';
94 $h++;
95
96 $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id;
97 $head[$h][1] = $langs->trans('Info');
98 $head[$h][2] = 'info';
99 $h++;
100
101 complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'add', 'external');
102
103 complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'remove');
104
105 return $head;
106}
107
114{
115 global $langs, $conf, $user, $db;
116
117 $extrafields = new ExtraFields($db);
118 $extrafields->fetch_name_optionals_label('supplier_proposal');
119 $extrafields->fetch_name_optionals_label('supplier_proposaldet');
120
121 $h = 0;
122 $head = array();
123
124 $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php';
125 $head[$h][1] = $langs->trans("Miscellaneous");
126 $head[$h][2] = 'general';
127 $h++;
128
129 // Show more tabs from modules
130 // Entries must be declared in modules descriptor with line
131 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
132 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
133 complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin');
134
135 $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php';
136 $head[$h][1] = $langs->trans("ExtraFields");
137 $nbExtrafields = $extrafields->attributes['supplier_proposal']['count'];
138 if ($nbExtrafields > 0) {
139 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
140 }
141 $head[$h][2] = 'attributes';
142 $h++;
143
144 $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposaldet_extrafields.php';
145 $head[$h][1] = $langs->trans("ExtraFieldsLines");
146 $nbExtrafields = $extrafields->attributes['supplier_proposaldet']['count'];
147 if ($nbExtrafields > 0) {
148 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
149 }
150 $head[$h][2] = 'attributeslines';
151 $h++;
152
153 complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin', 'remove');
154
155 return $head;
156}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage standard extra fields.
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_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.
supplier_proposal_prepare_head($object)
Prepare array with list of tabs.
supplier_proposal_admin_prepare_head()
Return array head with list of tabs to view object information.