dolibarr 22.0.5
invoicetemplate_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2003 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) 2013 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
8 * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
9 * Copyright (C) 2015-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
10 * Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
11 * Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr>
12 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35// Load Dolibarr environment
36require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
38require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
46
55// Load translation files required by the page
56$langs->loadLangs(array('companies', 'bills', 'compta', 'admin', 'other'));
57
58$action = GETPOST('action', 'alpha');
59$massaction = GETPOST('massaction', 'alpha');
60$show_files = GETPOSTINT('show_files');
61$confirm = GETPOST('confirm', 'alpha');
62$cancel = GETPOST('cancel', 'alpha');
63$toselect = GETPOST('toselect', 'array');
64$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
65$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
66$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
67$groupby = GETPOST('groupby', 'aZ09');
68
69$socid = GETPOSTINT('socid');
70
71$id = (GETPOSTINT('facid') ? GETPOSTINT('facid') : GETPOSTINT('id'));
72$lineid = GETPOSTINT('lineid');
73$ref = GETPOST('ref', 'alpha');
74if ($user->socid) {
75 $socid = $user->socid;
76}
77$objecttype = 'facture_rec';
78if ($action == "create" || $action == "add") {
79 $objecttype = '';
80}
81
82$search_ref = GETPOST('search_ref');
83$search_societe = GETPOST('search_societe');
84$search_montant_ht = GETPOST('search_montant_ht');
85$search_montant_vat = GETPOST('search_montant_vat');
86$search_montant_ttc = GETPOST('search_montant_ttc');
87$search_payment_mode = GETPOST('search_payment_mode');
88$search_payment_term = GETPOST('search_payment_term');
89$search_date_startday = GETPOSTINT('search_date_startday');
90$search_date_startmonth = GETPOSTINT('search_date_startmonth');
91$search_date_startyear = GETPOSTINT('search_date_startyear');
92$search_date_endday = GETPOSTINT('search_date_endday');
93$search_date_endmonth = GETPOSTINT('search_date_endmonth');
94$search_date_endyear = GETPOSTINT('search_date_endyear');
95$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
96$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
97$search_date_when_startday = GETPOSTINT('search_date_when_startday');
98$search_date_when_startmonth = GETPOSTINT('search_date_when_startmonth');
99$search_date_when_startyear = GETPOSTINT('search_date_when_startyear');
100$search_date_when_endday = GETPOSTINT('search_date_when_endday');
101$search_date_when_endmonth = GETPOSTINT('search_date_when_endmonth');
102$search_date_when_endyear = GETPOSTINT('search_date_when_endyear');
103$search_date_when_start = dol_mktime(0, 0, 0, $search_date_when_startmonth, $search_date_when_startday, $search_date_when_startyear); // Use tzserver
104$search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $search_date_when_endday, $search_date_when_endyear);
105$search_recurring = GETPOST('search_recurring', 'intcomma');
106$search_frequency = GETPOST('search_frequency', 'alpha');
107$search_unit_frequency = GETPOST('search_unit_frequency', 'alpha');
108$search_nb_gen_done = GETPOST('search_nb_gen_done', 'alpha');
109$search_status = GETPOST('search_status', 'intcomma');
110
111$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
112$sortfield = GETPOST('sortfield', 'aZ09comma');
113$sortorder = GETPOST('sortorder', 'aZ09comma');
114$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
115if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
116 // If $page is not defined, or '' or -1 or if we click on clear filters
117 $page = 0;
118}
119$offset = $limit * $page;
120$pageprev = $page - 1;
121$pagenext = $page + 1;
122
123// Initialize a technical objects
124$object = new FactureRec($db);
125$extrafields = new ExtraFields($db);
126
127if (($id > 0 || $ref) && $action != 'create' && $action != 'add') {
128 $ret = $object->fetch($id, $ref);
129 if (!$ret) {
130 setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
131 }
132}
133
134// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
135$hookmanager->initHooks(array('invoicereclist'));
136
137// Fetch optionals attributes and labels
138$extrafields->fetch_name_optionals_label($object->table_element);
139
140$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
141
142// Default sort order (if not yet defined by previous GETPOST)
143if (!$sortorder) {
144 $sortorder = 'DESC';
145}
146if (!$sortfield) {
147 $sortfield = 'f.titre';
148}
149
150$arrayfields = array(
151 'f.titre' => array('label' => "Ref", 'checked' => '1'),
152 's.nom' => array('label' => "ThirdParty", 'checked' => '1'),
153 'f.total_ht' => array('label' => "AmountHT", 'checked' => '1'),
154 'f.total_tva' => array('label' => "AmountVAT", 'checked' => '-1'),
155 'f.total_ttc' => array('label' => "AmountTTC", 'checked' => '1'),
156 'f.fk_mode_reglement' => array('label' => "PaymentMode", 'checked' => '0'),
157 'f.fk_cond_reglement' => array('label' => "PaymentTerm", 'checked' => '0'),
158 'recurring' => array('label' => "RecurringInvoice", 'checked' => '1'),
159 'f.frequency' => array('label' => "Frequency", 'checked' => '1'),
160 'f.unit_frequency' => array('label' => "FrequencyUnit", 'checked' => '1'),
161 'f.nb_gen_done' => array('label' => "NbOfGenerationDoneShort", 'checked' => '1'),
162 'f.date_last_gen' => array('label' => "DateLastGenerationShort", 'checked' => '1'),
163 'f.date_when' => array('label' => "NextDateToExecutionShort", 'checked' => '1'),
164 'f.fk_user_author' => array('label' => "UserCreation", 'checked' => '0', 'position' => 500),
165 'f.fk_user_modif' => array('label' => "UserModification", 'checked' => '0', 'position' => 505),
166 'f.datec' => array('label' => "DateCreation", 'checked' => '0', 'position' => 520),
167 'f.tms' => array('label' => "DateModificationShort", 'checked' => '0', 'position' => 525),
168 'status' => array('label' => "Status", 'checked' => '1', 'position' => 1000),
169);
170// Extra fields
171include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
172
173$object->fields = dol_sort_array($object->fields, 'position');
174$arrayfields = dol_sort_array($arrayfields, 'position');
175
176if ($socid > 0) {
177 $tmpthirdparty = new Societe($db);
178 $res = $tmpthirdparty->fetch($socid);
179 if ($res > 0) {
180 $search_societe = $tmpthirdparty->name;
181 }
182}
183
184$objecttype = 'facture_rec';
185
186$permissiontoread = $user->hasRight("facture", "read");
187$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php
188$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php
189$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php
190$permissiontodelete = $user->hasRight("facture", "delete");
191
192$uploaddir = $conf->facture->dir_output;
193
194// Security check
195$result = restrictedArea($user, 'facture', $object->id, $objecttype);
196
197
198/*
199 * Actions
200 */
201
202if (GETPOST('cancel', 'alpha')) {
203 $action = 'list';
204 $massaction = '';
205}
206if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
207 $massaction = '';
208}
209
210$parameters = array('arrayfields' => &$arrayfields, 'socid' => $socid);
211$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
212if ($reshook < 0) {
213 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
214}
215
216if (empty($reshook)) {
217 /*if (GETPOST('cancel', 'alpha')) {
218 $action = '';
219 }*/
220
221 // Selection of new fields
222 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
223
224 // Purge search criteria
225 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
226 $search_ref = '';
227 $search_societe = '';
228 $search_montant_ht = '';
229 $search_montant_vat = '';
230 $search_montant_ttc = '';
231 $search_payment_mode = '';
232 $search_payment_term = '';
233 $search_date_startday = '';
234 $search_date_startmonth = '';
235 $search_date_startyear = '';
236 $search_date_endday = '';
237 $search_date_endmonth = '';
238 $search_date_endyear = '';
239 $search_date_start = '';
240 $search_date_end = '';
241 $search_date_when_startday = '';
242 $search_date_when_startmonth = '';
243 $search_date_when_startyear = '';
244 $search_date_when_endday = '';
245 $search_date_when_endmonth = '';
246 $search_date_when_endyear = '';
247 $search_date_when_start = '';
248 $search_date_when_end = '';
249 $search_recurring = '';
250 $search_frequency = '';
251 $search_unit_frequency = '';
252 $search_nb_gen_done = '';
253 $search_status = '';
254 $toselect = array();
255 $search_array_options = array();
256 }
257 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
258 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
259 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
260 }
261
262 // Mass actions
263 /*$objectclass = 'MyObject';
264 $objectlabel = 'MyObject';
265 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
266}
267
268
269/*
270 * View
271 */
272
273$form = new Form($db);
274$formother = new FormOther($db);
275if (isModEnabled('project')) {
276 $formproject = new FormProjets($db);
277}
278$companystatic = new Societe($db);
279$invoicerectmp = new FactureRec($db);
280$tmpuser = new User($db);
281
282$now = dol_now();
283
284$help_url = '';
285$title = $langs->trans("RepeatableInvoices");
286$morejs = array();
287$morecss = array();
288
289$tmparray = dol_getdate($now);
290$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
291
292// Build and execute select
293// --------------------------------------------------------------------
294
295$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.entity, f.titre as title, f.total_ht, f.total_tva, f.total_ttc, f.frequency, f.unit_frequency,";
296$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
297$sql .= " f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
298$sql .= " f.fk_cond_reglement, f.fk_mode_reglement";
299// Add fields from extrafields
300if (!empty($extrafields->attributes[$object->table_element]['label'])) {
301 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
302 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
303 }
304}
305// Add fields from hooks
306$parameters = array();
307$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
308$sql .= $hookmanager->resPrint;
309$sql = preg_replace('/,\s*$/', '', $sql);
310
311$sqlfields = $sql; // $sql fields to remove for count total
312
313$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f";
314$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
315if (!$user->hasRight('societe', 'client', 'voir')) {
316 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
317}
318// Add table from hooks
319$parameters = array();
320$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
321$sql .= $hookmanager->resPrint;
322
323$sql .= " WHERE f.fk_soc = s.rowid";
324$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
325if (!$user->hasRight("societe", "client", "voir") && !$socid) {
326 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
327}
328if ($search_ref) {
329 $sql .= natural_search('f.titre', $search_ref);
330}
331if ($socid) {
332 $sql .= ' AND s.rowid = '.(int) $socid;
333}
334if ($search_societe) {
335 $sql .= natural_search('s.nom', $search_societe);
336}
337if ($search_montant_ht != '') {
338 $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
339}
340if ($search_montant_vat != '') {
341 $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
342}
343if ($search_montant_ttc != '') {
344 $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
345}
346if (!empty($search_payment_mode) && $search_payment_mode != '-1') {
347 $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
348}
349if (!empty($search_payment_term) && $search_payment_term != '-1') {
350 $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
351}
352if ($search_recurring == '1') {
353 $sql .= ' AND f.frequency > 0';
354}
355if ($search_recurring == '0') {
356 $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
357}
358if ($search_frequency != '') {
359 $sql .= natural_search('f.frequency', $search_frequency, 1);
360}
361if ($search_unit_frequency != '') {
362 $sql .= ' AND f.frequency > 0';
363 $sql .= natural_search('f.unit_frequency', $search_unit_frequency);
364}
365if ($search_nb_gen_done != '') {
366 $sql .= natural_search("f.nb_gen_done", $search_nb_gen_done, 1);
367}
368if ($search_status != '' && $search_status >= -1) {
369 if ($search_status == 0) {
370 $sql .= ' AND frequency = 0 AND suspended = 0';
371 }
372 if ($search_status == 1) {
373 $sql .= ' AND frequency != 0 AND suspended = 0';
374 }
375 if ($search_status == -1) {
376 $sql .= ' AND suspended = 1';
377 }
378}
379if ($search_date_start) {
380 $sql .= " AND f.date_last_gen >= '".$db->idate($search_date_start)."'";
381}
382if ($search_date_end) {
383 $sql .= " AND f.date_last_gen <= '".$db->idate($search_date_end)."'";
384}
385if ($search_date_when_start) {
386 $sql .= " AND f.date_when >= '".$db->idate($search_date_when_start)."'";
387}
388if ($search_date_when_end) {
389 $sql .= " AND f.date_when <= '".$db->idate($search_date_when_end)."'";
390}
391// Add where from extra fields
392include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
393
394// Count total nb of records
395$nbtotalofrecords = '';
396if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
397 /* The fast and low memory method to get and count full list converts the sql into a sql count */
398 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
399 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
400 $resql = $db->query($sqlforcount);
401 if ($resql) {
402 $objforcount = $db->fetch_object($resql);
403 $nbtotalofrecords = $objforcount->nbtotalofrecords;
404 } else {
405 dol_print_error($db);
406 }
407
408 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
409 $page = 0;
410 $offset = 0;
411 }
412 $db->free($resql);
413}
414
415$tmpsortfield = $sortfield;
416if ($tmpsortfield == 'recurring') {
417 $tmpsortfield = 'f.frequency';
418}
419
420// Complete request and execute it with limit
421$sql .= $db->order($tmpsortfield, $sortorder);
422if ($limit) {
423 $sql .= $db->plimit($limit + 1, $offset);
424}
425
426$resql = $db->query($sql);
427if (!$resql) {
428 dol_print_error($db);
429 exit;
430}
431
432$num = $db->num_rows($resql);
433
434
435// Output page
436// --------------------------------------------------------------------
437
438llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
439
440$arrayofselected = is_array($toselect) ? $toselect : array();
441
442$param = '';
443if (!empty($mode)) {
444 $param .= '&mode='.urlencode($mode);
445}
446if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
447 $param .= '&contextpage='.urlencode($contextpage);
448}
449if ($limit > 0 && $limit != $conf->liste_limit) {
450 $param .= '&limit='.((int) $limit);
451}
452if ($optioncss != '') {
453 $param .= '&optioncss='.urlencode($optioncss);
454}
455if ($groupby != '') {
456 $param .= '&groupby='.urlencode($groupby);
457}
458if ($socid > 0) {
459 $param .= '&socid='.urlencode((string) ($socid));
460}
461if ($search_date_startday) {
462 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
463}
464if ($search_date_startmonth) {
465 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
466}
467if ($search_date_startyear) {
468 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
469}
470if ($search_date_endday) {
471 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
472}
473if ($search_date_endmonth) {
474 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
475}
476if ($search_date_endyear) {
477 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
478}
479if ($search_date_when_startday) {
480 $param .= '&search_date_when_startday='.urlencode((string) ($search_date_when_startday));
481}
482if ($search_date_when_startmonth) {
483 $param .= '&search_date_when_startmonth='.urlencode((string) ($search_date_when_startmonth));
484}
485if ($search_date_when_startyear) {
486 $param .= '&search_date_when_startyear='.urlencode((string) ($search_date_when_startyear));
487}
488if ($search_date_when_endday) {
489 $param .= '&search_date_when_endday='.urlencode((string) ($search_date_when_endday));
490}
491if ($search_date_when_endmonth) {
492 $param .= '&search_date_when_endmonth='.urlencode((string) ($search_date_when_endmonth));
493}
494if ($search_date_when_endyear) {
495 $param .= '&search_date_when_endyear='.urlencode((string) ($search_date_when_endyear));
496}
497if ($search_ref) {
498 $param .= '&search_ref='.urlencode($search_ref);
499}
500if ($search_societe) {
501 $param .= '&search_societe='.urlencode($search_societe);
502}
503if ($search_montant_ht != '') {
504 $param .= '&search_montant_ht='.urlencode($search_montant_ht);
505}
506if ($search_montant_vat != '') {
507 $param .= '&search_montant_vat='.urlencode($search_montant_vat);
508}
509if ($search_montant_ttc != '') {
510 $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
511}
512if ($search_payment_mode != '') {
513 $param .= '&search_payment_mode='.urlencode($search_payment_mode);
514}
515if ($search_payment_term != '') {
516 $param .= '&search_payment_term='.urlencode($search_payment_term);
517}
518if ($search_recurring != '' && $search_recurring != '-1') {
519 $param .= '&search_recurring='.urlencode($search_recurring);
520}
521if ($search_frequency > 0) {
522 $param .= '&search_frequency='.urlencode($search_frequency);
523}
524if ($search_unit_frequency != '') {
525 $param .= '&search_unit_frequency='.urlencode($search_unit_frequency);
526}
527if ($search_nb_gen_done != '') {
528 $param .= '&search_nb_gen_done='.urlencode($search_nb_gen_done);
529}
530if ($search_status != '') {
531 $param .= '&search_status='.urlencode($search_status);
532}
533// Add $param from extra fields
534include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
535// Add $param from hooks
536$parameters = array('param' => &$param);
537$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
538$param .= $hookmanager->resPrint;
539
540// List of mass actions available
541$arrayofmassactions = array(
542 //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
543 //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
544 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
545 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
546);
547
548$massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend' => $langs->trans("SendByMail"), 'builddoc' => $langs->trans("PDFMerge")));
549
550$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
551$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup
552$selectedfields = ($mode != 'kanban' ? $htmlofselectarray : '');
553//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
554
555print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
556if ($optioncss != '') {
557 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
558}
559print '<input type="hidden" name="token" value="'.newToken().'">';
560print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
561print '<input type="hidden" name="action" value="list">';
562print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
563print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
564print '<input type="hidden" name="page" value="'.$page.'">';
565print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
566print '<input type="hidden" name="page_y" value="">';
567print '<input type="hidden" name="mode" value="'.$mode.'">';
568
569
570print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
571
572print '<span class="opacitymedium">'.$langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'</span><br><br>';
573
574$i = 0;
575
576$moreforfilter = '';
577
578$parameters = array();
579$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
580if (empty($reshook)) {
581 $moreforfilter .= $hookmanager->resPrint;
582} else {
583 $moreforfilter = $hookmanager->resPrint;
584}
585
586if (!empty($moreforfilter)) {
587 print '<div class="liste_titre liste_titre_bydiv centpercent">';
588 print $moreforfilter;
589 print '</div>';
590}
591
592$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
593$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
594$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
595
596print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
597print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
598
599
600// Fields title search
601// --------------------------------------------------------------------
602print '<tr class="liste_titre_filter">';
603// Action column
604if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
605 print '<td class="liste_titre center maxwidthsearch">';
606 $searchpicto = $form->showFilterButtons('left');
607 print $searchpicto;
608 print '</td>';
609}
610// Ref
611if (!empty($arrayfields['f.titre']['checked'])) {
612 print '<td class="liste_titre left">';
613 print '<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
614 print '</td>';
615}
616// Thirdparty
617if (!empty($arrayfields['s.nom']['checked'])) {
618 print '<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag((string) $search_societe).'"></td>';
619}
620if (!empty($arrayfields['f.total_ht']['checked'])) {
621 // Amount net
622 print '<td class="liste_titre right">';
623 print '<input class="flat width50" type="text"" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
624 print '</td>';
625}
626if (!empty($arrayfields['f.total_tva']['checked'])) {
627 // Amount Vat
628 print '<td class="liste_titre right">';
629 print '<input class="flat width50" type="text" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
630 print '</td>';
631}
632if (!empty($arrayfields['f.total_ttc']['checked'])) {
633 // Amount
634 print '<td class="liste_titre right">';
635 print '<input class="flat width50" type="text" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
636 print '</td>';
637}
638if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
639 // Payment term
640 print '<td class="liste_titre">';
641 print $form->getSelectConditionsPaiements((int) $search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
642 print "</td>";
643}
644if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
645 // Payment mode
646 print '<td class="liste_titre">';
647 print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1);
648 print '</td>';
649}
650if (!empty($arrayfields['recurring']['checked'])) {
651 // Recurring or not
652 print '<td class="liste_titre center">';
653 print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
654 print '</td>';
655}
656if (!empty($arrayfields['f.frequency']['checked'])) {
657 // Recurring or not
658 print '<td class="liste_titre center">';
659 print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
660 print '</td>';
661}
662if (!empty($arrayfields['f.unit_frequency']['checked'])) {
663 // Frequency unit
664 print '<td class="liste_titre center">';
665 print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
666 print '</td>';
667}
668if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
669 // Nb generation
670 print '<td class="liste_titre" align="center">';
671 print '<input class="flat" type="text" size="1" name="search_nb_gen_done" value="'.dol_escape_htmltag($search_nb_gen_done).'">';
672 print '</td>';
673}
674// Date invoice
675if (!empty($arrayfields['f.date_last_gen']['checked'])) {
676 print '<td class="liste_titre center">';
677 print '<div class="nowrapfordate">';
678 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
679 print '</div>';
680 print '<div class="nowrapfordate">';
681 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
682 print '</div>';
683 print '</td>';
684}
685// Date next generation
686if (!empty($arrayfields['f.date_when']['checked'])) {
687 print '<td class="liste_titre center">';
688 print '<div class="nowrapfordate">';
689 print $form->selectDate($search_date_when_start ? $search_date_when_start : -1, 'search_date_when_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
690 print '</div>';
691 print '<div class="nowrapfordate">';
692 print $form->selectDate($search_date_when_end ? $search_date_when_end : -1, 'search_date_when_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
693 print '</div>';
694 print '</td>';
695}
696// Extra fields
697include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
698
699// Fields from hook
700$parameters = array('arrayfields' => $arrayfields);
701$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
702print $hookmanager->resPrint;
703// User creation
704if (!empty($arrayfields['f.fk_user_author']['checked'])) {
705 print '<td class="liste_titre">';
706 print '</td>';
707}
708// User modification
709if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
710 print '<td class="liste_titre">';
711 print '</td>';
712}
713// Date creation
714if (!empty($arrayfields['f.datec']['checked'])) {
715 print '<td class="liste_titre">';
716 print '</td>';
717}
718// Date modification
719if (!empty($arrayfields['f.tms']['checked'])) {
720 print '<td class="liste_titre">';
721 print '</td>';
722}
723// Status
724if (!empty($arrayfields['status']['checked'])) {
725 print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
726 $liststatus = array(
727 0 => $langs->trans("Draft"),
728 1 => $langs->trans("Active"),
729 -1 => $langs->trans("Disabled"),
730 );
731 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
732 print $form->selectarray('search_status', $liststatus, $search_status, -2, 0, 0, '', 0, 0, 0, '', 'width100 onrightofpage');
733 print '</td>';
734}
735// Action column
736if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
737 print '<td class="liste_titre center maxwidthsearch">';
738 $searchpicto = $form->showFilterButtons();
739 print $searchpicto;
740 print '</td>';
741}
742print '</tr>'."\n";
743
744$totalarray = array();
745$totalarray['nbfield'] = 0;
746
747// Fields title label
748// --------------------------------------------------------------------
749print '<tr class="liste_titre">';
750// Action column
751if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
752 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
753 $totalarray['nbfield']++;
754}
755if (!empty($arrayfields['f.titre']['checked'])) {
756 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
757 print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
758 $totalarray['nbfield']++;
759}
760if (!empty($arrayfields['s.nom']['checked'])) {
761 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
762 $totalarray['nbfield']++;
763}
764if (!empty($arrayfields['f.total_ht']['checked'])) {
765 print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
766 $totalarray['nbfield']++;
767}
768if (!empty($arrayfields['f.total_tva']['checked'])) {
769 print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, '', $sortfield, $sortorder, 'right ');
770 $totalarray['nbfield']++;
771}
772if (!empty($arrayfields['f.total_ttc']['checked'])) {
773 print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, '', $sortfield, $sortorder, 'right ');
774 $totalarray['nbfield']++;
775}
776if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
777 print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
778 $totalarray['nbfield']++;
779}
780if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
781 print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
782 $totalarray['nbfield']++;
783}
784if (!empty($arrayfields['recurring']['checked'])) {
785 print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, '', $sortfield, $sortorder, 'center ');
786 $totalarray['nbfield']++;
787}
788if (!empty($arrayfields['f.frequency']['checked'])) {
789 print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, '', $sortfield, $sortorder, 'center ');
790 $totalarray['nbfield']++;
791}
792if (!empty($arrayfields['f.unit_frequency']['checked'])) {
793 print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, '', $sortfield, $sortorder, 'center ');
794 $totalarray['nbfield']++;
795}
796if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
797 print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, '', $sortfield, $sortorder, 'center ');
798 $totalarray['nbfield']++;
799}
800if (!empty($arrayfields['f.date_last_gen']['checked'])) {
801 print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, '', $sortfield, $sortorder, 'center ');
802 $totalarray['nbfield']++;
803}
804if (!empty($arrayfields['f.date_when']['checked'])) {
805 print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, '', $sortfield, $sortorder, 'center ');
806 $totalarray['nbfield']++;
807}
808if (!empty($arrayfields['f.fk_user_author']['checked'])) {
809 print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, '', $sortfield, $sortorder, 'center ');
810 $totalarray['nbfield']++;
811}
812if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
813 print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, '', $sortfield, $sortorder, 'center ');
814 $totalarray['nbfield']++;
815}
816if (!empty($arrayfields['f.datec']['checked'])) {
817 print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, '', $sortfield, $sortorder, 'center ');
818 $totalarray['nbfield']++;
819}
820if (!empty($arrayfields['f.tms']['checked'])) {
821 print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, '', $sortfield, $sortorder, 'center ');
822 $totalarray['nbfield']++;
823}
824// Extra fields
825include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
826if (!empty($arrayfields['status']['checked'])) {
827 print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, '', $sortfield, $sortorder, 'center ');
828 $totalarray['nbfield']++;
829}
830// Action column
831if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
832 print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
833 $totalarray['nbfield']++;
834}
835print '</tr>'."\n";
836
837$i = 0;
838$savnbfield = $totalarray['nbfield'];
839$totalarray = array();
840$totalarray['nbfield'] = 0;
841$totalarray['val']['f.total_ht'] = 0;
842$totalarray['val']['f.total_tva'] = 0;
843$totalarray['val']['f.total_ttc'] = 0;
844$imaxinloop = ($limit ? min($num, $limit) : $num);
845while ($i < $imaxinloop) {
846 $objp = $db->fetch_object($resql);
847 if (empty($objp)) {
848 break;
849 }
850
851 $companystatic->id = $objp->socid;
852 $companystatic->name = $objp->name;
853
854 $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
855 $invoicerectmp->frequency = $objp->frequency;
856 $invoicerectmp->suspended = $objp->suspended;
857 $invoicerectmp->unit_frequency = $objp->unit_frequency;
858 $invoicerectmp->nb_gen_max = $objp->nb_gen_max;
859 $invoicerectmp->nb_gen_done = $objp->nb_gen_done;
860 $invoicerectmp->ref = $objp->title;
861 $invoicerectmp->total_ht = $objp->total_ht;
862 $invoicerectmp->total_tva = $objp->total_tva;
863 $invoicerectmp->total_ttc = $objp->total_ttc;
864
865 // Show here line of result
866 $j = 0;
867 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
868 // Action column
869 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
870 print '<td class="center tdoverflowmax125">';
871 if ($user->hasRight('facture', 'creer') && empty($invoicerectmp->suspended)) {
872 if ($invoicerectmp->isMaxNbGenReached()) {
873 print $langs->trans("MaxNumberOfGenerationReached");
874 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
875 print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
876 print img_picto($langs->trans("CreateBill"), 'add', 'class="none"');
877 print '</a>';
878 } else {
879 print $form->textwithpicto('', $langs->trans("DateIsNotEnough"));
880 }
881 }
882 print '</td>';
883 if (!$i) {
884 $totalarray['nbfield']++;
885 }
886 }
887 if (!empty($arrayfields['f.titre']['checked'])) {
888 print '<td class="nowrap tdoverflowmax200">';
889 print $invoicerectmp->getNomUrl(1);
890 print "</td>\n";
891 if (!$i) {
892 $totalarray['nbfield']++;
893 }
894 }
895 if (!empty($arrayfields['s.nom']['checked'])) {
896 print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
897 if (!$i) {
898 $totalarray['nbfield']++;
899 }
900 }
901 if (!empty($arrayfields['f.total_ht']['checked'])) {
902 print '<td class="nowrap right amount">'.price($objp->total_ht).'</td>'."\n";
903 if (!$i) {
904 $totalarray['nbfield']++;
905 }
906 if (!$i) {
907 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
908 }
909 $totalarray['val']['f.total_ht'] += $objp->total_ht;
910 }
911 if (!empty($arrayfields['f.total_tva']['checked'])) {
912 print '<td class="nowrap right amount">'.price($objp->total_tva).'</td>'."\n";
913 if (!$i) {
914 $totalarray['nbfield']++;
915 }
916 if (!$i) {
917 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva';
918 }
919 $totalarray['val']['f.total_tva'] += $objp->total_tva;
920 }
921 if (!empty($arrayfields['f.total_ttc']['checked'])) {
922 print '<td class="nowrap right amount">'.price($objp->total_ttc).'</td>'."\n";
923 if (!$i) {
924 $totalarray['nbfield']++;
925 }
926 if (!$i) {
927 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
928 }
929 $totalarray['val']['f.total_ttc'] += $objp->total_ttc;
930 }
931 // Payment term
932 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
933 print '<td class="tdoverflowmax150">';
934 $form->form_conditions_reglement('0', $objp->fk_cond_reglement, 'none');
935 print '</td>'."\n";
936 if (!$i) {
937 $totalarray['nbfield']++;
938 }
939 }
940 // Payment mode
941 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
942 print '<td class="tdoverflowmax150">';
943 $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
944 print '</td>'."\n";
945 if (!$i) {
946 $totalarray['nbfield']++;
947 }
948 }
949 // Is it a recurring invoice
950 if (!empty($arrayfields['recurring']['checked'])) {
951 print '<td class="center">'.($objp->frequency ? img_picto($langs->trans("Frequency").': '.$objp->frequency.' '.$objp->unit_frequency, 'recurring', 'class="opacitymedium"').' ' : '').yn($objp->frequency ? 1 : 0).'</td>';
952 if (!$i) {
953 $totalarray['nbfield']++;
954 }
955 }
956 if (!empty($arrayfields['f.frequency']['checked'])) {
957 print '<td class="center">';
958 print($objp->frequency > 0 ? $objp->frequency : '');
959 print '</td>';
960 if (!$i) {
961 $totalarray['nbfield']++;
962 }
963 }
964 if (!empty($arrayfields['f.unit_frequency']['checked'])) {
965 print '<td class="center">';
966 if ($objp->frequency > 1) {
967 $dur = array("i" => $langs->trans("Minutes"), "h" => $langs->trans("Hours"), "d" => $langs->trans("Days"), "w" => $langs->trans("Weeks"), "m" => $langs->trans("Months"), "y" => $langs->trans("Years"));
968 } else {
969 $dur = array("i" => $langs->trans("Minute"), "h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year"));
970 }
971 print($objp->frequency > 0 ? $dur[$objp->unit_frequency] : '');
972 print '</td>';
973 if (!$i) {
974 $totalarray['nbfield']++;
975 }
976 }
977 if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
978 print '<td class="center">';
979 print($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
980 print '</td>';
981 if (!$i) {
982 $totalarray['nbfield']++;
983 }
984 }
985 // Date last generation
986 if (!empty($arrayfields['f.date_last_gen']['checked'])) {
987 print '<td class="center">';
988 print($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
989 print '</td>';
990 if (!$i) {
991 $totalarray['nbfield']++;
992 }
993 }
994 // Date next generation
995 if (!empty($arrayfields['f.date_when']['checked'])) {
996 print '<td class="center">';
997 print '<div class="nowraponall">';
998 print($objp->frequency ? ($invoicerectmp->isMaxNbGenReached() ? '<strike>' : '').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached() ? '</strike>' : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
999 if (!$invoicerectmp->isMaxNbGenReached()) {
1000 if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
1001 print img_warning($langs->trans("Late"));
1002 }
1003 } else {
1004 print img_info($langs->trans("MaxNumberOfGenerationReached"));
1005 }
1006 print '</div>';
1007 print '</td>';
1008 if (!$i) {
1009 $totalarray['nbfield']++;
1010 }
1011 }
1012 if (!empty($arrayfields['f.fk_user_author']['checked'])) {
1013 print '<td class="center tdoverflowmax150">';
1014 if ($objp->fk_user_author > 0) {
1015 $tmpuser->fetch($objp->fk_user_author);
1016 print $tmpuser->getNomUrl(1);
1017 }
1018 print '</td>';
1019 if (!$i) {
1020 $totalarray['nbfield']++;
1021 }
1022 }
1023 if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
1024 print '<td class="center tdoverflowmax150">';
1025 if ($objp->fk_user_author > 0) {
1026 $tmpuser->fetch($objp->fk_user_author);
1027 print $tmpuser->getNomUrl(1);
1028 }
1029 print '</td>';
1030 if (!$i) {
1031 $totalarray['nbfield']++;
1032 }
1033 }
1034 if (!empty($arrayfields['f.datec']['checked'])) {
1035 print '<td class="center nowraponall">';
1036 print dol_print_date($db->jdate($objp->datec), 'dayhour');
1037 print '</td>';
1038 if (!$i) {
1039 $totalarray['nbfield']++;
1040 }
1041 }
1042 if (!empty($arrayfields['f.tms']['checked'])) {
1043 print '<td class="center nowraponall">';
1044 print dol_print_date($db->jdate($objp->tms), 'dayhour');
1045 print '</td>';
1046 if (!$i) {
1047 $totalarray['nbfield']++;
1048 }
1049 }
1050
1051 $obj = $objp;
1052 // Extra fields
1053 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1054 // Fields from hook
1055 $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
1056 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1057 print $hookmanager->resPrint;
1058 // Status
1059 if (!empty($arrayfields['status']['checked'])) {
1060 print '<td class="center">';
1061 print $invoicerectmp->getLibStatut(5, 0);
1062 print '</td>';
1063 if (!$i) {
1064 $totalarray['nbfield']++;
1065 }
1066 }
1067 // Action column
1068 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1069 print '<td class="nowrap center tdoverflowmax125">';
1070 if ($user->hasRight('facture', 'creer') && empty($invoicerectmp->suspended)) {
1071 if ($invoicerectmp->isMaxNbGenReached()) {
1072 print $langs->trans("MaxNumberOfGenerationReached");
1073 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
1074 print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
1075 print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"');
1076 //print $langs->trans("CreateBill");
1077 print '</a>';
1078 } else {
1079 print $form->textwithpicto('', $langs->trans("DateIsNotEnough"));
1080 }
1081 }
1082 print '</td>';
1083 if (!$i) {
1084 $totalarray['nbfield']++;
1085 }
1086 }
1087
1088 print '</tr>'."\n";
1089
1090 $i++;
1091}
1092
1093// Show total line
1094include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
1095
1096// If no record found
1097if ($num == 0) {
1098 $colspan = 1;
1099 foreach ($arrayfields as $key => $val) {
1100 if (!empty($val['checked'])) {
1101 $colspan++;
1102 }
1103 }
1104 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1105}
1106
1107$db->free($resql);
1108
1109
1110$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
1111$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1112print $hookmanager->resPrint;
1113
1114print '</table>'."\n";
1115print '</div>'."\n";
1116
1117print '</form>'."\n";
1118
1119
1120// End of page
1121llxFooter();
1122$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
$totalarray
Definition export.php:1206
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 invoice templates.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class to manage building of HTML components.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
img_info($titlealt='default')
Show info logo.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.