dolibarr  7.0.0-beta
fourn.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
4  * Copyright (C) 2006 Marc Barilley <marc@ocebo.com>
5  * Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  * or see http://www.gnu.org/
20  */
21 
34 function facturefourn_prepare_head($object)
35 {
36  global $db, $langs, $conf;
37 
38  $h = 0;
39  $head = array();
40 
41  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id;
42  $head[$h][1] = $langs->trans('Card');
43  $head[$h][2] = 'card';
44  $h++;
45 
46  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
47  {
48  $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
49  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
50  $head[$h][1] = $langs->trans('ContactsAddresses');
51  if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
52  $head[$h][2] = 'contact';
53  $h++;
54  }
55 
56  // Show more tabs from modules
57  // Entries must be declared in modules descriptor with line
58  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
59  // $this->tabs = array('entity:-tabname); to remove a tab
60  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
61 
62  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
63  {
64  $nbNote = 0;
65  if(!empty($object->note_private)) $nbNote++;
66  if(!empty($object->note_public)) $nbNote++;
67  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
68  $head[$h][1] = $langs->trans('Notes');
69  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
70  $head[$h][2] = 'note';
71  $h++;
72  }
73 
74  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
75  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
76  $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$object->ref;
77  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
78  $nbLinks=Link::count($db, $object->element, $object->id);
79  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id;
80  $head[$h][1] = $langs->trans('Documents');
81  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
82  $head[$h][2] = 'documents';
83  $h++;
84 
85  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id;
86  $head[$h][1] = $langs->trans('Info');
87  $head[$h][2] = 'info';
88  $h++;
89 
90  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice','remove');
91 
92  return $head;
93 }
94 
95 
102 function ordersupplier_prepare_head($object)
103 {
104  global $db, $langs, $conf, $user;
105 
106  $h = 0;
107  $head = array();
108 
109  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id;
110  $head[$h][1] = $langs->trans("OrderCard");
111  $head[$h][2] = 'card';
112  $h++;
113 
114  if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
115  {
116  $langs->load("stocks");
117  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
118  $head[$h][1] = $langs->trans("OrderDispatch");
119  $head[$h][2] = 'dispatch';
120  $h++;
121  }
122 
123  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
124  {
125  $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
126  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
127  $head[$h][1] = $langs->trans('ContactsAddresses');
128  if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
129  $head[$h][2] = 'contact';
130  $h++;
131  }
132 
133  // Show more tabs from modules
134  // Entries must be declared in modules descriptor with line
135  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
136  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
137  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
138 
139  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
140  {
141  $nbNote = 0;
142  if(!empty($object->note_private)) $nbNote++;
143  if(!empty($object->note_public)) $nbNote++;
144  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
145  $head[$h][1] = $langs->trans("Notes");
146  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
147  $head[$h][2] = 'note';
148  $h++;
149  }
150 
151  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
152  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
153  $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref);
154  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
155  $nbLinks=Link::count($db, $object->element, $object->id);
156  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id;
157  $head[$h][1] = $langs->trans('Documents');
158  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
159  $head[$h][2] = 'documents';
160  $h++;
161 
162  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id;
163  $head[$h][1].= $langs->trans("Events");
164  if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
165  {
166  $head[$h][1].= '/';
167  $head[$h][1].= $langs->trans("Agenda");
168  }
169  $head[$h][2] = 'info';
170  $h++;
171  complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove');
172  return $head;
173 }
174 
181 {
182  global $langs, $conf, $user;
183 
184  $h = 0;
185  $head = array();
186 
187  $head[$h][0] = DOL_URL_ROOT."/admin/supplier_order.php";
188  $head[$h][1] = $langs->trans("SupplierOrder");
189  $head[$h][2] = 'order';
190  $h++;
191 
192  $head[$h][0] = DOL_URL_ROOT."/admin/supplier_invoice.php";
193  $head[$h][1] = $langs->trans("SuppliersInvoice");
194  $head[$h][2] = 'invoice';
195  $h++;
196 
197  $head[$h][0] = DOL_URL_ROOT."/admin/supplier_payment.php";
198  $head[$h][1] = $langs->trans("SuppliersPayment");
199  $head[$h][2] = 'supplierpayment';
200  $h++;
201 
202  complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin');
203 
204  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php';
205  $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
206  $head[$h][2] = 'supplierorder';
207  $h++;
208 
209  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorderdet_extrafields.php';
210  $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines");
211  $head[$h][2] = 'supplierorderdet';
212  $h++;
213 
214 
215 
216  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php';
217  $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices");
218  $head[$h][2] = 'supplierinvoice';
219  $h++;
220 
221  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoicedet_extrafields.php';
222  $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesLines");
223  $head[$h][2] = 'supplierinvoicedet';
224  $h++;
225 
226  complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin','remove');
227 
228  return $head;
229 }
230 
231 
ordersupplier_prepare_head($object)
Prepare array with list of tabs.
Definition: fourn.lib.php:102
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.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
Return a path to have a the directory according to object where files are stored. ...
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: fourn.lib.php:180
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
facturefourn_prepare_head($object)
Prepare array with list of tabs.
Definition: fourn.lib.php:34