Skip to content

Commit

Permalink
Enhancement - timesheet report
Browse files Browse the repository at this point in the history
- Version 1 of the timesheet report.  Displays a specified number
  of weeks tasks, both started and completed.
  • Loading branch information
pbeckingham committed May 12, 2009
1 parent 4ab665b commit fd82387
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 41 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
example "task oldest 5" will display the 5 oldest tasks.
+ Modified the "stats" report so that it has the same aesthetics as the
other reports.
+ New "timesheet" command displays tasks completed and started, per week,
and can display multiple weeks.

------ old releases ------------------------------

Expand Down
11 changes: 9 additions & 2 deletions html/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,16 @@ <h2 class="title"><a name="advanced">Advanced Usage</a></h2>
report. It shows a colored bar graph and legend.
</p>

<strong>% task timesheet</strong>
<strong>% task timesheet 2</strong>
<p>
???
The timesheet report shows a list of tasks completed and started
during a one-week period. In the example above, 2 weeks of tasks
are shown.
</p>
<p>
By default, the report starts on a Monday. To override this
value, add an entry to your .taskrc file like this:
<pre><code>weekstart=Sunday</code></pre>
</p>

<strong>% task calendar</strong>
Expand Down
28 changes: 3 additions & 25 deletions html/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,36 +164,14 @@ <h4>New in version 1.7.0 (?)</h4>
example "task oldest 5" will display the 5 oldest tasks.
<li>Modified the "stats" report so that it has the same aesthetics as the
other reports.
<li>New "timesheet" command displays tasks completed and started, per week,
and can display multiple weeks.
</ul>

<p>
(Find out <a href="versions.html">what was new in prior versions</a>)
</p>
<!--
<h2>Task 1.7.0 Beta</h2>
<p>
The next version of task is in beta. This means it is approaching the
end of the current development and testing cycle, and feedback from
a wider audience is needed to find the last bugs. If you would like
to help test the next release of task, download the beta source below
and install in the usual manner.
</p>
<p>
Please note that beta software may contain significant bugs. If you
use this beta release, you should first backup your existing task
data files.
</p>
<p>
Refer to the ChangeLog file for details regarding the various fixes
and enhancements.
</p>
<table>
<tr>
<td>Source:</td>
<td><a href="http://www.beckingham.net/task-1.7.0beta.tar.gz">task-1.7.0beta.tar.gz</a></td>
</tr>
</table>
-->

<h2>Troubleshooting</h2>
<p>
Task has been built from source and tested in the following environments:
Expand Down
140 changes: 127 additions & 13 deletions src/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,42 +1346,156 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf)

