Skip to content

Commit

Permalink
NEW Add tab "Expense report" on user card
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 19, 2017
1 parent abd5251 commit d82af57
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 30 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/lib/usergroups.lib.php
Expand Up @@ -68,7 +68,7 @@ function user_prepare_head($object)
if ($canreadperms)
{
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id;
$head[$h][1] = $langs->trans("UserRights"). ' <span class="badge">'.($object->nb_rights).'</span>';
$head[$h][1] = $langs->trans("Rights"). ' <span class="badge">'.($object->nb_rights).'</span>';
$head[$h][2] = 'rights';
$h++;
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/modExpenseReport.class.php
Expand Up @@ -102,7 +102,7 @@ function __construct($db)
$r++;

// Array to add new pages in new tabs
$this->tabs = array();
$this->tabs = array('user:+expensereport:ExpenseReport:expensereport:$user->rights->expensereport->lire:/expensereport/list.php?mainmenu=hrm&id=__ID__');

// Boxes
$this->boxes = array(); // List of boxes
Expand Down
89 changes: 74 additions & 15 deletions htdocs/expensereport/list.php
Expand Up @@ -31,6 +31,7 @@
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';

$langs->load("companies");
$langs->load("users");
Expand Down Expand Up @@ -62,6 +63,7 @@
if (!$sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield="d.date_debut";

$id = GETPOST('id', 'int');

$sall = GETPOST('sall', 'alphanohtml');
$search_ref = GETPOST('search_ref');
Expand Down Expand Up @@ -181,12 +183,26 @@
$formother = new FormOther($db);
$formfile = new FormFile($db);

$fuser = new User($db);

$title = $langs->trans("ListOfTrips");
llxHeader('', $title);

$max_year = 5;
$min_year = 5;

// Récupération de l'ID de l'utilisateur
$user_id = $user->id;

if ($id > 0)
{
// Charge utilisateur edite
$fuser->fetch($id, '', '', 1);
$fuser->getrights();
$user_id = $fuser->id;

$search_user = $user_id;
}

$sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,";
$sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,";
Expand Down Expand Up @@ -327,9 +343,50 @@
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) // For user tab
{
$title = $langs->trans("User");
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$head = user_prepare_head($fuser);

dol_fiche_head($head, 'expensereport', $title, -1, 'user');

dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin);

print '<div class="underbanner clearboth"></div>';

print '<br>';

/*if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
print '<div class="underbanner clearboth"></div>';
print '<br>';
showMyBalance($holiday, $user_id);
}*/

dol_fiche_end();

print '<div class="tabsAction">';

$title = $langs->trans("ListTripsAndExpenses");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit);
$canedit=(($user->id == $user_id && $user->rights->expensereport->creer) || ($user->id != $user_id));

// Boutons d'actions
if ($canedit)
{
print '<a href="'.DOL_URL_ROOT.'/expensereport/card.php?action=request&id='.$user_id.'" class="butAction">'.$langs->trans("AddTrip").'</a>';
}

print '</div>';
}
else
{
$title = $langs->trans("ListTripsAndExpenses");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit);
}

