dolibarr  21.0.0-alpha
supplier_proposal.lib.php
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  *
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  * or see https://www.gnu.org/
19  */
20 
33 function supplier_proposal_prepare_head($object)
34 {
35  global $db, $langs, $conf, $user;
36 
37  // Load translation files required by the page
38  $langs->loadLangs(array("supplier_proposal", "compta"));
39 
40  $h = 0;
41  $head = array();
42 
43  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$object->id;
44  $head[$h][1] = $langs->trans('CommRequests');
45  $head[$h][2] = 'comm';
46  $h++;
47 
48  if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
49  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
50  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id;
51  $head[$h][1] = $langs->trans('ContactsAddresses');
52  if ($nbContact > 0) {
53  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
54  }
55  $head[$h][2] = 'contact';
56  $h++;
57  }
58 
59  // Show more tabs from modules
60  // Entries must be declared in modules descriptor with line
61  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
62  // $this->tabs = array('entity:-tabname); to remove a tab
63  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'add', 'core');
64 
65  if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
66  $nbNote = 0;
67  if (!empty($object->note_private)) {
68  $nbNote++;
69  }
70  if (!empty($object->note_public)) {
71  $nbNote++;
72  }
73  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
74  $head[$h][1] = $langs->trans('Notes');
75  if ($nbNote > 0) {
76  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
77  }
78  $head[$h][2] = 'note';
79  $h++;
80  }
81 
82  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
83  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
84  $upload_dir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref);
85  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
86  $nbLinks = Link::count($db, $object->element, $object->id);
87  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
88  $head[$h][1] = $langs->trans('Documents');
89  if (($nbFiles + $nbLinks) > 0) {
90  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
91  }
92  $head[$h][2] = 'document';
93  $h++;
94 
95  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id;
96  $head[$h][1] = $langs->trans('Info');
97  $head[$h][2] = 'info';
98  $h++;
99 
100  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'add', 'external');
101 
102  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'remove');
103 
104  return $head;
105 }
106 
112 function supplier_proposal_admin_prepare_head()
113 {
114  global $langs, $conf, $user, $db;
115 
116  $extrafields = new ExtraFields($db);
117  $extrafields->fetch_name_optionals_label('supplier_proposal');
118  $extrafields->fetch_name_optionals_label('supplier_proposaldet');
119 
120  $h = 0;
121  $head = array();
122 
123  $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php';
124  $head[$h][1] = $langs->trans("Miscellaneous");
125  $head[$h][2] = 'general';
126  $h++;
127 
128  // Show more tabs from modules
129  // Entries must be declared in modules descriptor with line
130  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
131  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
132  complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin');
133 
134  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php';
135  $head[$h][1] = $langs->trans("ExtraFields");
136  $nbExtrafields = $extrafields->attributes['supplier_proposal']['count'];
137  if ($nbExtrafields > 0) {
138  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
139  }
140  $head[$h][2] = 'attributes';
141  $h++;
142 
143  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposaldet_extrafields.php';
144  $head[$h][1] = $langs->trans("ExtraFieldsLines");
145  $nbExtrafields = $extrafields->attributes['supplier_proposaldet']['count'];
146  if ($nbExtrafields > 0) {
147  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
148  }
149  $head[$h][2] = 'attributeslines';
150  $h++;
151 
152  complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin', 'remove');
153 
154  return $head;
155 }
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 dolibarr global constant string value.