dolibarr 25.0.0-alpha
facture.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2026 Jon Bendtsen <jon.bendtsen.github@jonb.dk>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
41require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
44
45// Load translation files required by the page
46$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal'));
47
48$action = GETPOST('action', 'aZ');
49
50$id = GETPOSTINT('id');
51$ref = GETPOST('ref', 'alpha');
52
53// Security check
54$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
55$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
56$socid = '';
57if (!empty($user->socid)) {
58 $socid = $user->socid;
59}
60
61// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
62$hookmanager->initHooks(array('productstatsinvoice'));
63$extrafields = new ExtraFields($db);
64
65// Fetch optionals attributes and labels
66$extrafields->fetch_name_optionals_label('facture');
67
68$search_array_options = $extrafields->getOptionalsFromPost('facture', '', 'search_');
69
70$showmessage = GETPOST('showmessage');
71
72// Load variable for pagination
73$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
74$sortfield = GETPOST('sortfield', 'aZ09comma');
75$sortorder = GETPOST('sortorder', 'aZ09comma');
76$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
77if (empty($page) || $page == -1) {
78 $page = 0;
79} // If $page is not defined, or '' or -1
80$offset = $limit * $page;
81$pageprev = $page - 1;
82$pagenext = $page + 1;
83if (!$sortorder) {
84 $sortorder = "DESC";
85}
86if (!$sortfield) {
87 $sortfield = "f.datef";
88}
89
90$option = '';
91
92$search_date_startday = GETPOSTINT('search_date_startday');
93if (!empty($search_date_startday)) {
94 $option .= '&search_date_startday='.$search_date_startday;
95}
96$search_date_startmonth = GETPOSTINT('search_date_startmonth');
97if (!empty($search_date_startmonth)) {
98 $option .= '&search_date_startmonth='.$search_date_startmonth;
99}
100$search_date_startyear = GETPOSTINT('search_date_startyear');
101if (!empty($search_date_startyear)) {
102 $option .= '&search_date_startyear='.$search_date_startyear;
103}
104$search_date_endday = GETPOSTINT('search_date_endday');
105if (!empty($search_date_endday)) {
106 $option .= '&search_date_endday='.$search_date_endday;
107}
108$search_date_endmonth = GETPOSTINT('search_date_endmonth');
109if (!empty($search_date_endmonth)) {
110 $option .= '&search_date_endmonth='.$search_date_endmonth;
111}
112$search_date_endyear = GETPOSTINT('search_date_endyear');
113if (!empty($search_date_endyear)) {
114 $option .= '&search_date_endyear='.$search_date_endyear;
115}
116$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
117$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
118
119if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
120 $search_date_startday = '';
121 $search_date_startmonth = '';
122 $search_date_startyear = '';
123 $search_date_endday = '';
124 $search_date_endmonth = '';
125 $search_date_endyear = '';
126 $search_date_start = '';
127 $search_date_end = '';
128}
129
130$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
131
132
133/*
134 * Actions
135 */
136
137$toselect = GETPOST('toselect', 'array:int');
138$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'invoicelist';
139$massaction = GETPOST('massaction', 'alpha');
140$diroutputmassaction = isModEnabled('invoice') ? $conf->invoice->dir_output.'/temp/massgeneration/'.$user->id : '';
141
142if (GETPOST('cancel', 'alpha')) {
143 $action = 'list';
144 $massaction = '';
145}
146if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
147 $massaction = '';
148}
149if (!isModEnabled('invoice')) {
150 // The mass actions of this page rely on the invoice module (objects, permissions, upload directory)
151 $massaction = '';
152}
153$arrayfields = array(
154 'f.ref' => array('label' => "Ref", 'checked' => '1', 'position' => 5),
155 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 50),
156 's.code_client' => array('label' => "CustomerCodeShort", 'checked' => '-1', 'position' => 52),
157 'f.datef' => array('label' => "DateInvoice", 'checked' => '1', 'position' => 60),
158 'd.qty' => array('label' => "Qty", 'checked' => '1', 'position' => 65),
159 'd.total_ht' => array('label' => "AmountHT", 'checked' => '1', 'position' => 70),
160 'f.fk_statut' => array('label' => "Status", 'checked' => '1', 'position' => 1000),
161);
162
163$invoicestatic = new Facture($db);
164$societestatic = new Societe($db);
165
166$form = new Form($db);
167$formother = new FormOther($db);
168
169
170
171$arrayofmassactions = array();
172if (isModEnabled('invoice')) {
173 $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail");
174}
175$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
176$arrayofselected = is_array($toselect) ? $toselect : array();
177$selectedfields = (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
178
179
180$totalarray = array();
181$totalarray['nbfield'] = 0;
182
183$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
184$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
185if ($reshook < 0) {
186 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
187}
188if (empty($reshook) && isModEnabled('invoice')) {
189 $objectclass = 'Facture';
190 $objectlabel = 'Invoices';
191 $permissiontoread = $user->hasRight("facture", "lire");
192 $permissiontoadd = $user->hasRight("facture", "creer");
193 $permissiontodelete = $user->hasRight("facture", "supprimer");
194 $uploaddir = $conf->invoice->dir_output;
195
196 if (isset($_POST['massaction'])) {
197 $massaction = $_POST['massaction'];
198 }
199
200 if (isset($_POST['confirmmassaction']) && isset($_POST['massaction']) && $_POST['massaction'] == 'presend') {
201 global $arrayofselected;
202
203 $toselect = is_array($_POST['toselect']) ? $_POST['toselect'] : array();
204 $arrayofselected = array();
205
206 // Store only VALID IDs (those with emails)
207 foreach ($toselect as $invoice_id) {
208 $objecttmp = new Facture($db);
209 if ($objecttmp->fetch((int) $invoice_id) > 0) {
210 // Force loading the thirdparty object
211 if (empty($objecttmp->thirdparty) || !is_object($objecttmp->thirdparty)) {
212 $objecttmp->fetch_thirdparty();
213 }
214
215 // Only add to array if email exists
216 if (!empty($objecttmp->thirdparty->email)) {
217 // Store just the ID, not the object
218 $arrayofselected[] = $invoice_id;
219 }
220 }
221 }
222
223 if (empty($arrayofselected)) {
224 setEventMessages($langs->trans("DefaultStatusEmptyMandatory").' '.$langs->trans("Select"), null, 'errors');
225 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
226 exit;
227 }
228 } else {
229 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
230 }
231}
232
233
234/*
235 * View
236 */
237
238if ($id > 0 || !empty($ref)) {
239 $product = new Product($db);
240 $result = $product->fetch($id, $ref);
241
242 $object = $product;
243
244 $parameters = array('id' => $id);
245 $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks
246 if ($reshook < 0) {
247 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
248 }
249
250 $title = $langs->trans('ProductServiceCard');
251 $helpurl = '';
252 $shortlabel = dol_trunc($object->label, 16);
253 if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
254 $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers');
255 $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
256 }
257 if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
258 $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers');
259 $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
260 }
261
262 llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'mod-product page-stats_facture');
263
264 if ($result > 0) {
265 $head = product_prepare_head($product);
266 $titre = $langs->trans("CardProduct".$product->type);
267 $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
268 print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
269
270 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook
271 print $hookmanager->resPrint;
272 if ($reshook < 0) {
273 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
274 }
275
276 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
277 $object->next_prev_filter = "(te.fk_product_type:=:".((int) $object->type).")";
278
279 $shownav = 1;
280 if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
281 $shownav = 0;
282 }
283
284 dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
285
286 print '<div class="fichecenter">';
287
288 print '<div class="clearboth"></div>';
289 print '<table class="noborder tableforfield centpercent">';
290
291 $nboflines = show_stats_for_company($product, $socid);
292
293 print "</table>";
294
295 print '</div>';
296 print '<div class="clearboth"></div>';
297
298 print dol_get_fiche_end();
299
300 if ($showmessage && $nboflines > 1) {
301 // Nothing shown
302 } elseif ($user->hasRight('facture', 'lire')) {
303 $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
304 $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
305 $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
306 if (!$user->hasRight('societe', 'client', 'voir')) {
307 $sql .= ", sc.fk_soc, sc.fk_user ";
308 }
309 // Add fields from extrafields
310 if (!empty($extrafields->attributes['facture']['label'])) {
311 foreach ($extrafields->attributes['facture']['label'] as $key => $val) {
312 $sql .= ($extrafields->attributes['facture']['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
313 }
314 }
315 // Add fields from hooks
316 $parameters = array();
317 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
318 $sql .= $hookmanager->resPrint;
319 $sql = preg_replace('/,\s*$/', '', $sql);
320
321 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
322 $sql .= ", ".MAIN_DB_PREFIX."facture as f";
323 if (isset($extrafields->attributes['facture']['label']) && is_array($extrafields->attributes['facture']['label']) && count($extrafields->attributes['facture']['label'])) {
324 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'facture'."_extrafields as ef on (f.rowid = ef.fk_object)";
325 }
326 $sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
327 if (!$user->hasRight('societe', 'client', 'voir')) {
328 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
329 }
330 // Add table from hooks
331 $parameters = array();
332 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
333 $sql .= $hookmanager->resPrint;
334
335 $sql .= " WHERE f.fk_soc = s.rowid";
336 $sql .= " AND f.entity IN (".getEntity('invoice').")";
337 $sql .= " AND d.fk_facture = f.rowid";
338 $sql .= " AND d.fk_product = ".((int) $product->id);
339 if ($search_date_start) {
340 $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
341 }
342 if ($search_date_end) {
343 $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
344 }
345 if (!$user->hasRight('societe', 'client', 'voir')) {
346 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
347 }
348 if ($socid) {
349 $sql .= " AND f.fk_soc = ".((int) $socid);
350 }
351 // Add where from extra fields
352 $extrafieldsobjectkey = 'facture';
353 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
354 // Add where from hooks
355 $parameters = array();
356 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
357 $sql .= $hookmanager->resPrint;
358
359 // Add HAVING from hooks
360 $parameters = array();
361 $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
362 if (empty($reshook)) {
363 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
364 } else {
365 $sql = $hookmanager->resPrint;
366 }
367
368 $sql .= $db->order($sortfield, $sortorder);
369
370 // Calcul total qty and amount for global if full scan list
371 $total_ht = 0;
372 $total_qty = 0;
373
374 // Count total nb of records
375 $totalofrecords = '';
376 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
377 $result = $db->query($sql);
378 $totalofrecords = $db->num_rows($result);
379 }
380
381 $sql .= $db->plimit($limit + 1, $offset);
382
383 $result = $db->query($sql);
384 if ($result) {
385 $num = $db->num_rows($result);
386 // I am saving the result here, because some hooks a little later will change $result such that I can not get the contents
387 $all_rows = array();
388 $num = $db->num_rows($result);
389 while ($row = $db->fetch_object($result)) {
390 $all_rows[] = $row;
391 }
392 $db->free($result); // Free immediately
393 $result = null; // Clear the variable
394
395 $option .= '&id='.$product->id;
396
397 if ($limit > 0 && $limit != $conf->liste_limit) {
398 $option .= '&limit='.((int) $limit);
399 }
400
401 // Add $param from extra fields
402 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
403 // Add $param from hooks
404 '@phan-var-force string $param';
406 $parameters = array('param' => &$param);
407 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
408 $option .= $hookmanager->resPrint;
409
410 print '<span id="anchorundermenu" class="anchorundermenu"></span>';
411 print '<form method="post" action="'.$_SERVER ['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n";
412 print '<input type="hidden" name="token" value="'.newToken().'">';
413 print '<input type="hidden" name="page_y" value="">';
414 if (!empty($sortfield)) {
415 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
416 }
417 if (!empty($sortorder)) {
418 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
419 }
420
421 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
422 print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, $massactionbutton, $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
423
424 if ($massaction == 'presend' && !empty($arrayofselected)) {
425 // Set variables expected by the template
426 $topicmail = "SendBillRef";
427 $modelmail = "facture_send";
428 $objecttmp = new Facture($db);
429 $trackid = 'inv'.$id;
430
431 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
432 }
433
434 if (!empty($page)) {
435 $option .= '&page='.urlencode((string) ($page));
436 }
437
438 print '<div class="liste_titre liste_titre_bydiv centpercent">';
439 print '<div class="divsearchfield">';
440 print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - ';
441 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
442 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
443 $parameters = array();
444 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
445 print $hookmanager->resPrint;
446
447 print '<div style="vertical-align: middle; display: inline-block">';
448 print '<input type="image" class="liste_titre reposition" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
449 print '<input type="image" class="liste_titre reposition" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
450 print '</div>';
451 print '</div>';
452 print '</div>';
453
454 $i = 0;
455 $colspan = 3;
456 print '<div class="div-table-responsive">';
457 print '<table class="tagtable liste listwithfilterbefore centpercent">';
458 print '<tr class="liste_titre">';
459 // Action column
460 if ($conf->main_checkbox_left_column) {
461 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
462 $colspan++;
463 }
464 print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder);
465 print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder);
466 print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder);
467 print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder);
468 print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
469 print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
470 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
471 // Hook fields
472 $parameters = array('param' => $option, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
473 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
474 print $hookmanager->resPrint;
475 // Action column
476 if (!$conf->main_checkbox_left_column) {
477 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
478 }
479 print "</tr>\n";
480
481 if ($num > 0) {
482 while ($i < min($num, $limit)) {
483 $objp = $all_rows[$i];
484 if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
485 $objp->qty = -($objp->qty);
486 }
487
488 $total_ht += $objp->total_ht;
489 $total_qty += $objp->qty;
490
491 $invoicestatic->id = $objp->facid;
492 $invoicestatic->ref = $objp->ref;
493 $societestatic->fetch($objp->socid);
494 $paiement = $invoicestatic->getSommePaiement();
495
496 print '<tr data-row-id="'.$invoicestatic->id.'" class="oddeven row-with-select status2">';
497
498 // Action column
499 if ($conf->main_checkbox_left_column) {
500 print '<td class="nowrap center">';
501 if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
502 $selected = 0;
503 if (in_array($invoicestatic->id, $arrayofselected)) {
504 $selected = 1;
505 }
506 print '<input id="cb'.$invoicestatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$invoicestatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
507 }
508 print '</td>';
509 if (!$i) {
510 $totalarray['nbfield']++;
511 }
512 }
513
514 print '<td class="tdoverflowmax150">';
515 print $invoicestatic->getNomUrl(1);
516 print "</td>\n";
517 print '<td class="tdoverflowmax125">'.$societestatic->getNomUrl(1).'</td>';
518 print '<td class="tdoverflowmax125">'.dolPrintHTML($objp->code_client)."</td>\n";
519 print '<td class="center">';
520 print dol_print_date($db->jdate($objp->datef), 'dayhour')."</td>";
521 print '<td class="center">'.dolPrintHTML($objp->qty)."</td>\n";
522 print '<td class="right">'.price($objp->total_ht)."</td>\n";
523 print '<td class="right">'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5, $paiement, $objp->type).'</td>';
524 // Fields from hook
525 $parameters = array();
526 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
527 print $hookmanager->resPrint;
528
529 // Action column
530 if (!$conf->main_checkbox_left_column) {
531 print '<td class="nowrap center">';
532 if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
533 $selected = 0;
534 if (in_array($invoicestatic->id, $arrayofselected)) {
535 $selected = 1;
536 }
537 print '<input id="cb'.$invoicestatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$invoicestatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
538 }
539 print '</td>';
540 if (!$i) {
541 $totalarray['nbfield']++;
542 }
543 }
544
545 print "</tr>\n";
546 $i++;
547 }
548 }
549
550 // Total line
551 print '<tr class="liste_total">';
552 if ($num < $limit && empty($offset)) {
553 print '<td>'.$langs->trans("Total").'</td>';
554 } else {
555 print '<td>'.$form->textwithpicto($langs->trans("Total"), $langs->trans("Totalforthispage")).'</td>';
556 }
557 print '<td colspan="'.$colspan.'"></td>';
558 print '<td class="center">'.$total_qty.'</td>';
559 print '<td class="right">'.price($total_ht).'</td>';
560 print '<td></td>';
561 print "</table>";
562 print '</div>';
563 print '</form>';
564 } else {
566 }
567 }
568 }
569} else {
571}
572
573// End of page
574llxFooter();
575$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:498
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to manage invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage third parties objects (customers, suppliers, prospects...)
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
product_prepare_head($object)
Prepare array with list of tabs.
show_stats_for_company($product, $socid)
Show stats for a product.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.