dolibarr 22.0.5
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';
29
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
34require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
35require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
36require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
40
50// Load translation files required by the page
51$langs->loadLangs(array("compta", "bills", "other", "accountancy", "productbatch", "products"));
52
53$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
54
55$account_parent = GETPOST('account_parent');
56$changeaccount = GETPOST('changeaccount', 'array');
57// Search Getpost
58$search_societe = GETPOST('search_societe', 'alpha');
59$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100'
60$search_ref = GETPOST('search_ref', 'alpha');
61$search_invoice = GETPOST('search_invoice', 'alpha');
62//$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha');
63$search_label = GETPOST('search_label', 'alpha');
64$search_desc = GETPOST('search_desc', 'alpha');
65$search_amount = GETPOST('search_amount', 'alpha');
66$search_account = GETPOST('search_account', 'alpha');
67$search_vat = GETPOST('search_vat', 'alpha');
68$search_date_startday = GETPOSTINT('search_date_startday');
69$search_date_startmonth = GETPOSTINT('search_date_startmonth');
70$search_date_startyear = GETPOSTINT('search_date_startyear');
71$search_date_endday = GETPOSTINT('search_date_endday');
72$search_date_endmonth = GETPOSTINT('search_date_endmonth');
73$search_date_endyear = GETPOSTINT('search_date_endyear');
74$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
75$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
76$search_country = GETPOST('search_country', 'aZ09');
77$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
78
79// Load variable for pagination
80$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
81$sortfield = GETPOST('sortfield', 'aZ09comma');
82$sortorder = GETPOST('sortorder', 'aZ09comma');
83$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
84if (empty($page) || $page < 0) {
85 $page = 0;
86}
87$offset = $limit * $page;
88$pageprev = $page - 1;
89$pagenext = $page + 1;
90if (!$sortfield) {
91 $sortfield = "f.datef, f.ref, l.rowid";
92}
93if (!$sortorder) {
94 if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_DONE') > 0) {
95 $sortorder = "DESC";
96 } else {
97 $sortorder = "ASC";
98 }
99}
100
101// Initialize technical objects
102$contextpage = 'accountancysupplierlines';
103$hookmanager->initHooks([$contextpage]);
104
105// Security check
106if (!isModEnabled('accounting')) {
108}
109if ($user->socid > 0) {
111}
112if (!$user->hasRight('accounting', 'bind', 'write')) {
114}
115
116$formaccounting = new FormAccounting($db);
117
118$arrayfields = array(
119 'l.rowid' => array('label' => "LineId", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
120 'f.ref' => array('label' => "Invoice", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
121 'f.libelle' => array('label' => "InvoiceLabel", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
122 'f.datef' => array('label' => "Date", 'position' => 1, 'checked' => '1', 'enabled' => '1'), // f.datef, f.ref, l.rowid
123 'p.ref' => array('label' => "ProductRef", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
124 'l.description' => array('label' => "ProductDescription", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
125 'l.total_ht' => array('label' => "Amount", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
126 'l.tva_tx' => array('label' => "VATRate", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
127 's.nom' => array('label' => "ThirdParty", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
128 'co.label' => array('label' => "Country", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
129 's.tva_intra' => array('label' => "VATIntra", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
130 'aa.account_number' => array('label' => "AccountAccounting", 'position' => 1, 'checked' => '1', 'enabled' => '1'),
131);
132// @phpstan-ignore-next-line
133$arrayfields = dol_sort_array($arrayfields, 'position');
134
135
136/*
137 * Actions
138 */
139
140$parameters = array('arrayfields' => &$arrayfields);
141$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
142if ($reshook < 0) {
143 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
144}
145
146if (empty($reshook)) {
147 // Selection of new fields
148 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
149
150 // Purge search criteria
151 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
152 $search_societe = '';
153 $search_lineid = '';
154 $search_ref = '';
155 $search_invoice = '';
156 //$search_ref_supplier = '';
157 $search_label = '';
158 $search_desc = '';
159 $search_amount = '';
160 $search_account = '';
161 $search_vat = '';
162 $search_date_startday = '';
163 $search_date_startmonth = '';
164 $search_date_startyear = '';
165 $search_date_endday = '';
166 $search_date_endmonth = '';
167 $search_date_endyear = '';
168 $search_date_start = '';
169 $search_date_end = '';
170 $search_country = '';
171 $search_tvaintra = '';
172 }
173
174 if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
175 $error = 0;
176
177 if (!(GETPOSTINT('account_parent') >= 0)) {
178 $error++;
179 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
180 }
181
182 if (!$error) {
183 $db->begin();
184
185 $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
186 $sql1 .= " SET fk_code_ventilation=".(GETPOSTINT('account_parent') > 0 ? GETPOSTINT('account_parent') : '0');
187 $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
188
189 dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
190 $resql1 = $db->query($sql1);
191 if (!$resql1) {
192 $error++;
193 setEventMessages($db->lasterror(), null, 'errors');
194 }
195 if (!$error) {
196 $db->commit();
197 setEventMessages($langs->trans("Save"), null, 'mesgs');
198 } else {
199 $db->rollback();
200 setEventMessages($db->lasterror(), null, 'errors');
201 }
202
203 $account_parent = ''; // Protection to avoid to mass apply it a second time
204 }
205 }
206}
207
208if (GETPOST('sortfield') == 'f.datef, f.ref, l.rowid') {
209 $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1);
210 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
211 $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity);
212}
213
214
215/*
216 * View
217 */
218
219$form = new Form($db);
220$formother = new FormOther($db);
221
222$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
223
224llxHeader('', $langs->trans("SuppliersVentilation").' - '.$langs->trans("Dispatched"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-supplier page-lines');
225
226print '<script type="text/javascript">
227 $(function () {
228 $(\'#select-all\').click(function(event) {
229 // Iterate each checkbox
230 $(\':checkbox\').each(function() {
231 this.checked = true;
232 });
233 });
234 $(\'#unselect-all\').click(function(event) {
235 // Iterate each checkbox
236 $(\':checkbox\').each(function() {
237 this.checked = false;
238 });
239 });
240 });
241 </script>';
242
243/*
244 * Supplier Invoice lines
245 */
246$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,";
247$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,";
248$sql .= " aa.rowid as fk_compte, aa.label as label_account, aa.labelshort as labelshort_account, aa.account_number,";
249$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,";
250if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
251 $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
252} else {
253 $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
254}
255$sql .= " co.code as country_code, co.label as country,";
256$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";
257if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
258 $sql .= ", spe.accountancy_code_customer as code_compta_client";
259 $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
260} else {
261 $sql .= ", s.code_compta as code_compta_client";
262 $sql .= ", s.code_compta_fournisseur";
263}
264$parameters = array();
265$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
266$sql .= $hookmanager->resPrint;
267$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
268$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
269if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
270 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
271}
272$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
273$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
274$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
275if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
276 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
277}
278$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
279$parameters = array();
280$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
281$sql .= $hookmanager->resPrint;
282$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
283// Add search filter like
284if ($search_societe) {
285 $sql .= natural_search('s.nom', $search_societe);
286}
287if ($search_lineid) {
288 $sql .= natural_search("l.rowid", $search_lineid, 1);
289}
290if (strlen(trim($search_invoice))) {
291 $sql .= natural_search(array("f.ref", "f.ref_supplier"), $search_invoice);
292}
293/*if (strlen(trim($search_ref_supplier))) {
294 $sql .= natural_search("f.ref_supplier", $search_ref_supplier);
295}*/
296if (strlen(trim($search_label))) {
297 $sql .= natural_search("f.libelle", $search_label);
298}
299if (strlen(trim($search_ref))) {
300 $sql .= natural_search("p.ref", $search_ref);
301}
302if (strlen(trim($search_desc))) {
303 $sql .= natural_search("l.description", $search_desc);
304}
305if (strlen(trim($search_amount))) {
306 $sql .= natural_search("l.total_ht", $search_amount, 1);
307}
308if (strlen(trim($search_account))) {
309 $sql .= natural_search("aa.account_number", $search_account);
310}
311if (strlen(trim($search_vat))) {
312 $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
313}
314if ($search_date_start) {
315 $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
316}
317if ($search_date_end) {
318 $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
319}
320if (strlen(trim($search_country))) {
321 $arrayofcode = getCountriesInEEC();
322 $country_code_in_EEC = $country_code_in_EEC_without_me = '';
323 foreach ($arrayofcode as $key => $value) {
324 $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
325 if ($value != $mysoc->country_code) {
326 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
327 }
328 }
329 if ($search_country == 'special_allnotme') {
330 $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
331 } elseif ($search_country == 'special_eec') {
332 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
333 } elseif ($search_country == 'special_eecnotme') {
334 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
335 } elseif ($search_country == 'special_noteec') {
336 $sql .= " AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
337 } else {
338 $sql .= natural_search("co.code", $search_country);
339 }
340}
341if (strlen(trim($search_tvaintra))) {
342 $sql .= natural_search("s.tva_intra", $search_tvaintra);
343}
344$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
345
346// Add where from hooks
347$parameters = array();
348$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
349$sql .= $hookmanager->resPrint;
350
351$sql .= $db->order($sortfield, $sortorder);
352
353// Count total nb of records
354$nbtotalofrecords = '';
355if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
356 $result = $db->query($sql);
357 $nbtotalofrecords = $db->num_rows($result);
358 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
359 $page = 0;
360 $offset = 0;
361 }
362}
363
364$sql .= $db->plimit($limit + 1, $offset);
365
366dol_syslog("accountancy/supplier/lines.php", LOG_DEBUG);
367$result = $db->query($sql);
368if ($result) {
369 $num_lines = $db->num_rows($result);
370 $i = 0;
371
372 $param = '';
373 if ($contextpage != $_SERVER["PHP_SELF"]) {
374 $param .= '&contextpage='.urlencode($contextpage);
375 }
376 if ($limit > 0 && $limit != $conf->liste_limit) {
377 $param .= '&limit='.((int) $limit);
378 }
379 if ($search_societe) {
380 $param .= "&search_societe=".urlencode($search_societe);
381 }
382 if ($search_invoice) {
383 $param .= "&search_invoice=".urlencode($search_invoice);
384 }
385 if ($search_ref) {
386 $param .= "&search_ref=".urlencode($search_ref);
387 }
388 /*if ($search_ref_supplier) {
389 $param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
390 }*/
391 if ($search_label) {
392 $param .= "&search_label=".urlencode($search_label);
393 }
394 if ($search_desc) {
395 $param .= "&search_desc=".urlencode($search_desc);
396 }
397 if ($search_account) {
398 $param .= "&search_account=".urlencode($search_account);
399 }
400 if ($search_vat) {
401 $param .= "&search_vat=".urlencode($search_vat);
402 }
403 if ($search_date_startday) {
404 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
405 }
406 if ($search_date_startmonth) {
407 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
408 }
409 if ($search_date_startyear) {
410 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
411 }
412 if ($search_date_endday) {
413 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
414 }
415 if ($search_date_endmonth) {
416 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
417 }
418 if ($search_date_endyear) {
419 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
420 }
421 if ($search_country) {
422 $param .= "&search_country=".urlencode($search_country);
423 }
424 if ($search_tvaintra) {
425 $param .= "&search_tvaintra=".urlencode($search_tvaintra);
426 }
427 // Add $param from hooks
428 $parameters = array('param' => &$param);
429 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
430 $param .= $hookmanager->resPrint;
431
432 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
433 print '<input type="hidden" name="action" value="ventil">';
434 if ($optioncss != '') {
435 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
436 }
437 print '<input type="hidden" name="token" value="'.newToken().'">';
438 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
439 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
440 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
441 print '<input type="hidden" name="page" value="'.$page.'">';
442
443 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
444 print_barre_liste($langs->trans("InvoiceLinesDone").'<br><span class="opacitymedium small">'.$langs->trans("DescVentilDoneSupplier").'</span>', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
445
446 print '<br>'.$langs->trans("ChangeAccount").' <div class="inline-block paddingbottom marginbottomonly">';
447 print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
448 print '<input type="submit" class="button small smallpaddingimp valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
449
450 $moreforfilter = '';
451
452 $varpage = $contextpage;
453 $htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column); // This also change content of $arrayfields with user setup
454 $selectedfields = $htmlofselectarray;
455 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
456
457 print '<div class="div-table-responsive">';
458 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
459
460 // We add search filter
461 print '<tr class="liste_titre_filter">';
462 // Action column
463 if ($conf->main_checkbox_left_column) {
464 print '<td class="liste_titre maxwidthsearch center actioncolumn">';
465 $searchpicto = $form->showFilterButtons('left');
466 print $searchpicto;
467 print '</td>';
468 }
469 // Line ID
470 if (!empty($arrayfields['l.rowid']['checked'])) {
471 print '<td class="liste_titre" data-key="lineid">';
472 print '<input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'">';
473 print '</td>';
474 }
475 // Ref invoice
476 if (!empty($arrayfields['f.ref']['checked'])) {
477 print '<td class="liste_titre" data-key="invoice">';
478 print '<input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'">';
479 print '</td>';
480 }
481 // Invoice label
482 if (!empty($arrayfields['f.libelle']['checked'])) {
483 print '<td class="liste_titre" data-key="invoice">';
484 print '<input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
485 print '</td>';
486 }
487 // Date
488 if (!empty($arrayfields['f.datef']['checked'])) {
489 print '<td class="liste_titre center">';
490 print '<div class="nowrapfordate">';
491 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
492 print '</div>';
493 print '<div class="nowrapfordate">';
494 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
495 print '</div>';
496 print '</td>';
497 }
498 // Product ref
499 if (!empty($arrayfields['p.ref']['checked'])) {
500 print '<td class="liste_titre" data-key="ref">';
501 print '<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
502 print '</td>';
503 }
504 // description
505 if (!empty($arrayfields['l.description']['checked'])) {
506 print '<td class="liste_titre" data-key="desc">';
507 print '<input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'">';
508 print '</td>';
509 }
510 // amount
511 if (!empty($arrayfields['l.total_ht']['checked'])) {
512 print '<td class="liste_titre" data-key="amount">';
513 print '<input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
514 print '</td>';
515 }
516 // VAT
517 if (!empty($arrayfields['l.tva_tx']['checked'])) {
518 print '<td class="liste_titre" data-key="vat">';
519 print '<input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="'.dol_escape_htmltag($search_vat).'">';
520 print '</td>';
521 }
522 // Thirdparty
523 if (!empty($arrayfields['s.nom']['checked'])) {
524 print '<td class="liste_titre" data-key="societe">';
525 print '<input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
526 print '</td>';
527 }
528 // Country
529 if (!empty($arrayfields['co.label']['checked'])) {
530 print '<td class="liste_titre" data-key="country">';
531 print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
532 //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
533 print '</td>';
534 }
535 // TVA Intracom
536 if (!empty($arrayfields['s.tva_intra']['checked'])) {
537 print '<td class="liste_titre">';
538 print '<input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'">';
539 print '</td>';
540 }
541 // Account
542 if (!empty($arrayfields['aa.account_number']['checked'])) {
543 print '<td class="liste_titre">';
544 print '<input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'">';
545 print '</td>';
546 }
547 // Fields from hook
548 $parameters = array('arrayfields' => $arrayfields);
549 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
550 print $hookmanager->resPrint;
551
552 // Action column
553 if (!$conf->main_checkbox_left_column) {
554 print '<td class="liste_titre center maxwidthsearch actioncolumn">';
555 $searchpicto = $form->showFilterButtons();
556 print $searchpicto;
557 print '</td>';
558 }
559 print "</tr>\n";
560
561 // Fields title label
562 // --------------------------------------------------------------------
563 $totalarray = array();
564 $totalarray['nbfield'] = 0;
565
566 print '<tr class="liste_titre">';
567 // Action column
568 if ($conf->main_checkbox_left_column) {
569 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
570 $totalarray['nbfield']++;
571 }
572 // Line ID
573 if (!empty($arrayfields['l.rowid']['checked'])) {
574 print_liste_field_titre($arrayfields['l.rowid']['label'], $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
575 $totalarray['nbfield']++;
576 }
577 // Ref invoice
578 if (!empty($arrayfields['f.ref']['checked'])) {
579 print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
580 $totalarray['nbfield']++;
581 }
582 // invoice label
583 if (!empty($arrayfields['f.libelle']['checked'])) {
584 print_liste_field_titre($arrayfields['f.libelle']['label'], $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
585 $totalarray['nbfield']++;
586 }
587 // date
588 if (!empty($arrayfields['f.datef']['checked'])) {
589 print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
590 $totalarray['nbfield']++;
591 }
592 // Product ref
593 if (!empty($arrayfields['p.ref']['checked'])) {
594 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
595 $totalarray['nbfield']++;
596 }
597 // description
598 if (!empty($arrayfields['l.description']['checked'])) {
599 print_liste_field_titre($arrayfields['l.description']['label'], $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
600 $totalarray['nbfield']++;
601 }
602 // Amount
603 if (!empty($arrayfields['l.total_ht']['checked'])) {
604 print_liste_field_titre($arrayfields['l.total_ht']['label'], $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
605 $totalarray['nbfield']++;
606 }
607 // VAT
608 if (!empty($arrayfields['l.tva_tx']['checked'])) {
609 print_liste_field_titre($arrayfields['l.tva_tx']['label'], $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
610 $totalarray['nbfield']++;
611 }
612 // Thirdparty
613 if (!empty($arrayfields['s.nom']['checked'])) {
614 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
615 $totalarray['nbfield']++;
616 }
617 // Country
618 if (!empty($arrayfields['co.label']['checked'])) {
619 print_liste_field_titre($arrayfields['co.label']['label'], $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
620 $totalarray['nbfield']++;
621 }
622 // TVA Intracom
623 if (!empty($arrayfields['s.tva_intra']['checked'])) {
624 print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
625 $totalarray['nbfield']++;
626 }
627 // Account
628 if (!empty($arrayfields['aa.account_number']['checked'])) {
629 print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
630 $totalarray['nbfield']++;
631 }
632 // Hook fields
633 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
634 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
635 print $hookmanager->resPrint;
636 // Action column
637 if (!$conf->main_checkbox_left_column) {
638 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
639 $totalarray['nbfield']++;
640 }
641 print "</tr>\n";
642
643 $thirdpartystatic = new Societe($db);
644 $facturefournisseur_static = new FactureFournisseur($db);
645 $productstatic = new ProductFournisseur($db);
646 $accountingaccountstatic = new AccountingAccount($db);
647 $totalarray = array();
648 $totalarray['nbfield'] = 0;
649
650 $i = 0;
651 while ($i < min($num_lines, $limit)) {
652 $objp = $db->fetch_object($result);
653
654 $facturefournisseur_static->ref = $objp->ref;
655 $facturefournisseur_static->id = $objp->facid;
656 $facturefournisseur_static->type = $objp->ftype;
657 $facturefournisseur_static->ref_supplier = $objp->ref_supplier;
658 $facturefournisseur_static->label = $objp->invoice_label;
659
660 $thirdpartystatic->id = $objp->socid;
661 $thirdpartystatic->name = $objp->name;
662 $thirdpartystatic->client = $objp->client;
663 $thirdpartystatic->fournisseur = $objp->fournisseur;
664 $thirdpartystatic->code_client = $objp->code_client;
665 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
666 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
667 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
668 $thirdpartystatic->email = $objp->email;
669 $thirdpartystatic->country_code = $objp->country_code;
670
671 $productstatic->ref = $objp->product_ref;
672 $productstatic->id = $objp->product_id;
673 $productstatic->label = $objp->product_label;
674 $productstatic->type = $objp->line_type;
675 $productstatic->status = $objp->tosell;
676 $productstatic->status_buy = $objp->tobuy;
677 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
678 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
679 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
680
681 $accountingaccountstatic->rowid = $objp->fk_compte;
682 $accountingaccountstatic->label = $objp->label_account;
683 $accountingaccountstatic->labelshort = $objp->labelshort_account;
684 $accountingaccountstatic->account_number = $objp->account_number;
685
686 print '<tr class="oddeven">';
687
688 // Action column
689 if ($conf->main_checkbox_left_column) {
690 print '<td class="nowrap center actioncolumn">';
691 $selected = in_array($objp->rowid, $changeaccount);
692 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect checkforaction" type="checkbox" name="changeaccount[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
693 print '</td>';
694 if (!$i) {
695 $totalarray['nbfield']++;
696 }
697 }
698
699 // Line id
700 if (!empty($arrayfields['l.rowid']['checked'])) {
701 print '<td>'.$objp->rowid.'</td>';
702 $totalarray['nbfield']++;
703 }
704 // Ref Invoice
705 if (!empty($arrayfields['f.ref']['checked'])) {
706 print '<td class="nowraponall tdoverflowmax125">';
707 print $facturefournisseur_static->getNomUrl(1);
708 if ($objp->ref_supplier) {
709 print '<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->ref_supplier).'</span>';
710 }
711 print '</td>';
712 $totalarray['nbfield']++;
713 }
714 // Ref supplier invoice
715 /*
716 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($objp->ref_supplier).'">';
717 print $objp->ref_supplier;
718 print '</td>';
719 */
720 // Supplier invoice label
721 if (!empty($arrayfields['f.libelle']['checked'])) {
722 print '<td class="tdoverflowmax125 small" title="'.dol_escape_htmltag($objp->invoice_label).'">';
723 print dol_escape_htmltag($objp->invoice_label);
724 print '</td>';
725 $totalarray['nbfield']++;
726 }
727 // Date invoice
728 if (!empty($arrayfields['f.datef']['checked'])) {
729 print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
730 $totalarray['nbfield']++;
731 }
732 // Ref Product
733 if (!empty($arrayfields['p.ref']['checked'])) {
734 print '<td class="tdoverflowmax100">';
735 if ($productstatic->id > 0) {
736 print $productstatic->getNomUrl(1);
737 }
738 if ($productstatic->id > 0 && $objp->product_label) {
739 print '<br>';
740 }
741 if ($objp->product_label) {
742 print '<span class="opacitymedium">'.$objp->product_label.'</span>';
743 }
744 print '</td>';
745 $totalarray['nbfield']++;
746 }
747 // Description
748 if (!empty($arrayfields['l.description']['checked'])) {
749 $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
750 print '<td class="tdoverflowmax200 small" title="'.dol_escape_htmltag($text).'">';
751 $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
752 print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
753 print '</td>';
754 $totalarray['nbfield']++;
755 }
756 // Amount
757 if (!empty($arrayfields['l.total_ht']['checked'])) {
758 print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
759 $totalarray['nbfield']++;
760 }
761 // VAT Rate
762 if (!empty($arrayfields['l.tva_tx']['checked'])) {
763 print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
764 $totalarray['nbfield']++;
765 }
766 // Thirdparty
767 if (!empty($arrayfields['s.nom']['checked'])) {
768 print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
769 $totalarray['nbfield']++;
770 }
771 // Country
772 if (!empty($arrayfields['co.label']['checked'])) {
773 print '<td class="tdoverflowmax100">';
774 if ($objp->country_code) {
775 print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
776 }
777 print '</td>';
778 $totalarray['nbfield']++;
779 }
780 // TVA Intracom
781 if (!empty($arrayfields['s.tva_intra']['checked'])) {
782 print '<td class="tdoverflowmax80" title="'.dol_escape_htmltag($objp->tva_intra).'">'.dol_escape_htmltag($objp->tva_intra).'</td>';
783 $totalarray['nbfield']++;
784 }
785 // Account
786 if (!empty($arrayfields['aa.account_number']['checked'])) {
787 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($accountingaccountstatic->label).'">';
788 print '<a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
789 print img_edit();
790 print '</a> ';
791 print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
792 print '</td>';
793 $totalarray['nbfield']++;
794 }
795 // Fields from hook
796 $parameters = array('arrayfields' => $arrayfields, 'obj' => $objp, 'i' => $i, 'totalarray' => &$totalarray);
797 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
798 print $hookmanager->resPrint;
799 // Action column
800 if (!$conf->main_checkbox_left_column) {
801 print '<td class="nowrap center actioncolumn">';
802 $selected = in_array($objp->rowid, $changeaccount);
803 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect checkforaction" type="checkbox" name="changeaccount[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
804 print '</td>';
805 if (!$i) {
806 $totalarray['nbfield']++;
807 }
808 }
809
810 print '</tr>';
811 $i++;
812 }
813 if ($num_lines == 0) {
814 $colspan = 1;
815 foreach ($arrayfields as $key => $val) {
816 if (!empty($val['checked'])) {
817 $colspan++;
818 }
819 }
820 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
821 }
822
823 $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
824 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
825 print $hookmanager->resPrint;
826
827
828 print '</table>';
829 print "</div>";
830
831 if ($nbtotalofrecords > $limit) {
832 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
833 }
834
835 print '</form>';
836} else {
837 print $db->lasterror();
838}
839
840// End of page
841llxFooter();
842$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
$totalarray
Definition export.php:1206
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 permettant la generation de composants html autre 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...
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)
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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.