27 require
'../../main.inc.php';
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.
'/expensereport/class/expensereport.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
38 $langs->loadLangs(array(
"compta",
"bills",
"other",
"accountancy",
"trips",
"productbatch",
"hrm"));
40 $optioncss =
GETPOST(
'optioncss',
'aZ');
42 $account_parent =
GETPOST(
'account_parent',
'int');
43 $changeaccount =
GETPOST(
'changeaccount');
45 $search_login =
GETPOST(
'search_login',
'alpha');
46 $search_expensereport =
GETPOST(
'search_expensereport',
'alpha');
47 $search_label =
GETPOST(
'search_label',
'alpha');
48 $search_desc =
GETPOST(
'search_desc',
'alpha');
49 $search_amount =
GETPOST(
'search_amount',
'alpha');
50 $search_account =
GETPOST(
'search_account',
'alpha');
51 $search_vat =
GETPOST(
'search_vat',
'alpha');
52 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
53 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
54 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
55 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
56 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
57 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
58 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
59 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
62 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
63 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66 if (empty($page) || $page < 0) {
69 $offset = $limit * $page;
70 $pageprev = $page - 1;
71 $pagenext = $page + 1;
73 $sortfield =
"erd.date, erd.rowid";
76 if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
85 if ($user->socid > 0) {
88 if (empty($user->rights->accounting->mouvements->lire)) {
101 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
103 $search_expensereport =
'';
107 $search_account =
'';
109 $search_date_startday =
'';
110 $search_date_startmonth =
'';
111 $search_date_startyear =
'';
112 $search_date_endday =
'';
113 $search_date_endmonth =
'';
114 $search_date_endyear =
'';
115 $search_date_start =
'';
116 $search_date_end =
'';
119 if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) {
122 if (!(
GETPOST(
'account_parent',
'int') >= 0)) {
124 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Account")),
null,
'errors');
130 $sql1 =
"UPDATE ".MAIN_DB_PREFIX.
"expensereport_det as erd";
131 $sql1 .=
" SET erd.fk_code_ventilation=".(GETPOST(
'account_parent',
'int') > 0 ?
GETPOST(
'account_parent',
'int') :
'0');
132 $sql1 .=
' WHERE erd.rowid IN ('.$db->sanitize(implode(
',', $changeaccount)).
')';
134 dol_syslog(
'accountancy/expensereport/lines.php::changeaccount sql= '.$sql1);
135 $resql1 = $db->query($sql1);
148 $account_parent =
'';
160 llxHeader(
'', $langs->trans(
"ExpenseReportsVentilation").
' - '.$langs->trans(
"Dispatched"));
162 print
'<script type="text/javascript">
164 $(\'#select-all\').click(function(event) {
165 // Iterate each checkbox
166 $(\':checkbox\').each(function() {
170 $(\'#unselect-all\').click(function(event) {
171 // Iterate each checkbox
172 $(\':checkbox\').each(function() {
173 this.checked = false;
182 $sql =
"SELECT er.ref, er.rowid as erid,";
183 $sql .=
" erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, erd.vat_src_code, erd.date,";
184 $sql .=
" f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
185 $sql .=
" u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
186 $sql .=
" aa.label, aa.labelshort, aa.account_number";
187 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as er";
188 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"expensereport_det as erd ON er.rowid = erd.fk_expensereport";
189 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
190 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_fees as f ON f.id = erd.fk_c_type_fees";
191 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = er.fk_user_author";
192 $sql .=
" WHERE erd.fk_code_ventilation > 0";
193 $sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
196 if (strlen(trim($search_login))) {
199 if (strlen(trim($search_expensereport))) {
202 if (strlen(trim($search_label))) {
205 if (strlen(trim($search_desc))) {
208 if (strlen(trim($search_amount))) {
211 if (strlen(trim($search_account))) {
214 if (strlen(trim($search_vat))) {
217 if ($search_date_start) {
218 $sql .=
" AND erd.date >= '".$db->idate($search_date_start).
"'";
220 if ($search_date_end) {
221 $sql .=
" AND erd.date <= '".$db->idate($search_date_end).
"'";
223 $sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
225 $sql .= $db->order($sortfield, $sortorder);
229 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
230 $result = $db->query($sql);
238 $sql .= $db->plimit($limit + 1, $offset);
240 dol_syslog(
"accountancy/expensereport/lines.php", LOG_DEBUG);
241 $result = $db->query($sql);
243 $num_lines = $db->num_rows($result);
247 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
248 $param .=
'&contextpage='.urlencode($contextpage);
250 if ($limit > 0 && $limit != $conf->liste_limit) {
251 $param .=
'&limit='.urlencode($limit);
254 $param .=
'&search_login='.urlencode($search_login);
256 if ($search_expensereport) {
257 $param .=
"&search_expensereport=".urlencode($search_expensereport);
260 $param .=
"&search_label=".urlencode($search_label);
263 $param .=
"&search_desc=".urlencode($search_desc);
265 if ($search_account) {
266 $param .=
"&search_account=".urlencode($search_account);
269 $param .=
"&search_vat=".urlencode($search_vat);
271 if ($search_date_startday) {
272 $param .=
'&search_date_startday='.urlencode($search_date_startday);
274 if ($search_date_startmonth) {
275 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
277 if ($search_date_startyear) {
278 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
280 if ($search_date_endday) {
281 $param .=
'&search_date_endday='.urlencode($search_date_endday);
283 if ($search_date_endmonth) {
284 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
286 if ($search_date_endyear) {
287 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
290 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
291 print
'<input type="hidden" name="action" value="ventil">';
292 if ($optioncss !=
'') {
293 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
295 print
'<input type="hidden" name="token" value="'.newToken().
'">';
296 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
297 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
298 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
299 print
'<input type="hidden" name="page" value="'.$page.
'">';
301 print_barre_liste($langs->trans(
"ExpenseReportLinesDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines,
$nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit);
302 print
'<span class="opacitymedium">'.$langs->trans(
"DescVentilDoneExpenseReport").
'</span><br>';
304 print
'<br><div class="inline-block divButAction paddingbottom">'.$langs->trans(
"ChangeAccount").
' ';
305 print $formaccounting->select_account($account_parent,
'account_parent', 2, array(), 0, 0,
'maxwidth300 maxwidthonsmartphone valignmiddle');
306 print
'<input type="submit" class="button small valignmiddle" value="'.$langs->trans(
"ChangeBinding").
'"/></div>';
310 print
'<div class="div-table-responsive">';
311 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
313 print
'<tr class="liste_titre_filter">';
314 print
'<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.
'"></td>';
315 print
'<td class="liste_titre"></td>';
316 print
'<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).
'"></td>';
317 if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
318 print
'<td class="liste_titre"></td>';
320 print
'<td class="liste_titre center">';
321 print
'<div class="nowrap">';
322 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
324 print
'<div class="nowrap">';
325 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
328 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).
'"></td>';
329 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
330 print
'<td class="liste_titre right"><input type="text" class="flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
331 print
'<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" value="'.dol_escape_htmltag($search_vat).
'"></td>';
332 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).
'"></td>';
333 print
'<td class="liste_titre center">';
334 $searchpicto =
$form->showFilterButtons();
339 print
'<tr class="liste_titre">';
342 print_liste_field_titre(
"ExpenseReport", $_SERVER[
"PHP_SELF"],
"er.ref",
"", $param,
'', $sortfield, $sortorder);
343 if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
344 print_liste_field_titre(
"DateValidation", $_SERVER[
"PHP_SELF"],
"er.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
346 print_liste_field_titre(
"DateOfLine", $_SERVER[
"PHP_SELF"],
"erd.date, erd.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
348 print_liste_field_titre(
"Description", $_SERVER[
"PHP_SELF"],
"erd.comments",
"", $param,
'', $sortfield, $sortorder);
349 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"erd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
350 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
"erd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center ');
351 print_liste_field_titre(
"AccountAccounting", $_SERVER[
"PHP_SELF"],
"aa.account_number",
"", $param,
'', $sortfield, $sortorder);
352 $checkpicto =
$form->showCheckAddButtons();
358 $userstatic =
new User($db);
361 while ($i < min($num_lines, $limit)) {
362 $objp = $db->fetch_object($result);
364 $expensereportstatic->ref = $objp->ref;
365 $expensereportstatic->id = $objp->erid;
367 $userstatic->id = $objp->userid;
368 $userstatic->ref = $objp->label;
369 $userstatic->login = $objp->login;
370 $userstatic->statut = $objp->statut;
371 $userstatic->email = $objp->email;
372 $userstatic->gender = $objp->gender;
373 $userstatic->firstname = $objp->firstname;
374 $userstatic->lastname = $objp->lastname;
375 $userstatic->employee = $objp->employee;
376 $userstatic->photo = $objp->photo;
378 $accountingaccountstatic->rowid = $objp->fk_compte;
379 $accountingaccountstatic->label = $objp->label;
380 $accountingaccountstatic->labelshort = $objp->labelshort;
381 $accountingaccountstatic->account_number = $objp->account_number;
383 print
'<tr class="oddeven">';
386 print
'<td class="nowraponall">';
387 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 1,
'login',
'', 1);
391 print
'<td>'.$objp->rowid.
'</td>';
394 print
'<td>'.$expensereportstatic->getNomUrl(1).
'</td>';
397 if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
398 print
'<td class="center">'.dol_print_date($db->jdate($objp->date_valid),
'day').
'</td>';
401 print
'<td class="center">'.dol_print_date($db->jdate($objp->date),
'day').
'</td>';
404 print
'<td class="tdoverflow">'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).
'</td>';
409 $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
410 print
$form->textwithtooltip(
dol_trunc($text, $trunclength), $objp->comments);
414 print
'<td class="right nowraponall amount">'.price($objp->total_ht).
'</td>';
417 print
'<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ?
' ('.$objp->vat_src_code.
')' :
'')).
'</td>';
421 print $accountingaccountstatic->getNomUrl(0, 1, 1,
'', 1);
422 print
' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($param ?
'?'.$param :
'')).
'">';
425 print
'<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.
'"/></td>';
430 if ($num_lines == 0) {
432 if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
435 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
442 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines,
$nbtotalofrecords,
'', 0,
'',
'', $limit, 1);
447 print $db->lasterror();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage Trips and Expenses.
const STATUS_CLOSED
Classified paid.
Class to manage Dolibarr users.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.