dolibarr  7.0.0-beta
invoice.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
4  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
5  * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
7  * Copyright (C) 2017 ATM-CONSULTING <contact@atm-consulting.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  * or see http://www.gnu.org/
22  */
23 
36 function facture_prepare_head($object)
37 {
38  global $db, $langs, $conf;
39 
40  $h = 0;
41  $head = array();
42 
43  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$object->id;
44  $head[$h][1] = $langs->trans('Card');
45  $head[$h][2] = 'compta';
46  $h++;
47 
48  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
49  {
50  $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
51  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
52  $head[$h][1] = $langs->trans('ContactsAddresses');
53  if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
54  $head[$h][2] = 'contact';
55  $h++;
56  }
57 
58  //if ($fac->mode_reglement_code == 'PRE')
59  if (! empty($conf->prelevement->enabled))
60  {
61  $nbStandingOrders=0;
62  $sql = "SELECT COUNT(pfd.rowid) as nb";
63  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
64  $sql .= " WHERE pfd.fk_facture = ".$object->id;
65  $resql=$db->query($sql);
66  if ($resql)
67  {
68  $obj=$db->fetch_object($resql);
69  if ($obj) $nbStandingOrders = $obj->nb;
70  }
71  else dol_print_error($db);
72  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id;
73  $head[$h][1] = $langs->trans('StandingOrders');
74  if ($nbStandingOrders > 0) $head[$h][1].= ' <span class="badge">'.$nbStandingOrders.'</span>';
75  $head[$h][2] = 'standingorders';
76  $h++;
77  }
78 
79  // Show more tabs from modules
80  // Entries must be declared in modules descriptor with line
81  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
82  // $this->tabs = array('entity:-tabname); to remove a tab
83  complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice');
84 
85  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
86  {
87  $nbNote = 0;
88  if(!empty($object->note_private)) $nbNote++;
89  if(!empty($object->note_public)) $nbNote++;
90  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
91  $head[$h][1] = $langs->trans('Notes');
92  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
93  $head[$h][2] = 'note';
94  $h++;
95  }
96 
97  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
98  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
99  $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
100  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
101  $nbLinks=Link::count($db, $object->element, $object->id);
102  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id;
103  $head[$h][1] = $langs->trans('Documents');
104  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
105  $head[$h][2] = 'documents';
106  $h++;
107 
108  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$object->id;
109  $head[$h][1] = $langs->trans('Info');
110  $head[$h][2] = 'info';
111  $h++;
112 
113  complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice','remove');
114 
115  return $head;
116 }
117 
124 {
125  global $langs, $conf, $user;
126 
127  $h = 0;
128  $head = array();
129 
130  $head[$h][0] = DOL_URL_ROOT.'/admin/facture.php';
131  $head[$h][1] = $langs->trans("Miscellaneous");
132  $head[$h][2] = 'general';
133  $h++;
134 
135  $head[$h][0] = DOL_URL_ROOT.'/admin/payment.php';
136  $head[$h][1] = $langs->trans("Payments");
137  $head[$h][2] = 'payment';
138  $h++;
139 
140  // Show more tabs from modules
141  // Entries must be declared in modules descriptor with line
142  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
143  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
144  complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin');
145 
146  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php';
147  $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices");
148  $head[$h][2] = 'attributes';
149  $h++;
150 
151  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_cust_extrafields.php';
152  $head[$h][1] = $langs->trans("ExtraFieldsLines");
153  $head[$h][2] = 'attributeslines';
154  $h++;
155 
156  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_rec_cust_extrafields.php';
157  $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoicesRec");
158  $head[$h][2] = 'attributesrec';
159  $h++;
160 
161  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_rec_cust_extrafields.php';
162  $head[$h][1] = $langs->trans("ExtraFieldsLinesRec");
163  $head[$h][2] = 'attributeslinesrec';
164  $h++;
165 
166  complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin','remove');
167 
168  return $head;
169 }
170 
171 
172 function invoice_rec_prepare_head($object)
173 {
174  global $db, $langs, $conf;
175 
176  $h = 0;
177  $head = array();
178 
179  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?id='.$object->id;
180  $head[$h][1] = $langs->trans("CardBill");
181  $head[$h][2] = 'card';
182  $h++;
183 
184  // Show more tabs from modules
185  // Entries must be declared in modules descriptor with line
186  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
187  // $this->tabs = array('entity:-tabname); to remove a tab
188  complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice-rec');
189 
190  complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice-rec','remove');
191 
192  return $head;
193 }
194 
195 
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_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
invoice_admin_prepare_head()
Return array head with list of tabs to view object informations.
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
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->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)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
Definition: invoice.lib.php:36