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