dolibarr  13.0.2
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@inodbox.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 <https://www.gnu.org/licenses/>.
19  * or see https://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('SupplierInvoice');
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 marginleftonlyshort">'.$nbContact.'</span>';
52  $head[$h][2] = 'contact';
53  $h++;
54  }
55 
56  //if ($fac->mode_reglement_code == 'PRE')
57  if (!empty($conf->paymentbybanktransfer->enabled))
58  {
59  $nbStandingOrders = 0;
60  $sql = "SELECT COUNT(pfd.rowid) as nb";
61  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
62  $sql .= " WHERE pfd.fk_facture_fourn = ".$object->id;
63  $sql .= " AND pfd.ext_payment_id IS NULL";
64  $resql = $db->query($sql);
65  if ($resql)
66  {
67  $obj = $db->fetch_object($resql);
68  if ($obj) $nbStandingOrders = $obj->nb;
69  }
70  else dol_print_error($db);
71  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id.'&type=bank-transfer';
72  $head[$h][1] = $langs->trans('BankTransfer');
73  if ($nbStandingOrders > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbStandingOrders.'</span>';
74  $head[$h][2] = 'standingorders';
75  $h++;
76  }
77 
78  // Show more tabs from modules
79  // Entries must be declared in modules descriptor with line
80  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
81  // $this->tabs = array('entity:-tabname); to remove a tab
82  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice');
83 
84  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
85  {
86  $nbNote = 0;
87  if (!empty($object->note_private)) $nbNote++;
88  if (!empty($object->note_public)) $nbNote++;
89  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
90  $head[$h][1] = $langs->trans('Notes');
91  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
92  $head[$h][2] = 'note';
93  $h++;
94  }
95 
96  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
97  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
98  $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object->ref;
99  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
100  $nbLinks = Link::count($db, $object->element, $object->id);
101  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id;
102  $head[$h][1] = $langs->trans('Documents');
103  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
104  $head[$h][2] = 'documents';
105  $h++;
106 
107  $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id;
108  $head[$h][1] = $langs->trans('Info');
109  $head[$h][2] = 'info';
110  $h++;
111 
112  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice', 'remove');
113 
114  return $head;
115 }
116 
117 
124 function ordersupplier_prepare_head($object)
125 {
126  global $db, $langs, $conf, $user;
127 
128  $h = 0;
129  $head = array();
130 
131  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id;
132  $head[$h][1] = $langs->trans("SupplierOrder");
133  $head[$h][2] = 'card';
134  $h++;
135 
136  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
137  {
138  $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
139  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
140  $head[$h][1] = $langs->trans('ContactsAddresses');
141  if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
142  $head[$h][2] = 'contact';
143  $h++;
144  }
145 
146  if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
147  {
148  $langs->load("stocks");
149  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
150  $head[$h][1] = $langs->trans("OrderDispatch");
151  $head[$h][2] = 'dispatch';
152  $h++;
153  }
154 
155  // Show more tabs from modules
156  // Entries must be declared in modules descriptor with line
157  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
158  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
159  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_order');
160 
161  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
162  {
163  $nbNote = 0;
164  if (!empty($object->note_private)) $nbNote++;
165  if (!empty($object->note_public)) $nbNote++;
166  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
167  $head[$h][1] = $langs->trans("Notes");
168  if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
169  $head[$h][2] = 'note';
170  $h++;
171  }
172 
173  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
174  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
175  $upload_dir = $conf->fournisseur->dir_output."/commande/".dol_sanitizeFileName($object->ref);
176  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
177  $nbLinks = Link::count($db, $object->element, $object->id);
178  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id;
179  $head[$h][1] = $langs->trans('Documents');
180  if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
181  $head[$h][2] = 'documents';
182  $h++;
183 
184  $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id;
185  $head[$h][1] .= $langs->trans("Events");
186  if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
187  {
188  $head[$h][1] .= '/';
189  $head[$h][1] .= $langs->trans("Agenda");
190  }
191  $head[$h][2] = 'info';
192  $h++;
193  complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_order', 'remove');
194  return $head;
195 }
196 
203 {
204  global $langs, $conf, $user;
205 
206  $h = 0;
207  $head = array();
208 
209  $head[$h][0] = DOL_URL_ROOT."/admin/supplier_order.php";
210  $head[$h][1] = $langs->trans("SupplierOrder");
211  $head[$h][2] = 'order';
212  $h++;
213 
214  $head[$h][0] = DOL_URL_ROOT."/admin/supplier_invoice.php";
215  $head[$h][1] = $langs->trans("SuppliersInvoice");
216  $head[$h][2] = 'invoice';
217  $h++;
218 
219  $head[$h][0] = DOL_URL_ROOT."/admin/supplier_payment.php";
220  $head[$h][1] = $langs->trans("SuppliersPayment");
221  $head[$h][2] = 'supplierpayment';
222  $h++;
223 
224  complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin');
225 
226  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php';
227  $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
228  $head[$h][2] = 'supplierorder';
229  $h++;
230 
231  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorderdet_extrafields.php';
232  $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines");
233  $head[$h][2] = 'supplierorderdet';
234  $h++;
235 
236  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php';
237  $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices");
238  $head[$h][2] = 'supplierinvoice';
239  $h++;
240 
241  $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoicedet_extrafields.php';
242  $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesLines");
243  $head[$h][2] = 'supplierinvoicedet';
244  $h++;
245 
246  complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin', 'remove');
247 
248  return $head;
249 }
ordersupplier_prepare_head($object)
Prepare array with list of tabs.
Definition: fourn.lib.php:124
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: fourn.lib.php:202
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
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:60
facturefourn_prepare_head($object)
Prepare array with list of tabs.
Definition: fourn.lib.php:34
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).