28require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
47$langs->loadLangs(array(
"compta",
"bills",
"other",
"accountancy",
"trips",
"productbatch",
"hrm"));
49$optioncss =
GETPOST(
'optioncss',
'aZ');
51$account_parent =
GETPOST(
'account_parent');
52$changeaccount =
GETPOST(
'changeaccount');
54$search_lineid =
GETPOST(
'search_lineid',
'alpha');
55$search_login =
GETPOST(
'search_login',
'alpha');
56$search_expensereport =
GETPOST(
'search_expensereport',
'alpha');
57$search_label =
GETPOST(
'search_label',
'alpha');
58$search_desc =
GETPOST(
'search_desc',
'alpha');
59$search_amount =
GETPOST(
'search_amount',
'alpha');
60$search_account =
GETPOST(
'search_account',
'alpha');
61$search_vat =
GETPOST(
'search_vat',
'alpha');
62$search_date_startday =
GETPOSTINT(
'search_date_startday');
63$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
64$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
65$search_date_endday =
GETPOSTINT(
'search_date_endday');
66$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
67$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
68$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
69$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
73$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
76if (empty($page) || $page < 0) {
79$offset = $limit * $page;
83 $sortfield =
"erd.date, erd.rowid";
94if (!isModEnabled(
'accounting')) {
97if ($user->socid > 0) {
100if (!$user->hasRight(
'accounting',
'bind',
'write')) {
113if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
116 $search_expensereport =
'';
120 $search_account =
'';
122 $search_date_startday =
'';
123 $search_date_startmonth =
'';
124 $search_date_startyear =
'';
125 $search_date_endday =
'';
126 $search_date_endmonth =
'';
127 $search_date_endyear =
'';
128 $search_date_start =
'';
129 $search_date_end =
'';
132if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight(
'accounting',
'bind',
'write')) {
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Account")),
null,
'errors');
143 $sql1 =
"UPDATE ".MAIN_DB_PREFIX.
"expensereport_det as erd";
144 $sql1 .=
" SET erd.fk_code_ventilation=".(GETPOSTINT(
'account_parent') > 0 ?
GETPOSTINT(
'account_parent') :
'0');
145 $sql1 .=
' WHERE erd.rowid IN ('.$db->sanitize(implode(
',', $changeaccount)).
')';
147 dol_syslog(
'accountancy/expensereport/lines.php::changeaccount sql= '.$sql1);
148 $resql1 = $db->query($sql1);
161 $account_parent =
'';
165if (
GETPOST(
'sortfield') ==
'erd.date, erd.rowid') {
166 $value = (
GETPOST(
'sortorder') ==
'asc,asc' ? 0 : 1);
167 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
168 $res =
dolibarr_set_const($db,
"ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value,
'yesno', 0,
'',
$conf->entity);
176$form =
new Form($db);
179$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables';
181llxHeader(
'', $langs->trans(
"ExpenseReportsVentilation").
' - '.$langs->trans(
"Dispatched"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-expensereport page-lines');
183print
'<script type="text/javascript">
185 $(\'#select-all\').click(function(event) {
186 // Iterate each checkbox
187 $(\':checkbox\').each(function() {
191 $(\'#unselect-all\').click(function(event) {
192 // Iterate each checkbox
193 $(\':checkbox\').each(function() {
194 this.checked = false;
203$sql =
"SELECT er.ref, er.rowid as erid,";
204$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,";
205$sql .=
" f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
206$sql .=
" u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
207$sql .=
" aa.label, aa.labelshort, aa.account_number";
208$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as er";
209$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"expensereport_det as erd ON er.rowid = erd.fk_expensereport";
210$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
211$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_fees as f ON f.id = erd.fk_c_type_fees";
212$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = er.fk_user_author";
213$sql .=
" WHERE erd.fk_code_ventilation > 0";
214$sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
217if (strlen($search_lineid)) {
220if (strlen(trim($search_login))) {
223if (strlen(trim($search_expensereport))) {
226if (strlen(trim($search_label))) {
229if (strlen(trim($search_desc))) {
232if (strlen(trim($search_amount))) {
235if (strlen(trim($search_account))) {
238if (strlen(trim($search_vat))) {
241if ($search_date_start) {
242 $sql .=
" AND erd.date >= '".$db->idate($search_date_start).
"'";
244if ($search_date_end) {
245 $sql .=
" AND erd.date <= '".$db->idate($search_date_end).
"'";
247$sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
249$sql .= $db->order($sortfield, $sortorder);
252$nbtotalofrecords =
'';
254 $result = $db->query($sql);
255 $nbtotalofrecords = $db->num_rows($result);
256 if (($page * $limit) > $nbtotalofrecords) {
262$sql .= $db->plimit($limit + 1, $offset);
264dol_syslog(
"accountancy/expensereport/lines.php", LOG_DEBUG);
265$result = $db->query($sql);
267 $num_lines = $db->num_rows($result);
271 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
272 $param .=
'&contextpage='.urlencode($contextpage);
274 if ($limit > 0 && $limit !=
$conf->liste_limit) {
275 $param .=
'&limit='.((int) $limit);
278 $param .=
'&search_login='.urlencode($search_login);
280 if ($search_expensereport) {
281 $param .=
"&search_expensereport=".urlencode($search_expensereport);
284 $param .=
"&search_label=".urlencode($search_label);
287 $param .=
"&search_desc=".urlencode($search_desc);
289 if ($search_account) {
290 $param .=
"&search_account=".urlencode($search_account);
293 $param .=
"&search_vat=".urlencode($search_vat);
295 if ($search_date_startday) {
296 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
298 if ($search_date_startmonth) {
299 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
301 if ($search_date_startyear) {
302 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
304 if ($search_date_endday) {
305 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
307 if ($search_date_endmonth) {
308 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
310 if ($search_date_endyear) {
311 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
314 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
315 print
'<input type="hidden" name="action" value="ventil">';
316 if ($optioncss !=
'') {
317 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
319 print
'<input type="hidden" name="token" value="'.newToken().
'">';
320 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
321 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
322 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
323 print
'<input type="hidden" name="page" value="'.$page.
'">';
326 print_barre_liste($langs->trans(
"ExpenseReportLinesDone").
'<br><span class="opacitymedium small">'.$langs->trans(
"DescVentilDoneExpenseReport").
'</span>', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit, 0, 0, 1);
328 print
'<br>'.$langs->trans(
"ChangeAccount").
' <div class="inline-block paddingbottom marginbottomonly">';
329 print $formaccounting->select_account($account_parent,
'account_parent', 2, array(), 0, 0,
'maxwidth300 maxwidthonsmartphone valignmiddle');
330 print
'<input type="submit" class="button small smallpaddingimp valignmiddle" value="'.$langs->trans(
"ChangeBinding").
'"/></div>';
334 print
'<div class="div-table-responsive">';
335 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
337 print
'<tr class="liste_titre_filter">';
338 print
'<td class="liste_titre"><input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).
'"></td>';
339 print
'<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.
'"></td>';
340 print
'<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).
'"></td>';
342 print
'<td class="liste_titre"></td>';
344 print
'<td class="liste_titre center">';
345 print
'<div class="nowrapfordate">';
346 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
348 print
'<div class="nowrapfordate">';
349 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
352 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).
'"></td>';
353 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
354 print
'<td class="liste_titre right"><input type="text" class="flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
355 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>';
356 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).
'"></td>';
357 print
'<td class="liste_titre center">';
358 $searchpicto = $form->showFilterButtons();
363 print
'<tr class="liste_titre">';
366 print_liste_field_titre(
"ExpenseReport", $_SERVER[
"PHP_SELF"],
"er.ref",
"", $param,
'', $sortfield, $sortorder);
368 print_liste_field_titre(
"DateValidation", $_SERVER[
"PHP_SELF"],
"er.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
370 print_liste_field_titre(
"DateOfLine", $_SERVER[
"PHP_SELF"],
"erd.date, erd.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
372 print_liste_field_titre(
"Description", $_SERVER[
"PHP_SELF"],
"erd.comments",
"", $param,
'', $sortfield, $sortorder);
373 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"erd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
374 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
"erd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center ');
375 print_liste_field_titre(
"AccountAccounting", $_SERVER[
"PHP_SELF"],
"aa.account_number",
"", $param,
'', $sortfield, $sortorder);
376 $checkpicto = $form->showCheckAddButtons();
382 $userstatic =
new User($db);
385 while ($i < min($num_lines, $limit)) {
386 $objp = $db->fetch_object($result);
388 $expensereportstatic->ref = $objp->ref;
389 $expensereportstatic->id = $objp->erid;
391 $userstatic->id = $objp->userid;
392 $userstatic->ref = $objp->label;
393 $userstatic->login = $objp->login;
394 $userstatic->status = $objp->statut;
395 $userstatic->email = $objp->email;
396 $userstatic->gender = $objp->gender;
397 $userstatic->firstname = $objp->firstname;
398 $userstatic->lastname = $objp->lastname;
399 $userstatic->employee = $objp->employee;
400 $userstatic->photo = $objp->photo;
402 $accountingaccountstatic->rowid = $objp->fk_compte;
403 $accountingaccountstatic->label = $objp->label;
404 $accountingaccountstatic->labelshort = $objp->labelshort;
405 $accountingaccountstatic->account_number = $objp->account_number;
407 print
'<tr class="oddeven">';
410 print
'<td>'.$objp->rowid.
'</td>';
413 print
'<td class="nowraponall">';
414 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 1,
'login',
'', 1);
418 print
'<td>'.$expensereportstatic->getNomUrl(1).
'</td>';
422 print
'<td class="center">'.dol_print_date($db->jdate($objp->date_valid),
'day').
'</td>';
425 print
'<td class="center">'.dol_print_date($db->jdate($objp->date),
'day').
'</td>';
428 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>';
434 print $form->textwithtooltip(
dol_trunc($text, $trunclength), $objp->comments);
438 print
'<td class="right nowraponall amount">'.price($objp->total_ht).
'</td>';
441 print
'<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ?
' ('.$objp->vat_src_code.
')' :
'')).
'</td>';
444 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($accountingaccountstatic->label).
'">';
445 print
'<a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($param ?
'?'.$param :
'')).
'">';
448 print $accountingaccountstatic->getNomUrl(0, 1, 1,
'', 1);
451 print
'<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.
'"/></td>';
456 if ($num_lines == 0) {
461 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
467 if ($nbtotalofrecords > $limit) {
468 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines, $nbtotalofrecords,
'', 0,
'',
'', $limit, 1);
473 print $db->lasterror();
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.
Class to manage accounting accounts.
Class to manage Trips and Expenses.
const STATUS_CLOSED
Classified paid.
Class to manage Dolibarr users.
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.
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.
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.
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...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.