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