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