dolibarr 21.0.0-beta
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 <alexandre@inovea-conseil.com>
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
32require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
35require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38
47// Load translation files required by the page
48$langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "trips", "productbatch", "hrm"));
49
50$action = GETPOST('action', 'aZ09');
51$massaction = GETPOST('massaction', 'alpha');
52$confirm = GETPOST('confirm', 'alpha');
53$toselect = GETPOST('toselect', 'array');
54$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'accountancyexpensereportlist'; // To manage different context of search
55$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
56
57
58// Select Box
59$mesCasesCochees = GETPOST('toselect', 'array');
60
61// Search Getpost
62$search_login = GETPOST('search_login', 'alpha');
63$search_lineid = GETPOST('search_lineid', 'alpha');
64$search_expensereport = GETPOST('search_expensereport', 'alpha');
65$search_label = GETPOST('search_label', 'alpha');
66$search_desc = GETPOST('search_desc', 'alpha');
67$search_amount = GETPOST('search_amount', 'alpha');
68$search_account = GETPOST('search_account', 'alpha');
69$search_vat = GETPOST('search_vat', 'alpha');
70$search_date_startday = GETPOSTINT('search_date_startday');
71$search_date_startmonth = GETPOSTINT('search_date_startmonth');
72$search_date_startyear = GETPOSTINT('search_date_startyear');
73$search_date_endday = GETPOSTINT('search_date_endday');
74$search_date_endmonth = GETPOSTINT('search_date_endmonth');
75$search_date_endyear = GETPOSTINT('search_date_endyear');
76$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
77$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
78
79// Define begin binding date
80if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
81 $search_date_start = $db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'));
82}
83
84// Load variable for pagination
85$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
86$sortfield = GETPOST('sortfield', 'aZ09comma');
87$sortorder = GETPOST('sortorder', 'aZ09comma');
88$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
89if (empty($page) || $page < 0) {
90 $page = 0;
91}
92$offset = $limit * $page;
93$pageprev = $page - 1;
94$pagenext = $page + 1;
95if (!$sortfield) {
96 $sortfield = "erd.date, erd.rowid";
97}
98if (!$sortorder) {
99 if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_TODO') > 0) {
100 $sortorder = "DESC";
101 } else {
102 $sortorder = "ASC";
103 }
104}
105
106// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
107$hookmanager->initHooks(array('accountancyexpensereportlist'));
108
109$formaccounting = new FormAccounting($db);
110$accounting = new AccountingAccount($db);
111
112$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
113
114// Security check
115if (!isModEnabled('accounting')) {
117}
118if ($user->socid > 0) {
120}
121if (!$user->hasRight('accounting', 'bind', 'write')) {
123}
124
125
126/*
127 * Actions
128 */
129
130if (GETPOST('cancel', 'alpha')) {
131 $action = 'list';
132 $massaction = '';
133}
134if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
135 $massaction = '';
136}
137
138$parameters = array();
139$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
140if ($reshook < 0) {
141 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
142}
143
144if (empty($reshook)) {
145 // Purge search criteria
146 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
147 $search_lineid = '';
148 $search_login = '';
149 $search_expensereport = '';
150 $search_label = '';
151 $search_desc = '';
152 $search_amount = '';
153 $search_account = '';
154 $search_vat = '';
155 $search_date_startday = '';
156 $search_date_startmonth = '';
157 $search_date_startyear = '';
158 $search_date_endday = '';
159 $search_date_endmonth = '';
160 $search_date_endyear = '';
161 $search_date_start = '';
162 $search_date_end = '';
163 $search_country = '';
164 $search_tvaintra = '';
165 }
166
167 // Mass actions
168 $objectclass = 'ExpenseReport';
169 $objectlabel = 'ExpenseReport';
170 $permissiontoread = $user->hasRight('accounting', 'read');
171 $permissiontodelete = $user->hasRight('accounting', 'delete');
172 $uploaddir = $conf->expensereport->dir_output;
173 include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
174}
175
176
177if ($massaction == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) {
178 $msg = '';
179
180 if (!empty($mesCasesCochees)) {
181 $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
182 $msg .= '<div class="detail">';
183 $cpt = 0;
184 $ok = 0;
185 $ko = 0;
186
187 foreach ($mesCasesCochees as $maLigneCochee) {
188 $maLigneCourante = explode("_", $maLigneCochee);
189 $monId = $maLigneCourante[0];
190 $monCompte = GETPOST('codeventil'.$monId);
191
192 if ($monCompte <= 0) {
193 $msg .= '<div><span class="error">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>';
194 $ko++;
195 } else {
196 $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
197 $sql .= " SET fk_code_ventilation = ".((int) $monCompte);
198 $sql .= " WHERE rowid = ".((int) $monId);
199
200 $accountventilated = new AccountingAccount($db);
201 $accountventilated->fetch($monCompte, '', 1);
202
203 dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
204 if ($db->query($sql)) {
205 $msg .= '<div><span class="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</span></div>';
206 $ok++;
207 } else {
208 $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>';
209 $ko++;
210 }
211 }
212
213 $cpt++;
214 }
215 $msg .= '</div>';
216 $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
217 }
218}
219
220if (GETPOST('sortfield') == 'erd.date, erd.rowid') {
221 $value = (GETPOST('sortorder') == 'asc,asc' ? 0 : 1);
222 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
223 $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $value, 'yesno', 0, '', $conf->entity);
224}
225
226
227/*
228 * View
229 */
230
231$form = new Form($db);
232$formother = new FormOther($db);
233
234$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
235
236llxHeader('', $langs->trans("ExpenseReportsVentilation"), $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-accountancy accountancy-expensereport page-list');
237
238if (empty($chartaccountcode)) {
239 print $langs->trans("ErrorChartOfAccountSystemNotSelected");
240 // End of page
241 llxFooter();
242 $db->close();
243 exit;
244}
245
246// Expense report lines
247$sql = "SELECT er.ref, er.rowid as erid, er.date_debut, er.date_valid,";
248$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,";
249$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,";
250$sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
251$sql .= " aa.rowid as aarowid";
252$parameters = array();
253$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
254$sql .= $hookmanager->resPrint;
255$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
256$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
257$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
258$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
259$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;
260$sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
261// Add search filter like
262if (strlen($search_lineid)) {
263 $sql .= natural_search("er.rowid", $search_lineid, 1);
264}
265if (strlen(trim($search_login))) {
266 $sql .= natural_search("u.login", $search_login);
267}
268if (strlen(trim($search_expensereport))) {
269 $sql .= natural_search("er.ref", $search_expensereport);
270}
271if (strlen(trim($search_label))) {
272 $sql .= natural_search("f.label", $search_label);
273}
274if (strlen(trim($search_desc))) {
275 $sql .= natural_search("erd.comments", $search_desc);
276}
277if (strlen(trim($search_amount))) {
278 $sql .= natural_search("erd.total_ht", $search_amount, 1);
279}
280if (strlen(trim($search_account))) {
281 $sql .= natural_search("aa.account_number", $search_account);
282}
283if (strlen(trim($search_vat))) {
284 $sql .= natural_search("erd.tva_tx", $search_vat, 1);
285}
286if ($search_date_start) {
287 $sql .= " AND erd.date >= '".$db->idate($search_date_start)."'";
288}
289if ($search_date_end) {
290 $sql .= " AND erd.date <= '".$db->idate($search_date_end)."'";
291}
292$sql .= " AND er.entity IN (".getEntity('expensereport', 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 = '';
303if (!getDolGlobalInt('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//print $sql;
312
313$sql .= $db->plimit($limit + 1, $offset);
314
315dol_syslog("accountancy/expensereport/list.php", LOG_DEBUG);
316// MAX_JOIN_SIZE can be very low (ex: 300000) on some limited configurations (ex: https://www.online.net/fr/hosting/online-perso)
317// 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
318if ($db->type == 'mysqli') {
319 $db->query("SET SQL_BIG_SELECTS=1");
320}
321
322$result = $db->query($sql);
323if ($result) {
324 $num_lines = $db->num_rows($result);
325 $i = 0;
326
327 $arrayofselected = is_array($toselect) ? $toselect : array();
328
329 $param = '';
330 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
331 $param .= '&contextpage='.urlencode($contextpage);
332 }
333 if ($limit > 0 && $limit != $conf->liste_limit) {
334 $param .= '&limit='.((int) $limit);
335 }
336 if ($search_lineid) {
337 $param .= '&search_lineid='.urlencode($search_lineid);
338 }
339 if ($search_login) {
340 $param .= '&search_login='.urlencode($search_login);
341 }
342 if ($search_date_startday) {
343 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
344 }
345 if ($search_date_startmonth) {
346 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
347 }
348 if ($search_date_startyear) {
349 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
350 }
351 if ($search_date_endday) {
352 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
353 }
354 if ($search_date_endmonth) {
355 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
356 }
357 if ($search_date_endyear) {
358 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
359 }
360 if ($search_expensereport) {
361 $param .= '&search_expensereport='.urlencode($search_expensereport);
362 }
363 if ($search_label) {
364 $param .= '&search_label='.urlencode($search_label);
365 }
366 if ($search_desc) {
367 $param .= '&search_desc='.urlencode($search_desc);
368 }
369 if ($search_amount) {
370 $param .= '&search_amount='.urlencode($search_amount);
371 }
372 if ($search_vat) {
373 $param .= '&search_vat='.urlencode($search_vat);
374 }
375
376 $arrayofmassactions = array(
377 'ventil' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate")
378 );
379 $massactionbutton = '';
380 if ($massaction !== 'set_default_account') {
381 $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
382 }
383
384 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
385 print '<input type="hidden" name="action" value="ventil">';
386 if ($optioncss != '') {
387 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
388 }
389 print '<input type="hidden" name="token" value="'.newToken().'">';
390 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
391 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
392 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
393 print '<input type="hidden" name="page" value="'.$page.'">';
394
395 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
396 print_barre_liste($langs->trans("ExpenseReportLines").'<br><span class="opacitymedium small">'.$langs->trans("DescVentilTodoExpenseReport").'</span>', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
397
398 if (!empty($msg)) {
399 print $msg.'<br>';
400 }
401
402 $moreforfilter = '';
403
404 print '<div class="div-table-responsive">';
405 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
406
407 // We add search filter
408 print '<tr class="liste_titre_filter">';
409 print '<td class="liste_titre"><input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
410 print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.dol_escape_htmltag($search_login).'"></td>';
411 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
412 if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) {
413 print '<td class="liste_titre"></td>';
414 }
415 print '<td class="liste_titre center">';
416 print '<div class="nowrapfordate">';
417 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
418 print '</div>';
419 print '<div class="nowrapfordate">';
420 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
421 print '</div>';
422 print '</td>';
423 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
424 print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
425 print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
426 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>';
427 print '<td class="liste_titre"></td>';
428 print '<td class="liste_titre"></td>';
429 print '<td class="center liste_titre">';
430 $searchpicto = $form->showFilterButtons();
431 print $searchpicto;
432 print '</td>';
433 print '</tr>';
434
435 print '<tr class="liste_titre">';
436 print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
437 print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
438 print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
439 if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) {
440 print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
441 }
442 print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
443 print_liste_field_titre("TypeFees", $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder);
444 print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
445 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 ');
446 print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
447 print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall ');
448 print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', '');
449 $checkpicto = '';
450 if ($massactionbutton) {
451 $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
452 }
453 print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
454 print "</tr>\n";
455
456
457 $expensereport_static = new ExpenseReport($db);
458 $userstatic = new User($db);
459 $form = new Form($db);
460
461 while ($i < min($num_lines, $limit)) {
462 $objp = $db->fetch_object($result);
463
464 $objp->aarowid_suggest = '';
465 $objp->aarowid_suggest = $objp->aarowid;
466
467 $expensereport_static->ref = $objp->ref;
468 $expensereport_static->id = $objp->erid;
469
470 $userstatic->id = $objp->userid;
471 $userstatic->login = $objp->login;
472 $userstatic->status = $objp->statut;
473 $userstatic->email = $objp->email;
474 $userstatic->gender = $objp->gender;
475 $userstatic->firstname = $objp->firstname;
476 $userstatic->lastname = $objp->lastname;
477 $userstatic->employee = $objp->employee;
478 $userstatic->photo = $objp->photo;
479
480 print '<tr class="oddeven">';
481
482 // Line id
483 print '<td>'.$objp->rowid.'</td>';
484
485 // Login
486 print '<td class="nowraponall">';
487 print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
488 print '</td>';
489
490 // Ref Expense report
491 print '<td class="tdoverflowmax150">'.$expensereport_static->getNomUrl(1).'</td>';
492
493 // Date validation
494 if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) {
495 print '<td class="center">'.dol_print_date($db->jdate($objp->date_valid), 'day').'</td>';
496 }
497
498 // Date
499 print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
500
501 // Fees label
502 print '<td>';
503 print($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code)));
504 print '</td>';
505
506 // Fees description -- Can be null
507 print '<td>';
508 $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1));
509 $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
510 print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
511 print '</td>';
512
513 // Amount without taxes
514 print '<td class="right nowraponall amount">';
515 print price($objp->price);
516 print '</td>';
517
518 // Vat rate
519 print '<td class="right">';
520 print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
521 print '</td>';
522
523 // Current account
524 print '<td>';
525 print length_accountg(html_entity_decode($objp->code_buy));
526 print '</td>';
527
528 // Suggested accounting account
529 print '<td>';
530 print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
531 print '</td>';
532
533 print '<td class="center">';
534 print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($objp->aarowid ? "checked" : "").'/>';
535 print '</td>';
536
537 print "</tr>";
538 $i++;
539 }
540 if ($num_lines == 0) {
541 print '<tr><td colspan="13"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
542 }
543
544 print '</table>';
545 print "</div>";
546
547 print '</form>';
548} else {
549 print $db->error();
550}
551if ($db->type == 'mysqli') {
552 $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation
553}
554
555// Add code to auto check the box when we select an account
556print '<script type="text/javascript">
557jQuery(document).ready(function() {
558 jQuery(".codeventil").change(function() {
559 var s=$(this).attr("id").replace("codeventil", "")
560 console.log(s+" "+$(this).val());
561 if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
562 else jQuery(".checkforselect"+s).prop("checked", true);
563 });
564});
565</script>';
566
567// End of page
568llxFooter();
569$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage accounting accounts.
Class to manage 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.
Class permettant la generation de composants html autre Only common components are here.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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.
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.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.