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