dolibarr 18.0.6
list-rec.php
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') : 'invoicetemplatelist'; // To manage different context of search
54$optioncss = GETPOST('optioncss', 'alpha');
55
56$socid = GETPOST('socid', 'int');
57
58// Security check
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_status = GETPOST('search_status', 'int');
97
98$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
99$sortfield = GETPOST('sortfield', 'alpha');
100$sortorder = GETPOST('sortorder', 'alpha');
101$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
102if (empty($page) || $page == -1) {
103 $page = 0;
104} // If $page is not defined, or '' or -1
105$offset = $limit * $page;
106if (!$sortorder) {
107 $sortorder = 'DESC';
108}
109if (!$sortfield) {
110 $sortfield = 'f.titre';
111}
112$pageprev = $page - 1;
113$pagenext = $page + 1;
114
115$object = new FactureFournisseurRec($db);
116if (($id > 0 || $ref) && $action != 'create' && $action != 'add') {
117 $ret = $object->fetch($id, $ref);
118 if (!$ret) {
119 setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
120 }
121}
122
123// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
124$hookmanager->initHooks(array('supplierinvoicereclist'));
125$extrafields = new ExtraFields($db);
126
127// fetch optionals attributes and labels
128$extrafields->fetch_name_optionals_label($object->table_element);
129
130$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
131
132$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php
133$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php
134$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php
135
136$arrayfields = array(
137 'f.titre'=>array('label'=>'Ref', 'checked'=>1),
138 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1),
139 'f.total_ht'=>array('label'=>'AmountHT', 'checked'=>1),
140 'f.total_tva'=>array('label'=>'AmountVAT', 'checked'=>1),
141 'f.total_ttc'=>array('label'=>'AmountTTC', 'checked'=>1),
142 'f.fk_mode_reglement'=>array('label'=>'PaymentMode', 'checked'=>0),
143 'f.fk_cond_reglement'=>array('label'=>'PaymentTerm', 'checked'=>0),
144 'recurring'=>array('label'=>'RecurringInvoice', 'checked'=>1),
145 'f.frequency'=>array('label'=>'Frequency', 'checked'=>1),
146 'f.unit_frequency'=>array('label'=>'FrequencyUnit', 'checked'=>1),
147 'f.nb_gen_done'=>array('label'=>'NbOfGenerationDoneShort', 'checked'=>1),
148 'f.date_last_gen'=>array('label'=>'DateLastGenerationShort', 'checked'=>1),
149 'f.date_when'=>array('label'=>'NextDateToExecutionShort', 'checked'=>1),
150 'f.fk_user_author'=>array('label'=>'UserCreation', 'checked'=>0, 'position'=>500),
151 'f.fk_user_modif'=>array('label'=>'UserModification', 'checked'=>0, 'position'=>505),
152 'f.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>520),
153 'f.tms'=>array('label'=>'DateModificationShort', 'checked'=>0, 'position'=>525),
154 'suspended '=>array('label'=>'Status', 'checked'=>1, 'position'=>1000),
155);
156// Extra fields
157include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
158
159$object->fields = dol_sort_array($object->fields, 'position');
160$arrayfields = dol_sort_array($arrayfields, 'position');
161
162if ($socid > 0) {
163 $tmpthirdparty = new Societe($db);
164 $res = $tmpthirdparty->fetch($socid);
165 if ($res > 0) {
166 $search_societe = $tmpthirdparty->name;
167 }
168}
169$objecttype = 'facture_fourn_rec';
170
171$result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype);
172
173
174/*
175 * Actions
176 */
177
178if (GETPOST('cancel', 'alpha')) {
179 $action = 'list';
180 $massaction = '';
181}
182if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
183 $massaction = '';
184}
185
186$parameters = array('socid' => $socid);
187$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
188if ($reshook < 0) {
189 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
190}
191
192if (empty($reshook)) {
193 if (GETPOST('cancel', 'alpha')) {
194 $action = '';
195 }
196
197 // Selection of new fields
198 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
199
200 // Do we click on purge search criteria ?
201 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
202 $search_ref = '';
203 $search_societe = '';
204 $search_montant_ht = '';
205 $search_montant_vat = '';
206 $search_montant_ttc = '';
207 $search_payment_mode = '';
208 $search_payment_term = '';
209 $search_date_startday = '';
210 $search_date_startmonth = '';
211 $search_date_startyear = '';
212 $search_date_endday = '';
213 $search_date_endmonth = '';
214 $search_date_endyear = '';
215 $search_date_start = '';
216 $search_date_end = '';
217 $search_date_when_startday = '';
218 $search_date_when_startmonth = '';
219 $search_date_when_startyear = '';
220 $search_date_when_endday = '';
221 $search_date_when_endmonth = '';
222 $search_date_when_endyear = '';
223 $search_date_when_start = '';
224 $search_date_when_end = '';
225 $search_recurring = '';
226 $search_frequency = '';
227 $search_unit_frequency = '';
228 $search_status = '';
229 $search_array_options = array();
230 }
231
232 // Mass actions
233 /*$objectclass='MyObject';
234 $objectlabel='MyObject';
235 $permissiontoread = $user->hasRight("mymodule", "read");
236 $permissiontodelete = $user->hasRight("mymodule", "delete");
237 $uploaddir = $conf->mymodule->dir_output;
238 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
239}
240
241
242/*
243 * View
244 */
245
246$help_url = '';
247llxHeader('', $langs->trans("RepeatableSupplierInvoices"), $help_url);
248
249$form = new Form($db);
250$formother = new FormOther($db);
251if (isModEnabled('project')) {
252 $formproject = new FormProjets($db);
253}
254$companystatic = new Societe($db);
255$supplierinvoicerectmp = new FactureFournisseurRec($db);
256$tmpuser = new User($db);
257
258$now = dol_now();
259$tmparray = dol_getdate($now);
260$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
261
262
263/*
264 * List mode
265 */
266
267$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,";
268$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
269$sql .= " f.datec, f.fk_user_author, f.tms, f.fk_user_modif,";
270$sql .= " f.fk_cond_reglement, f.fk_mode_reglement";
271// Add fields from extrafields
272if (!empty($extrafields->attributes[$object->table_element]['label'])) {
273 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
274 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
275 }
276}
277// Add fields from hooks
278$parameters = array();
279$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
280$sql .= $hookmanager->resPrint;
281$sql = preg_replace('/,\s*$/', '', $sql);
282
283$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn_rec as f';
284$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_rec_extrafields as ef ON ef.fk_object = f.rowid';
285if (!$user->hasRight("societe", "client", "voir") && !$socid) {
286 $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc';
287}
288$sql .= ' WHERE f.fk_soc = s.rowid';
289$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
290if (!$user->hasRight("societe", "client", "voir") && !$socid) {
291 $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '. (int) $user->id;
292}
293if ($search_ref) {
294 $sql .= natural_search('f.titre', $search_ref);
295}
296if ($socid) {
297 $sql .= ' AND s.rowid = '.(int) $socid;
298}
299if ($search_societe) {
300 $sql .= natural_search('s.nom', $search_societe);
301}
302if ($search_montant_ht != '') {
303 $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
304}
305if ($search_montant_vat != '') {
306 $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
307}
308if ($search_montant_ttc != '') {
309 $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
310}
311if (!empty($search_payment_mode) && $search_payment_mode != '-1') {
312 $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
313}
314if (!empty($search_payment_term) && $search_payment_term != '-1') {
315 $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
316}
317if ($search_recurring == '1') {
318 $sql .= ' AND f.frequency > 0';
319}
320if ($search_recurring == '0') {
321 $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
322}
323if ($search_frequency != '') {
324 $sql .= natural_search('f.frequency', $search_frequency, 1);
325}
326if ($search_unit_frequency != '') {
327 $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency);
328}
329if ($search_status != '' && $search_status >= -1) {
330 if ($search_status == 0) {
331 $sql .= ' AND frequency = 0 AND suspended = 0';
332 }
333 if ($search_status == 1) {
334 $sql .= ' AND frequency != 0 AND suspended = 0';
335 }
336 if ($search_status == -1) {
337 $sql .= ' AND suspended = 1';
338 }
339}
340if ($search_date_start) {
341 $sql .= " AND f.date_last_gen >= '".$db->idate($search_date_start)."'";
342}
343if ($search_date_end) {
344 $sql .= " AND f.date_last_gen <= '".$db->idate($search_date_end)."'";
345}
346if ($search_date_when_start) {
347 $sql .= " AND f.date_when >= '".$db->idate($search_date_when_start)."'";
348}
349if ($search_date_when_end) {
350 $sql .= " AND f.date_when <= '".$db->idate($search_date_when_end)."'";
351}
352
353$tmpsortfield = $sortfield;
354if ($tmpsortfield == 'recurring') {
355 $tmpsortfield = 'f.frequency';
356}
357$sql .= $db->order($tmpsortfield, $sortorder);
358
359$nbtotalofrecords = '';
360if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
361 $result = $db->query($sql);
362 $nbtotalofrecords = $db->num_rows($result);
363 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
364 $page = 0;
365 $offset = 0;
366 }
367}
368
369$sql .= $db->plimit($limit + 1, $offset);
370
371$resql = $db->query($sql);
372if ($resql) {
373 $num = $db->num_rows($resql);
374
375 $param = '';
376 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
377 $param .= '&contextpage='.urlencode($contextpage);
378 }
379 if ($limit > 0 && $limit != $conf->liste_limit) {
380 $param .= '&limit='.((int) $limit);
381 }
382 if ($socid > 0) {
383 $param .= '&socid='.urlencode($socid);
384 }
385 if ($search_date_startday) {
386 $param .= '&search_date_startday='.urlencode($search_date_startday);
387 }
388 if ($search_date_startmonth) {
389 $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
390 }
391 if ($search_date_startyear) {
392 $param .= '&search_date_startyear='.urlencode($search_date_startyear);
393 }
394 if ($search_date_endday) {
395 $param .= '&search_date_endday='.urlencode($search_date_endday);
396 }
397 if ($search_date_endmonth) {
398 $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
399 }
400 if ($search_date_endyear) {
401 $param .= '&search_date_endyear='.urlencode($search_date_endyear);
402 }
403 if ($search_date_when_startday) {
404 $param .= '&search_date_when_startday='.urlencode($search_date_when_startday);
405 }
406 if ($search_date_when_startmonth) {
407 $param .= '&search_date_when_startmonth='.urlencode($search_date_when_startmonth);
408 }
409 if ($search_date_when_startyear) {
410 $param .= '&search_date_when_startyear='.urlencode($search_date_when_startyear);
411 }
412 if ($search_date_when_endday) {
413 $param .= '&search_date_when_endday='.urlencode($search_date_when_endday);
414 }
415 if ($search_date_when_endmonth) {
416 $param .= '&search_date_when_endmonth='.urlencode($search_date_when_endmonth);
417 }
418 if ($search_date_when_endyear) {
419 $param .= '&search_date_when_endyear='.urlencode($search_date_when_endyear);
420 }
421 if ($search_ref) {
422 $param .= '&search_ref='.urlencode($search_ref);
423 }
424 if ($search_societe) {
425 $param .= '&search_societe='.urlencode($search_societe);
426 }
427 if ($search_montant_ht != '') {
428 $param .= '&search_montant_ht='.urlencode($search_montant_ht);
429 }
430 if ($search_montant_vat != '') {
431 $param .= '&search_montant_vat='.urlencode($search_montant_vat);
432 }
433 if ($search_montant_ttc != '') {
434 $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
435 }
436 if ($search_payment_mode != '') {
437 $param .= '&search_payment_mode='.urlencode($search_payment_mode);
438 }
439 if ($search_payment_term != '') {
440 $param .= '&search_payment_term='.urlencode($search_payment_term);
441 }
442 if ($search_recurring != '' && $search_recurring != '-1') {
443 $param .= '&search_recurring='.urlencode($search_recurring);
444 }
445 if ($search_frequency > 0) {
446 $param .= '&search_frequency='.urlencode($search_frequency);
447 }
448 if ($search_unit_frequency != '') {
449 $param .= '&search_unit_frequency='.urlencode($search_unit_frequency);
450 }
451 if ($search_status != '') {
452 $param .= '&search_status='.urlencode($search_status);
453 }
454 if ($optioncss != '') {
455 $param .= '&optioncss='.urlencode($optioncss);
456 }
457 // Add $param from extra fields
458 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
459
460 $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
461
462 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
463 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
464 //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
465
466 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
467 if ($optioncss != '') {
468 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
469 }
470 print '<input type="hidden" name="token" value="'.newToken().'">';
471 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
472 print '<input type="hidden" name="action" value="list">';
473 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
474 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
475 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
476 print '<input type="hidden" name="search_status" value="'.$search_status.'">';
477
478 $title = $langs->trans("RepeatableSupplierInvoices");
479
480 print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1);
481
482 print '<span class="opacitymedium">'.$langs->trans("ToCreateAPredefinedSupplierInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'</span><br><br>';
483
484 $i = 0;
485
486 $moreforfilter = '';
487
488 print '<div class="div-table-responsive">';
489 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
490
491 // Filters lines
492 print '<tr class="liste_titre_filter">';
493 // Ref
494 if (!empty($arrayfields['f.titre']['checked'])) {
495 print '<td class="liste_titre left">';
496 print '<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
497 print '</td>';
498 }
499 // Thirdparty
500 if (!empty($arrayfields['s.nom']['checked'])) {
501 print '<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
502 }
503 if (!empty($arrayfields['f.total_ht']['checked'])) {
504 // Amount net
505 print '<td class="liste_titre right">';
506 print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
507 print '</td>';
508 }
509 if (!empty($arrayfields['f.total_tva']['checked'])) {
510 // Amount Vat
511 print '<td class="liste_titre right">';
512 print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
513 print '</td>';
514 }
515 if (!empty($arrayfields['f.total_ttc']['checked'])) {
516 // Amount
517 print '<td class="liste_titre right">';
518 print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
519 print '</td>';
520 }
521 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
522 // Payment term
523 print '<td class="liste_titre right">';
524 print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
525 print "</td>";
526 }
527 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
528 // Payment mode
529 print '<td class="liste_titre right">';
530 print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100', 1);
531 print '</td>';
532 }
533 if (!empty($arrayfields['recurring']['checked'])) {
534 // Recurring or not
535 print '<td class="liste_titre center">';
536 print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
537 print '</td>';
538 }
539 if (!empty($arrayfields['f.frequency']['checked'])) {
540 // Recurring or not
541 print '<td class="liste_titre center">';
542 print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
543 print '</td>';
544 }
545 if (!empty($arrayfields['f.unit_frequency']['checked'])) {
546 // Frequency unit
547 print '<td class="liste_titre center">';
548 print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
549 print '</td>';
550 }
551 if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
552 // Nb generation
553 print '<td class="liste_titre" align="center">';
554 print '</td>';
555 }
556 // Date invoice
557 if (!empty($arrayfields['f.date_last_gen']['checked'])) {
558 print '<td class="liste_titre center">';
559 print '<div class="nowrap">';
560 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
561 print '</div>';
562 print '<div class="nowrap">';
563 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
564 print '</div>';
565 print '</td>';
566 }
567 // Date next generation
568 if (!empty($arrayfields['f.date_when']['checked'])) {
569 print '<td class="liste_titre center">';
570 print '<div class="nowrap">';
571 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'));
572 print '</div>';
573 print '<div class="nowrap">';
574 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'));
575 print '</div>';
576 print '</td>';
577 }
578 // Extra fields
579 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
580
581 // Fields from hook
582 $parameters = array('arrayfields'=>$arrayfields);
583 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
584 print $hookmanager->resPrint;
585 // User creation
586 if (!empty($arrayfields['f.fk_user_author']['checked'])) {
587 print '<td class="liste_titre">';
588 print '</td>';
589 }
590 // User modification
591 if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
592 print '<td class="liste_titre">';
593 print '</td>';
594 }
595 // Date creation
596 if (!empty($arrayfields['f.datec']['checked'])) {
597 print '<td class="liste_titre">';
598 print '</td>';
599 }
600 // Date modification
601 if (!empty($arrayfields['f.tms']['checked'])) {
602 print '<td class="liste_titre">';
603 print '</td>';
604 }
605 // Action column
606 print '<td class="liste_titre" align="middle">';
607 $searchpicto = $form->showFilterButtons();
608 print $searchpicto;
609 print '</td>';
610 print "</tr>\n";
611
612 print '<tr class="liste_titre">';
613 if (!empty($arrayfields['f.titre']['checked'])) {
614 print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
615 }
616 if (!empty($arrayfields['s.nom']['checked'])) {
617 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
618 }
619 if (!empty($arrayfields['f.total_ht']['checked'])) {
620 print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], "f.total_ht", "", $param, 'class="right"', $sortfield, $sortorder);
621 }
622 if (!empty($arrayfields['f.total_tva']['checked'])) {
623 print_liste_field_titre($arrayfields['f.total_tva']['label'], $_SERVER['PHP_SELF'], "f.total_tva", "", $param, 'class="right"', $sortfield, $sortorder);
624 }
625 if (!empty($arrayfields['f.total_ttc']['checked'])) {
626 print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
627 }
628 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
629 print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
630 }
631 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
632 print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
633 }
634 if (!empty($arrayfields['recurring']['checked'])) {
635 print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder);
636 }
637 if (!empty($arrayfields['f.frequency']['checked'])) {
638 print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
639 }
640 if (!empty($arrayfields['f.unit_frequency']['checked'])) {
641 print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder);
642 }
643 if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
644 print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder);
645 }
646 if (!empty($arrayfields['f.date_last_gen']['checked'])) {
647 print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder);
648 }
649 if (!empty($arrayfields['f.date_when']['checked'])) {
650 print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder);
651 }
652 if (!empty($arrayfields['f.fk_user_author']['checked'])) {
653 print_liste_field_titre($arrayfields['f.fk_user_author']['label'], $_SERVER['PHP_SELF'], "f.fk_user_author", "", $param, 'align="center"', $sortfield, $sortorder);
654 }
655 if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
656 print_liste_field_titre($arrayfields['f.fk_user_modif']['label'], $_SERVER['PHP_SELF'], "f.fk_user_modif", "", $param, 'align="center"', $sortfield, $sortorder);
657 }
658 if (!empty($arrayfields['f.datec']['checked'])) {
659 print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder);
660 }
661 if (!empty($arrayfields['f.tms']['checked'])) {
662 print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder);
663 }
664 // Extra fields
665 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
666 if (!empty($arrayfields['status']['checked'])) {
667 print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
668 }
669 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch ');
670 print "</tr>\n";
671
672 if ($num > 0) {
673 $i = 0;
674 $totalarray = array();
675 $totalarray['nbfield'] = 0;
676 $totalarray['val']['f.total_ht'] = 0;
677 $totalarray['val']['f.total_tva'] = 0;
678 $totalarray['val']['f.total_ttc'] = 0;
679 while ($i < min($num, $limit)) {
680 $objp = $db->fetch_object($resql);
681 if (empty($objp)) {
682 break;
683 }
684
685 $companystatic->id = $objp->socid;
686 $companystatic->name = $objp->name;
687
688 $supplierinvoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
689 $supplierinvoicerectmp->frequency = $objp->frequency;
690 $supplierinvoicerectmp->suspended = $objp->suspended;
691 $supplierinvoicerectmp->unit_frequency = $objp->unit_frequency;
692 $supplierinvoicerectmp->nb_gen_max = $objp->nb_gen_max;
693 $supplierinvoicerectmp->nb_gen_done = $objp->nb_gen_done;
694 $supplierinvoicerectmp->ref = $objp->title;
695 $supplierinvoicerectmp->total_ht = $objp->total_ht;
696 $supplierinvoicerectmp->total_tva = $objp->total_tva;
697 $supplierinvoicerectmp->total_ttc = $objp->total_ttc;
698
699 print '<tr class="oddeven">';
700
701 if (!empty($arrayfields['f.titre']['checked'])) {
702 print '<td class="nowrap tdoverflowmax200">';
703 print $supplierinvoicerectmp->getNomUrl(1);
704 print "</a>";
705 print "</td>\n";
706 if (!$i) {
707 $totalarray['nbfield']++;
708 }
709 }
710 if (!empty($arrayfields['s.nom']['checked'])) {
711 print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
712 if (!$i) {
713 $totalarray['nbfield']++;
714 }
715 }
716 if (!empty($arrayfields['f.total_ht']['checked'])) {
717 print '<td class="nowrap right amount">'.price($objp->total_ht).'</td>'."\n";
718 if (!$i) {
719 $totalarray['nbfield']++;
720 }
721 if (!$i) {
722 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht';
723 }
724 $totalarray['val']['f.total_ht'] += $objp->total_ht;
725 }
726 if (!empty($arrayfields['f.total_tva']['checked'])) {
727 print '<td class="nowrap right amount">'.price($objp->total_tva).'</td>'."\n";
728 if (!$i) {
729 $totalarray['nbfield']++;
730 }
731 if (!$i) {
732 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva';
733 }
734 $totalarray['val']['f.total_tva'] += $objp->total_tva;
735 }
736 if (!empty($arrayfields['f.total_ttc']['checked'])) {
737 print '<td class="nowrap right amount">'.price($objp->total_ttc).'</td>'."\n";
738 if (!$i) {
739 $totalarray['nbfield']++;
740 }
741 if (!$i) {
742 $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
743 }
744 $totalarray['val']['f.total_ttc'] += $objp->total_ttc;
745 }
746 // Payment term
747 if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
748 print '<td class="right">';
749 $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
750 print '</td>'."\n";
751 if (!$i) {
752 $totalarray['nbfield']++;
753 }
754 }
755 // Payment mode
756 if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
757 print '<td class="right">';
758 $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
759 print '</td>'."\n";
760 if (!$i) {
761 $totalarray['nbfield']++;
762 }
763 }
764 // Is it a recurring invoice
765 if (!empty($arrayfields['recurring']['checked'])) {
766 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>';
767 if (!$i) {
768 $totalarray['nbfield']++;
769 }
770 }
771 if (!empty($arrayfields['f.frequency']['checked'])) {
772 print '<td class="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
773 if (!$i) {
774 $totalarray['nbfield']++;
775 }
776 }
777 if (!empty($arrayfields['f.unit_frequency']['checked'])) {
778 print '<td class="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
779 if (!$i) {
780 $totalarray['nbfield']++;
781 }
782 }
783 if (!empty($arrayfields['f.nb_gen_done']['checked'])) {
784 print '<td class="center">';
785 print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
786 print '</td>';
787 if (!$i) {
788 $totalarray['nbfield']++;
789 }
790 }
791 // Date last generation
792 if (!empty($arrayfields['f.date_last_gen']['checked'])) {
793 print '<td class="center">';
794 print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
795 print '</td>';
796 if (!$i) {
797 $totalarray['nbfield']++;
798 }
799 }
800 // Date next generation
801 if (!empty($arrayfields['f.date_when']['checked'])) {
802 print '<td class="center">';
803 print '<div class="nowraponall">';
804 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>');
805 if (!$supplierinvoicerectmp->isMaxNbGenReached()) {
806 if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) {
807 print img_warning($langs->trans("Late"));
808 }
809 } else {
810 print img_info($langs->trans("MaxNumberOfGenerationReached"));
811 }
812 print '</div>';
813 print '</td>';
814 if (!$i) {
815 $totalarray['nbfield']++;
816 }
817 }
818 if (!empty($arrayfields['f.fk_user_author']['checked'])) {
819 print '<td class="center tdoverflowmax150">';
820 if ($objp->fk_user_author > 0) {
821 $tmpuser->fetch($objp->fk_user_author);
822 print $tmpuser->getNomUrl(1);
823 }
824 print '</td>';
825 if (!$i) {
826 $totalarray['nbfield']++;
827 }
828 }
829 if (!empty($arrayfields['f.fk_user_modif']['checked'])) {
830 print '<td class="center tdoverflowmax150">';
831 if ($objp->fk_user_author > 0) {
832 $tmpuser->fetch($objp->fk_user_author);
833 print $tmpuser->getNomUrl(1);
834 }
835 print '</td>';
836 if (!$i) {
837 $totalarray['nbfield']++;
838 }
839 }
840 if (!empty($arrayfields['f.datec']['checked'])) {
841 print '<td class="center">';
842 print dol_print_date($db->jdate($objp->datec), 'dayhour');
843 print '</td>';
844 if (!$i) {
845 $totalarray['nbfield']++;
846 }
847 }
848 if (!empty($arrayfields['f.tms']['checked'])) {
849 print '<td class="center">';
850 print dol_print_date($db->jdate($objp->tms), 'dayhour');
851 print '</td>';
852 if (!$i) {
853 $totalarray['nbfield']++;
854 }
855 }
856
857 $obj = $objp;
858 // Extra fields
859 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
860 // Fields from hook
861 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
862 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
863 print $hookmanager->resPrint;
864 // Status
865 if (!empty($arrayfields['status']['checked'])) {
866 print '<td class="center">';
867 print $supplierinvoicerectmp->getLibStatut(3, 0);
868 print '</td>';
869 if (!$i) {
870 $totalarray['nbfield']++;
871 }
872 }
873 // Action column
874 print '<td class="center tdoverflowmax125">';
875 if ($user->hasRight('facture', 'creer') && empty($supplierinvoicerectmp->suspended)) {
876 if ($supplierinvoicerectmp->isMaxNbGenReached()) {
877 print $langs->trans("MaxNumberOfGenerationReached");
878 } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
879 print '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
880 print img_picto($langs->trans("CreateBill"), 'add', 'class="paddingrightonly"');
881 print $langs->trans("CreateBill").'</a>';
882 } else {
883 print $form->textwithpicto('', $langs->trans("DateIsNotEnough"));
884 }
885 } else {
886 print "&nbsp;";
887 }
888 if (!$i) {
889 $totalarray['nbfield']++;
890 }
891 print "</td>";
892
893 print "</tr>\n";
894
895 $i++;
896 }
897 } else {
898 $colspan = 1;
899 foreach ($arrayfields as $key => $val) {
900 if (!empty($val['checked'])) {
901 $colspan++;
902 }
903 }
904 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
905 }
906
907 // Show total line
908 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
909
910
911 print "</table>";
912 print "</div>";
913 print "</form>";
914
915 $db->free($resql);
916} else {
917 dol_print_error($db);
918}
919
920// End of page
921llxFooter();
922$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:56
llxFooter()
Empty footer.
Definition wrapper.php:70
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 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.
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.
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.