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