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