Enhance filtering for bank transaction and timesheet.

This commit is contained in:
Laurent Destailleur 2015-04-09 20:40:49 +02:00
parent 3ee2790737
commit 503a4ff7a0
7 changed files with 139 additions and 40 deletions

View File

@ -403,7 +403,7 @@ if ($id > 0 || ! empty($ref))
print '<input name="label" class="flat" type="text" size="24" value="'.GETPOST("label").'">';
if ($nbcategories)
{
print '<br>'.$langs->trans("Category").': <select class="flat" name="cat1">'.$options.'</select>';
print '<br>'.$langs->trans("Rubrique").': <select class="flat" name="cat1">'.$options.'</select>';
}
print '</td>';
print '<td align=right><input name="debit" class="flat" type="text" size="4" value="'.GETPOST("debit").'"></td>';

View File

@ -178,9 +178,10 @@ if ($resql)
print '<form method="post" action="search.php" name="search_form">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
$moreforfilter .= $langs->trans('Period') . ' ' . $langs->trans('StartDate') . ': ';
$moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 1, 1);
$moreforfilter .= $langs->trans('EndDate') . ':' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 1, 1);
$moreforfilter .= $langs->trans('Period') . ' ('.$langs->trans('DateOperationShort').') : ' . $langs->trans('StartDate') . ' ';
$moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1);
$moreforfilter .= ' - ';
$moreforfilter .= $langs->trans('EndDate') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1);
if ($moreforfilter) {

View File

@ -504,9 +504,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
* @param string $tasksrole Array of roles user has on task
* @param string $mine Show only task lines I am assigned to
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
* @param int $preselectedday Preselected day
* @return $inc
*/
function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask=0)
function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask=0, $preselectedday='')
{
global $db, $user, $bc, $langs;
global $form, $formother, $projectstatic, $taskstatic;
@ -527,6 +528,12 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
{
$var = !$var;
$lastprojectid=$lines[$i]->fk_project;
if ($preselectedday)
{
$projectstatic->id = $lines[$i]->fk_project;
$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTaks for all day of a week
}
}
// If we want all or we have a role on task, we show it
@ -549,7 +556,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
// Ref
print '<td>';
$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
print $taskstatic->getNomUrl(1);
print $taskstatic->getNomUrl(1,'withproject');
print '</td>';
// Label task
@ -559,7 +566,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
$taskstatic->ref=$lines[$i]->label;
$taskstatic->date_start=$lines[$i]->date_start;
$taskstatic->date_end=$lines[$i]->date_end;
print $taskstatic->getNomUrl(0);
print $taskstatic->getNomUrl(0,'withproject');
//print "<br>";
//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
@ -613,14 +620,21 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
// Form to add new time
print '<td class="nowrap" align="center">';
$s='';
$s.=$form->select_date('',$lines[$i]->id,1,1,2,"addtime",1,0,1,$disabledtask);
print $s;
$tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask);
print $tableCell;
print '</td><td align="right">';
//$s.='&nbsp;&nbsp;&nbsp;';
$s=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
//$s.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
print $s;
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$tableCell='';
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled="disabled" id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
$tableCell.=' + ';
//$tableCell.='&nbsp;&nbsp;&nbsp;';
$tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
//$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
print $tableCell;
print '</td>';
print '<td align="right">';
@ -633,7 +647,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
$inc++;
$level++;
if ($lines[$i]->id) projectLinesPerDay($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
if ($lines[$i]->id) projectLinesPerDay($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday);
$level--;
}
else
@ -776,18 +790,30 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
for ($idw = 0; $idw < 7; $idw++)
{
$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
$tmparray=dol_getdate($tmpday);
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$tableCell ='<td align="center">';
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled="disabled" id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
$tableCell.='+';
$tableCell.='<input type="text" class="center" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
$tableCell.= 'onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
//$placeholder=' placeholder="00:00"';
$placeholder='';
//if (! $disabledtask)
//{
$tableCell.='+';
$tableCell.='<input type="text" alt="'.$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']).'" title="'.$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']).'" '.($disabledtask?'disabled="disabled"':$placeholder).' class="center" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
$tableCell.= 'onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
//}
$tableCell.='</td>';
print $tableCell;
}
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou"));
print '</td>';
print "</tr>\n";
}

View File

@ -220,6 +220,7 @@ Next=Next
Cards=Cards
Card=Card
Now=Now
HourStart=Start hour
Date=Date
DateAndHour=Date and hour
DateStart=Date start

View File

@ -14,6 +14,7 @@ MyTasksDesc=This view is limited to projects or tasks you are a contact for (wha
OnlyOpenedProject=Only opened projects are visible (projects with draft or closed status are not visible).
TasksPublicDesc=This view presents all projects and tasks you are allowed to read.
TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything).
AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task you are assigned on.
ProjectsArea=Projects area
NewProject=New project
AddProject=Create project

View File

