Skip to content

Commit

Permalink
NEW Can filter on project ref on the "new time consumed" page.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 18, 2016
1 parent c1bf7c5 commit 0f88bdd
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 20 deletions.
54 changes: 48 additions & 6 deletions htdocs/projet/activity/perday.php
Expand Up @@ -62,6 +62,7 @@
$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");
$search_project_ref = GETPOST('search_project_ref', 'alpha');


$monthofday=GETPOST('addtimemonth');
Expand All @@ -79,6 +80,17 @@
* Actions
*/

// Purge criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$action = '';
$search_project_ref = '';
}
if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search"))
{
$action = '';
}

if (GETPOST('submitdateselect'))
{
$daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
Expand Down Expand Up @@ -253,6 +265,8 @@
$projectstatic=new Project($db);
$project = new Project($db);
$taskstatic = new Task($db);
$thirdpartystatic = new Societe($db);


$prev = dol_getdate($daytoparse - (24 * 3600));
$prev_year = $prev['year'];
Expand All @@ -278,7 +292,8 @@
}

$onlyopenedproject=1; // or -1
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$morewherefilter='';
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
//var_dump($tasksarray);
Expand All @@ -290,12 +305,14 @@

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');

$param=($mode?'&mode='.$mode:'');
$param='';
$param.=($mode?'&mode='.$mode:'');
$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:'');

// 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 ='<a class="inline-block valignmiddle" 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.='<a class="inline-block valignmiddle" 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").'">';
Expand Down Expand Up @@ -362,6 +379,9 @@
//print '<input type="hidden" name="year" value="'.$year.'">';
//print '<input type="hidden" name="month" value="'.$month.'">';
//print '<input type="hidden" name="day" value="'.$day.'">';

print '<div class="floatright">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.

print '<div class="float">';
print $langs->trans("AssignTaskToMe").'<br>';
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
Expand All @@ -370,15 +390,18 @@
//print '</form>';
print '</div>';

print '<div class="floatright">'.$nav.'</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>';


print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>';
if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
{
print '<td>'.$langs->trans("ThirdParty").'</td>';
}
print '<td align="right">'.$langs->trans("PlannedWorkload").'</td>';
print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
Expand All @@ -389,6 +412,25 @@
print '<td align="right">'.$langs->trans("Note").'</td>';
print "</tr>\n";

print '<tr class="liste_titre">';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
// Action column
print '<td class="liste_titre nowrap" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
print '</td>';
print "</tr>\n";


// By default, we can edit only tasks we are assigned to
$restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0);

Expand Down
66 changes: 52 additions & 14 deletions htdocs/projet/activity/perweek.php
Expand Up @@ -58,11 +58,12 @@
$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"));
$year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y"));
$month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m"));
$day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d"));
$day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$search_project_ref = GETPOST('search_project_ref', 'alpha');

$startdayarray=dol_get_first_day_week($day, $month, $year);

Expand Down Expand Up @@ -93,6 +94,17 @@
* Actions
*/

// Purge criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$action = '';
$search_project_ref = '';
}
if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search"))
{
$action = '';
}

if (GETPOST('submitdateselect'))
{
$daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
Expand All @@ -103,7 +115,7 @@
if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask'))
{
$action = 'assigntask';

if ($taskid > 0)
{
$result = $object->fetch($taskid, $ref);
Expand All @@ -119,6 +131,7 @@
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
$error++;
}

if (! $error)
{
$idfortaskuser=$user->id;
Expand Down Expand Up @@ -176,7 +189,7 @@
$action='';
}

if ($action == 'addtime' && $user->rights->projet->lire)
if ($weclickonassign && $action == 'addtime' && $user->rights->projet->lire)
{
$timetoadd=$_POST['task'];
if (empty($timetoadd))
Expand Down Expand Up @@ -276,7 +289,8 @@
}

$onlyopenedproject=1; // or -1
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$morewherefilter='';
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
//var_dump($tasksarray);
Expand All @@ -288,12 +302,14 @@

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');

$param=($mode?'&amp;mode='.$mode:'');
$param='';
$param.=($mode?'&amp;mode='.$mode:'');
$param.=($search_project_ref?'&amp;search_project_ref='.$search_project_ref:'');

// 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 ='<a class="inline-block valignmiddle" 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("WeekShort")." ".$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.='<a class="inline-block valignmiddle" 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").'">';
Expand Down Expand Up @@ -358,6 +374,9 @@
//print '<input type="hidden" name="year" value="'.$year.'">';
//print '<input type="hidden" name="month" value="'.$month.'">';
//print '<input type="hidden" name="day" value="'.$day.'">';

print '<div class="floatright">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.

print '<div class="float">';
print $langs->trans("AssignTaskToMe").'<br>';
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
Expand All @@ -366,19 +385,19 @@
//print '</form>';
print '</div>';

print '<div class="floatright">'.$nav.'</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>';


print '<table class="noborder" width="100%">';

print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>';
if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
{
print '<td>'.$langs->trans("ThirdParty").'</td>';
}
print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("PlannedWorkload").'</td>';
print '<td align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
Expand All @@ -389,10 +408,29 @@

for($i=0;$i<7;$i++)
{
print '<td width="7%" align="center" class="hide'.$i.'">'.dol_print_date($startday + ($i * 3600 * 24), '%a').'<br>'.dol_print_date($startday + ($i * 3600 * 24), 'dayreduceformat').'</td>';
print '<td width="7%" align="center" class="hide'.$i.'">'.dol_print_date($startday + ($i * 3600 * 24), '%a').'<br>'.dol_print_date($startday + ($i * 3600 * 24), 'dayreduceformat').'</td>';
}
print '<td class="liste_total"></td>';
print "</tr>\n";

print '<tr class="liste_titre">';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
print '<td class="liste_total"></td>';
for($i=0;$i<7;$i++)
{
print '<td class="liste_total"></td>';
}
// Action column
print '<td class="liste_titre nowrap" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
print '</td>';
print "</tr>\n";

// By default, we can edit only tasks we are assigned to
Expand Down

0 comments on commit 0f88bdd

Please sign in to comment.