for (int week = 0; week < quantity; ++week)
{
out << start.toString (conf.get ("dateformat", "m/d/Y"))
out << std::endl
<< Text::colorize (Text::bold, Text::nocolor)
<< start.toString (conf.get ("dateformat", "m/d/Y"))
<< " - "
<< end.toString (conf.get ("dateformat", "m/d/Y"))
<< Text::colorize ()
<< std::endl;

// Render the completed table.
Table completed;
completed.setTableWidth (width);
completed.addColumn (" ");
completed.addColumn ("Project");
completed.addColumn ("Due");
completed.addColumn ("Description");

completed.setColumnUnderline (1);
completed.setColumnUnderline (2);
completed.setColumnUnderline (3);

completed.setColumnWidth (0, Table::minimum);
completed.setColumnWidth (1, Table::minimum);
completed.setColumnWidth (2, Table::minimum);
completed.setColumnWidth (3, Table::flexible);

completed.setColumnJustification (0, Table::left);
completed.setColumnJustification (1, Table::left);
completed.setColumnJustification (2, Table::right);
completed.setColumnJustification (3, Table::left);

foreach (t, tasks)
{
// TODO If task completed within range.
// If task completed within range.
if (t->getStatus () == T::completed)
{
Date compDate (::atoi (t->getAttribute ("end").c_str ()));
if (compDate >= start && compDate < end)
{
int row = completed.addRow ();
completed.addCell (row, 1, t->getAttribute ("project"));

std::string due = t->getAttribute ("due");
if (due.length ())
{
Date d (::atoi (due.c_str ()));
due = d.toString (conf.get ("dateformat", "m/d/Y"));
completed.addCell (row, 2, due);
}

std::string description = t->getDescription ();
std::string when;
std::map <time_t, std::string> annotations;
t->getAnnotations (annotations);
foreach (anno, annotations)
{
Date dt (anno->first);
when = dt.toString (conf.get ("dateformat", "m/d/Y"));
description += "\n" + when + " " + anno->second;
}
completed.addCell (row, 3, description);

if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
{
Text::color fg = Text::colorCode (t->getAttribute ("fg"));
Text::color bg = Text::colorCode (t->getAttribute ("bg"));
autoColorize (*t, fg, bg, conf);
completed.setRowFg (row, fg);
completed.setRowBg (row, bg);
}
}
}
}

out << " Completed (" << completed.rowCount () << ")" << std::endl;
out << " Completed (" << completed.rowCount () << " tasks)" << std::endl;

if (completed.rowCount ())
out << optionalBlankLine (conf)
<< completed.render ()
out << completed.render ()
<< std::endl;
else
out << " None" << std::endl;

// Now render the started table.
Table started;
started.setTableWidth (width);
started.addColumn (" ");
started.addColumn ("Project");
started.addColumn ("Due");
started.addColumn ("Description");

started.setColumnUnderline (1);
started.setColumnUnderline (2);
started.setColumnUnderline (3);

started.setColumnWidth (0, Table::minimum);
started.setColumnWidth (1, Table::minimum);
started.setColumnWidth (2, Table::minimum);
started.setColumnWidth (3, Table::flexible);

started.setColumnJustification (0, Table::left);
started.setColumnJustification (1, Table::left);
started.setColumnJustification (2, Table::right);
started.setColumnJustification (3, Table::left);
foreach (t, tasks)
{
// TODO If task started withing range, but not completed withing range.
// If task started within range, but not completed withing range.
if (t->getStatus () == T::pending &&
t->getAttribute ("start") != "")
{
Date startDate (::atoi (t->getAttribute ("start").c_str ()));
if (startDate >= start && startDate < end)
{
int row = started.addRow ();
started.addCell (row, 1, t->getAttribute ("project"));

std::string due = t->getAttribute ("due");
if (due.length ())
{
Date d (::atoi (due.c_str ()));
due = d.toString (conf.get ("dateformat", "m/d/Y"));
started.addCell (row, 2, due);
}

std::string description = t->getDescription ();
std::string when;
std::map <time_t, std::string> annotations;
t->getAnnotations (annotations);
foreach (anno, annotations)
{
Date dt (anno->first);
when = dt.toString (conf.get ("dateformat", "m/d/Y"));
description += "\n" + when + " " + anno->second;
}
started.addCell (row, 3, description);

if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
{
Text::color fg = Text::colorCode (t->getAttribute ("fg"));
Text::color bg = Text::colorCode (t->getAttribute ("bg"));
autoColorize (*t, fg, bg, conf);
started.setRowFg (row, fg);
started.setRowBg (row, bg);
}
}
}
}

out << " Started (" << started.rowCount () << ")" << std::endl;
out << " Started (" << started.rowCount () << " tasks)" << std::endl;

if (started.rowCount ())
out << optionalBlankLine (conf)
<< started.render ()
out << started.render ()
<< std::endl
<< std::endl;
else
out << " None" << std::endl;

// Prior week.
start -= 7 * 86400;
Expand Down
2 changes: 1 addition & 1 deletion src/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static std::string shortUsage (Config& conf)
table.addCell (row, 2, "Shows a report of task status by project");

row = table.addRow ();
table.addCell (row, 1, "task timesheet [duration]");
table.addCell (row, 1, "task timesheet [weeks]");
table.addCell (row, 2, "Shows a weekly report of tasks completed and started");

row = table.addRow ();
Expand Down

0 comments on commit fd82387

Please sign in to comment.