dolibarr  13.0.2
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@inodbox.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 <https://www.gnu.org/licenses/>.
21  * or see https://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('CustomerInvoice');
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 marginleftonlyshort">'.$nbContact.'</span>';
54  $head[$h][2] = 'contact';
55  $h++;
56  }
57 
58  if (!empty($conf->prelevement->enabled))
59  {
60  $nbStandingOrders = 0;
61  $sql = "SELECT COUNT(pfd.rowid) as nb";
62  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
63  $sql .= " WHERE pfd.fk_facture = ".$object->id;
64  $sql .= " AND pfd.ext_payment_id IS NULL";
65  $resql = $db->query($sql);
66  if ($resql)
67  {
68  $obj = $db->fetch_object($resql);
69  if ($obj) $nbStandingOrders = $obj->nb;
70  } else dol_print_error($db);
71  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id;
72  $head[$h][1] = $langs->trans('StandingOrders');
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, '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.'/compta/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->facture->dir_output."/".dol_sanitizeFileName($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.'/compta/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.'/compta/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, 'invoice', 'remove');
113 
114  return $head;
115 }
116 
123 {
124  global $langs, $conf, $user;
125 
126  $h = 0;
127  $head = array();
128 
129  $head[$h][0] = DOL_URL_ROOT.'/admin/facture.php';
130  $head[$h][1] = $langs->trans("Miscellaneous");
131  $head[$h][2] = 'general';
132  $h++;
133 
134  $head[$h][0] = DOL_URL_ROOT.'/admin/payment.php';
135  $head[$h][1] = $langs->trans("Payments");
136  $head[$h][2] = 'payment';
137  $h++;
138 
139  // Show more tabs from modules
140  // Entries must be declared in modules descriptor with line
141  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
142  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
143  complete_head_from_modules($conf, $langs, null, $head, $h, 'invoice_admin');
144 
145  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php';
146  $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices");
147  $head[$h][2] = 'attributes';
148  $h++;
149 
150  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_cust_extrafields.php';
151  $head[$h][1] = $langs->trans("ExtraFieldsLines");
152  $head[$h][2] = 'attributeslines';
153  $h++;
154 
155  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_rec_cust_extrafields.php';
156  $head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoicesRec");
157  $head[$h][2] = 'attributesrec';
158  $h++;
159 
160  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_rec_cust_extrafields.php';
161  $head[$h][1] = $langs->trans("ExtraFieldsLinesRec");
162  $head[$h][2] = 'attributeslinesrec';
163  $h++;
164 
165  if ($conf->global->INVOICE_USE_SITUATION) { // Warning, implementation is seriously bugged and a new one not compatible is expected to become stable
166  $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php';
167  $head[$h][1] = $langs->trans("InvoiceSituation");
168  $head[$h][2] = 'situation';
169  $h++;
170  }
171 
172  complete_head_from_modules($conf, $langs, null, $head, $h, 'invoice_admin', 'remove');
173 
174  return $head;
175 }
176 
177 
184 function invoice_rec_prepare_head($object)
185 {
186  global $db, $langs, $conf;
187 
188  $h = 0;
189  $head = array();
190 
191  $head[$h][0] = DOL_URL_ROOT.'/compta/facture/card-rec.php?id='.$object->id;
192  $head[$h][1] = $langs->trans("RepeatableInvoice");
193  $head[$h][2] = 'card';
194  $h++;
195 
196  // Show more tabs from modules
197  // Entries must be declared in modules descriptor with line
198  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
199  // $this->tabs = array('entity:-tabname); to remove a tab
200  complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice-rec');
201 
202  complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice-rec', 'remove');
203 
204  return $head;
205 }
invoice_admin_prepare_head()
Return array head with list of tabs to view object informations.
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
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).
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object informations.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
Definition: invoice.lib.php:36