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