dolibarr 21.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-2024 Alexandre Spangaro <aspangaro@easya.solutions>
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');
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$formaccounting = new FormAccounting($db);
102
103// Security check
104if (!isModEnabled('accounting')) {
106}
107if ($user->socid > 0) {
109}
110if (!$user->hasRight('accounting', 'bind', 'write')) {
112}
113
114
115$formaccounting = new FormAccounting($db);
116
117
118/*
119 * Actions
120 */
121
122// Purge search criteria
123if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
124 $search_societe = '';
125 $search_lineid = '';
126 $search_ref = '';
127 $search_invoice = '';
128 //$search_ref_supplier = '';
129 $search_label = '';
130 $search_desc = '';
131 $search_amount = '';
132 $search_account = '';
133 $search_vat = '';
134 $search_date_startday = '';
135 $search_date_startmonth = '';
136 $search_date_startyear = '';
137 $search_date_endday = '';
138 $search_date_endmonth = '';
139 $search_date_endyear = '';
140 $search_date_start = '';
141 $search_date_end = '';
142 $search_country = '';
143 $search_tvaintra = '';
144}
145
146if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
147 $error = 0;
148
149 if (!(GETPOSTINT('account_parent') >= 0)) {
150 $error++;
151 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
152 }
153
154 if (!$error) {
155 $db->begin();
156
157 $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
158 $sql1 .= " SET fk_code_ventilation=".(GETPOSTINT('account_parent') > 0 ? GETPOSTINT('account_parent') : '0');
159 $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
160
161 dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
162 $resql1 = $db->query($sql1);
163 if (!$resql1) {
164 $error++;
165 setEventMessages($db->lasterror(), null, 'errors');
166 }
167 if (!$error) {
168 $db->commit();
169 setEventMessages($langs->trans("Save"), null, 'mesgs');
170 } else {
171 $db->rollback();
172 setEventMessages($db->lasterror(), null, 'errors');
173 }
174
175 $account_parent = ''; // Protection to avoid to mass apply it a second time
176 }
177}
178
179if (GETPOST('sortfield') == 'f.datef, f.ref, l.rowid') {
180 $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1);
181 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
182 $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity);
183}
184
185
186/*
187 * View
188 */
189
190$form = new Form($db);
191$formother = new FormOther($db);
192
193$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
194
195llxHeader('', $langs->trans("SuppliersVentilation").' - '.$langs->trans("Dispatched"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-supplier page-lines');
196
197print '<script type="text/javascript">
198 $(function () {
199 $(\'#select-all\').click(function(event) {
200 // Iterate each checkbox
201 $(\':checkbox\').each(function() {
202 this.checked = true;
203 });
204 });
205 $(\'#unselect-all\').click(function(event) {
206 // Iterate each checkbox
207 $(\':checkbox\').each(function() {
208 this.checked = false;
209 });
210 });
211 });
212 </script>';
213
214/*
215 * Supplier Invoice lines
216 */
217$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,";
218$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,";
219$sql .= " aa.rowid as fk_compte, aa.label as label_account, aa.labelshort as labelshort_account, aa.account_number,";
220$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,";
221if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
222 $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
223} else {
224 $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
225}
226$sql .= " co.code as country_code, co.label as country,";
227$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";
228if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
229 $sql .= ", spe.accountancy_code_customer as code_compta_client";
230 $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
231} else {
232 $sql .= ", s.code_compta as code_compta_client";
233 $sql .= ", s.code_compta_fournisseur";
234}
235$parameters = array();
236$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
237$sql .= $hookmanager->resPrint;
238$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
239$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
240if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
241 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
242}
243$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
244$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
245$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
246if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
247 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
248}
249$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
250$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
251// Add search filter like
252if ($search_societe) {
253 $sql .= natural_search('s.nom', $search_societe);
254}
255if ($search_lineid) {
256 $sql .= natural_search("l.rowid", $search_lineid, 1);
257}
258if (strlen(trim($search_invoice))) {
259 $sql .= natural_search(array("f.ref", "f.ref_supplier"), $search_invoice);
260}
261/*if (strlen(trim($search_ref_supplier))) {
262 $sql .= natural_search("f.ref_supplier", $search_ref_supplier);
263}*/
264if (strlen(trim($search_label))) {
265 $sql .= natural_search("f.libelle", $search_label);
266}
267if (strlen(trim($search_ref))) {
268 $sql .= natural_search("p.ref", $search_ref);
269}
270if (strlen(trim($search_desc))) {
271 $sql .= natural_search("l.description", $search_desc);
272}
273if (strlen(trim($search_amount))) {
274 $sql .= natural_search("l.total_ht", $search_amount, 1);
275}
276if (strlen(trim($search_account))) {
277 $sql .= natural_search("aa.account_number", $search_account);
278}
279if (strlen(trim($search_vat))) {
280 $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
281}
282if ($search_date_start) {
283 $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
284}
285if ($search_date_end) {
286 $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
287}
288if (strlen(trim($search_country))) {
289 $arrayofcode = getCountriesInEEC();
290 $country_code_in_EEC = $country_code_in_EEC_without_me = '';
291 foreach ($arrayofcode as $key => $value) {
292 $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
293 if ($value != $mysoc->country_code) {
294 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
295 }
296 }
297 if ($search_country == 'special_allnotme') {
298 $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
299 } elseif ($search_country == 'special_eec') {
300 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
301 } elseif ($search_country == 'special_eecnotme') {
302 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
303 } elseif ($search_country == 'special_noteec') {
304 $sql .= " AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
305 } else {
306 $sql .= natural_search("co.code", $search_country);
307 }
308}
309if (strlen(trim($search_tvaintra))) {
310 $sql .= natural_search("s.tva_intra", $search_tvaintra);
311}
312$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
313
314// Add where from hooks
315$parameters = array();
316$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
317$sql .= $hookmanager->resPrint;
318
319$sql .= $db->order($sortfield, $sortorder);
320
321// Count total nb of records
322$nbtotalofrecords = '';
323if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
324 $result = $db->query($sql);
325 $nbtotalofrecords = $db->num_rows($result);
326 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
327 $page = 0;
328 $offset = 0;
329 }
330}
331
332$sql .= $db->plimit($limit + 1, $offset);
333
334dol_syslog("accountancy/supplier/lines.php", LOG_DEBUG);
335$result = $db->query($sql);
336if ($result) {
337 $num_lines = $db->num_rows($result);
338 $i = 0;
339
340 $param = '';
341 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
342 $param .= '&contextpage='.urlencode($contextpage);
343 }
344 if ($limit > 0 && $limit != $conf->liste_limit) {
345 $param .= '&limit='.((int) $limit);
346 }
347 if ($search_societe) {
348 $param .= "&search_societe=".urlencode($search_societe);
349 }
350 if ($search_invoice) {
351 $param .= "&search_invoice=".urlencode($search_invoice);
352 }
353 if ($search_ref) {
354 $param .= "&search_ref=".urlencode($search_ref);
355 }
356 /*if ($search_ref_supplier) {
357 $param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
358 }*/
359 if ($search_label) {
360 $param .= "&search_label=".urlencode($search_label);
361 }
362 if ($search_desc) {
363 $param .= "&search_desc=".urlencode($search_desc);
364 }
365 if ($search_account) {
366 $param .= "&search_account=".urlencode($search_account);
367 }
368 if ($search_vat) {
369 $param .= "&search_vat=".urlencode($search_vat);
370 }
371 if ($search_date_startday) {
372 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
373 }
374 if ($search_date_startmonth) {
375 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
376 }
377 if ($search_date_startyear) {
378 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
379 }
380 if ($search_date_endday) {
381 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
382 }
383 if ($search_date_endmonth) {
384 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
385 }
386 if ($search_date_endyear) {
387 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
388 }
389 if ($search_country) {
390 $param .= "&search_country=".urlencode($search_country);
391 }
392 if ($search_tvaintra) {
393 $param .= "&search_tvaintra=".urlencode($search_tvaintra);
394 }
395
396 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
397 print '<input type="hidden" name="action" value="ventil">';
398 if ($optioncss != '') {
399 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
400 }
401 print '<input type="hidden" name="token" value="'.newToken().'">';
402 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
403 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
404 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
405 print '<input type="hidden" name="page" value="'.$page.'">';
406
407 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
408 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);
409
410 print '<br>'.$langs->trans("ChangeAccount").' <div class="inline-block paddingbottom marginbottomonly">';
411 print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
412 print '<input type="submit" class="button small smallpaddingimp valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
413
414 $moreforfilter = '';
415
416 print '<div class="div-table-responsive">';
417 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
418
419 // We add search filter
420 print '<tr class="liste_titre_filter">';
421 print '<td class="liste_titre"><input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
422 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
423 //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'"></td>';
424 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
425 print '<td class="liste_titre center">';
426 print '<div class="nowrapfordate">';
427 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
428 print '</div>';
429 print '<div class="nowrapfordate">';
430 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
431 print '</div>';
432 print '</td>';
433 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
434 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
435 print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
436 print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
437 print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
438 print '<td class="liste_titre">';
439 print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100', 'code2', 1, 0, 1);
440 // print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
441 print '</td>';
442 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
443 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
444 print '<td class="liste_titre center">';
445 $searchpicto = $form->showFilterButtons();
446 print $searchpicto;
447 print "</td></tr>\n";
448
449 print '<tr class="liste_titre">';
450 print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
451 print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
452 //print_liste_field_titre("RefSupplier", $_SERVER["PHP_SELF"], "f.ref_supplier", "", $param, '', $sortfield, $sortorder);
453 print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
454 print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
455 print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
456 //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
457 print_liste_field_titre("ProductDescription", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
458 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
459 print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
460 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
461 print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
462 print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
463 print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
464 $checkpicto = $form->showCheckAddButtons();
465 print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
466 print "</tr>\n";
467
468 $thirdpartystatic = new Societe($db);
469 $facturefournisseur_static = new FactureFournisseur($db);
470 $productstatic = new ProductFournisseur($db);
471 $accountingaccountstatic = new AccountingAccount($db);
472
473 $i = 0;
474 while ($i < min($num_lines, $limit)) {
475 $objp = $db->fetch_object($result);
476
477 $facturefournisseur_static->ref = $objp->ref;
478 $facturefournisseur_static->id = $objp->facid;
479 $facturefournisseur_static->type = $objp->ftype;
480 $facturefournisseur_static->ref_supplier = $objp->ref_supplier;
481 $facturefournisseur_static->label = $objp->invoice_label;
482
483 $thirdpartystatic->id = $objp->socid;
484 $thirdpartystatic->name = $objp->name;
485 $thirdpartystatic->client = $objp->client;
486 $thirdpartystatic->fournisseur = $objp->fournisseur;
487 $thirdpartystatic->code_client = $objp->code_client;
488 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
489 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
490 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
491 $thirdpartystatic->email = $objp->email;
492 $thirdpartystatic->country_code = $objp->country_code;
493
494 $productstatic->ref = $objp->product_ref;
495 $productstatic->id = $objp->product_id;
496 $productstatic->label = $objp->product_label;
497 $productstatic->type = $objp->line_type;
498 $productstatic->status = $objp->tosell;
499 $productstatic->status_buy = $objp->tobuy;
500 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
501 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
502 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
503
504 $accountingaccountstatic->rowid = $objp->fk_compte;
505 $accountingaccountstatic->label = $objp->label_account;
506 $accountingaccountstatic->labelshort = $objp->labelshort_account;
507 $accountingaccountstatic->account_number = $objp->account_number;
508
509 print '<tr class="oddeven">';
510
511 // Line id
512 print '<td>'.$objp->rowid.'</td>';
513
514 // Ref Invoice
515 print '<td class="nowraponall tdoverflowmax125">';
516 print $facturefournisseur_static->getNomUrl(1);
517 if ($objp->ref_supplier) {
518 print '<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->ref_supplier).'</span>';
519 }
520 print '</td>';
521
522 // Ref supplier invoice
523 /*
524 print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($objp->ref_supplier).'">';
525 print $objp->ref_supplier;
526 print '</td>';
527 */
528
529 // Supplier invoice label
530 print '<td class="tdoverflowmax125 small" title="'.dol_escape_htmltag($objp->invoice_label).'">';
531 print dol_escape_htmltag($objp->invoice_label);
532 print '</td>';
533
534 // Date invoice
535 print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
536
537 // Ref Product
538 print '<td class="tdoverflowmax100">';
539 if ($productstatic->id > 0) {
540 print $productstatic->getNomUrl(1);
541 }
542 if ($productstatic->id > 0 && $objp->product_label) {
543 print '<br>';
544 }
545 if ($objp->product_label) {
546 print '<span class="opacitymedium">'.$objp->product_label.'</span>';
547 }
548 print '</td>';
549
550 $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
551 print '<td class="tdoverflowmax200 small" title="'.dol_escape_htmltag($text).'">';
552 $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
553 print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
554 print '</td>';
555
556 print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
557
558 print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
559
560 // Thirdparty
561 print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
562
563 // Country
564 print '<td class="tdoverflowmax100">';
565 if ($objp->country_code) {
566 print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
567 }
568 print '</td>';
569
570 print '<td class="tdoverflowmax80" title="'.dol_escape_htmltag($objp->tva_intra).'">'.dol_escape_htmltag($objp->tva_intra).'</td>';
571
572 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($accountingaccountstatic->label).'">';
573 print '<a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
574 print img_edit();
575 print '</a> ';
576 print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
577 print '</td>';
578
579 print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
580
581 print '</tr>';
582 $i++;
583 }
584 if ($num_lines == 0) {
585 print '<tr><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
586 }
587
588 print '</table>';
589 print "</div>";
590
591 if ($nbtotalofrecords > $limit) {
592 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
593 }
594
595 print '</form>';
596} else {
597 print $db->lasterror();
598}
599
600// End of page
601llxFooter();
602$db->close();
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).
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:71
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...
llxFooter()
Footer empty.
Definition document.php:107
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_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.
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.
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.