dolibarr  7.0.0-beta
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@capnetworks.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  $langs->load("supplier_proposal");
36  $langs->load("compta");
37 
38  $h = 0;
39  $head = array();
40 
41  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$object->id;
42  $head[$h][1] = $langs->trans('SupplierProposalCard');
43  $head[$h][2] = 'comm';
44  $h++;
45 
46 
47  // Show more tabs from modules
48  // Entries must be declared in modules descriptor with line
49  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
50  // $this->tabs = array('entity:-tabname); to remove a tab
51  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal');
52 
53  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
54  {
55  $nbNote = 0;
56  if(!empty($object->note_private)) $nbNote++;
57  if(!empty($object->note_public)) $nbNote++;
58  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
59  $head[$h][1] = $langs->trans('Notes');
60  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$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->supplier_proposal->dir_output . "/" . 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_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
71  $head[$h][1] = $langs->trans('Documents');
72  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
73  $head[$h][2] = 'document';
74  $h++;
75 
76  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id;
77  $head[$h][1] = $langs->trans('Info');
78  $head[$h][2] = 'info';
79  $h++;
80 
81  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal','remove');
82 
83  return $head;
84 }
85 
91 function supplier_proposal_admin_prepare_head()
92 {
93  global $langs, $conf, $user;
94 
95  $h = 0;
96  $head = array();
97 
98  $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php';
99  $head[$h][1] = $langs->trans("Miscellaneous");
100  $head[$h][2] = 'general';
101  $h++;
102 
103  // Show more tabs from modules
104  // Entries must be declared in modules descriptor with line
105  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
106  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
107  complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin');
108 
109  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php';
110  $head[$h][1] = $langs->trans("ExtraFields");
111  $head[$h][2] = 'attributes';
112  $h++;
113 
114  $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposaldet_extrafields.php';
115  $head[$h][1] = $langs->trans("ExtraFieldsLines");
116  $head[$h][2] = 'attributeslines';
117  $h++;
118 
119  complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin','remove');
120 
121  return $head;
122 }
123 
124 
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="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58