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