@ -48,11 +48,33 @@ $socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $projectid);
$now=dol_now();
$nowtmp=dol_getdate($now);
$nowday=$nowtmp['mday'];
$nowmonth=$nowtmp['mon'];
$nowyear=$nowtmp['year'];
$year=GETPOST('reyear')?GETPOST('reyear'):(GETPOST("year","int")?GETPOST("year","int"):date("Y"));
$month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("month","int"):date("m"));
$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d"));
$day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$daytoparse = $now;
if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, $year);
/*
* Actions
*/
if (GETPOST('submitdateselect'))
{
$daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$action = '';
}
if ($action == 'addtime' && $user->rights->projet->creer)
{
$task = new Task($db);
@ -133,6 +155,16 @@ $projectstatic=new Project($db);
$project = new Project($db);
$taskstatic = new Task($db);
$prev = dol_getdate($daytoparse - (24 * 3600));
$prev_year = $prev['year'];
$prev_month = $prev['mon'];
$prev_day = $prev['mday'];
$next = dol_getdate($daytoparse + (24 * 3600));
$next_year = $next['year'];
$next_month = $next['mon'];
$next_day = $next['mday'];
$title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
@ -160,7 +192,18 @@ llxHeader("",$title,"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">';
// Show navigation bar
$nav ="<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$month,$day,$year),"day")." </span>\n";
$nav.="<a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\">".img_next($langs->trans("Next"))."</a>\n";
$nav.=" &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav.='<br>'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' ';
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
$picto='calendarweek';
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].($project->id > 0 ? '?id='.$project->id : '').'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addtime">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -169,13 +212,15 @@ $head=project_timesheet_prepare_head($mode);
dol_fiche_head($head, 'inputperday', '', 0, 'task');
// Show description of content
if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br><br>';
if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br><br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').'<br><br>';
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').'<br>';
}
print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>';
print '<br>';
print "\n";
// Filter on user
/* dol_fiche_head('');
@ -197,6 +242,10 @@ else
dol_fiche_end();
*/
print '<div align="right">'.$nav.'</div>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
@ -207,7 +256,7 @@ print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td align="right">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td align="right">'.$langs->trans("TimeSpentByUser").'</td>';
print '<td align="center">'.$langs->trans("DateAndHour").'</td>';
print '<td align="center">'.$langs->trans("HourStart").'</td>';
print '<td align="center" colspan="2">'.$langs->trans("Duration").'</td>';
print "</tr>\n";
@ -217,7 +266,7 @@ $restricteditformytask=(empty($conf->global->PROJECT_TIME_ON_ALL_TASKS_MY_PROJEC
if (count($tasksarray) > 0)
{
$j=0;
projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask);
projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $daytoparse);
}
else
{
@ -234,6 +283,13 @@ print '</div>';
print '</form>';
print '<script type="text/javascript">';
print "jQuery(document).ready(function () {\n";
print ' jQuery(".timesheetalreadyrecorded").tipTip({ maxWidth: "600px", edgeOffset: 10, delay: 50, fadeIn: 50, fadeOut: 50, content: \''.dol_escape_js($langs->trans("TimeAlreadyRecorded", $user->getFullName($langs))).'\'});';
print "});";
print '</script>';
llxFooter();
$db->close();

View File

@ -49,12 +49,15 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $projectid);
$now=dol_now();
$year=GETPOST("year","int")?GETPOST("year","int"):date("Y");
$month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$day=GETPOST("day","int")?GETPOST("day","int"):date("d");
$nowtmp=dol_getdate($now);
$nowday=$nowtmp['mday'];
$nowmonth=$nowtmp['mon'];
$nowyear=$nowtmp['year'];
$year=GETPOST('reyear')?GETPOST('reyear'):(GETPOST("year","int")?GETPOST("year","int"):date("Y"));
$month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("month","int"):date("m"));
$day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d"));
$day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$startdayarray=dol_get_first_day_week($day, $month, $year);
@ -83,6 +86,13 @@ $usertoprocess=$user;
* Actions
*/
if (GETPOST('submitdateselect'))
{
$daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$action = '';
}
if ($action == 'addtime' && $user->rights->projet->creer)
{
$task = new Task($db);
@ -176,16 +186,15 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js'));
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
$tmpday = $first_day;
// Show navigation bar
$nav ="<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week;
$nav.=" </span>\n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week." </span>\n";
$nav.="<a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\">".img_next($langs->trans("Next"))."</a>\n";
$nav.=" &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$picto='calendarweek';
$nav.='<br>'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' ';
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
$picto='calendarweek';
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -199,12 +208,14 @@ $head=project_timesheet_prepare_head($mode);
dol_fiche_head($head, 'inputperweek', '', 0, 'task');
// Show description of content
if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br><br>';
if ($mine) print $langs->trans("MyTasksDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br><br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').'<br><br>';
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopened?' '.$langs->trans("OnlyOpenedProject"):'').'<br>';
else print $langs->trans("ProjectsPublicTaskDesc").($onlyopened?' '.$langs->trans("AlsoOnlyOpenedProject"):'').'<br>';
}
print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>';
print '<br>';
print "\n";
// Filter on user
@ -248,6 +259,7 @@ for($i=0;$i<7;$i++)
{
print '<td width="7%" align="center">'.dol_print_date($startday + ($i * 3600 * 24), '%a').'<br>'.dol_print_date($startday + ($i * 3600 * 24), 'day').'</td>';
}
print '<td class="liste_total"></td>';
print "</tr>\n";
@ -268,11 +280,12 @@ if (count($tasksarray) > 0)
<td class="liste_total" width="7%" align="center"><div id="totalDay[4]">&nbsp;</div></td>
<td class="liste_total" width="7%" align="center"><div id="totalDay[5]">&nbsp;</div></td>
<td class="liste_total" width="7%" align="center"><div id="totalDay[6]">&nbsp;</div></td>
<td class="liste_total"></td>
</tr>';
}
else
{
print '<tr><td colspan="10">'.$langs->trans("NoTasks").'</td></tr>';
print '<tr><td colspan="11">'.$langs->trans("NoTasks").'</td></tr>';
}
print "</table>";
@ -287,6 +300,7 @@ print '</div>';
print '</form>'."\n\n";
$modeinput='hours';
print '<script type="text/javascript">';