dolibarr  19.0.0-dev
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-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
4  * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
5  * Copyright (C) 2014-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.'/compta/facture/class/facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array("bills", "compta", "accountancy", "productbatch", "products"));
41 
42 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
43 
44 $account_parent = GETPOST('account_parent');
45 $changeaccount = GETPOST('changeaccount');
46 // Search Getpost
47 $search_societe = GETPOST('search_societe', 'alpha');
48 $search_lineid = GETPOST('search_lineid', 'int');
49 $search_ref = GETPOST('search_ref', 'alpha');
50 $search_invoice = GETPOST('search_invoice', 'alpha');
51 $search_label = GETPOST('search_label', 'alpha');
52 $search_desc = GETPOST('search_desc', 'alpha');
53 $search_amount = GETPOST('search_amount', 'alpha');
54 $search_account = GETPOST('search_account', 'alpha');
55 $search_vat = GETPOST('search_vat', 'alpha');
56 $search_date_startday = GETPOST('search_date_startday', 'int');
57 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
58 $search_date_startyear = GETPOST('search_date_startyear', 'int');
59 $search_date_endday = GETPOST('search_date_endday', 'int');
60 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
61 $search_date_endyear = GETPOST('search_date_endyear', 'int');
62 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
63 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
64 $search_country = GETPOST('search_country', 'alpha');
65 $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
66 
67 // Load variable for pagination
68 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
69 $sortfield = GETPOST('sortfield', 'aZ09comma');
70 $sortorder = GETPOST('sortorder', 'aZ09comma');
71 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
72 if (empty($page) || $page < 0) {
73  $page = 0;
74 }
75 $offset = $limit * $page;
76 $pageprev = $page - 1;
77 $pagenext = $page + 1;
78 if (!$sortfield) {
79  $sortfield = "f.datef, f.ref, fd.rowid";
80 }
81 if (!$sortorder) {
82  if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
83  $sortorder = "DESC";
84  } else {
85  $sortorder = "ASC";
86  }
87 }
88 
89 // Security check
90 if (!isModEnabled('accounting')) {
92 }
93 if ($user->socid > 0) {
95 }
96 if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
98 }
99 
100 
101 $formaccounting = new FormAccounting($db);
102 
103 
104 /*
105  * Actions
106  */
107 
108 // Purge search criteria
109 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
110  $search_societe = '';
111  $search_lineid = '';
112  $search_ref = '';
113  $search_invoice = '';
114  $search_label = '';
115  $search_desc = '';
116  $search_amount = '';
117  $search_account = '';
118  $search_vat = '';
119  $search_date_startday = '';
120  $search_date_startmonth = '';
121  $search_date_startyear = '';
122  $search_date_endday = '';
123  $search_date_endmonth = '';
124  $search_date_endyear = '';
125  $search_date_start = '';
126  $search_date_end = '';
127  $search_country = '';
128  $search_tvaintra = '';
129 }
130 
131 if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
132  $error = 0;
133 
134  if (!(GETPOST('account_parent', 'int') >= 0)) {
135  $error++;
136  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
137  }
138 
139  if (!$error) {
140  $db->begin();
141 
142  $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet";
143  $sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
144  $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
145 
146  dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1);
147  $resql1 = $db->query($sql1);
148  if (!$resql1) {
149  $error++;
150  setEventMessages($db->lasterror(), null, 'errors');
151  }
152  if (!$error) {
153  $db->commit();
154  setEventMessages($langs->trans("Save"), null, 'mesgs');
155  } else {
156  $db->rollback();
157  setEventMessages($db->lasterror(), null, 'errors');
158  }
159 
160  $account_parent = ''; // Protection to avoid to mass apply it a second time
161  }
162 }
163 
164 if (GETPOST('sortfield') == 'f.datef, f.ref, fd.rowid') {
165  $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1);
166  require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
167  $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity);
168 }
169 
170 
171 /*
172  * View
173  */
174 
175 $form = new Form($db);
176 $formother = new FormOther($db);
177 
178 llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched"));
179 
180 print '<script type="text/javascript">
181  $(function () {
182  $(\'#select-all\').click(function(event) {
183  // Iterate each checkbox
184  $(\':checkbox\').each(function() {
185  this.checked = true;
186  });
187  });
188  $(\'#unselect-all\').click(function(event) {
189  // Iterate each checkbox
190  $(\':checkbox\').each(function() {
191  this.checked = false;
192  });
193  });
194  });
195  </script>';
196 
197 /*
198  * Customer Invoice lines
199  */
200 $sql = "SELECT f.rowid as facid, f.ref as ref, f.type as ftype, f.situation_cycle_ref, f.datef, f.ref_client,";
201 $sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc, fd.situation_percent,";
202 $sql .= " s.rowid as socid, s.nom as name, s.code_client,";
203 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
204  $sql .= " spe.accountancy_code_customer as code_compta_client,";
205  $sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
206 } else {
207  $sql .= " s.code_compta as code_compta_client,";
208  $sql .= " s.code_compta_fournisseur,";
209 }
210 $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.tobuy, p.tosell,";
211 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
212  $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,";
213 } else {
214  $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
215 }
216 $sql .= " aa.rowid as fk_compte, aa.account_number, aa.label as label_account, aa.labelshort as labelshort_account,";
217 $sql .= " fd.situation_percent,";
218 $sql .= " co.code as country_code, co.label as country,";
219 $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";
220 $parameters = array();
221 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
222 $sql .= $hookmanager->resPrint;
223 $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
224 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
225 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
226  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
227 }
228 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
229 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
230 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
231 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
232  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
233 }
234 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
235 $sql .= " WHERE fd.fk_code_ventilation > 0";
236 $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
237 $sql .= " AND f.fk_statut > 0";
238 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
239  $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
240 } else {
241  $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
242 }
243 // Add search filter like
244 if ($search_societe) {
245  $sql .= natural_search('s.nom', $search_societe);
246 }
247 if ($search_lineid) {
248  $sql .= natural_search("fd.rowid", $search_lineid, 1);
249 }
250 if (strlen(trim($search_invoice))) {
251  $sql .= natural_search("f.ref", $search_invoice);
252 }
253 if (strlen(trim($search_ref))) {
254  $sql .= natural_search("p.ref", $search_ref);
255 }
256 if (strlen(trim($search_label))) {
257  $sql .= natural_search("p.label", $search_label);
258 }
259 if (strlen(trim($search_desc))) {
260  $sql .= natural_search("fd.description", $search_desc);
261 }
262 if (strlen(trim($search_amount))) {
263  $sql .= natural_search("fd.total_ht", $search_amount, 1);
264 }
265 if (strlen(trim($search_account))) {
266  $sql .= natural_search("aa.account_number", $search_account);
267 }
268 if (strlen(trim($search_vat))) {
269  $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1);
270 }
271 if ($search_date_start) {
272  $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
273 }
274 if ($search_date_end) {
275  $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
276 }
277 if (strlen(trim($search_country))) {
278  $arrayofcode = getCountriesInEEC();
279  $country_code_in_EEC = $country_code_in_EEC_without_me = '';
280  foreach ($arrayofcode as $key => $value) {
281  $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
282  if ($value != $mysoc->country_code) {
283  $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
284  }
285  }
286  if ($search_country == 'special_allnotme') {
287  $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
288  } elseif ($search_country == 'special_eec') {
289  $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
290  } elseif ($search_country == 'special_eecnotme') {
291  $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
292  } elseif ($search_country == 'special_noteec') {
293  $sql .= " AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
294  } else {
295  $sql .= natural_search("co.code", $search_country);
296  }
297 }
298 if (strlen(trim($search_tvaintra))) {
299  $sql .= natural_search("s.tva_intra", $search_tvaintra);
300 }
301 $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
302 $sql .= $db->order($sortfield, $sortorder);
303 
304 // Count total nb of records
305 $nbtotalofrecords = '';
306 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
307  $result = $db->query($sql);
308  $nbtotalofrecords = $db->num_rows($result);
309  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
310  $page = 0;
311  $offset = 0;
312  }
313 }
314 
315 $sql .= $db->plimit($limit + 1, $offset);
316 
317 dol_syslog("/accountancy/customer/lines.php", LOG_DEBUG);
318 $result = $db->query($sql);
319 if ($result) {
320  $num_lines = $db->num_rows($result);
321  $i = 0;
322 
323  $param = '';
324  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
325  $param .= '&contextpage='.urlencode($contextpage);
326  }
327  if ($limit > 0 && $limit != $conf->liste_limit) {
328  $param .= '&limit='.((int) $limit);
329  }
330  if ($search_societe) {
331  $param .= "&search_societe=".urlencode($search_societe);
332  }
333  if ($search_invoice) {
334  $param .= "&search_invoice=".urlencode($search_invoice);
335  }
336  if ($search_ref) {
337  $param .= "&search_ref=".urlencode($search_ref);
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("DescVentilDoneCustomer").'</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  print '<tr class="liste_titre_filter">';
400  print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
401  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
402  print '<td class="liste_titre center">';
403  print '<div class="nowrap">';
404  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
405  print '</div>';
406  print '<div class="nowrap">';
407  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
408  print '</div>';
409  print '</td>';
410  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
411  //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
412  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
413  print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
414  print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
415  print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
416  print '<td class="liste_titre">';
417  print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
418  //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
419  print '</td>';
420  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
421  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
422  print '<td class="liste_titre center">';
423  $searchpicto = $form->showFilterButtons();
424  print $searchpicto;
425  print "</td></tr>\n";
426 
427  print '<tr class="liste_titre">';
428  print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "fd.rowid", "", $param, '', $sortfield, $sortorder);
429  print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
430  print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, fd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
431  print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
432  //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
433  print_liste_field_titre("ProductDescription", $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder);
434  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
435  print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
436  print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
437  print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
438  print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
439  print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
440  $checkpicto = $form->showCheckAddButtons();
441  print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
442  print "</tr>\n";
443 
444  $thirdpartystatic = new Societe($db);
445  $facturestatic = new Facture($db);
446  $productstatic = new Product($db);
447  $accountingaccountstatic = new AccountingAccount($db);
448 
449  $i = 0;
450  while ($i < min($num_lines, $limit)) {
451  $objp = $db->fetch_object($result);
452 
453  $facturestatic->ref = $objp->ref;
454  $facturestatic->id = $objp->facid;
455  $facturestatic->type = $objp->ftype;
456 
457  $thirdpartystatic->id = $objp->socid;
458  $thirdpartystatic->name = $objp->name;
459  $thirdpartystatic->client = $objp->client;
460  $thirdpartystatic->fournisseur = $objp->fournisseur;
461  $thirdpartystatic->code_client = $objp->code_client;
462  $thirdpartystatic->code_compta_client = $objp->code_compta_client;
463  $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
464  $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
465  $thirdpartystatic->email = $objp->email;
466  $thirdpartystatic->country_code = $objp->country_code;
467 
468  $productstatic->ref = $objp->product_ref;
469  $productstatic->id = $objp->product_id;
470  $productstatic->label = $objp->product_label;
471  $productstatic->type = $objp->line_type;
472  $productstatic->status = $objp->tosell;
473  $productstatic->status_buy = $objp->tobuy;
474  $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
475  $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
476  $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
477 
478  $accountingaccountstatic->rowid = $objp->fk_compte;
479  $accountingaccountstatic->label = $objp->label_account;
480  $accountingaccountstatic->labelshort = $objp->labelshort_account;
481  $accountingaccountstatic->account_number = $objp->account_number;
482 
483  print '<tr class="oddeven">';
484 
485  // Line id
486  print '<td>'.$objp->rowid.'</td>';
487 
488  // Ref Invoice
489  print '<td class="nowraponall">'.$facturestatic->getNomUrl(1).'</td>';
490 
491  // Date invoice
492  print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
493 
494  // Ref Product
495  print '<td class="tdoverflowmax100">';
496  if ($productstatic->id > 0) {
497  print $productstatic->getNomUrl(1);
498  }
499  if ($productstatic->id > 0 && $objp->product_label) {
500  print '<br>';
501  }
502  if ($objp->product_label) {
503  print '<span class="opacitymedium">'.$objp->product_label.'</span>';
504  }
505  print '</td>';
506 
507  print '<td class="tdoverflowonsmartphone small">';
508  $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
509  $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
510  print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
511  print '</td>';
512 
513  // Amount
514  print '<td class="right nowraponall amount">';
515 
516  // Create a compensation rate for old situation invoice feature.
517  $situation_ratio = 1;
518  if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
519  if ($objp->situation_cycle_ref) {
520  // Avoid divide by 0
521  if ($objp->situation_percent == 0) {
522  $situation_ratio = 0;
523  } else {
524  $line = new FactureLigne($db);
525  $line->fetch($objp->rowid);
526 
527  // Situation invoices handling
528  $prev_progress = $line->get_prev_progress($objp->facid);
529 
530  $situation_ratio = ($objp->situation_percent - $prev_progress) / $objp->situation_percent;
531  }
532  }
533  print price($objp->total_ht * $situation_ratio);
534  } else {
535  print price($objp->total_ht);
536  }
537  print '</td>';
538 
539  // Vat rate
540  print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
541 
542  // Thirdparty
543  print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
544 
545  // Country
546  print '<td>';
547  if ($objp->country_code) {
548  print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
549  }
550  print '</td>';
551 
552  print '<td class="tdoverflowmax80" title="'.dol_escape_htmltag($objp->tva_intra).'">'.dol_escape_htmltag($objp->tva_intra).'</td>';
553 
554  print '<td>';
555  print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
556  print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
557  print img_edit();
558  print '</a></td>';
559 
560  print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
561 
562  print '</tr>';
563  $i++;
564  }
565  if ($num_lines == 0) {
566  print '<tr><td colspan="12"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
567  }
568 
569  print '</table>';
570  print "</div>";
571 
572  if ($nbtotalofrecords > $limit) {
573  print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
574  }
575 
576  print '</form>';
577 } else {
578  print $db->lasterror();
579 }
580 
581 // End of page
582 llxFooter();
583 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:51
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:4059
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
dol_escape_htmltag
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...
Definition: functions.lib.php:1600
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:609
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
Facture
Class to manage invoices.
Definition: facture.class.php:60
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4652
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:5955
Facture\TYPE_DEPOSIT
const TYPE_DEPOSIT
Deposit invoice.
Definition: facture.class.php:422
getCountriesInEEC
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
Definition: company.lib.php:748
Facture\TYPE_REPLACEMENT
const TYPE_REPLACEMENT
Replacement invoice.
Definition: facture.class.php:412
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
FactureLigne
Class to manage invoice lines.
Definition: facture.class.php:6013
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:7046
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
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:5530
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
Facture\TYPE_CREDIT_NOTE
const TYPE_CREDIT_NOTE
Credit note invoice.
Definition: facture.class.php:417
dolibarr_set_const
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).
Definition: admin.lib.php:638
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:509
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:5295
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:10024
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5829
dolGetFirstLineOfText
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
Definition: functions.lib.php:7278
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1169
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:2968
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156
Facture\TYPE_SITUATION
const TYPE_SITUATION
Situation invoice.
Definition: facture.class.php:432
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25