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