dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
17  * or see http://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('SupplierProposalCard');
44  $head[$h][2] = 'comm';
45  $h++;
46 
47  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
48  {
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) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
53  $head[$h][2] = 'contact';
54  $h++;
55  }
56 
57  // Show more tabs from modules
58  // Entries must be declared in modules descriptor with line
59  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
60  // $this->tabs = array('entity:-tabname); to remove a tab
61  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal');
62 
63  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
64  {
65  $nbNote = 0;
66  if(!empty($object->note_private)) $nbNote++;
67  if(!empty($object->note_public)) $nbNote++;
68  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
69  $head[$h][1] = $langs->trans('Notes');
70  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
71  $head[$h][2] = 'note';
72  $h++;
73  }
74 
75  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
76  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
77  $upload_dir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref);
78  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
79  $nbLinks=Link::count($db, $object->element, $object->id);
80  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
81  $head[$h][1] = $langs->trans('Documents');
82  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
83  $head[$h][2] = 'document';
84  $h++;
85 
86  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id;
87  $head[$h][1] = $langs->trans('Info');
88  $head[$h][2] = 'info';
89  $h++;
90 
91  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal','remove');
92 
93  return $head;
94 }
95 
101 function supplier_proposal_admin_prepare_head()
102 {
103  global $langs, $conf, $user;
104 
105  $h = 0;
106  $head = array();
107 
108  $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php';
109  $head[$h][1] = $langs->trans("Miscellaneous");
110  $head[$h][2] = 'general';
111  $h++;
112 
113  // Show more tabs from modules
114  // Entries must be declared in modules descriptor with line
115  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
116  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
117  complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin');
118 
119  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php';
120  $head[$h][1] = $langs->trans("ExtraFields");
121  $head[$h][2] = 'attributes';
122  $h++;
123 
124  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposaldet_extrafields.php';
125  $head[$h][1] = $langs->trans("ExtraFieldsLines");
126  $head[$h][2] = 'attributeslines';
127  $h++;
128 
129  complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin','remove');
130 
131  return $head;
132 }
133 
134 
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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:59