dolibarr  16.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-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
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  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
27 require '../../main.inc.php';
28 
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array("compta", "bills", "other", "accountancy", "productbatch", "products"));
42 
43 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
44 
45 $account_parent = GETPOST('account_parent');
46 $changeaccount = GETPOST('changeaccount');
47 // Search Getpost
48 $search_societe = GETPOST('search_societe', 'alpha');
49 $search_lineid = GETPOST('search_lineid', 'int');
50 $search_ref = GETPOST('search_ref', 'alpha');
51 $search_invoice = GETPOST('search_invoice', 'alpha');
52 $search_ref_supplier = GETPOST('search_ref_supplier', 'alpha');
53 $search_label = GETPOST('search_label', 'alpha');
54 $search_desc = GETPOST('search_desc', 'alpha');
55 $search_amount = GETPOST('search_amount', 'alpha');
56 $search_account = GETPOST('search_account', 'alpha');
57 $search_vat = GETPOST('search_vat', 'alpha');
58 $search_date_startday = GETPOST('search_date_startday', 'int');
59 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
60 $search_date_startyear = GETPOST('search_date_startyear', 'int');
61 $search_date_endday = GETPOST('search_date_endday', 'int');
62 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
63 $search_date_endyear = GETPOST('search_date_endyear', 'int');
64 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
65 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
66 $search_country = GETPOST('search_country', 'alpha');
67 $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
68 
69 // Load variable for pagination
70 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
71 $sortfield = GETPOST('sortfield', 'aZ09comma');
72 $sortorder = GETPOST('sortorder', 'aZ09comma');
73 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
74 if (empty($page) || $page < 0) {
75  $page = 0;
76 }
77 $offset = $limit * $page;
78 $pageprev = $page - 1;
79 $pagenext = $page + 1;
80 if (!$sortfield) {
81  $sortfield = "f.datef, f.ref, l.rowid";
82 }
83 if (!$sortorder) {
84  if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
85  $sortorder = "DESC";
86  }
87 }
88 
89 $formaccounting = new FormAccounting($db);
90 
91 // Security check
92 if (!isModEnabled('accounting')) {
94 }
95 if ($user->socid > 0) {
97 }
98 if (empty($user->rights->accounting->mouvements->lire)) {
100 }
101 
102 
103 $formaccounting = new FormAccounting($db);
104 
105 
106 /*
107  * Actions
108  */
109 
110 // Purge search criteria
111 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
112  $search_societe = '';
113  $search_lineid = '';
114  $search_ref = '';
115  $search_invoice = '';
116  $search_ref_supplier = '';
117  $search_label = '';
118  $search_desc = '';
119  $search_amount = '';
120  $search_account = '';
121  $search_vat = '';
122  $search_date_startday = '';
123  $search_date_startmonth = '';
124  $search_date_startyear = '';
125  $search_date_endday = '';
126  $search_date_endmonth = '';
127  $search_date_endyear = '';
128  $search_date_start = '';
129  $search_date_end = '';
130  $search_country = '';
131  $search_tvaintra = '';
132 }
133 
134 if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) {
135  $error = 0;
136 
137  if (!(GETPOST('account_parent', 'int') >= 0)) {
138  $error++;
139  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
140  }
141 
142  if (!$error) {
143  $db->begin();
144 
145  $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
146  $sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
147  $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
148 
149  dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
150  $resql1 = $db->query($sql1);
151  if (!$resql1) {
152  $error++;
153  setEventMessages($db->lasterror(), null, 'errors');
154  }
155  if (!$error) {
156  $db->commit();
157  setEventMessages($langs->trans("Save"), null, 'mesgs');
158  } else {
159  $db->rollback();
160  setEventMessages($db->lasterror(), null, 'errors');
161  }
162 
163  $account_parent = ''; // Protection to avoid to mass apply it a second time
164  }
165 }
166 
167 
168 /*
169  * View
170  */
171 
172 $form = new Form($db);
173 $formother = new FormOther($db);
174 
175 llxHeader('', $langs->trans("SuppliersVentilation").' - '.$langs->trans("Dispatched"));
176 
177 print '<script type="text/javascript">
178  $(function () {
179  $(\'#select-all\').click(function(event) {
180  // Iterate each checkbox
181  $(\':checkbox\').each(function() {
182  this.checked = true;
183  });
184  });
185  $(\'#unselect-all\').click(function(event) {
186  // Iterate each checkbox
187  $(\':checkbox\').each(function() {
188  this.checked = false;
189  });
190  });
191  });
192  </script>';
193 
194 /*
195  * Supplier Invoice lines
196  */
197 $sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
198 $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,";
199 $sql .= " aa.label as label_account, aa.labelshort as labelshort_account, aa.account_number,";
200 $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,";
201 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
202  $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
203 } else {
204  $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
205 }
206 $sql .= " co.code as country_code, co.label as country,";
207 $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";
208 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
209  $sql .= ", spe.accountancy_code_customer as code_compta_client";
210  $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
211 } else {
212  $sql .= ", s.code_compta as code_compta_client";
213  $sql .= ", s.code_compta_fournisseur";
214 }
215 $parameters = array();
216 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
217 $sql .= $hookmanager->resPrint;
218 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
219 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
220 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
221  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
222 }
223 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
224 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
225 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
226 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
227  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
228 }
229 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
230 $sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
231 // Add search filter like
232 if ($search_societe) {
233  $sql .= natural_search('s.nom', $search_societe);
234 }
235 if ($search_lineid) {
236  $sql .= natural_search("l.rowid", $search_lineid, 1);
237 }
238 if (strlen(trim($search_invoice))) {
239  $sql .= natural_search("f.ref", $search_invoice);
240 }
241 if (strlen(trim($search_ref_supplier))) {
242  $sql .= natural_search("f.ref_supplier", $search_ref_supplier);
243 }
244 if (strlen(trim($search_label))) {
245  $sql .= natural_search("f.libelle", $search_label);
246 }
247 if (strlen(trim($search_ref))) {
248  $sql .= natural_search("p.ref", $search_ref);
249 }
250 if (strlen(trim($search_desc))) {
251  $sql .= natural_search("l.description", $search_desc);
252 }
253 if (strlen(trim($search_amount))) {
254  $sql .= natural_search("l.total_ht", $search_amount, 1);
255 }
256 if (strlen(trim($search_account))) {
257  $sql .= natural_search("aa.account_number", $search_account);
258 }
259 if (strlen(trim($search_vat))) {
260  $sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
261 }
262 if ($search_date_start) {
263  $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
264 }
265 if ($search_date_end) {
266  $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
267 }
268 if (strlen(trim($search_country))) {
269  $arrayofcode = getCountriesInEEC();
270  $country_code_in_EEC = $country_code_in_EEC_without_me = '';
271  foreach ($arrayofcode as $key => $value) {
272  $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
273  if ($value != $mysoc->country_code) {
274  $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
275  }
276  }
277  if ($search_country == 'special_allnotme') {
278  $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
279  } elseif ($search_country == 'special_eec') {
280  $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
281  } elseif ($search_country == 'special_eecnotme') {
282  $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
283  } elseif ($search_country == 'special_noteec') {
284  $sql .= " AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
285  } else {
286  $sql .= natural_search("co.code", $search_country);
287  }
288 }
289 if (strlen(trim($search_tvaintra))) {
290  $sql .= natural_search("s.tva_intra", $search_tvaintra);
291 }
292 $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
293 
294 // Add where from hooks
295 $parameters = array();
296 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
297 $sql .= $hookmanager->resPrint;
298 
299 $sql .= $db->order($sortfield, $sortorder);
300 
301 // Count total nb of records
302 $nbtotalofrecords = '';
303 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
304  $result = $db->query($sql);
305  $nbtotalofrecords = $db->num_rows($result);
306  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
307  $page = 0;
308  $offset = 0;
309  }
310 }
311 
312 $sql .= $db->plimit($limit + 1, $offset);
313 
314 dol_syslog("accountancy/supplier/lines.php", LOG_DEBUG);
315 $result = $db->query($sql);
316 if ($result) {
317  $num_lines = $db->num_rows($result);
318  $i = 0;
319 
320  $param = '';
321  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
322  $param .= '&contextpage='.urlencode($contextpage);
323  }
324  if ($limit > 0 && $limit != $conf->liste_limit) {
325  $param .= '&limit='.urlencode($limit);
326  }
327  if ($search_societe) {
328  $param .= "&search_societe=".urlencode($search_societe);
329  }
330  if ($search_invoice) {
331  $param .= "&search_invoice=".urlencode($search_invoice);
332  }
333  if ($search_ref) {
334  $param .= "&search_ref=".urlencode($search_ref);
335  }
336  if ($search_ref_supplier) {
337  $param .= '&search_ref_supplier='.urlencode($search_ref_supplier);
338  }
339  if ($search_label) {
340  $param .= "&search_label=".urlencode($search_label);
341  }
342  if ($search_desc) {
343  $param .= "&search_desc=".urlencode($search_desc);
344  }
345  if ($search_account) {
346  $param .= "&search_account=".urlencode($search_account);
347  }
348  if ($search_vat) {
349  $param .= "&search_vat=".urlencode($search_vat);
350  }
351  if ($search_date_startday) {
352  $param .= '&search_date_startday='.urlencode($search_date_startday);
353  }
354  if ($search_date_startmonth) {
355  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
356  }
357  if ($search_date_startyear) {
358  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
359  }
360  if ($search_date_endday) {
361  $param .= '&search_date_endday='.urlencode($search_date_endday);
362  }
363  if ($search_date_endmonth) {
364  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
365  }
366  if ($search_date_endyear) {
367  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
368  }
369  if ($search_country) {
370  $param .= "&search_country=".urlencode($search_country);
371  }
372  if ($search_tvaintra) {
373  $param .= "&search_tvaintra=".urlencode($search_tvaintra);
374  }
375 
376  print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
377  print '<input type="hidden" name="action" value="ventil">';
378  if ($optioncss != '') {
379  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
380  }
381  print '<input type="hidden" name="token" value="'.newToken().'">';
382  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
383  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
384  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
385  print '<input type="hidden" name="page" value="'.$page.'">';
386 
387  print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
388  print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier").'</span><br>';
389 
390  print '<br><div class="inline-block divButAction paddingbottom">'.$langs->trans("ChangeAccount").' ';
391  print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
392  print '<input type="submit" class="button small valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
393 
394  $moreforfilter = '';
395 
396  print '<div class="div-table-responsive">';
397  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
398 
399  // We add search filter
400  print '<tr class="liste_titre_filter">';
401  print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
402  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
403  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'"></td>';
404  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
405  print '<td class="liste_titre center">';
406  print '<div class="nowrap">';
407  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
408  print '</div>';
409  print '<div class="nowrap">';
410  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
411  print '</div>';
412  print '</td>';
413  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
414  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
415  print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
416  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>';
417  print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
418  print '<td class="liste_titre">';
419  print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
420  // print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
421  print '</td>';
422  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
423  print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
424  print '<td class="liste_titre center">';
425  $searchpicto = $form->showFilterButtons();
426  print $searchpicto;
427  print "</td></tr>\n";
428 
429  print '<tr class="liste_titre">';
430  print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
431  print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
432  print_liste_field_titre("RefSupplier", $_SERVER["PHP_SELF"], "f.ref_supplier", "", $param, '', $sortfield, $sortorder);
433  print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
434  print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
435  print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
436  //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
437  print_liste_field_titre("ProductDescription", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
438  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
439  print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
440  print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
441  print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
442  print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
443  print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
444  $checkpicto = $form->showCheckAddButtons();
445  print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
446  print "</tr>\n";
447 
448  $thirdpartystatic = new Societe($db);
449  $facturefournisseur_static = new FactureFournisseur($db);
450  $productstatic = new ProductFournisseur($db);
451  $accountingaccountstatic = new AccountingAccount($db);
452 
453  $i = 0;
454  while ($i < min($num_lines, $limit)) {
455  $objp = $db->fetch_object($result);
456 
457  $facturefournisseur_static->ref = $objp->ref;
458  $facturefournisseur_static->id = $objp->facid;
459  $facturefournisseur_static->type = $objp->ftype;
460  $facturefournisseur_static->ref_supplier = $objp->ref_supplier;
461  $facturefournisseur_static->label = $objp->invoice_label;
462 
463  $thirdpartystatic->id = $objp->socid;
464  $thirdpartystatic->name = $objp->name;
465  $thirdpartystatic->client = $objp->client;
466  $thirdpartystatic->fournisseur = $objp->fournisseur;
467  $thirdpartystatic->code_client = $objp->code_client;
468  $thirdpartystatic->code_compta_client = $objp->code_compta_client;
469  $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
470  $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
471  $thirdpartystatic->email = $objp->email;
472  $thirdpartystatic->country_code = $objp->country_code;
473 
474  $productstatic->ref = $objp->product_ref;
475  $productstatic->id = $objp->product_id;
476  $productstatic->label = $objp->product_label;
477  $productstatic->type = $objp->line_type;
478  $productstatic->status = $objp->tosell;
479  $productstatic->status_buy = $objp->tobuy;
480  $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
481  $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_sell_buy_intra;
482  $productstatic->accountancy_code_buy_export = $objp->accountancy_code_sell_buy_export;
483 
484  $accountingaccountstatic->rowid = $objp->fk_compte;
485  $accountingaccountstatic->label = $objp->label_account;
486  $accountingaccountstatic->labelshort = $objp->labelshort_account;
487  $accountingaccountstatic->account_number = $objp->account_number;
488 
489  print '<tr class="oddeven">';
490 
491  // Line id
492  print '<td>'.$objp->rowid.'</td>';
493 
494  // Ref Invoice
495  print '<td class="nowraponall">'.$facturefournisseur_static->getNomUrl(1).'</td>';
496 
497  // Ref supplier invoice
498  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($objp->ref_supplier).'">';
499  print $objp->ref_supplier;
500  print '</td>';
501 
502  // Supplier invoice label
503  print '<td class="tdoverflowonsmartphone small" title="'.dol_escape_htmltag($objp->invoice_label).'">';
504  print $objp->invoice_label;
505  print '</td>';
506 
507  // Date invoice
508  print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
509 
510  // Ref Product
511  print '<td class="tdoverflowmax100">';
512  if ($productstatic->id > 0) {
513  print $productstatic->getNomUrl(1);
514  }
515  if ($productstatic->id > 0 && $objp->product_label) {
516  print '<br>';
517  }
518  if ($objp->product_label) {
519  print '<span class="opacitymedium">'.$objp->product_label.'</span>';
520  }
521  print '</td>';
522 
523  print '<td class="tdoverflowonsmartphone small">';
524  $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
525  $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
526  print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
527  print '</td>';
528 
529  print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
530 
531  print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
532 
533  // Thirdparty
534  print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
535 
536  // Country
537  print '<td>';
538  if ($objp->country_code) {
539  print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
540  }
541  print '</td>';
542 
543  print '<td class="tdoverflowmax80" title="'.dol_escape_htmltag($objp->tva_intra).'">'.dol_escape_htmltag($objp->tva_intra).'</td>';
544 
545  print '<td>';
546  print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
547  print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
548  print img_edit();
549  print '</a></td>';
550  print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
551 
552  print '</tr>';
553  $i++;
554  }
555  print '</table>';
556  print "</div>";
557 
558  if ($nbtotalofrecords > $limit) {
559  print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
560  }
561 
562  print '</form>';
563 } else {
564  print $db->lasterror();
565 }
566 
567 // End of page
568 llxFooter();
569 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1454
dol_trunc
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.
Definition: functions.lib.php:3791
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
ProductFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.product.class.php:41
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FactureFournisseur
Class to manage suppliers invoices.
Definition: fournisseur.facture.class.php:53
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4375
FormAccounting
Class to manage generation of HTML components for accounting management.
Definition: html.formaccounting.class.php:33
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5647
getCountriesInEEC
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
Definition: company.lib.php:716
dol_string_nohtmltag
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Definition: functions.lib.php:6680
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1589
print_barre_liste
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
Definition: functions.lib.php:5243
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
AccountingAccount
Class to manage accounting accounts.
Definition: accountingaccount.class.php:36
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5012
natural_search
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...
Definition: functions.lib.php:9406
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8123
dolGetFirstLineOfText
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
Definition: functions.lib.php:6893
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2743
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25