dolibarr 24.0.0-beta
lines.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3 * Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
4 * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
5 * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
28require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
40require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
41require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
42require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
43require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
47
48// Load translation files required by the page
49$langs->loadLangs(array("compta", "bills", "other", "accountancy", "productbatch", "products"));
50
51$action = GETPOST('action', 'aZ');
52$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
53
54$account_parent = GETPOST('account_parent');
55$changeaccount = GETPOST('changeaccount', 'array');
56// Search Getpost
57$search_societe = GETPOST('search_societe', 'alpha');
58$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100'
59$search_ref = GETPOST('search_ref', 'alpha');
60$search_invoice = GETPOST('search_invoice', 'alpha');
61//$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha');
62$search_label = GETPOST('search_label', 'alpha');
63$search_desc = GETPOST('search_desc', 'alpha');
64$search_amount = GETPOST('search_amount', 'alpha');
65$search_account = GETPOST('search_account', 'alpha');
66$search_vat = GETPOST('search_vat', 'alpha');
67$search_date_startday = GETPOSTINT('search_date_startday');
68$search_date_startmonth = GETPOSTINT('search_date_startmonth');
69$search_date_startyear = GETPOSTINT('search_date_startyear');
70$search_date_endday = GETPOSTINT('search_date_endday');
71$search_date_endmonth = GETPOSTINT('search_date_endmonth');
72$search_date_endyear = GETPOSTINT('search_date_endyear');
73$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
74$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
75$search_country = GETPOST('search_country', 'aZ09');
76$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
77
78// Load variable for pagination
79$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
80$sortfield = GETPOST('sortfield', 'aZ09comma');
81$sortorder = GETPOST('sortorder', 'aZ09comma');
82$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
83if (empty($page) || $page < 0) {
84 $page = 0;
85}
86$offset = $limit * $page;
87$pageprev = $page - 1;
88$pagenext = $page + 1;
89if (!$sortfield) {
90 $sortfield = "f.datef, f.ref, l.rowid";
91}
92if (!$sortorder) {
93 if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_DONE') > 0) {
94 $sortorder = "DESC";
95 } else {
96 $sortorder = "ASC";
97 }
98}
99
100// Initialize technical objects
101$contextpage = 'accountancysupplierlines';
102$hookmanager->initHooks([$contextpage]);
103
105
106// Security check
107if (!isModEnabled('accounting')) {
109}
110if ($user->socid > 0) {
112}
113if (!$user->hasRight('accounting', 'bind', 'write')) {
115}
116
117$formaccounting = new FormAccounting($db);
118
119$arrayfields = array(
120 'l.rowid' => array('label' => "LineId", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
121 'f.ref' => array('label' => "Invoice", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
122 'f.libelle' => array('label' => "InvoiceLabel", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
123 'f.datef' => array('label' => "Date", 'position' => 1, 'checked' => '1', 'enabled' => '1'), // f.datef, f.ref, l.rowid
124 'p.ref' => array('label' => "ProductRef", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
125 'l.description' => array('label' => "ProductDescription", 'position' => 1, 'checked' => '-1', 'enabled' => '1'),
126 'l.total_ht' => array('label' => "Amount", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
127 'l.tva_tx' => array('label' => "VATRate", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
128 's.nom' => array('label' => "ThirdParty", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
129 'co.label' => array('label' => "Country", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
130 's.tva_intra' => array('label' => "VATIntra", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
131 'aa.account_number' => array('label' => "AccountAccounting", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
132);
133// @phpstan-ignore-next-line
134$arrayfields = dol_sort_array($arrayfields, 'position');
135
136
137/*
138 * Actions
139 */
140
141$parameters = array('arrayfields' => &$arrayfields);
142$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
143if ($reshook < 0) {
144 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
145}
146
147if (empty($reshook)) {
148 // Selection of new fields
149 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
150
151 // Purge search criteria
152 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
153 $search_societe = '';
154 $search_lineid = '';
155 $search_ref = '';
156 $search_invoice = '';
157 //$search_ref_supplier = '';
158 $search_label = '';
159 $search_desc = '';
160 $search_amount = '';
161 $search_account = '';
162 $search_vat = '';
163 $search_date_startday = '';
164 $search_date_startmonth = '';
165 $search_date_startyear = '';
166 $search_date_endday = '';
167 $search_date_endmonth = '';
168 $search_date_endyear = '';
169 $search_date_start = '';
170 $search_date_end = '';
171 $search_country = '';
172 $search_tvaintra = '';
173 }
174
175 if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
176 $error = 0;
177
178 if (!(GETPOSTINT('account_parent') >= 0)) {
179 $error++;
180 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
181 }
182
183 if (!$error) {
184 $db->begin();
185
186 $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
187 $sql1 .= " SET fk_code_ventilation=".(GETPOSTINT('account_parent') > 0 ? GETPOSTINT('account_parent') : '0');
188 $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
189
190 dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
191 $resql1 = $db->query($sql1);
192 if (!$resql1) {
193 $error++;
194 setEventMessages($db->lasterror(), null, 'errors');
195 }
196 if (!$error) {
197 $db->commit();
198 setEventMessages($langs->trans("Save"), null, 'mesgs');
199 } else {
200 $db->rollback();
201 setEventMessages($db->lasterror(), null, 'errors');
202 }
203
204 $account_parent = ''; // Protection to avoid to mass apply it a second time
205 }
206 }
207}
208
209if (GETPOST('sortfield') == 'f.datef, f.ref, l.rowid') {
210 $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1);
211 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
212 $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity);
213}
214
215
216/*
217 * View
218 */
219
220$form = new Form($db);
221$formother = new FormOther($db);
222
223$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
224
225llxHeader('', $langs->trans("SuppliersVentilation").' - '.$langs->trans("Dispatched"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-supplier page-lines');
226
227print '<script type="text/javascript">
228 $(function () {
229 $(\'#select-all\').click(function(event) {
230 // Iterate each checkbox
231 $(\':checkbox\').each(function() {
232 this.checked = true;
233 });
234 });
235 $(\'#unselect-all\').click(function(event) {
236 // Iterate each checkbox
237 $(\':checkbox\').each(function() {
238 this.checked = false;
239 });
240 });
241 });
242 </script>';
243
244/*
245 * Supplier Invoice lines
246 */
247$sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.type as ftype, f.libelle as invoice_label, f.datef, f.fk_soc,";
248$sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
249$sql .= " aa.rowid as fk_compte, aa.label as label_account, aa.labelshort as labelshort_account, aa.account_number,";
250$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tobuy, p.tosell,";
251if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
252 $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
253} else {
254 $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
255}
256$sql .= " co.code as country_code, co.label as country,";
257$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
258if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
259 $sql .= ", spe.accountancy_code_customer as code_compta_client";
260 $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
261} else {
262 $sql .= ", s.code_compta as code_compta_client";
263 $sql .= ", s.code_compta_fournisseur";
264}
265$parameters = array();
266$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
267$sql .= $hookmanager->resPrint;
268$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
269$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
270if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
271 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
272}
273$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
274$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
275$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
276if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
277 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
278}
279$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
280$parameters = array();
281$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
282$sql .= $hookmanager->resPrint;
283$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
284// Add search filter like
285if ($search_societe) {
286 $sql .= natural_search('s.nom', $search_societe);
287}
288if ($search_lineid) {
289 $sql .= natural_search("l.rowid", $search_lineid, 1);
290}
291if (strlen(trim($search_invoice))) {
292 $sql .= natural_search(array("f.ref", "f.ref_supplier"), $search_invoice);
293}
294/*if (strlen(trim($search_ref_supplier))) {
295 $sql .= natural_search("f.ref_supplier", $search_ref_supplier);
296}*/
297if (strlen(trim($search_label))) {
298 $sql .= natural_search("f.libelle", $search_label);
299}
300if (strlen(trim($search_ref))) {
301 $sql .= natural_search("p.ref", $search_ref);
302}
303if (strlen(trim($search_desc))) {
304 $sql .= natural_search("l.description", $search_desc);
305}
306if (strlen(trim($search_amount))) {
307 $sql .= natural_search("l.total_ht", $search_amount, 1);
308}
309if (strlen(trim($search_account))) {
310 $sql .= natural_search("aa.account_number", $search_account);
311}
312if (strlen(trim($search_vat))) {
313 $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
314}
315if ($search_date_start) {
316 $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
317}
318if ($search_date_end) {
319 $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
320}
321if (strlen(trim($search_country))) {
322 $arrayofcode = getCountriesInEEC();
323 $country_code_in_EEC = $country_code_in_EEC_without_me = '';
324 foreach ($arrayofcode as $key => $value) {
325 $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
326 if ($value != $mysoc->country_code) {
327 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
328 }
329 }
330 if ($search_country == 'special_allnotme') {
331 $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
332 } elseif ($search_country == 'special_eec') {
333 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
334 } elseif ($search_country == 'special_eecnotme') {
335 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
336 } elseif ($search_country == 'special_noteec') {
337 $sql .= " AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
338 } else {
339 $sql .= natural_search("co.code", $search_country);
340 }
341}
342if (strlen(trim($search_tvaintra))) {
343 $sql .= natural_search("s.tva_intra", $search_tvaintra);
344}
345$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
346
347// Add where from hooks
348$parameters = array();
349$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
350$sql .= $hookmanager->resPrint;
351
352$sql .= $db->order($sortfield, $sortorder);
353
354// Count total nb of records
355$nbtotalofrecords = '';
356if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
357 $result = $db->query($sql);
358 $nbtotalofrecords = $db->num_rows($result);
359 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
360 $page = 0;
361 $offset = 0;
362 }
363}
364
365$sql .= $db->plimit($limit + 1, $offset);
366
367dol_syslog("accountancy/supplier/lines.php", LOG_DEBUG);
368$result = $db->query($sql);
369if ($result) {
370 $num_lines = $db->num_rows($result);
371 $i = 0;
372
373 $param = '';
374 if ($contextpage != $_SERVER["PHP_SELF"]) {
375 $param .= '&contextpage='.urlencode($contextpage);
376 }
377 if ($limit > 0 && $limit != $conf->liste_limit) {
378 $param .= '&limit='.((int) $limit);
379 }
380 if ($search_societe) {
381 $param .= "&search_societe=".urlencode($search_societe);
382 }
383 if ($search_invoice) {
384 $param .= "&search_invoice=".urlencode($search_invoice);
385 }
386 if ($search_ref) {
387 $param .= "&search_ref=".urlencode($search_ref);
388 }
389 /*if ($search_ref_supplier) {
390 $param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
391 }*/
392 if ($search_label) {
393 $param .= "&search_label=".urlencode($search_label);
394 }
395 if ($search_desc) {
396 $param .= "&search_desc=".urlencode($search_desc);
397 }
398 if ($search_account) {
399 $param .= "&search_account=".urlencode($search_account);
400 }
401 if ($search_vat) {
402 $param .= "&search_vat=".urlencode($search_vat);
403 }
404 if ($search_date_startday) {
405 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
406 }
407 if ($search_date_startmonth) {
408 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
409 }
410 if ($search_date_startyear) {
411 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
412 }
413 if ($search_date_endday) {
414 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
415 }
416 if ($search_date_endmonth) {
417 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
418 }
419 if ($search_date_endyear) {
420 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
421 }
422 if ($search_country) {
423 $param .= "&search_country=".urlencode($search_country);
424 }
425 if ($search_tvaintra) {
426 $param .= "&search_tvaintra=".urlencode($search_tvaintra);
427 }
428 // Add $param from hooks
429 $parameters = array('param' => &$param);
430 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
431 $param .= $hookmanager->resPrint;
432
433 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
434 print '<input type="hidden" name="action" value="ventil">';
435 if ($optioncss != '') {
436 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
437 }
438 print '<input type="hidden" name="token" value="'.newToken().'">';
439 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
440 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
441 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
442 print '<input type="hidden" name="page" value="'.$page.'">';
443
444 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
445 print_barre_liste($langs->trans("InvoiceLinesDone").'<br><span class="opacityhigh small">'.$langs->trans("DescVentilDoneSupplier").'</span>', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
446
447 print '<br>'.$langs->trans("ChangeAccount").' <div class="inline-block paddingbottom paddingtop">';
448 print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
449 print '<input type="submit" class="button small smallpaddingimp valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
450 print '<br><br>';
451
452 $moreforfilter = '';
453
454 $varpage = $contextpage;
455 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
456 $selectedfields = $htmlofselectarray;
457 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
458
459 print '<div class="div-table-responsive">';
460 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
461
462 // We add search filter
463 print '<tr class="liste_titre_filter">';
464 // Action column
465 if ($conf->main_checkbox_left_column) {
466 print '<td class="liste_titre maxwidthsearch center actioncolumn">';
467 $searchpicto = $form->showFilterButtons('left');
468 print $searchpicto;
469 print '</td>';
470 }
471 // Line ID
472 if (!empty($arrayfields['l.rowid']['checked'])) {
473 print '<td class="liste_titre" data-key="lineid">';
474 print '<input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'">';
475 print '</td>';
476 }
477 // Ref invoice
478 if (!empty($arrayfields['f.ref']['checked'])) {
479 print '<td class="liste_titre" data-key="invoice">';
480 print '<input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'">';
481 print '</td>';
482 }
483 // Invoice label
484 if (!empty($arrayfields['f.libelle']['checked'])) {
485 print '<td class="liste_titre" data-key="invoice">';
486 print '<input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
487 print '</td>';
488 }
489 // Date
490 if (!empty($arrayfields['f.datef']['checked'])) {
491 print '<td class="liste_titre center">';
492 print '<div class="nowrapfordate">';
493 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
494 print '</div>';
495 print '<div class="nowrapfordate">';
496 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
497 print '</div>';
498 print '</td>';
499 }
500 // Product ref
501 if (!empty($arrayfields['p.ref']['checked'])) {
502 print '<td class="liste_titre" data-key="ref">';
503 print '<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
504 print '</td>';
505 }
506 // description
507 if (!empty($arrayfields['l.description']['checked'])) {
508 print '<td class="liste_titre" data-key="desc">';
509 print '<input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'">';
510 print '</td>';
511 }
512 // amount
513 if (!empty($arrayfields['l.total_ht']['checked'])) {
514 print '<td class="liste_titre" data-key="amount">';
515 print '<input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
516 print '</td>';
517 }
518 // VAT
519 if (!empty($arrayfields['l.tva_tx']['checked'])) {
520 print '<td class="liste_titre" data-key="vat">';
521 print '<input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="'.dol_escape_htmltag($search_vat).'">';
522 print '</td>';
523 }
524 // Thirdparty
525 if (!empty($arrayfields['s.nom']['checked'])) {
526 print '<td class="liste_titre" data-key="societe">';
527 print '<input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
528 print '</td>';
529 }
530 // Country
531 if (!empty($arrayfields['co.label']['checked'])) {
532 print '<td class="liste_titre" data-key="country">';
533 print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
534 //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
535 print '</td>';
536 }
537 // TVA Intracom
538 if (!empty($arrayfields['s.tva_intra']['checked'])) {
539 print '<td class="liste_titre">';
540 print '<input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'">';
541 print '</td>';
542 }
543 // Account
544 if (!empty($arrayfields['aa.account_number']['checked'])) {
545 print '<td class="liste_titre">';
546 print '<input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'">';
547 print '</td>';
548 }
549 // Fields from hook
550 $parameters = array('arrayfields' => $arrayfields);
551 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
552 print $hookmanager->resPrint;
553
554 // Action column
555 if (!$conf->main_checkbox_left_column) {
556 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
557 $searchpicto = $form->showFilterButtons();
558 print $searchpicto;
559 print '</td>';
560 }
561 print "</tr>\n";
562
563 // Fields title label
564 // --------------------------------------------------------------------
565 $totalarray = array();
566 $totalarray['nbfield'] = 0;
567
568 print '<tr class="liste_titre">';
569 // Action column
570 if ($conf->main_checkbox_left_column) {
571 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
572 $totalarray['nbfield']++;
573 }
574 // Line ID
575 if (!empty($arrayfields['l.rowid']['checked'])) {
576 print_liste_field_titre($arrayfields['l.rowid']['label'], $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
577 $totalarray['nbfield']++;
578 }
579 // Ref invoice
580 if (!empty($arrayfields['f.ref']['checked'])) {
581 print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
582 $totalarray['nbfield']++;
583 }
584 // invoice label
585 if (!empty($arrayfields['f.libelle']['checked'])) {
586 print_liste_field_titre($arrayfields['f.libelle']['label'], $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
587 $totalarray['nbfield']++;
588 }
589 // date
590 if (!empty($arrayfields['f.datef']['checked'])) {
591 print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
592 $totalarray['nbfield']++;
593 }
594 // Product ref
595 if (!empty($arrayfields['p.ref']['checked'])) {
596 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
597 $totalarray['nbfield']++;
598 }
599 // description
600 if (!empty($arrayfields['l.description']['checked'])) {
601 print_liste_field_titre($arrayfields['l.description']['label'], $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
602 $totalarray['nbfield']++;
603 }
604 // Amount
605 if (!empty($arrayfields['l.total_ht']['checked'])) {
606 print_liste_field_titre($arrayfields['l.total_ht']['label'], $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
607 $totalarray['nbfield']++;
608 }
609 // VAT
610 if (!empty($arrayfields['l.tva_tx']['checked'])) {
611 print_liste_field_titre($arrayfields['l.tva_tx']['label'], $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
612 $totalarray['nbfield']++;
613 }
614 // Thirdparty
615 if (!empty($arrayfields['s.nom']['checked'])) {
616 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
617 $totalarray['nbfield']++;
618 }
619 // Country
620 if (!empty($arrayfields['co.label']['checked'])) {
621 print_liste_field_titre($arrayfields['co.label']['label'], $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
622 $totalarray['nbfield']++;
623 }
624 // TVA Intracom
625 if (!empty($arrayfields['s.tva_intra']['checked'])) {
626 print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
627 $totalarray['nbfield']++;
628 }
629 // Account
630 if (!empty($arrayfields['aa.account_number']['checked'])) {
631 print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
632 $totalarray['nbfield']++;
633 }
634 // Hook fields
635 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
636 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
637 print $hookmanager->resPrint;
638 // Action column
639 if (!$conf->main_checkbox_left_column) {
640 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
641 $totalarray['nbfield']++;
642 }
643 print "</tr>\n";
644
645 $thirdpartystatic = new Societe($db);
646 $facturefournisseur_static = new FactureFournisseur($db);
647 $productstatic = new ProductFournisseur($db);
648 $accountingaccountstatic = new AccountingAccount($db);
649 $totalarray = array();
650 $totalarray['nbfield'] = 0;
651
652 $i = 0;
653 while ($i < min($num_lines, $limit)) {
654 $objp = $db->fetch_object($result);
655
656 $facturefournisseur_static->ref = $objp->ref;
657 $facturefournisseur_static->id = $objp->facid;
658 $facturefournisseur_static->type = $objp->ftype;
659 $facturefournisseur_static->ref_supplier = $objp->ref_supplier;
660 $facturefournisseur_static->label = $objp->invoice_label;
661
662 $thirdpartystatic->id = $objp->socid;
663 $thirdpartystatic->name = $objp->name;
664 $thirdpartystatic->client = $objp->client;
665 $thirdpartystatic->fournisseur = $objp->fournisseur;
666 $thirdpartystatic->code_client = $objp->code_client;
667 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
668 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
669 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
670 $thirdpartystatic->email = $objp->email;
671 $thirdpartystatic->country_code = $objp->country_code;
672
673 $productstatic->ref = $objp->product_ref;
674 $productstatic->id = $objp->product_id;
675 $productstatic->label = $objp->product_label;
676 $productstatic->type = $objp->line_type;
677 $productstatic->status = $objp->tosell;
678 $productstatic->status_buy = $objp->tobuy;
679 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
680 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
681 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
682
683 $accountingaccountstatic->rowid = $objp->fk_compte;
684 $accountingaccountstatic->label = $objp->label_account;
685 $accountingaccountstatic->labelshort = $objp->labelshort_account;
686 $accountingaccountstatic->account_number = $objp->account_number;
687
688 print '<tr class="oddeven">';
689
690 // Action column
691 if ($conf->main_checkbox_left_column) {
692 print '<td class="nowrap center actioncolumn">';
693 $selected = in_array($objp->rowid, $changeaccount);
694 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect checkforaction" type="checkbox" name="changeaccount[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
695 print '</td>';
696 if (!$i) {
697 $totalarray['nbfield']++;
698 }
699 }
700
701 // Line id
702 if (!empty($arrayfields['l.rowid']['checked'])) {
703 print '<td>'.$objp->rowid.'</td>';
704 $totalarray['nbfield']++;
705 }
706 // Ref Invoice
707 if (!empty($arrayfields['f.ref']['checked'])) {
708 print '<td class="nowraponall tdoverflowmax125 cell2linesheight">';
709 print $facturefournisseur_static->getNomUrl(1);
710 if ($objp->ref_supplier) {
711 print '<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->ref_supplier).'</span>';
712 }
713 print '</td>';
714 $totalarray['nbfield']++;
715 }
716 // Ref supplier invoice
717 /*
718 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($objp->ref_supplier).'">';
719 print $objp->ref_supplier;
720 print '</td>';
721 */
722 // Supplier invoice label
723 if (!empty($arrayfields['f.libelle']['checked'])) {
724 print '<td class="tdoverflowmax125 small" title="'.dol_escape_htmltag($objp->invoice_label).'">';
725 print dol_escape_htmltag($objp->invoice_label);
726 print '</td>';
727 $totalarray['nbfield']++;
728 }
729 // Date invoice
730 if (!empty($arrayfields['f.datef']['checked'])) {
731 print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
732 $totalarray['nbfield']++;
733 }
734 // Ref Product
735 if (!empty($arrayfields['p.ref']['checked'])) {
736 print '<td class="tdoverflowmax100 cell2linesheight">';
737 if ($productstatic->id > 0) {
738 print $productstatic->getNomUrl(1);
739 }
740 if ($productstatic->id > 0 && $objp->product_label) {
741 print '<br>';
742 }
743 if ($objp->product_label) {
744 print '<span class="opacitymedium">'.dolPrintHTML($objp->product_label).'</span>';
745 }
746 print '</td>';
747 $totalarray['nbfield']++;
748 }
749 // Description
750 if (!empty($arrayfields['l.description']['checked'])) {
751 $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
752 print '<td class="tdoverflowmax200 small" title="'.dolPrintHTMLForAttribute($text).'">';
753 $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
754 print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
755 print '</td>';
756 $totalarray['nbfield']++;
757 }
758 // Amount
759 if (!empty($arrayfields['l.total_ht']['checked'])) {
760 print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
761 $totalarray['nbfield']++;
762 }
763 // VAT Rate
764 if (!empty($arrayfields['l.tva_tx']['checked'])) {
765 print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
766 $totalarray['nbfield']++;
767 }
768 // Thirdparty
769 if (!empty($arrayfields['s.nom']['checked'])) {
770 print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
771 $totalarray['nbfield']++;
772 }
773 // Country
774 if (!empty($arrayfields['co.label']['checked'])) {
775 print '<td class="tdoverflowmax100" title="'.dolPrintHTMLForAttribute($langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')').'">';
776 if ($objp->country_code) {
777 print $langs->trans("Country".$objp->country_code);
778 //print ' ('.$objp->country_code.')';
779 }
780 print '</td>';
781 $totalarray['nbfield']++;
782 }
783 // TVA Intracom
784 if (!empty($arrayfields['s.tva_intra']['checked'])) {
785 print '<td class="tdoverflowmax80" title="'.dolPrintHTMLForAttribute($objp->tva_intra).'">'.dol_escape_htmltag($objp->tva_intra).'</td>';
786 $totalarray['nbfield']++;
787 }
788 // Account
789 if (!empty($arrayfields['aa.account_number']['checked'])) {
790 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($accountingaccountstatic->label).'">';
791 print '<a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
792 print img_edit();
793 print '</a> ';
794 print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
795 print '</td>';
796 $totalarray['nbfield']++;
797 }
798 // Fields from hook
799 $parameters = array('arrayfields' => $arrayfields, 'obj' => $objp, 'i' => $i, 'totalarray' => &$totalarray);
800 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
801 print $hookmanager->resPrint;
802 // Action column
803 if (!$conf->main_checkbox_left_column) {
804 print '<td class="nowrap center actioncolumn">';
805 $selected = in_array($objp->rowid, $changeaccount);
806 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect checkforaction" type="checkbox" name="changeaccount[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
807 print '</td>';
808 if (!$i) {
809 $totalarray['nbfield']++;
810 }
811 }
812
813 print '</tr>';
814 $i++;
815 }
816 if ($num_lines == 0) {
817 $colspan = 1;
818 foreach ($arrayfields as $key => $val) {
819 if (!empty($val['checked'])) {
820 $colspan++;
821 }
822 }
823 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
824 }
825
826 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
827 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
828 print $hookmanager->resPrint;
829
830
831 print '</table>';
832 print "</div>";
833
834 if ($nbtotalofrecords > $limit) {
835 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
836 }
837
838 print '</form>';
839} else {
840 print $db->lasterror();
841}
842
843// End of page
844llxFooter();
845$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$totalarray
Definition list.php:497
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage accounting accounts.
Class to manage suppliers invoices.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage predefined suppliers products.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.