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