dolibarr  18.0.0-alpha
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2014 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-2014 Florian Henry <florian.henry@open-concept.pro>
6  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
7  * Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
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 
28 require '../../main.inc.php';
29 
30 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.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 
38 // Load translation files required by the page
39 $langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "trips", "productbatch", "hrm"));
40 
41 $action = GETPOST('action', 'aZ09');
42 $massaction = GETPOST('massaction', 'alpha');
43 $confirm = GETPOST('confirm', 'alpha');
44 $toselect = GETPOST('toselect', 'array');
45 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'accountancyexpensereportlist'; // To manage different context of search
46 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
47 
48 
49 // Select Box
50 $mesCasesCochees = GETPOST('toselect', 'array');
51 
52 // Search Getpost
53 $search_login = GETPOST('search_login', 'alpha');
54 $search_lineid = GETPOST('search_lineid', 'alpha');
55 $search_expensereport = GETPOST('search_expensereport', 'alpha');
56 $search_label = GETPOST('search_label', 'alpha');
57 $search_desc = GETPOST('search_desc', 'alpha');
58 $search_amount = GETPOST('search_amount', 'alpha');
59 $search_account = GETPOST('search_account', 'alpha');
60 $search_vat = GETPOST('search_vat', 'alpha');
61 $search_date_startday = GETPOST('search_date_startday', 'int');
62 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
63 $search_date_startyear = GETPOST('search_date_startyear', 'int');
64 $search_date_endday = GETPOST('search_date_endday', 'int');
65 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
66 $search_date_endyear = GETPOST('search_date_endyear', 'int');
67 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
68 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
69 
70 // Load variable for pagination
71 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
72 $sortfield = GETPOST('sortfield', 'aZ09comma');
73 $sortorder = GETPOST('sortorder', 'aZ09comma');
74 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
75 if (empty($page) || $page < 0) {
76  $page = 0;
77 }
78 $offset = $limit * $page;
79 $pageprev = $page - 1;
80 $pagenext = $page + 1;
81 if (!$sortfield) {
82  $sortfield = "erd.date, erd.rowid";
83 }
84 if (!$sortorder) {
85  if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
86  $sortorder = "DESC";
87  }
88 }
89 
90 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
91 $hookmanager->initHooks(array('accountancyexpensereportlist'));
92 
93 $formaccounting = new FormAccounting($db);
94 $accounting = new AccountingAccount($db);
95 
96 $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
97 
98 // Security check
99 if (!isModEnabled('accounting')) {
100  accessforbidden();
101 }
102 if ($user->socid > 0) {
103  accessforbidden();
104 }
105 if (empty($user->rights->accounting->mouvements->lire)) {
106  accessforbidden();
107 }
108 
109 
110 /*
111  * Actions
112  */
113 
114 if (GETPOST('cancel', 'alpha')) {
115  $action = 'list'; $massaction = '';
116 }
117 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
118  $massaction = '';
119 }
120 
121 $parameters = array();
122 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
123 if ($reshook < 0) {
124  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
125 }
126 
127 if (empty($reshook)) {
128  // Purge search criteria
129  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
130  $search_login = '';
131  $search_expensereport = '';
132  $search_label = '';
133  $search_desc = '';
134  $search_amount = '';
135  $search_account = '';
136  $search_vat = '';
137  $search_date_startday = '';
138  $search_date_startmonth = '';
139  $search_date_startyear = '';
140  $search_date_endday = '';
141  $search_date_endmonth = '';
142  $search_date_endyear = '';
143  $search_date_start = '';
144  $search_date_end = '';
145  $search_country = '';
146  $search_tvaintra = '';
147  }
148 
149  // Mass actions
150  $objectclass = 'ExpenseReport';
151  $objectlabel = 'ExpenseReport';
152  $permissiontoread = $user->hasRight('accounting', 'read');
153  $permissiontodelete = $user->hasRight('accounting', 'delete');
154  $uploaddir = $conf->expensereport->dir_output;
155  include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
156 }
157 
158 
159 if ($massaction == 'ventil' && $user->rights->accounting->bind->write) {
160  $msg = '';
161 
162  if (!empty($mesCasesCochees)) {
163  $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
164  $msg .= '<div class="detail">';
165  $cpt = 0;
166  $ok = 0;
167  $ko = 0;
168 
169  foreach ($mesCasesCochees as $maLigneCochee) {
170  $maLigneCourante = explode("_", $maLigneCochee);
171  $monId = $maLigneCourante[0];
172  $monCompte = GETPOST('codeventil'.$monId);
173 
174  if ($monCompte <= 0) {
175  $msg .= '<div><span class="error">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>';
176  $ko++;
177  } else {
178  $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
179  $sql .= " SET fk_code_ventilation = ".((int) $monCompte);
180  $sql .= " WHERE rowid = ".((int) $monId);
181 
182  $accountventilated = new AccountingAccount($db);
183  $accountventilated->fetch($monCompte, '', 1);
184 
185  dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
186  if ($db->query($sql)) {
187  $msg .= '<div><span class="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</span></div>';
188  $ok++;
189  } else {
190  $msg .= '<div><span class="error">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></span></div>';
191  $ko++;
192  }
193  }
194 
195  $cpt++;
196  }
197  $msg .= '</div>';
198  $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
199  }
200 }
201 
202 
203 
204 /*
205  * View
206  */
207 
208 $form = new Form($db);
209 $formother = new FormOther($db);
210 
211 llxHeader('', $langs->trans("ExpenseReportsVentilation"));
212 
213 if (empty($chartaccountcode)) {
214  print $langs->trans("ErrorChartOfAccountSystemNotSelected");
215  // End of page
216  llxFooter();
217  $db->close();
218  exit;
219 }
220 
221 // Expense report lines
222 $sql = "SELECT er.ref, er.rowid as erid, er.date_debut, er.date_valid,";
223 $sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,";
224 $sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,";
225 $sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
226 $sql .= " aa.rowid as aarowid";
227 $parameters = array();
228 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
229 $sql .= $hookmanager->resPrint;
230 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
231 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
232 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
233 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
234 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
235 $sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
236 // Define begin binding date
237 if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
238  $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
239 }
240 // Add search filter like
241 if (strlen(trim($search_login))) {
242  $sql .= natural_search("u.login", $search_login);
243 }
244 if (strlen(trim($search_expensereport))) {
245  $sql .= natural_search("er.ref", $search_expensereport);
246 }
247 if (strlen(trim($search_label))) {
248  $sql .= natural_search("f.label", $search_label);
249 }
250 if (strlen(trim($search_desc))) {
251  $sql .= natural_search("erd.comments", $search_desc);
252 }
253 if (strlen(trim($search_amount))) {
254  $sql .= natural_search("erd.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("erd.tva_tx", $search_vat, 1);
261 }
262 if ($search_date_start) {
263  $sql .= " AND erd.date >= '".$db->idate($search_date_start)."'";
264 }
265 if ($search_date_end) {
266  $sql .= " AND erd.date <= '".$db->idate($search_date_end)."'";
267 }
268 $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
269 
270 // Add where from hooks
271 $parameters = array();
272 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
273 $sql .= $hookmanager->resPrint;
274 
275 $sql .= $db->order($sortfield, $sortorder);
276 
277 // Count total nb of records
278 $nbtotalofrecords = '';
279 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
280  $result = $db->query($sql);
281  $nbtotalofrecords = $db->num_rows($result);
282  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
283  $page = 0;
284  $offset = 0;
285  }
286 }
287 
288 $sql .= $db->plimit($limit + 1, $offset);
289 
290 dol_syslog("accountancy/expensereport/list.php", LOG_DEBUG);
291 // MAX_JOIN_SIZE can be very low (ex: 300000) on some limited configurations (ex: https://www.online.net/fr/hosting/online-perso)
292 // This big SELECT command may exceed the MAX_JOIN_SIZE limit => Therefore we use SQL_BIG_SELECTS=1 to disable the MAX_JOIN_SIZE security
293 if ($db->type == 'mysqli') {
294  $db->query("SET SQL_BIG_SELECTS=1");
295 }
296 
297 $result = $db->query($sql);
298 if ($result) {
299  $num_lines = $db->num_rows($result);
300  $i = 0;
301 
302  $arrayofselected = is_array($toselect) ? $toselect : array();
303 
304  $param = '';
305  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
306  $param .= '&contextpage='.urlencode($contextpage);
307  }
308  if ($limit > 0 && $limit != $conf->liste_limit) {
309  $param .= '&limit='.urlencode($limit);
310  }
311  if ($search_login) {
312  $param .= '&search_login='.urlencode($search_login);
313  }
314  if ($search_lineid) {
315  $param .= '&search_lineid='.urlencode($search_lineid);
316  }
317  if ($search_date_startday) {
318  $param .= '&search_date_startday='.urlencode($search_date_startday);
319  }
320  if ($search_date_startmonth) {
321  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
322  }
323  if ($search_date_startyear) {
324  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
325  }
326  if ($search_date_endday) {
327  $param .= '&search_date_endday='.urlencode($search_date_endday);
328  }
329  if ($search_date_endmonth) {
330  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
331  }
332  if ($search_date_endyear) {
333  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
334  }
335  if ($search_expensereport) {
336  $param .= '&search_expensereport='.urlencode($search_expensereport);
337  }
338  if ($search_label) {
339  $param .= '&search_label='.urlencode($search_label);
340  }
341  if ($search_desc) {
342  $param .= '&search_desc='.urlencode($search_desc);
343  }
344  if ($search_amount) {
345  $param .= '&search_amount='.urlencode($search_amount);
346  }
347  if ($search_vat) {
348  $param .= '&search_vat='.urlencode($search_vat);
349  }
350 
351  $arrayofmassactions = array(
352  'ventil' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate")
353  );
354  $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
355 
356  print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
357  print '<input type="hidden" name="action" value="ventil">';
358  if ($optioncss != '') {
359  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
360  }
361  print '<input type="hidden" name="token" value="'.newToken().'">';
362  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
363  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
364  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
365  print '<input type="hidden" name="page" value="'.$page.'">';
366 
367  print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
368 
369  print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport").'</span></br><br>';
370 
371  if (!empty($msg)) {
372  print $msg.'<br>';
373  }
374 
375  $moreforfilter = '';
376 
377  print '<div class="div-table-responsive">';
378  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
379 
380  // We add search filter
381  print '<tr class="liste_titre_filter">';
382  print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
383  print '<td class="liste_titre"></td>';
384  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
385  if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
386  print '<td class="liste_titre"></td>';
387  }
388  print '<td class="liste_titre center">';
389  print '<div class="nowrap">';
390  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
391  print '</div>';
392  print '<div class="nowrap">';
393  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
394  print '</div>';
395  print '</td>';
396  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
397  print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
398  print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
399  print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
400  print '<td class="liste_titre"></td>';
401  print '<td class="liste_titre"></td>';
402  print '<td class="center liste_titre">';
403  $searchpicto = $form->showFilterButtons();
404  print $searchpicto;
405  print '</td>';
406  print '</tr>';
407 
408  print '<tr class="liste_titre">';
409  print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
410  print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
411  print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
412  if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
413  print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
414  }
415  print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
416  print_liste_field_titre("TypeFees", $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder);
417  print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
418  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 ');
419  print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
420  print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall ');
421  print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', '');
422  $checkpicto = '';
423  if ($massactionbutton) {
424  $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
425  }
426  print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
427  print "</tr>\n";
428 
429 
430  $expensereport_static = new ExpenseReport($db);
431  $userstatic = new User($db);
432  $form = new Form($db);
433 
434  while ($i < min($num_lines, $limit)) {
435  $objp = $db->fetch_object($result);
436 
437  $objp->aarowid_suggest = '';
438  $objp->aarowid_suggest = $objp->aarowid;
439 
440  $expensereport_static->ref = $objp->ref;
441  $expensereport_static->id = $objp->erid;
442 
443  $userstatic->id = $objp->userid;
444  $userstatic->login = $objp->login;
445  $userstatic->statut = $objp->statut;
446  $userstatic->email = $objp->email;
447  $userstatic->gender = $objp->gender;
448  $userstatic->firstname = $objp->firstname;
449  $userstatic->lastname = $objp->lastname;
450  $userstatic->employee = $objp->employee;
451  $userstatic->photo = $objp->photo;
452 
453  print '<tr class="oddeven">';
454 
455  // Login
456  print '<td class="nowraponall">';
457  print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
458  print '</td>';
459 
460  // Line id
461  print '<td>'.$objp->rowid.'</td>';
462 
463  // Ref Expense report
464  print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
465 
466  // Date validation
467  if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
468  print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
469  }
470 
471  // Date
472  print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
473 
474  // Fees label
475  print '<td>';
476  print ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code)));
477  print '</td>';
478 
479  // Fees description -- Can be null
480  print '<td>';
481  $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1));
482  $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
483  print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
484  print '</td>';
485 
486  // Amount without taxes
487  print '<td class="right nowraponall amount">';
488  print price($objp->price);
489  print '</td>';
490 
491  // Vat rate
492  print '<td class="right">';
493  print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
494  print '</td>';
495 
496  // Current account
497  print '<td>';
498  print length_accountg(html_entity_decode($objp->code_buy));
499  print '</td>';
500 
501  // Suggested accounting account
502  print '<td>';
503  print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
504  print '</td>';
505 
506  print '<td class="center">';
507  print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($objp->aarowid ? "checked" : "").'/>';
508  print '</td>';
509 
510  print "</tr>";
511  $i++;
512  }
513  if ($num_lines == 0) {
514  print '<tr><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
515  }
516 
517  print '</table>';
518  print "</div>";
519 
520  print '</form>';
521 } else {
522  print $db->error();
523 }
524 if ($db->type == 'mysqli') {
525  $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation
526 }
527 
528 // Add code to auto check the box when we select an account
529 print '<script type="text/javascript">
530 jQuery(document).ready(function() {
531  jQuery(".codeventil").change(function() {
532  var s=$(this).attr("id").replace("codeventil", "")
533  console.log(s+" "+$(this).val());
534  if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
535  else jQuery(".checkforselect"+s).prop("checked", true);
536  });
537 });
538 </script>';
539 
540 // End of page
541 llxFooter();
542 $db->close();
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:3950
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
$sql
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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:745
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:530
$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
FormAccounting
Class to manage generation of HTML components for accounting management.
Definition: html.formaccounting.class.php:33
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4025
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
ExpenseReport\STATUS_CLOSED
const STATUS_CLOSED
Classified paid.
Definition: expensereport.class.php:211
dol_getIdFromCode
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
Definition: functions.lib.php:8911
length_accountg
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
Definition: accounting.lib.php:94
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:6921
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1639
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:5416
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:147
AccountingAccount
Class to manage accounting accounts.
Definition: accountingaccount.class.php:36
User
Class to manage Dolibarr users.
Definition: user.class.php:44
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:431
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:5181
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:9823
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
ExpenseReport
Class to manage Trips and Expenses.
Definition: expensereport.class.php:36
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:5708
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8509
dolGetFirstLineOfText
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
Definition: functions.lib.php:7145
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:1106
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:2859
$nbtotalofrecords
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
vatrate
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
Definition: functions.lib.php:5659