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