27 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.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_day =
GETPOST(
"search_day",
"int");
53 $search_month =
GETPOST(
"search_month",
"int");
54 $search_year =
GETPOST(
"search_year",
"int");
57 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
58 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61 if (empty($page) || $page < 0) $page = 0;
62 $pageprev = $page - 1;
63 $pagenext = $page + 1;
64 $offset = $limit * $page;
66 $sortfield =
"erd.date, erd.rowid";
68 if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
76 if (!$user->rights->accounting->bind->write)
87 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
90 $search_expensereport =
'';
101 if (is_array($changeaccount) && count($changeaccount) > 0) {
104 if (!(
GETPOST(
'account_parent',
'int') >= 0))
107 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Account")), null,
'errors');
114 $sql1 =
"UPDATE ".MAIN_DB_PREFIX.
"expensereport_det as erd";
115 $sql1 .=
" SET erd.fk_code_ventilation=".(GETPOST(
'account_parent',
'int') > 0 ?
GETPOST(
'account_parent',
'int') :
'0');
116 $sql1 .=
' WHERE erd.rowid IN ('.implode(
',', $changeaccount).
')';
118 dol_syslog(
'accountancy/expensereport/lines.php::changeaccount sql= '.$sql1);
119 $resql1 = $db->query($sql1);
132 $account_parent =
'';
141 $form =
new Form($db);
144 llxHeader(
'', $langs->trans(
"ExpenseReportsVentilation").
' - '.$langs->trans(
"Dispatched"));
146 print '<script type="text/javascript">
148 $(\'#select-all\').click(function(event) {
149 // Iterate each checkbox
150 $(\':checkbox\').each(function() {
154 $(\'#unselect-all\').click(function(event) {
155 // Iterate each checkbox
156 $(\':checkbox\').each(function() {
157 this.checked = false;
166 $sql =
"SELECT er.ref, er.rowid as erid,";
167 $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,";
168 $sql .=
" f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
169 $sql .=
" u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
170 $sql .=
" aa.label, aa.labelshort, aa.account_number";
171 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as er";
172 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"expensereport_det as erd ON er.rowid = erd.fk_expensereport";
173 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
174 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_fees as f ON f.id = erd.fk_c_type_fees";
175 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = er.fk_user_author";
176 $sql .=
" WHERE erd.fk_code_ventilation > 0";
177 $sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
180 if (strlen(trim($search_login))) {
183 if (strlen(trim($search_expensereport))) {
186 if (strlen(trim($search_label))) {
189 if (strlen(trim($search_desc))) {
192 if (strlen(trim($search_amount))) {
195 if (strlen(trim($search_account))) {
198 if (strlen(trim($search_vat))) {
201 $sql .=
dolSqlDateFilter(
'erd.date', $search_day, $search_month, $search_year);
202 $sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
204 $sql .= $db->order($sortfield, $sortorder);
207 $nbtotalofrecords =
'';
208 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
210 $result = $db->query($sql);
211 $nbtotalofrecords = $db->num_rows($result);
212 if (($page * $limit) > $nbtotalofrecords)
219 $sql .= $db->plimit($limit + 1, $offset);
221 dol_syslog(
'accountancy/expensereport/lines.php::list');
222 $result = $db->query($sql);
225 $num_lines = $db->num_rows($result);
229 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
230 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
231 if ($search_login) $param .=
'&search_login='.urlencode($search_login);
232 if ($search_expensereport) $param .=
"&search_expensereport=".urlencode($search_expensereport);
233 if ($search_label) $param .=
"&search_label=".urlencode($search_label);
234 if ($search_desc) $param .=
"&search_desc=".urlencode($search_desc);
235 if ($search_account) $param .=
"&search_account=".urlencode($search_account);
236 if ($search_vat) $param .=
"&search_vat=".urlencode($search_vat);
237 if ($search_day) $param .=
'&search_day='.urlencode($search_day);
238 if ($search_month) $param .=
'&search_month='.urlencode($search_month);
239 if ($search_year) $param .=
'&search_year='.urlencode($search_year);
241 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
242 print
'<input type="hidden" name="action" value="ventil">';
243 if ($optioncss !=
'') print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
244 print
'<input type="hidden" name="token" value="'.newToken().
'">';
245 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
246 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
247 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
248 print
'<input type="hidden" name="page" value="'.$page.
'">';
250 print_barre_liste($langs->trans(
"ExpenseReportLinesDone"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit);
252 print
'<span class="opacitymedium">'.$langs->trans(
"DescVentilDoneExpenseReport").
'</span><br>';
254 print
'<br><div class="inline-block divButAction">'.$langs->trans(
"ChangeAccount").
'<br>';
255 print $formaccounting->select_account($account_parent,
'account_parent', 2, array(), 0, 0,
'maxwidth300 maxwidthonsmartphone valignmiddle');
256 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"ChangeBinding").
'" /></div>';
260 print
'<div class="div-table-responsive">';
261 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
263 print
'<tr class="liste_titre_filter">';
264 print
'<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.
'"></td>';
265 print
'<td class="liste_titre"></td>';
266 print
'<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).
'"></td>';
267 if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
268 print
'<td class="liste_titre"></td>';
270 print
'<td class="liste_titre center">';
271 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.
'">';
272 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.
'">';
273 $formother->select_year($search_year,
'search_year', 1, 20, 5);
275 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).
'"></td>';
276 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
277 print
'<td class="liste_titre right"><input type="text" class="flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
278 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>';
279 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).
'"></td>';
280 print
'<td class="liste_titre center">';
281 $searchpicto = $form->showFilterButtons();
286 print
'<tr class="liste_titre">';
289 print_liste_field_titre(
"ExpenseReport", $_SERVER[
"PHP_SELF"],
"er.ref",
"", $param,
'', $sortfield, $sortorder);
290 if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
291 print_liste_field_titre(
"DateValidation", $_SERVER[
"PHP_SELF"],
"er.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
293 print_liste_field_titre(
"DateOfLine", $_SERVER[
"PHP_SELF"],
"erd.date, erd.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
295 print_liste_field_titre(
"Description", $_SERVER[
"PHP_SELF"],
"erd.comments",
"", $param,
'', $sortfield, $sortorder);
296 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"erd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
297 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
"erd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center ');
298 print_liste_field_titre(
"AccountAccounting", $_SERVER[
"PHP_SELF"],
"aa.account_number",
"", $param,
'', $sortfield, $sortorder);
299 $checkpicto = $form->showCheckAddButtons();
305 $userstatic =
new User($db);
308 while ($i < min($num_lines, $limit)) {
309 $objp = $db->fetch_object($result);
311 $expensereportstatic->ref = $objp->ref;
312 $expensereportstatic->id = $objp->erid;
314 $userstatic->id = $objp->userid;
315 $userstatic->ref = $objp->label;
316 $userstatic->login = $objp->login;
317 $userstatic->statut = $objp->statut;
318 $userstatic->email = $objp->email;
319 $userstatic->gender = $objp->gender;
320 $userstatic->firstname = $objp->firstname;
321 $userstatic->lastname = $objp->lastname;
322 $userstatic->employee = $objp->employee;
323 $userstatic->photo = $objp->photo;
325 $accountingaccountstatic->rowid = $objp->fk_compte;
326 $accountingaccountstatic->label = $objp->label;
327 $accountingaccountstatic->labelshort = $objp->labelshort;
328 $accountingaccountstatic->account_number = $objp->account_number;
330 print
'<tr class="oddeven">';
333 print
'<td class="nowraponall">';
334 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 1,
'login',
'', 1);
338 print
'<td>'.$objp->rowid.
'</td>';
341 print
'<td>'.$expensereportstatic->getNomUrl(1).
'</td>';
344 if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
345 print
'<td class="center">'.dol_print_date($db->jdate($objp->date_valid),
'day').
'</td>';
348 print
'<td class="center">'.dol_print_date($db->jdate($objp->date),
'day').
'</td>';
351 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>';
356 $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
357 print $form->textwithtooltip(
dol_trunc($text, $trunclength), $objp->comments);
361 print
'<td class="nowrap right">'.price($objp->total_ht).
'</td>';
364 print
'<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ?
' ('.$objp->vat_src_code.
')' :
'')).
'</td>';
367 print
'<td class="center">';
368 print $accountingaccountstatic->getNomUrl(0, 1, 1,
'', 1);
369 print
' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($param ?
'?'.$param :
'')).
'">';
372 print
'<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.
'"/></td>';
381 if ($nbtotalofrecords > $limit) {
382 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines, $nbtotalofrecords,
'', 0,
'',
'', $limit, 1);
387 print $db->lasterror();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
Class to manage Dolibarr users.
const STATUS_CLOSED
Classified paid.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
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 Calling this function terminate execution ...
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...
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
Class to manage Trips and Expenses.
print $_SERVER["PHP_SELF"]
Edit parameters.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
print
Draft customers invoices.
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.
Class to manage accounting accounts.