Merge branch 'timesheet' into 1.7.0

This commit is contained in:
Paul Beckingham 2009-05-08 21:26:43 -04:00
commit f9c3103264
6 changed files with 94 additions and 12 deletions

View file

@ -225,6 +225,17 @@ Year Month Added Completed Deleted Net
number decreased as more task were completed than added.
</p>
<strong>% task ghistory</strong>
<p>
The ghistory report is a "graphical" version of the history
report. It shows a colored bar graph and legend.
</p>
<strong>% task timesheet</strong>
<p>
???
</p>
<strong>% task calendar</strong>
<p>
This report shows a calendar of the current month, with any task

View file

@ -185,6 +185,12 @@
only show as many that will fit.
</dd>
<dt>weekstart</dt>
<dd>
The day of the week that represents the first day of the week.
Defaults to "Monday".
</dd>
<dt>defaultwidth</dt>
<dd>
The width of tables used when ncurses support is not available.

View file

@ -116,6 +116,7 @@ static const char* attributes[] =
"",
};
// Alphabetical please.
static const char* commands[] =
{
"active",
@ -142,6 +143,7 @@ static const char* commands[] =
"stop",
"summary",
"tags",
"timesheet",
"undelete",
"undo",
"version",

View file

@ -1299,6 +1299,63 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf)
{
std::stringstream out;
// Determine window size, and set table accordingly.
int width = conf.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
if (conf.get ("curses", true))
{
WINDOW* w = initscr ();
width = w->_maxx + 1;
endwin ();
}
#endif
// Get all the tasks.
std::vector <T> tasks;
tdb.allT (tasks);
filter (tasks, task);
// TODO Was a duration argument specified?
// by default, duration = 1week
// TODO Determine start date
// by default, start = prior Monday
// otherwise, start = prior Monday - ((duration - 1) * 7 * 86,400)
// TODO end date = next Sunday
Table table;
// TODO Render report
/*
% task timesheet [filter] 2w
4/19/2009 - 4/26/2009
...
4/27/2009 - 5/3/2009
Tasks Completed (5)
<project> <description> <annotations>
...
Tasks Started (2)
<project> <description> <annotations>
...
*/
if (table.rowCount ())
out << optionalBlankLine (conf)
<< table.render ()
<< std::endl;
else
out << "No tasks." << std::endl;
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string renderMonths (
int firstMonth,

View file

@ -152,6 +152,10 @@ static std::string shortUsage (Config& conf)
table.addCell (row, 1, "task summary");
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, 2, "Shows a weekly report of tasks completed and started");
row = table.addRow ();
table.addCell (row, 1, "task history");
table.addCell (row, 2, "Shows a report of task history, by month");
@ -861,18 +865,19 @@ std::string runTaskCommand (
std::string out;
// Read-only commands with no side effects.
if (command == "export") { out = handleExport (tdb, task, conf); }
else if (command == "projects") { out = handleProjects (tdb, task, conf); }
else if (command == "tags") { out = handleTags (tdb, task, conf); }
else if (command == "info") { out = handleInfo (tdb, task, conf); }
else if (command == "stats") { out = handleReportStats (tdb, task, conf); }
else if (command == "history") { out = handleReportHistory (tdb, task, conf); }
else if (command == "ghistory") { out = handleReportGHistory (tdb, task, conf); }
else if (command == "calendar") { out = handleReportCalendar (tdb, task, conf); }
else if (command == "summary") { out = handleReportSummary (tdb, task, conf); }
else if (command == "colors") { out = handleColor ( conf); }
else if (command == "version") { out = handleVersion ( conf); }
else if (command == "help") { out = longUsage ( conf); }
if (command == "export") { out = handleExport (tdb, task, conf); }
else if (command == "projects") { out = handleProjects (tdb, task, conf); }
else if (command == "tags") { out = handleTags (tdb, task, conf); }
else if (command == "info") { out = handleInfo (tdb, task, conf); }
else if (command == "stats") { out = handleReportStats (tdb, task, conf); }
else if (command == "history") { out = handleReportHistory (tdb, task, conf); }
else if (command == "ghistory") { out = handleReportGHistory (tdb, task, conf); }
else if (command == "calendar") { out = handleReportCalendar (tdb, task, conf); }
else if (command == "summary") { out = handleReportSummary (tdb, task, conf); }
else if (command == "timesheet") { out = handleReportTimesheet (tdb, task, conf); }
else if (command == "colors") { out = handleColor ( conf); }
else if (command == "version") { out = handleVersion ( conf); }
else if (command == "help") { out = longUsage ( conf); }
// Commands that cause updates.
else if (command == "" && task.getId ()) { cmdMod = true; out = handleModify (tdb, task, conf); }

View file

@ -110,6 +110,7 @@ std::string handleReportCalendar (TDB&, T&, Config&);
std::string handleReportActive (TDB&, T&, Config&);
std::string handleReportOverdue (TDB&, T&, Config&);
std::string handleReportStats (TDB&, T&, Config&);
std::string handleReportTimesheet (TDB&, T&, Config&);
std::string handleCustomReport (TDB&, T&, Config&, const std::string&);
void validReportColumns (const std::vector <std::string>&);