From 57a11a74e1d1dbe39bc4efc1a3a7eafd6e44ba74 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 3 May 2009 11:32:04 -0400 Subject: [PATCH] New Report - timesheet - Added new timesheet report framework - Began adding logic pseudo-code - Added some documentation --- html/advanced.html | 11 +++++++++ html/config.html | 6 +++++ src/parse.cpp | 2 ++ src/report.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ src/task.cpp | 29 +++++++++++++---------- src/task.h | 1 + 6 files changed, 94 insertions(+), 12 deletions(-) diff --git a/html/advanced.html b/html/advanced.html index ec369652e..d5afcba85 100644 --- a/html/advanced.html +++ b/html/advanced.html @@ -219,6 +219,17 @@ Year Month Added Completed Deleted Net number decreased as more task were completed than added.

+ % task ghistory +

+ The ghistory report is a "graphical" version of the history + report. It shows a colored bar graph and legend. +

+ + % task timesheet +

+ ??? +

+ % task calendar

This report shows a calendar of the current month, with any task diff --git a/html/config.html b/html/config.html index 96c23422c..db38ba1b1 100644 --- a/html/config.html +++ b/html/config.html @@ -186,6 +186,12 @@ only show as many that will fit. +

weekstart
+
+ The day of the week that represents the first day of the week. + Defaults to "Monday". +
+
defaultwidth
The width of tables used when ncurses support is not available. diff --git a/src/parse.cpp b/src/parse.cpp index f4778307e..1d538624f 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -116,6 +116,7 @@ static const char* attributes[] = "", }; +// Alphabetical please. static const char* commands[] = { "active", @@ -141,6 +142,7 @@ static const char* commands[] = "stop", "summary", "tags", + "timesheet", "undelete", "undo", "version", diff --git a/src/report.cpp b/src/report.cpp index cdf2a6a79..53bf00662 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -1234,6 +1234,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 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) + + ... + + Tasks Started (2) + + ... +*/ + + if (table.rowCount ()) + out << optionalBlankLine (conf) + << table.render () + << std::endl; + else + out << "No tasks." << std::endl; + + return out.str (); +} + //////////////////////////////////////////////////////////////////////////////// std::string renderMonths ( int firstMonth, diff --git a/src/task.cpp b/src/task.cpp index e64fc0256..6d25adbb0 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -148,6 +148,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"); @@ -841,18 +845,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); } diff --git a/src/task.h b/src/task.h index ab4faa514..a1c9559a2 100644 --- a/src/task.h +++ b/src/task.h @@ -103,6 +103,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 &);