27require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_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);
63$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
65$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
66if (empty($page) || $page < 0) {
69$offset = $limit * $page;
73 $sortfield =
"erd.date, erd.rowid";
84if (!isModEnabled(
'accounting')) {
87if ($user->socid > 0) {
90if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
103if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
105 $search_expensereport =
'';
109 $search_account =
'';
111 $search_date_startday =
'';
112 $search_date_startmonth =
'';
113 $search_date_startyear =
'';
114 $search_date_endday =
'';
115 $search_date_endmonth =
'';
116 $search_date_endyear =
'';
117 $search_date_start =
'';
118 $search_date_end =
'';
121if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight(
'accounting',
'bind',
'write')) {
124 if (!(
GETPOST(
'account_parent',
'int') >= 0)) {
126 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Account")),
null,
'errors');
132 $sql1 =
"UPDATE ".MAIN_DB_PREFIX.
"expensereport_det as erd";
133 $sql1 .=
" SET erd.fk_code_ventilation=".(GETPOST(
'account_parent',
'int') > 0 ?
GETPOST(
'account_parent',
'int') :
'0');
134 $sql1 .=
' WHERE erd.rowid IN ('.$db->sanitize(implode(
',', $changeaccount)).
')';
136 dol_syslog(
'accountancy/expensereport/lines.php::changeaccount sql= '.$sql1);
137 $resql1 = $db->query($sql1);
150 $account_parent =
'';
154if (
GETPOST(
'sortfield') ==
'erd.date, erd.rowid') {
155 $value = (
GETPOST(
'sortorder') ==
'asc,asc' ? 0 : 1);
156 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
157 $res =
dolibarr_set_const($db,
"ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value,
'yesno', 0,
'', $conf->entity);
165$form =
new Form($db);
168$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables';
170llxHeader(
'', $langs->trans(
"ExpenseReportsVentilation").
' - '.$langs->trans(
"Dispatched"), $help_url);
172print
'<script type="text/javascript">
174 $(\'#select-all\').click(function(event) {
175 // Iterate each checkbox
176 $(\':checkbox\').each(function() {
180 $(\'#unselect-all\').click(function(event) {
181 // Iterate each checkbox
182 $(\':checkbox\').each(function() {
183 this.checked = false;
192$sql =
"SELECT er.ref, er.rowid as erid,";
193$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,";
194$sql .=
" f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
195$sql .=
" u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
196$sql .=
" aa.label, aa.labelshort, aa.account_number";
197$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport as er";
198$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"expensereport_det as erd ON er.rowid = erd.fk_expensereport";
199$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
200$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_fees as f ON f.id = erd.fk_c_type_fees";
201$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = er.fk_user_author";
202$sql .=
" WHERE erd.fk_code_ventilation > 0";
203$sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
206if (strlen(trim($search_login))) {
209if (strlen(trim($search_expensereport))) {
212if (strlen(trim($search_label))) {
215if (strlen(trim($search_desc))) {
218if (strlen(trim($search_amount))) {
221if (strlen(trim($search_account))) {
224if (strlen(trim($search_vat))) {
227if ($search_date_start) {
228 $sql .=
" AND erd.date >= '".$db->idate($search_date_start).
"'";
230if ($search_date_end) {
231 $sql .=
" AND erd.date <= '".$db->idate($search_date_end).
"'";
233$sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
235$sql .= $db->order($sortfield, $sortorder);
238$nbtotalofrecords =
'';
240 $result = $db->query($sql);
241 $nbtotalofrecords = $db->num_rows($result);
242 if (($page * $limit) > $nbtotalofrecords) {
248$sql .= $db->plimit($limit + 1, $offset);
250dol_syslog(
"accountancy/expensereport/lines.php", LOG_DEBUG);
251$result = $db->query($sql);
253 $num_lines = $db->num_rows($result);
257 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
258 $param .=
'&contextpage='.urlencode($contextpage);
260 if ($limit > 0 && $limit != $conf->liste_limit) {
261 $param .=
'&limit='.((int) $limit);
264 $param .=
'&search_login='.urlencode($search_login);
266 if ($search_expensereport) {
267 $param .=
"&search_expensereport=".urlencode($search_expensereport);
270 $param .=
"&search_label=".urlencode($search_label);
273 $param .=
"&search_desc=".urlencode($search_desc);
275 if ($search_account) {
276 $param .=
"&search_account=".urlencode($search_account);
279 $param .=
"&search_vat=".urlencode($search_vat);
281 if ($search_date_startday) {
282 $param .=
'&search_date_startday='.urlencode($search_date_startday);
284 if ($search_date_startmonth) {
285 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
287 if ($search_date_startyear) {
288 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
290 if ($search_date_endday) {
291 $param .=
'&search_date_endday='.urlencode($search_date_endday);
293 if ($search_date_endmonth) {
294 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
296 if ($search_date_endyear) {
297 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
300 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
301 print
'<input type="hidden" name="action" value="ventil">';
302 if ($optioncss !=
'') {
303 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
305 print
'<input type="hidden" name="token" value="'.newToken().
'">';
306 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
307 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
308 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
309 print
'<input type="hidden" name="page" value="'.$page.
'">';
311 print_barre_liste($langs->trans(
"ExpenseReportLinesDone"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit);
312 print
'<span class="opacitymedium">'.$langs->trans(
"DescVentilDoneExpenseReport").
'</span><br>';
314 print
'<br><div class="inline-block divButAction paddingbottom">'.$langs->trans(
"ChangeAccount").
' ';
315 print $formaccounting->select_account($account_parent,
'account_parent', 2, array(), 0, 0,
'maxwidth300 maxwidthonsmartphone valignmiddle');
316 print
'<input type="submit" class="button small valignmiddle" value="'.$langs->trans(
"ChangeBinding").
'"/></div>';
320 print
'<div class="div-table-responsive">';
321 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
323 print
'<tr class="liste_titre_filter">';
324 print
'<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.
'"></td>';
325 print
'<td class="liste_titre"></td>';
326 print
'<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).
'"></td>';
328 print
'<td class="liste_titre"></td>';
330 print
'<td class="liste_titre center">';
331 print
'<div class="nowrapfordate">';
332 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
334 print
'<div class="nowrapfordate">';
335 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
338 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).
'"></td>';
339 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
340 print
'<td class="liste_titre right"><input type="text" class="flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
341 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>';
342 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).
'"></td>';
343 print
'<td class="liste_titre center">';
344 $searchpicto = $form->showFilterButtons();
349 print
'<tr class="liste_titre">';
352 print_liste_field_titre(
"ExpenseReport", $_SERVER[
"PHP_SELF"],
"er.ref",
"", $param,
'', $sortfield, $sortorder);
354 print_liste_field_titre(
"DateValidation", $_SERVER[
"PHP_SELF"],
"er.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
356 print_liste_field_titre(
"DateOfLine", $_SERVER[
"PHP_SELF"],
"erd.date, erd.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
358 print_liste_field_titre(
"Description", $_SERVER[
"PHP_SELF"],
"erd.comments",
"", $param,
'', $sortfield, $sortorder);
359 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"erd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
360 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
"erd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center ');
361 print_liste_field_titre(
"AccountAccounting", $_SERVER[
"PHP_SELF"],
"aa.account_number",
"", $param,
'', $sortfield, $sortorder);
362 $checkpicto = $form->showCheckAddButtons();
368 $userstatic =
new User($db);
371 while ($i < min($num_lines, $limit)) {
372 $objp = $db->fetch_object($result);
374 $expensereportstatic->ref = $objp->ref;
375 $expensereportstatic->id = $objp->erid;
377 $userstatic->id = $objp->userid;
378 $userstatic->ref = $objp->label;
379 $userstatic->login = $objp->login;
380 $userstatic->statut = $objp->statut;
381 $userstatic->email = $objp->email;
382 $userstatic->gender = $objp->gender;
383 $userstatic->firstname = $objp->firstname;
384 $userstatic->lastname = $objp->lastname;
385 $userstatic->employee = $objp->employee;
386 $userstatic->photo = $objp->photo;
388 $accountingaccountstatic->rowid = $objp->fk_compte;
389 $accountingaccountstatic->label = $objp->label;
390 $accountingaccountstatic->labelshort = $objp->labelshort;
391 $accountingaccountstatic->account_number = $objp->account_number;
393 print
'<tr class="oddeven">';
396 print
'<td class="nowraponall">';
397 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 1,
'login',
'', 1);
401 print
'<td>'.$objp->rowid.
'</td>';
404 print
'<td>'.$expensereportstatic->getNomUrl(1).
'</td>';
408 print
'<td class="center">'.dol_print_date($db->jdate($objp->date_valid),
'day').
'</td>';
411 print
'<td class="center">'.dol_print_date($db->jdate($objp->date),
'day').
'</td>';
414 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>';
420 print $form->textwithtooltip(
dol_trunc($text, $trunclength), $objp->comments);
424 print
'<td class="right nowraponall amount">'.price($objp->total_ht).
'</td>';
427 print
'<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ?
' ('.$objp->vat_src_code.
')' :
'')).
'</td>';
431 print $accountingaccountstatic->getNomUrl(0, 1, 1,
'', 1);
432 print
' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($param ?
'?'.$param :
'')).
'">';
435 print
'<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.
'"/></td>';
440 if ($num_lines == 0) {
445 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
451 if ($nbtotalofrecords > $limit) {
452 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines, $nbtotalofrecords,
'', 0,
'',
'', $limit, 1);
457 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()
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 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...
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.
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.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.