|
@@ -54,18 +54,24 @@ $childids = $user->getAllChildIds(1);
|
|
|
|
|
|
// Security check
|
|
|
$socid = GETPOST('socid', 'int');
|
|
|
-if ($user->socid) $socid = $user->socid;
|
|
|
+if ($user->socid) {
|
|
|
+ $socid = $user->socid;
|
|
|
+}
|
|
|
$result = restrictedArea($user, 'expensereport', '', '');
|
|
|
$id = GETPOST('id', 'int');
|
|
|
// If we are on the view of a specific user
|
|
|
-if ($id > 0)
|
|
|
-{
|
|
|
+if ($id > 0) {
|
|
|
$canread = 0;
|
|
|
- if ($id == $user->id) $canread = 1;
|
|
|
- if (!empty($user->rights->expensereport->readall)) $canread = 1;
|
|
|
- if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread = 1;
|
|
|
- if (!$canread)
|
|
|
- {
|
|
|
+ if ($id == $user->id) {
|
|
|
+ $canread = 1;
|
|
|
+ }
|
|
|
+ if (!empty($user->rights->expensereport->readall)) {
|
|
|
+ $canread = 1;
|
|
|
+ }
|
|
|
+ if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) {
|
|
|
+ $canread = 1;
|
|
|
+ }
|
|
|
+ if (!$canread) {
|
|
|
accessforbidden();
|
|
|
}
|
|
|
}
|
|
@@ -78,12 +84,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
|
|
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
|
|
+if (empty($page) || $page == -1) {
|
|
|
+ $page = 0;
|
|
|
+} // If $page is not defined, or '' or -1
|
|
|
$offset = $limit * $page;
|
|
|
$pageprev = $page - 1;
|
|
|
$pagenext = $page + 1;
|
|
|
-if (!$sortorder) $sortorder = "DESC";
|
|
|
-if (!$sortfield) $sortfield = "d.date_debut";
|
|
|
+if (!$sortorder) {
|
|
|
+ $sortorder = "DESC";
|
|
|
+}
|
|
|
+if (!$sortfield) {
|
|
|
+ $sortfield = "d.date_debut";
|
|
|
+}
|
|
|
|
|
|
|
|
|
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
|
@@ -101,8 +113,12 @@ $month_end = GETPOST("month_end", "int");
|
|
|
$year_end = GETPOST("year_end", "int");
|
|
|
$optioncss = GETPOST('optioncss', 'alpha');
|
|
|
|
|
|
-if ($search_status == '') $search_status = -1;
|
|
|
-if ($search_user == '') $search_user = -1;
|
|
|
+if ($search_status == '') {
|
|
|
+ $search_status = -1;
|
|
|
+}
|
|
|
+if ($search_user == '') {
|
|
|
+ $search_user = -1;
|
|
|
+}
|
|
|
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
|
|
$object = new ExpenseReport($db);
|
|
@@ -123,7 +139,9 @@ $fieldstosearchall = array(
|
|
|
'u.firstname'=>"Firstname",
|
|
|
'u.login'=>"Login",
|
|
|
);
|
|
|
-if (empty($user->socid)) $fieldstosearchall["d.note_private"] = "NotePrivate";
|
|
|
+if (empty($user->socid)) {
|
|
|
+ $fieldstosearchall["d.note_private"] = "NotePrivate";
|
|
|
+}
|
|
|
|
|
|
$arrayfields = array(
|
|
|
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
|
@@ -151,21 +169,25 @@ $objectuser = new User($db);
|
|
|
* Actions
|
|
|
*/
|
|
|
|
|
|
-if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
|
|
-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
|
|
+if (GETPOST('cancel', 'alpha')) {
|
|
|
+ $action = 'list'; $massaction = '';
|
|
|
+}
|
|
|
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
|
|
+ $massaction = '';
|
|
|
+}
|
|
|
|
|
|
$parameters = array('socid'=>$socid);
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
|
|
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
+if ($reshook < 0) {
|
|
|
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
+}
|
|
|
|
|
|
-if (empty($reshook))
|
|
|
-{
|
|
|
+if (empty($reshook)) {
|
|
|
// Selection of new fields
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
|
|
|
|
|
// Purge search criteria
|
|
|
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
|
|
- {
|
|
|
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
|
|
$search_ref = "";
|
|
|
$search_user = "";
|
|
|
$search_amount_ht = "";
|
|
@@ -181,8 +203,7 @@ if (empty($reshook))
|
|
|
$search_array_options = array();
|
|
|
}
|
|
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
|
|
- || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
|
|
|
- {
|
|
|
+ || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
|
|
|
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
|
|
}
|
|
|
|
|
@@ -216,8 +237,7 @@ $min_year = 10;
|
|
|
// Get current user id
|
|
|
$user_id = $user->id;
|
|
|
|
|
|
-if ($id > 0)
|
|
|
-{
|
|
|
+if ($id > 0) {
|
|
|
// Charge utilisateur edite
|
|
|
$fuser->fetch($id, '', '', 1);
|
|
|
$fuser->getrights();
|
|
@@ -231,35 +251,50 @@ $sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_v
|
|
|
$sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo";
|
|
|
// Add fields from extrafields
|
|
|
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
|
|
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
|
|
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
|
|
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
|
|
+ }
|
|
|
}
|
|
|
// Add fields from hooks
|
|
|
$parameters = array();
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
|
|
$sql .= $hookmanager->resPrint;
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d";
|
|
|
-if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
|
|
|
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
|
|
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
|
|
|
+}
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."user as u";
|
|
|
$sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")";
|
|
|
// Search all
|
|
|
-if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
|
|
+if (!empty($sall)) {
|
|
|
+ $sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
|
|
+}
|
|
|
// Ref
|
|
|
-if (!empty($search_ref)) $sql .= natural_search('d.ref', $search_ref);
|
|
|
+if (!empty($search_ref)) {
|
|
|
+ $sql .= natural_search('d.ref', $search_ref);
|
|
|
+}
|
|
|
// Date Start
|
|
|
$sql .= dolSqlDateFilter("d.date_debut", $day_start, $month_start, $year_start);
|
|
|
// Date End
|
|
|
$sql .= dolSqlDateFilter("d.date_fin", $day_end, $month_end, $year_end);
|
|
|
|
|
|
-if ($search_amount_ht != '') $sql .= natural_search('d.total_ht', $search_amount_ht, 1);
|
|
|
-if ($search_amount_ttc != '') $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1);
|
|
|
+if ($search_amount_ht != '') {
|
|
|
+ $sql .= natural_search('d.total_ht', $search_amount_ht, 1);
|
|
|
+}
|
|
|
+if ($search_amount_ttc != '') {
|
|
|
+ $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1);
|
|
|
+}
|
|
|
// User
|
|
|
-if ($search_user != '' && $search_user >= 0) $sql .= " AND u.rowid = '".$db->escape($search_user)."'";
|
|
|
+if ($search_user != '' && $search_user >= 0) {
|
|
|
+ $sql .= " AND u.rowid = '".$db->escape($search_user)."'";
|
|
|
+}
|
|
|
// Status
|
|
|
-if ($search_status != '' && $search_status >= 0) $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
|
|
|
+if ($search_status != '' && $search_status >= 0) {
|
|
|
+ $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
|
|
|
+}
|
|
|
// RESTRICT RIGHTS
|
|
|
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
|
|
|
- && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)))
|
|
|
-{
|
|
|
+ && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) {
|
|
|
$sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n";
|
|
|
}
|
|
|
// Add where from extra fields
|
|
@@ -273,12 +308,10 @@ $sql .= $db->order($sortfield, $sortorder);
|
|
|
|
|
|
// Count total nb of records
|
|
|
$nbtotalofrecords = '';
|
|
|
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|
|
-{
|
|
|
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
|
|
$result = $db->query($sql);
|
|
|
$nbtotalofrecords = $db->num_rows($result);
|
|
|
- if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
|
|
- {
|
|
|
+ if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
|
|
$page = 0;
|
|
|
$offset = 0;
|
|
|
}
|
|
@@ -288,22 +321,39 @@ $sql .= $db->plimit($limit + 1, $offset);
|
|
|
|
|
|
//print $sql;
|
|
|
$resql = $db->query($sql);
|
|
|
-if ($resql)
|
|
|
-{
|
|
|
+if ($resql) {
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
|
|
|
|
|
$param = '';
|
|
|
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
|
|
- if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
|
|
- if ($sall) $param .= "&sall=".urlencode($sall);
|
|
|
- if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
|
|
|
- if ($search_user) $param .= "&search_user=".urlencode($search_user);
|
|
|
- if ($search_amount_ht) $param .= "&search_amount_ht=".urlencode($search_amount_ht);
|
|
|
- if ($search_amount_ttc) $param .= "&search_amount_ttc=".urlencode($search_amount_ttc);
|
|
|
- if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status);
|
|
|
- if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
|
|
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
|
|
+ $param .= '&contextpage='.urlencode($contextpage);
|
|
|
+ }
|
|
|
+ if ($limit > 0 && $limit != $conf->liste_limit) {
|
|
|
+ $param .= '&limit='.urlencode($limit);
|
|
|
+ }
|
|
|
+ if ($sall) {
|
|
|
+ $param .= "&sall=".urlencode($sall);
|
|
|
+ }
|
|
|
+ if ($search_ref) {
|
|
|
+ $param .= "&search_ref=".urlencode($search_ref);
|
|
|
+ }
|
|
|
+ if ($search_user) {
|
|
|
+ $param .= "&search_user=".urlencode($search_user);
|
|
|
+ }
|
|
|
+ if ($search_amount_ht) {
|
|
|
+ $param .= "&search_amount_ht=".urlencode($search_amount_ht);
|
|
|
+ }
|
|
|
+ if ($search_amount_ttc) {
|
|
|
+ $param .= "&search_amount_ttc=".urlencode($search_amount_ttc);
|
|
|
+ }
|
|
|
+ if ($search_status >= 0) {
|
|
|
+ $param .= "&search_status=".urlencode($search_status);
|
|
|
+ }
|
|
|
+ if ($optioncss != '') {
|
|
|
+ $param .= '&optioncss='.urlencode($optioncss);
|
|
|
+ }
|
|
|
// Add $param from extra fields
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
|
|
|
|
@@ -313,23 +363,30 @@ if ($resql)
|
|
|
'builddoc'=>$langs->trans("PDFMerge"),
|
|
|
'presend'=>$langs->trans("SendByMail"),
|
|
|
);
|
|
|
- if ($user->rights->expensereport->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
|
|
- if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
|
|
+ if ($user->rights->expensereport->supprimer) {
|
|
|
+ $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
|
|
+ }
|
|
|
+ if (in_array($massaction, array('presend', 'predelete'))) {
|
|
|
+ $arrayofmassactions = array();
|
|
|
+ }
|
|
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
|
|
|
|
|
// Lines of title fields
|
|
|
print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
|
|
- if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
+ if ($optioncss != '') {
|
|
|
+ print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
+ }
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
|
|
print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
|
|
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
|
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
|
- if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
|
|
|
+ if ($id > 0) {
|
|
|
+ print '<input type="hidden" name="id" value="'.$id.'">';
|
|
|
+ }
|
|
|
|
|
|
- if ($id > 0) // For user tab
|
|
|
- {
|
|
|
+ if ($id > 0) { // For user tab
|
|
|
$title = $langs->trans("User");
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
|
|
$head = user_prepare_head($fuser);
|
|
@@ -340,8 +397,7 @@ if ($resql)
|
|
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
|
|
- if ($action != 'edit')
|
|
|
- {
|
|
|
+ if ($action != 'edit') {
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
|
$childids = $user->getAllChildIds(1);
|
|
@@ -366,7 +422,9 @@ if ($resql)
|
|
|
$title = $langs->trans("ListTripsAndExpenses");
|
|
|
|
|
|
$url = DOL_URL_ROOT.'/expensereport/card.php?action=create';
|
|
|
- if (!empty($socid)) $url .= '&socid='.$socid;
|
|
|
+ if (!empty($socid)) {
|
|
|
+ $url .= '&socid='.$socid;
|
|
|
+ }
|
|
|
$newcardbutton = dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', $url, '', $user->rights->expensereport->creer);
|
|
|
|
|
|
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'trip', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
|
@@ -378,9 +436,10 @@ if ($resql)
|
|
|
$trackid = 'exp'.$object->id;
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
|
|
|
|
|
- if ($sall)
|
|
|
- {
|
|
|
- foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
|
|
+ if ($sall) {
|
|
|
+ foreach ($fieldstosearchall as $key => $val) {
|
|
|
+ $fieldstosearchall[$key] = $langs->trans($val);
|
|
|
+ }
|
|
|
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
|
|
}
|
|
|
|
|
@@ -388,11 +447,13 @@ if ($resql)
|
|
|
|
|
|
$parameters = array();
|
|
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
|
|
- if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
|
|
- else $moreforfilter = $hookmanager->resPrint;
|
|
|
+ if (empty($reshook)) {
|
|
|
+ $moreforfilter .= $hookmanager->resPrint;
|
|
|
+ } else {
|
|
|
+ $moreforfilter = $hookmanager->resPrint;
|
|
|
+ }
|
|
|
|
|
|
- if (!empty($moreforfilter))
|
|
|
- {
|
|
|
+ if (!empty($moreforfilter)) {
|
|
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
|
|
print $moreforfilter;
|
|
|
print '</div>';
|
|
@@ -407,17 +468,14 @@ if ($resql)
|
|
|
|
|
|
// Filters
|
|
|
print '<tr class="liste_titre_filter">';
|
|
|
- if (!empty($arrayfields['d.ref']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.ref']['checked'])) {
|
|
|
print '<td class="liste_titre" align="left">';
|
|
|
print '<input class="flat" size="15" type="text" name="search_ref" value="'.$search_ref.'">';
|
|
|
print '</td>';
|
|
|
}
|
|
|
// User
|
|
|
- if (!empty($arrayfields['user']['checked']))
|
|
|
- {
|
|
|
- if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous)
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['user']['checked'])) {
|
|
|
+ if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) {
|
|
|
print '<td class="liste_titre maxwidthonspartphone" align="left">';
|
|
|
print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
|
|
|
print '</td>';
|
|
@@ -426,8 +484,7 @@ if ($resql)
|
|
|
}
|
|
|
}
|
|
|
// Date start
|
|
|
- if (!empty($arrayfields['d.date_debut']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.date_debut']['checked'])) {
|
|
|
print '<td class="liste_titre" align="center">';
|
|
|
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
|
|
|
print '<input class="flat width25" type="text" maxlength="2" name="day_start" value="'.dol_escape_htmltag($day_start).'">';
|
|
@@ -438,8 +495,7 @@ if ($resql)
|
|
|
print '</td>';
|
|
|
}
|
|
|
// Date end
|
|
|
- if (!empty($arrayfields['d.date_fin']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.date_fin']['checked'])) {
|
|
|
print '<td class="liste_titre" align="center">';
|
|
|
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
|
|
|
print '<input class="flat width25" type="text" maxlength="2" name="day_end" value="'.dol_escape_htmltag($day_end).'">';
|
|
@@ -449,33 +505,28 @@ if ($resql)
|
|
|
print '</td>';
|
|
|
}
|
|
|
// Date valid
|
|
|
- if (!empty($arrayfields['d.date_valid']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.date_valid']['checked'])) {
|
|
|
print '<td class="liste_titre" align="center">';
|
|
|
//print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
|
|
|
//$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
|
|
|
print '</td>';
|
|
|
}
|
|
|
// Date approve
|
|
|
- if (!empty($arrayfields['d.date_approve']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.date_approve']['checked'])) {
|
|
|
print '<td class="liste_titre" align="center">';
|
|
|
//print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
|
|
|
//$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
|
|
|
print '</td>';
|
|
|
}
|
|
|
// Amount with no tax
|
|
|
- if (!empty($arrayfields['d.total_ht']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.total_ht']['checked'])) {
|
|
|
print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ht" value="'.$search_amount_ht.'"></td>';
|
|
|
}
|
|
|
- if (!empty($arrayfields['d.total_vat']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.total_vat']['checked'])) {
|
|
|
print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>';
|
|
|
}
|
|
|
// Amount with all taxes
|
|
|
- if (!empty($arrayfields['d.total_ttc']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.total_ttc']['checked'])) {
|
|
|
print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>';
|
|
|
}
|
|
|
// Extra fields
|
|
@@ -486,20 +537,17 @@ if ($resql)
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
// Date creation
|
|
|
- if (!empty($arrayfields['d.date_create']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.date_create']['checked'])) {
|
|
|
print '<td class="liste_titre">';
|
|
|
print '</td>';
|
|
|
}
|
|
|
// Date modification
|
|
|
- if (!empty($arrayfields['d.tms']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.tms']['checked'])) {
|
|
|
print '<td class="liste_titre">';
|
|
|
print '</td>';
|
|
|
}
|
|
|
// Status
|
|
|
- if (!empty($arrayfields['d.fk_statut']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.fk_statut']['checked'])) {
|
|
|
print '<td class="liste_titre right">';
|
|
|
$formexpensereport->selectExpensereportStatus($search_status, 'search_status', 1, 1);
|
|
|
print '</td>';
|
|
@@ -513,24 +561,48 @@ if ($resql)
|
|
|
print "</tr>\n";
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
- if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['user']['checked'])) print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.date_valid']['checked'])) print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.date_approve']['checked'])) print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ if (!empty($arrayfields['d.ref']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['user']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.date_debut']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.date_fin']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.date_valid']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.date_approve']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.total_ht']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.total_vat']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.total_ttc']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
// Extra fields
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
|
|
// Hook fields
|
|
|
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
- if (!empty($arrayfields['d.date_create']['checked'])) print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
|
|
- if (!empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ if (!empty($arrayfields['d.date_create']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.tms']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
+ if (!empty($arrayfields['d.fk_statut']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder);
|
|
|
+ }
|
|
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
|
|
print "</tr>\n";
|
|
|
|
|
@@ -541,12 +613,10 @@ if ($resql)
|
|
|
$expensereportstatic = new ExpenseReport($db);
|
|
|
$usertmp = new User($db);
|
|
|
|
|
|
- if ($num > 0)
|
|
|
- {
|
|
|
+ if ($num > 0) {
|
|
|
$i = 0;
|
|
|
$totalarray = array();
|
|
|
- while ($i < min($num, $limit))
|
|
|
- {
|
|
|
+ while ($i < min($num, $limit)) {
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
|
$expensereportstatic->id = $obj->rowid;
|
|
@@ -572,10 +642,13 @@ if ($resql)
|
|
|
print '</td>';
|
|
|
// Warning late icon and note
|
|
|
print '<td class="nobordernopadding nowrap">';
|
|
|
- if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) print img_warning($langs->trans("Late"));
|
|
|
- if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) print img_warning($langs->trans("Late"));
|
|
|
- if (!empty($obj->note_private) || !empty($obj->note_public))
|
|
|
- {
|
|
|
+ if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) {
|
|
|
+ print img_warning($langs->trans("Late"));
|
|
|
+ }
|
|
|
+ if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) {
|
|
|
+ print img_warning($langs->trans("Late"));
|
|
|
+ }
|
|
|
+ if (!empty($obj->note_private) || !empty($obj->note_public)) {
|
|
|
print ' <span class="note">';
|
|
|
print '<a href="'.DOL_URL_ROOT.'/expensereport/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').'</a>';
|
|
|
print '</span>';
|
|
@@ -589,7 +662,9 @@ if ($resql)
|
|
|
print '</td>';
|
|
|
print '</tr></table>';
|
|
|
print '</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// User
|
|
|
if (!empty($arrayfields['user']['checked'])) {
|
|
@@ -603,50 +678,69 @@ if ($resql)
|
|
|
$usertmp->email = $obj->email;
|
|
|
print $usertmp->getNomUrl(-1);
|
|
|
print '</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// Start date
|
|
|
if (!empty($arrayfields['d.date_debut']['checked'])) {
|
|
|
print '<td class="center">'.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').'</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// End date
|
|
|
if (!empty($arrayfields['d.date_fin']['checked'])) {
|
|
|
print '<td class="center">'.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').'</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// Date validation
|
|
|
if (!empty($arrayfields['d.date_valid']['checked'])) {
|
|
|
print '<td class="center">'.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').'</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// Date approval
|
|
|
if (!empty($arrayfields['d.date_approve']['checked'])) {
|
|
|
print '<td class="center">'.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').'</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// Amount HT
|
|
|
- if (!empty($arrayfields['d.total_ht']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.total_ht']['checked'])) {
|
|
|
print '<td class="right">'.price($obj->total_ht)."</td>\n";
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht';
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht';
|
|
|
+ }
|
|
|
$totalarray['val']['d.total_ht'] += $obj->total_ht;
|
|
|
}
|
|
|
// Amount VAT
|
|
|
- if (!empty($arrayfields['d.total_vat']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.total_vat']['checked'])) {
|
|
|
print '<td class="right">'.price($obj->total_tva)."</td>\n";
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva';
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva';
|
|
|
+ }
|
|
|
$totalarray['val']['d.total_tva'] += $obj->total_tva;
|
|
|
}
|
|
|
// Amount TTC
|
|
|
- if (!empty($arrayfields['d.total_ttc']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.total_ttc']['checked'])) {
|
|
|
print '<td class="right">'.price($obj->total_ttc)."</td>\n";
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc';
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc';
|
|
|
+ }
|
|
|
$totalarray['val']['d.total_ttc'] += $obj->total_ttc;
|
|
|
}
|
|
|
|
|
@@ -658,37 +752,43 @@ if ($resql)
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
// Date creation
|
|
|
- if (!empty($arrayfields['d.date_create']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.date_create']['checked'])) {
|
|
|
print '<td class="nowrap center">';
|
|
|
print dol_print_date($db->jdate($obj->date_create), 'dayhour');
|
|
|
print '</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// Date modification
|
|
|
- if (!empty($arrayfields['d.tms']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.tms']['checked'])) {
|
|
|
print '<td class="nowrap center">';
|
|
|
print dol_print_date($db->jdate($obj->date_modif), 'dayhour');
|
|
|
print '</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// Status
|
|
|
- if (!empty($arrayfields['d.fk_statut']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields['d.fk_statut']['checked'])) {
|
|
|
print '<td class="nowrap right">'.$expensereportstatic->getLibStatut(5).'</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
// Action column
|
|
|
print '<td class="nowrap center">';
|
|
|
- if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
|
|
- {
|
|
|
+ if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
|
|
$selected = 0;
|
|
|
- if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
|
|
+ if (in_array($obj->rowid, $arrayofselected)) {
|
|
|
+ $selected = 1;
|
|
|
+ }
|
|
|
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
|
|
}
|
|
|
print '</td>';
|
|
|
- if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
@@ -700,7 +800,11 @@ if ($resql)
|
|
|
}
|
|
|
} else {
|
|
|
$colspan = 1;
|
|
|
- foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
|
|
+ foreach ($arrayfields as $key => $val) {
|
|
|
+ if (!empty($val['checked'])) {
|
|
|
+ $colspan++;
|
|
|
+ }
|
|
|
+ }
|
|
|
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
|
|
}
|
|
|
|
|
@@ -718,10 +822,11 @@ if ($resql)
|
|
|
|
|
|
print '</form>'."\n";
|
|
|
|
|
|
- if (empty($id))
|
|
|
- {
|
|
|
+ if (empty($id)) {
|
|
|
$hidegeneratedfilelistifempty = 1;
|
|
|
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
|
|
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
|
|
|
+ $hidegeneratedfilelistifempty = 0;
|
|
|
+ }
|
|
|
|
|
|
// Show list of available documents
|
|
|
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|