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