dolibarr  16.0.5
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  *
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  * or see https://www.gnu.org/
18  */
19 
32 function supplier_proposal_prepare_head($object)
33 {
34  global $db, $langs, $conf, $user;
35 
36  // Load translation files required by the page
37  $langs->loadLangs(array("supplier_proposal", "compta"));
38 
39  $h = 0;
40  $head = array();
41 
42  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$object->id;
43  $head[$h][1] = $langs->trans('CommRequests');
44  $head[$h][2] = 'comm';
45  $h++;
46 
47  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
48  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
49  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id;
50  $head[$h][1] = $langs->trans('ContactsAddresses');
51  if ($nbContact > 0) {
52  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
53  }
54  $head[$h][2] = 'contact';
55  $h++;
56  }
57 
58  // Show more tabs from modules
59  // Entries must be declared in modules descriptor with line
60  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
61  // $this->tabs = array('entity:-tabname); to remove a tab
62  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal');
63 
64  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
65  $nbNote = 0;
66  if (!empty($object->note_private)) {
67  $nbNote++;
68  }
69  if (!empty($object->note_public)) {
70  $nbNote++;
71  }
72  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
73  $head[$h][1] = $langs->trans('Notes');
74  if ($nbNote > 0) {
75  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
76  }
77  $head[$h][2] = 'note';
78  $h++;
79  }
80 
81  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
82  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
83  $upload_dir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref);
84  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
85  $nbLinks = Link::count($db, $object->element, $object->id);
86  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
87  $head[$h][1] = $langs->trans('Documents');
88  if (($nbFiles + $nbLinks) > 0) {
89  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
90  }
91  $head[$h][2] = 'document';
92  $h++;
93 
94  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id;
95  $head[$h][1] = $langs->trans('Info');
96  $head[$h][2] = 'info';
97  $h++;
98 
99  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'remove');
100 
101  return $head;
102 }
103 
109 function supplier_proposal_admin_prepare_head()
110 {
111  global $langs, $conf, $user;
112 
113  $h = 0;
114  $head = array();
115 
116  $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php';
117  $head[$h][1] = $langs->trans("Miscellaneous");
118  $head[$h][2] = 'general';
119  $h++;
120 
121  // Show more tabs from modules
122  // Entries must be declared in modules descriptor with line
123  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
124  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
125  complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin');
126 
127  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php';
128  $head[$h][1] = $langs->trans("ExtraFields");
129  $head[$h][2] = 'attributes';
130  $h++;
131 
132  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposaldet_extrafields.php';
133  $head[$h][1] = $langs->trans("ExtraFieldsLines");
134  $head[$h][2] = 'attributeslines';
135  $h++;
136 
137  complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin', 'remove');
138 
139  return $head;
140 }
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1212
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9024