Menu

Timesheet Report

Help
2005-06-09
2013-04-06
  • Eric Moritz

    Eric Moritz - 2005-06-09

    Hi, is there anyone that could build me a timesheet report that displays all the projects that had activity during a certain date and display the times individually like a timesheet.  I tried to figure it out but I'm not a scheme programmer  :)

     
    • Andre Srinivasan

      I need to work on the timesheet format, but this is what I'm using to fill in my timesheets.  My apologies to all real Scheme programmers out there.

      -andre.

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title>Daily Task Report</title>
      <?scm (gtt-include "gtt-style.css") ?>
      </head>
      <body bgcolor="#c8c8d3">
      <div id="gnotime-body">
      <center>
      <h1>Daily Task Report for
      <?scm (gtt-show-project-title) ?>
      <?scm
        (let ((desc (gtt-project-desc (gtt-linked-project))))
          (if (not (null? desc))
          (lambda()
            (gtt-show '"-")
            (gtt-show desc))))
      ?>

      </h1>
      </center>

      <!--
      <div id="gnotime-project-daily-overview">
      <?scm (gtt-show-project-notes) ?>
      </div>

      <br><br>
      -->

      <table class=gnotime-daily-table bgcolor=#f8f8f8 border=0 cellspacing=2 cellpadding=4>
      <tr class=gnotime-daily-table-header bgcolor=#e8e8e8>
      <th>Date</th>
      <th>Task</th>
      <th>Time</th>
      <th>Memo</th>
      </tr>

      <?scm
        (use-modules (ice-9 format))
        (use-modules (ice-9 pretty-print))

        (gtt-links-off)

        ;; Return an updated task list based on task objects that consists
        ;; of ((name time (memo...))...), where name is the task title,
        ;; memo... is the list of memos for the task, and time is the number
        ;; of seconds spent on the task.

        (define (add-task-to-list tobj task-alist)
          (let ((ivl-total 0)
            (name (gtt-project-title (gtt-task-parent tobj)))
            (task-memo (gtt-task-memo tobj)))

            ;; Loop through and add all itervals for the task.

            (gtt-ivls tobj
              (list
               (lambda (ivl)
                 (set! ivl-total (+ ivl-total (gtt-interval-elapsed ivl))))))

            ;; Want time in hours

            (set! ivl-total (/ ivl-total 3600))

            ;; If the list is empty or the list doesn't have the task
            ;; name, then we create the list.  Otherwise, both the list of
            ;; memos and the total need to be updated.

            (if (null? task-alist)
            (set! task-alist (list (list name ivl-total (list task-memo))))

            (if (not (assoc name task-alist))
                (set-cdr! task-alist (list (list name ivl-total (list task-memo))))

                (let* ((e (assoc name task-alist))
                   (cur-total (cadr e))
                   (memo-list (caddr e)))
              (set! cur-total (+ cur-total ivl-total))
              (set! memo-list (append memo-list (list task-memo)))
              (set-cdr! e (cons cur-total (list memo-list))))))

      ;;      (gtt-show (format #f "length=~d task-alist=~y<br>" (length task-alist) task-alist))
            task-alist))

         ;; For the project in question, loop through the daily objects

           (begin
             (gtt-show-daily
          (gtt-daily-totals (gtt-selected-project))
          (list
           ''"<tr>"
           ''"<td>" gtt-daily-day-str ''"</td>"

           (lambda (dobj)
             (let ((task-list '())
               (task-names '())
               (task-times '())
               (task-memos '())
               (row-names "")
               (row-times "")
               (row-memos ""))

               ;; For each daily object, loop through the tasks

               (gtt-show-daily-tasks
                dobj
                (list
                 (lambda (task) (set! task-list (add-task-to-list task task-list)))
                 ))

               ;; task-list holds all tasks for this day.  First create
               ;; a parallel list of names, times, and memos so that the
               ;; table can be created.
         
               (for-each
                (lambda (t)
      ;;        (gtt-show (format #f "t=~y<br>" t))
              (set! task-names (cons (car t) task-names))
              (set! task-times (cons (cadr t) task-times))
              (let ((mlist (list-ref t 2))
                    (mstr ""))
      ;;          (gtt-show (format #f "length=~d mlist=~y<br>" (length mlist) mlist))
                (set! mstr (car mlist))
                (if (> (length mlist) 1)
                    (for-each
                     (lambda (m)
                   (set! mstr (string-append mstr ", " m)))
                     (cdr mlist)))
      ;;          (gtt-show (format #f "mstr=~y<br>" mstr))
                (set! task-memos (cons mstr task-memos))))
                task-list)
                       
      ;;         (gtt-show (format #f "task-names=~y task-times=~y task-memos=~y<br>" task-names task-times task-memos))

               ;; Now create strings for table

               (set! row-names (car task-names))
               (set! row-times (format #f "~$" (car task-times)))
               (set! row-memos (car task-memos))
               (if (> (length task-names) 1)
               (for-each
                (lambda (name time memo)
                  (set! row-names (string-append row-names "<br>" name))
                  (set! row-times (string-append row-times "<br>" (format #f "~$" time)))
                  (set! row-memos (string-append row-memos ", " memo)))
                (cdr task-names) (cdr task-times) (cdr task-memos)))

               (list "<td>" row-names "</td><td>" row-times "</td><td>" row-memos "</td></tr>"))))))
      ?>

      </table>

      <br><br>
      <div align=right>
      Brought to you by ...  <br>
      <a href="http://gttr.sourceforge.net/">
      <img src="gnotime-logo.png" border="0" width="155" height="28"></a>
      </div>

      </div>
      </body>
      </html>

       
      • Andre Srinivasan

        Sorry, pasting the source was a mistake.  I re-posted as a patch.

        -andre.

         
    • zabuch

      zabuch - 2007-10-03

      Hello,

      I needed functionality like this - and I don't think gnotime can generate multiple-project reports (or can it?) - so I've created a ruby script that parses XML file and generates CSV file. I'm going to release it as OS but at the moment the script is very specific to what I needed. If anyone is interested in generating timesheets from gnotime please let me know what you need. I could also use few sample gnotime-data.xml files for testing :).

       
      • Goedson Teixeira Paixao

        GnoTime can generate multi-project reports.
        There are two good examples of this kind of report in
        our patch tracker ( http://sourceforge.net/tracker/?group_id=55463&atid=477105 )
        I'm probably going to integrate modified versions of them in our next release so
        please discuss this feature there.

         

Log in to post a comment.