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 * Copyright (C) 2026 Vincent MAURY TimGroup <vmaury@timgroup.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal'));
48
49$action = GETPOST('action', 'aZ');
50
51$id = GETPOSTINT('id');
52$ref = GETPOST('ref', 'alpha');
53
54// Security check
55$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
56$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
57$socid = '';
58if (!empty($user->socid)) {
59 $socid = $user->socid;
60}
61
62// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
63$hookmanager->initHooks(array('productstatsinvoice'));
64$extrafields = new ExtraFields($db);
65
66// Fetch optionals attributes and labels
67$extrafields->fetch_name_optionals_label('facture');
68
69$search_array_options = $extrafields->getOptionalsFromPost('facture', '', 'search_');
70
71$showmessage = GETPOST('showmessage');
72
73// Load variable for pagination
74$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
75$sortfield = GETPOST('sortfield', 'aZ09comma');
76$sortorder = GETPOST('sortorder', 'aZ09comma');
77$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
78if (empty($page) || $page == -1) {
79 $page = 0;
80} // If $page is not defined, or '' or -1
81$offset = $limit * $page;
82$pageprev = $page - 1;
83$pagenext = $page + 1;
84if (!$sortorder) {
85 $sortorder = "DESC";
86}
87if (!$sortfield) {
88 $sortfield = "f.datef";
89}
90
91$option = '';
92
93$search_date_startday = GETPOSTINT('search_date_startday');
94if (!empty($search_date_startday)) {
95 $option .= '&search_date_startday='.$search_date_startday;
96}
97$search_date_startmonth = GETPOSTINT('search_date_startmonth');
98if (!empty($search_date_startmonth)) {
99 $option .= '&search_date_startmonth='.$search_date_startmonth;
100}
101$search_date_startyear = GETPOSTINT('search_date_startyear');
102if (!empty($search_date_startyear)) {
103 $option .= '&search_date_startyear='.$search_date_startyear;
104}
105$search_date_endday = GETPOSTINT('search_date_endday');
106if (!empty($search_date_endday)) {
107 $option .= '&search_date_endday='.$search_date_endday;
108}
109$search_date_endmonth = GETPOSTINT('search_date_endmonth');
110if (!empty($search_date_endmonth)) {
111 $option .= '&search_date_endmonth='.$search_date_endmonth;
112}
113$search_date_endyear = GETPOSTINT('search_date_endyear');
114if (!empty($search_date_endyear)) {
115 $option .= '&search_date_endyear='.$search_date_endyear;
116}
117$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
118$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
119$search_type = GETPOSTINT('search_type');
120$search_company = GETPOSTINT('search_company');
121if (empty($search_type)) $search_type = -1;
122
123if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
124 $search_date_startday = '';
125 $search_date_startmonth = '';
126 $search_date_startyear = '';
127 $search_date_endday = '';
128 $search_date_endmonth = '';
129 $search_date_endyear = '';
130 $search_date_start = '';
131 $search_date_end = '';
132 $search_type = '-1';
133 $search_company = '';
134}
135
136$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
137
138
139/*
140 * Actions
141 */
142
143$toselect = GETPOST('toselect', 'array:int');
144$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'invoicelist';
145$massaction = GETPOST('massaction', 'alpha');
146$diroutputmassaction = isModEnabled('invoice') ? $conf->invoice->dir_output.'/temp/massgeneration/'.$user->id : '';
147
148if (GETPOST('cancel', 'alpha')) {
149 $action = 'list';
150 $massaction = '';
151}
152if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
153 $massaction = '';
154}
155if (!isModEnabled('invoice')) {
156 // The mass actions of this page rely on the invoice module (objects, permissions, upload directory)
157 $massaction = '';
158}
159$arrayfields = array(
160 'f.ref' => array('label' => "Ref", 'checked' => '1', 'position' => 5),
161 's.nom' => array('label' => "ThirdParty", 'checked' => '1', 'position' => 50),
162 's.code_client' => array('label' => "CustomerCodeShort", 'checked' => '-1', 'position' => 52),
163 'f.datef' => array('label' => "DateInvoice", 'checked' => '1', 'position' => 60),
164 'd.qty' => array('label' => "Qty", 'checked' => '1', 'position' => 65),
165 'd.total_ht' => array('label' => "AmountHT", 'checked' => '1', 'position' => 70),
166 'f.fk_statut' => array('label' => "Status", 'checked' => '1', 'position' => 1000),
167);
168
169$invoicestatic = new Facture($db);
170$societestatic = new Societe($db);
171
172$form = new Form($db);
173$formother = new FormOther($db);
174
175
176
177$arrayofmassactions = array();
178if (isModEnabled('invoice')) {
179 $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail");
180}
181$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
182$arrayofselected = is_array($toselect) ? $toselect : array();
183$selectedfields = (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
184
185
186$totalarray = array();
187$totalarray['nbfield'] = 0;
188
189$parameters = array('socid' => $socid, 'arrayfields' => &$arrayfields);
190$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
191if ($reshook < 0) {
192 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
193}
194if (empty($reshook) && isModEnabled('invoice')) {
195 $objectclass = 'Facture';
196 $objectlabel = 'Invoices';
197 $permissiontoread = $user->hasRight("facture", "lire");
198 $permissiontoadd = $user->hasRight("facture", "creer");
199 $permissiontodelete = $user->hasRight("facture", "supprimer");
200 $uploaddir = $conf->invoice->dir_output;
201
202 if (isset($_POST['massaction'])) {
203 $massaction = $_POST['massaction'];
204 }
205
206 if (isset($_POST['confirmmassaction']) && isset($_POST['massaction']) && $_POST['massaction'] == 'presend') {
207 global $arrayofselected;
208
209 $toselect = is_array($_POST['toselect']) ? $_POST['toselect'] : array();
210 $arrayofselected = array();
211
212 // Store only VALID IDs (those with emails)
213 foreach ($toselect as $invoice_id) {
214 $objecttmp = new Facture($db);
215 if ($objecttmp->fetch((int) $invoice_id) > 0) {
216 // Force loading the thirdparty object
217 if (empty($objecttmp->thirdparty) || !is_object($objecttmp->thirdparty)) {
218 $objecttmp->fetch_thirdparty();
219 }
220
221 // Only add to array if email exists
222 if (!empty($objecttmp->thirdparty->email)) {
223 // Store just the ID, not the object
224 $arrayofselected[] = $invoice_id;
225 }
226 }
227 }
228
229 if (empty($arrayofselected)) {
230 setEventMessages($langs->trans("DefaultStatusEmptyMandatory").' '.$langs->trans("Select"), null, 'errors');
231 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
232 exit;
233 }
234 } else {
235 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
236 }
237}
238
239
240/*
241 * View
242 */
243
244if ($id > 0 || !empty($ref)) {
245 $product = new Product($db);
246 $result = $product->fetch($id, $ref);
247
248 $object = $product;
249
250 $parameters = array('id' => $id);
251 $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks
252 if ($reshook < 0) {
253 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
254 }
255
256 $title = $langs->trans('ProductServiceCard');
257 $helpurl = '';
258 $shortlabel = dol_trunc($object->label, 16);
259 if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
260 $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers');
261 $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
262 }
263 if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
264 $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers');
265 $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
266 }
267
268 llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'mod-product page-stats_facture');
269
270 if ($result > 0) {
271 $head = product_prepare_head($product);
272 $titre = $langs->trans("CardProduct".$product->type);
273 $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
274 print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
275
276 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook
277 print $hookmanager->resPrint;
278 if ($reshook < 0) {
279 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
280 }
281
282 $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
283 $object->next_prev_filter = "(te.fk_product_type:=:".((int) $object->type).")";
284
285 $shownav = 1;
286 if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
287 $shownav = 0;
288 }
289
290 dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
291
292 print '<div class="fichecenter">';
293
294 print '<div class="clearboth"></div>';
295 print '<table class="noborder tableforfield centpercent">';
296
297 $nboflines = show_stats_for_company($product, $socid);
298
299 print "</table>";
300
301 print '</div>';
302 print '<div class="clearboth"></div>';
303
304 print dol_get_fiche_end();
305
306 if ($showmessage && $nboflines > 1) {
307 // Nothing shown
308 } elseif ($user->hasRight('facture', 'lire')) {
309 $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
310 $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
311 $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
312 if (!$user->hasRight('societe', 'client', 'voir')) {
313 $sql .= ", sc.fk_soc, sc.fk_user ";
314 }
315 // Add fields from extrafields
316 if (!empty($extrafields->attributes['facture']['label'])) {
317 foreach ($extrafields->attributes['facture']['label'] as $key => $val) {
318 $sql .= ($extrafields->attributes['facture']['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
319 }
320 }
321 // Add fields from hooks
322 $parameters = array();
323 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
324 $sql .= $hookmanager->resPrint;
325 $sql = preg_replace('/,\s*$/', '', $sql);
326
327 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
328 $sql .= ", ".MAIN_DB_PREFIX."facture as f";
329 if (isset($extrafields->attributes['facture']['label']) && is_array($extrafields->attributes['facture']['label']) && count($extrafields->attributes['facture']['label'])) {
330 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'facture'."_extrafields as ef on (f.rowid = ef.fk_object)";
331 }
332 $sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
333 if (!$user->hasRight('societe', 'client', 'voir')) {
334 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
335 }
336 // Add table from hooks
337 $parameters = array();
338 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
339 $sql .= $hookmanager->resPrint;
340
341 $sql .= " WHERE f.fk_soc = s.rowid";
342 $sql .= " AND f.entity IN (".getEntity('invoice').")";
343 $sql .= " AND d.fk_facture = f.rowid";
344 $sql .= " AND d.fk_product = ".((int) $product->id);
345 if ($search_date_start) {
346 $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
347 }
348 if ($search_date_end) {
349 $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
350 }
351 if ($search_type != '' && $search_type != '-1') {
352 $sql .= " AND f.type = ".((int) $search_type);
353 }
354 if (!$user->hasRight('societe', 'client', 'voir')) {
355 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
356 }
357 if ($socid) {
358 $sql .= " AND f.fk_soc = ".((int) $socid);
359 } elseif ($search_company > 0) {
360 $sql .= " AND f.fk_soc = ".((int) $search_company);
361 }
362
363 // Add where from extra fields
364 $extrafieldsobjectkey = 'facture';
365 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
366 // Add where from hooks
367 $parameters = array();
368 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
369 $sql .= $hookmanager->resPrint;
370
371 // Add HAVING from hooks
372 $parameters = array();
373 $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
374 if (empty($reshook)) {
375 $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint;
376 } else {
377 $sql = $hookmanager->resPrint;
378 }
379
380 $sql .= $db->order($sortfield, $sortorder);
381
382 // Calcul total qty and amount for global if full scan list
383 $total_ht = 0;
384 $total_qty = 0;
385
386 // Count total nb of records
387 $totalofrecords = '';
388 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
389 $result = $db->query($sql);
390 $totalofrecords = $db->num_rows($result);
391 }
392
393 $sql .= $db->plimit($limit + 1, $offset);
394
395 $result = $db->query($sql);
396 if ($result) {
397 $num = $db->num_rows($result);
398 // I am saving the result here, because some hooks a little later will change $result such that I can not get the contents
399 $all_rows = array();
400 $num = $db->num_rows($result);
401 while ($row = $db->fetch_object($result)) {
402 $all_rows[] = $row;
403 }
404 $db->free($result); // Free immediately
405 $result = null; // Clear the variable
406
407 $option .= '&id='.$product->id;
408
409 if ($limit > 0 && $limit != $conf->liste_limit) {
410 $option .= '&limit='.((int) $limit);
411 }
412
413 // Add $param from extra fields
414 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
415 // Add $param from hooks
416 '@phan-var-force string $param';
418 $parameters = array('param' => &$param);
419 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
420 $option .= $hookmanager->resPrint;
421
422 print '<span id="anchorundermenu" class="anchorundermenu"></span>';
423 print '<form method="post" action="'.$_SERVER ['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n";
424 print '<input type="hidden" name="token" value="'.newToken().'">';
425 print '<input type="hidden" name="page_y" value="">';
426 if (!empty($sortfield)) {
427 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
428 }
429 if (!empty($sortorder)) {
430 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
431 }
432
433 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
434 print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, $massactionbutton, $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1);
435
436 if ($massaction == 'presend' && !empty($arrayofselected)) {
437 // Set variables expected by the template
438 $topicmail = "SendBillRef";
439 $modelmail = "facture_send";
440 $objecttmp = new Facture($db);
441 $trackid = 'inv'.$id;
442
443 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
444 }
445
446 if (!empty($page)) {
447 $option .= '&page='.urlencode((string) ($page));
448 }
449
450 print '<div class="liste_titre liste_titre_bydiv centpercent">';
451 print '<div class="divsearchfield">';
452 print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - ';
453 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
454 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
455 if (empty($socid)) print $langs->trans('Company').' : '.$form->select_company($search_company, 'search_company', '(s.client:in:1,2,3)', 1);
456 print $langs->trans('Type').' : ';
457 $listtype = array(
458 Facture::TYPE_STANDARD => $langs->trans("InvoiceStandard"),
459 Facture::TYPE_DEPOSIT => $langs->trans("InvoiceDeposit"),
460 Facture::TYPE_CREDIT_NOTE => $langs->trans("InvoiceAvoir"),
461 Facture::TYPE_REPLACEMENT => $langs->trans("InvoiceReplacement"),
462 );
463 if (getDolGlobalString('INVOICE_USE_SITUATION')) {
464 $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
465 }
466 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
467 print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth75');
468
469 $parameters = array();
470 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
471 print $hookmanager->resPrint;
472
473 print '<div style="vertical-align: middle; display: inline-block">';
474 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")).'">';
475 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")).'">';
476 print '</div>';
477 print '</div>';
478 print '</div>';
479
480 $i = 0;
481 $colspan = 3;
482 print '<div class="div-table-responsive">';
483 print '<table class="tagtable liste listwithfilterbefore centpercent">';
484 print '<tr class="liste_titre">';
485 // Action column
486 if ($conf->main_checkbox_left_column) {
487 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
488 $colspan++;
489 }
490 print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder);
491 print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder);
492 print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder);
493 print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder);
494 print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
495 print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
496 print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
497 // Hook fields
498 $parameters = array('param' => $option, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
499 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
500 print $hookmanager->resPrint;
501 // Action column
502 if (!$conf->main_checkbox_left_column) {
503 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
504 }
505 print "</tr>\n";
506
507 if ($num > 0) {
508 while ($i < min($num, $limit)) {
509 $objp = $all_rows[$i];
510 if ($objp->type == Facture::TYPE_CREDIT_NOTE) {
511 $objp->qty = -($objp->qty);
512 }
513
514 $total_ht += $objp->total_ht;
515 $total_qty += $objp->qty;
516
517 $invoicestatic->id = $objp->facid;
518 $invoicestatic->ref = $objp->ref;
519 $societestatic->fetch($objp->socid);
520 $paiement = $invoicestatic->getSommePaiement();
521
522 print '<tr data-row-id="'.$invoicestatic->id.'" class="oddeven row-with-select status2">';
523
524 // Action column
525 if ($conf->main_checkbox_left_column) {
526 print '<td class="nowrap center">';
527 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
528 $selected = 0;
529 if (in_array($invoicestatic->id, $arrayofselected)) {
530 $selected = 1;
531 }
532 print '<input id="cb'.$invoicestatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$invoicestatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
533 }
534 print '</td>';
535 if (!$i) {
536 $totalarray['nbfield']++;
537 }
538 }
539
540 print '<td class="tdoverflowmax150">';
541 print $invoicestatic->getNomUrl(1);
542 print "</td>\n";
543 print '<td class="tdoverflowmax125">'.$societestatic->getNomUrl(1).'</td>';
544 print '<td class="tdoverflowmax125">'.dolPrintHTML($objp->code_client)."</td>\n";
545 print '<td class="center">';
546 print dol_print_date($db->jdate($objp->datef), 'dayhour')."</td>";
547 print '<td class="center">'.dolPrintHTML($objp->qty)."</td>\n";
548 print '<td class="right">'.price($objp->total_ht)."</td>\n";
549 print '<td class="right">'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5, $paiement, $objp->type).'</td>';
550 // Fields from hook
551 $parameters = array();
552 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
553 print $hookmanager->resPrint;
554
555 // Action column
556 if (!$conf->main_checkbox_left_column) {
557 print '<td class="nowrap center">';
558 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
559 $selected = 0;
560 if (in_array($invoicestatic->id, $arrayofselected)) {
561 $selected = 1;
562 }
563 print '<input id="cb'.$invoicestatic->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$invoicestatic->id.'"'.($selected ? ' checked="checked"' : '').'>';
564 }
565 print '</td>';
566 if (!$i) {
567 $totalarray['nbfield']++;
568 }
569 }
570
571 print "</tr>\n";
572 $i++;
573 }
574 }
575
576 // Total line
577 print '<tr class="liste_total">';
578 if ($num < $limit && empty($offset)) {
579 print '<td>'.$langs->trans("Total").'</td>';
580 } else {
581 print '<td>'.$form->textwithpicto($langs->trans("Total"), $langs->trans("Totalforthispage")).'</td>';
582 }
583 print '<td colspan="'.$colspan.'"></td>';
584 print '<td class="center">'.$total_qty.'</td>';
585 print '<td class="right">'.price($total_ht).'</td>';
586 print '<td></td>';
587 print "</table>";
588 print '</div>';
589 print '</form>';
590 } else {
591 dol_print_error($db);
592 }
593 }
594 }
595} else {
596 dol_print_error();
597}
598
599// End of page
600llxFooter();
601$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
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_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
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:
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...
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_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.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:181
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, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.