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