if ($massaction == 'presend')
{
Expand Down Expand Up @@ -743,22 +800,24 @@

print '</form>'."\n";


if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
if (empty($id))
{
// Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
// Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);

$filedir=$diroutputmassaction;
$genallowed=$user->rights->expensereport->lire;
$delallowed=$user->rights->expensereport->creer;
$filedir=$diroutputmassaction;
$genallowed=$user->rights->expensereport->lire;
$delallowed=$user->rights->expensereport->creer;

print $formfile->showdocuments('massfilesarea_expensereport','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else
{
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
print $formfile->showdocuments('massfilesarea_expensereport','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else
{
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
}
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions htdocs/holiday/list.php
Expand Up @@ -259,6 +259,8 @@
$fuser->fetch($id, '', '', 1);
$fuser->getrights();
$user_id = $fuser->id;

$search_employee = $user_id;
}

// Récupération des congés payés de l'utilisateur ou de tous les users
Expand Down
6 changes: 4 additions & 2 deletions htdocs/theme/eldy/style.css.php
Expand Up @@ -1038,11 +1038,11 @@
height: calc(100% - 50px);*/
}

<?php if (!empty($conf->global->THEME_TOPMENU_STICKY_POSITION)) { ?>
<?php if (empty($conf->global->THEME_DISABLE_STICKY_TOPMENU)) { ?>
.side-nav-vert {
position: sticky;
top: 0px;
z-index: 90;
z-index: 210;
}
<?php } ?>

Expand Down Expand Up @@ -4875,10 +4875,12 @@
}
div.login_block {
<?php if ($conf->browser->layout == 'phone' && ((GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?>
/* Style when phone layout or when using the menuhider */
display: none;
padding-top: 20px;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 16px;
<?php } else { ?>
padding-top: 10px;
padding-left: 5px;
Expand Down
22 changes: 11 additions & 11 deletions htdocs/user/bank.php
Expand Up @@ -288,16 +288,16 @@
{
print '<div class="warning">'.$langs->trans("RIBControlError").'</div>';
}

print '</div><div class="fichehalfright"><div class="ficheaddleft">';

// Nbre max d'elements des petites listes
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;

/*
* Last salaries
*/
if (! empty($conf->salaries->enabled) &&
if (! empty($conf->salaries->enabled) &&
($user->rights->salaries->read || ($user->rights->salaries->read && $object->id == $user->id))
)
{
Expand Down Expand Up @@ -334,7 +334,7 @@
print '<td class="nowrap">';
$salary->id = $objp->rowid;
$salary->ref = $objp->rowid;

print $salary->getNomUrl(1);
print '</td><td align="right" width="80px">'.dol_print_date($db->jdate($objp->datesp),'day')."</td>\n";
print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->dateep),'day')."</td>\n";
Expand All @@ -350,11 +350,11 @@
dol_print_error($db);
}
}

/*
* Last holidays
*/
if (! empty($conf->holiday->enabled) &&
if (! empty($conf->holiday->enabled) &&
($user->rights->holiday->read_all || ($user->rights->holiday->read && $object->id == $user->id))
)
{
Expand Down Expand Up @@ -393,7 +393,7 @@
$holiday->ref = $objp->rowid;
$holiday->fk_type = $objp->fk_type;
$nbopenedday=num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday);

print $holiday->getNomUrl(1);
print '</td><td align="right" width="80px">'.dol_print_date($db->jdate($objp->date_debut),'day')."</td>\n";
print '<td align="right" style="min-width: 60px">'.$nbopenedday.' '.$langs->trans('DurationDays').'</td>';
Expand All @@ -413,7 +413,7 @@
/*
* Last expense report
*/
if (! empty($conf->expensereport->enabled) &&
if (! empty($conf->expensereport->enabled) &&
($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id))
)
{
Expand All @@ -436,7 +436,7 @@
print '<table class="noborder" width="100%">';

print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastExpenseReports",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expensereport/list.php?search_user='.$object->id.'">'.$langs->trans("AllExpenseReports").' <span class="badge">'.$num.'</span></a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastExpenseReports",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expensereport/list.php?id='.$object->id.'">'.$langs->trans("AllExpenseReports").' <span class="badge">'.$num.'</span></a></td>';
print '</tr></table></td>';
print '</tr>';
}
Expand All @@ -451,7 +451,7 @@
$exp->id = $objp->rowid;
$exp->ref = $objp->ref;
$exp->fk_type = $objp->fk_type;

print $exp->getNomUrl(1);
print '</td><td align="right" width="80px">'.dol_print_date($db->jdate($objp->date_debut),'day')."</td>\n";
print '<td align="right" style="min-width: 60px">'.price($objp->total_ttc).'</td>';
Expand Down

0 comments on commit d82af57

Please sign in to comment.