dolibarr  9.0.0
propal.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  *
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 propal_prepare_head($object)
33 {
34  global $db, $langs, $conf, $user;
35  $langs->loadLangs(array('propal', 'compta', 'companies'));
36 
37  $h = 0;
38  $head = array();
39 
40  $head[$h][0] = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id;
41  $head[$h][1] = $langs->trans('ProposalCard');
42  $head[$h][2] = 'comm';
43  $h++;
44 
45  if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
46  || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire))))
47  {
48  $langs->load("sendings");
49  $text = '';
50  $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id;
51  if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment");
52  if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings");
53  $head[$h][1] = $text;
54  $head[$h][2] = 'shipping';
55  $h++;
56  }
57 
58  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
59  {
60  $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
61  $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
62  $head[$h][1] = $langs->trans('ContactsAddresses');
63  if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
64  $head[$h][2] = 'contact';
65  $h++;
66  }
67 
68  // Show more tabs from modules
69  // Entries must be declared in modules descriptor with line
70  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
71  // $this->tabs = array('entity:-tabname); to remove a tab
72  complete_head_from_modules($conf,$langs,$object,$head,$h,'propal');
73 
74  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
75  {
76  $nbNote = 0;
77  if(!empty($object->note_private)) $nbNote++;
78  if(!empty($object->note_public)) $nbNote++;
79  $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id;
80  $head[$h][1] = $langs->trans('Notes');
81  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
82  $head[$h][2] = 'note';
83  $h++;
84  }
85 
86  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
87  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
88  $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref);
89  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
90  $nbLinks=Link::count($db, $object->element, $object->id);
91  $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id;
92  $head[$h][1] = $langs->trans('Documents');
93  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
94  $head[$h][2] = 'document';
95  $h++;
96 
97  $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id;
98  $head[$h][1] = $langs->trans('Info');
99  $head[$h][2] = 'info';
100  $h++;
101 
102  complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove');
103 
104  return $head;
105 }
106 
113 {
114  global $langs, $conf, $user;
115 
116  $h = 0;
117  $head = array();
118 
119  $head[$h][0] = DOL_URL_ROOT.'/admin/propal.php';
120  $head[$h][1] = $langs->trans("Miscellaneous");
121  $head[$h][2] = 'general';
122  $h++;
123 
124  // Show more tabs from modules
125  // Entries must be declared in modules descriptor with line
126  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
127  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
128  complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin');
129 
130  $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php';
131  $head[$h][1] = $langs->trans("ExtraFields");
132  $head[$h][2] = 'attributes';
133  $h++;
134 
135  $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php';
136  $head[$h][1] = $langs->trans("ExtraFieldsLines");
137  $head[$h][2] = 'attributeslines';
138  $h++;
139 
140  complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove');
141 
142  return $head;
143 }
144 
145 
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.
propal_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: propal.lib.php:112
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
propal_prepare_head($object)
Prepare array with list of tabs.
Definition: propal.lib.php:32