# GnoTime: Hello World!

# Custom Report Primer

You can design and use custom reports with GnoTime rather easily if you know a bit of basic HTML. If you also know scheme, then the world is at your feet, since the report generator uses guile to interpret the embedded scheme in a report template.

After designing your own report template, you can add it to GnoTime by picking the menu entry 'Reports' ... 'New Report' and entering the filename for the template.

The report template consists of standard HTML markup (including newer HTML features, such as CSS), with embedded scheme markup to provide project and diary display. GnoTime includes some built-in scheme primitives for generating HTML tables for projects and diary entries. This page shows some examples; you can view the HTML source for this example primer by viewing 'primer.ghtml' (probably installed at `/usr/share/gnotime/ghtml/C/primer.ghtml`)

Yes, images using standard HTML markup are now supported. You should see a GnoTime PNG logo on your right.

Some sample scheme forms, and their output:

- `(gtt-hello)` prints the following:
- `(gtt-show-project-title)` prints the following:
- `(gtt-show-project-desc)` prints the following:
- `(gtt-show (gtt-project-notes (gtt-selected-project)))` prints the notes for the selected project, which are:
  Note the slightly more complicated form of the above: `gtt-selected-project` denotes the project that is currently selected in the GnoTime main window. `gtt-project-notes` is a function that takes a project as an argument, and returns the notes on that project. `gtt-show` is a kind of 'print' statement (see below for more examples of `gtt-show`).
- Tables showing lists of projects, tasks and intervals can be created and displayed. The file `todo.ghtml` shows a working example of a list of projects, while `basic-journal.ghtml` and `basic-daily.ghtml` show lists of tasks and intervals. The file `invoice.ghtml` shows how lists of tasks can be selectively filtered, so that only certain tasks meeting certain criteria are displayed.
- The primitive `gtt-show` acts as the ghtml analog of the scheme primitive `display`, in that it merely prints the result of evaluating an expression. It differs, however, in one important way: it omits parenthesis. This allows good-looking text to be created. Note that HTML markup does pass through transparently:
  `(gtt-show '"yabba dabba <i>do</i> (<b>eh duude</b>)")` prints the following:
  do (eh duude)") ?>
- Scheme is a modern, advanced programming language, based on the newest and most advanced programming principles today. Scheme resembles LISP, somewhat. For example, `(gtt-show (+ 2 2))` prints the following:
- The primitive `gtt-show` can be used anywhere, such as this (slowly converging) Leibniz series expression for Pi:
  `(define (pi-sum a b) (if (> a b) 0
  (+ (/ 1 (* a (+ a 2))) (pi-sum (+ a 4) b)) ))
  a b) 0 (+ (/ 1 (* a (+ a 2))) (pi-sum (+ a 4) b)) )) ?> (define (pi-approx) (gtt-show (* 8 (pi-sum 1 1400)) ))
  (pi-approx)`
  prints the following: (Yes, the value printed is 'wrong', but that's because we didn't let the series expansion run long enough.)
- You can get access to the raw project/task/interval data from scheme. Currently, you can only have read-only access to the data from scheme, allowing reports to be generated, but not allowing core data to be changed. The following shows some of the available primitives:
  `(gtt-projects)` returns the tree of projects, which can be used with the getters: for example: `(gtt-show (gtt-project-title (gtt-projects)))` shows:
  We've already mentioned `(gtt-selected-project)` before; it returns the project that is currently selected in the main window. There is also the `(gtt-linked-project)` primitive, which returns the project that was linked to create this report. They are frequently the same, but need not be. For example, select a different project, and then hit the refresh button on this page:
  This is the linked project:
  This is the selected project:
  The following project attributes are supported:
  - `(gtt-project-title prj)`:
  - `(gtt-project-title-link prj)`:
  - `(gtt-project-desc prj)`:
  - `(gtt-project-notes prj)`:
  - `(gtt-project-urgency prj)`:
  - `(gtt-project-importance prj)`:
  - `(gtt-project-status prj)`:
  - `(gtt-project-estimated-start prj)`: (seconds since January 1, 1970)
  - `(gtt-project-estimated-end prj)`: (seconds since January 1, 1970)
  - `(gtt-project-due-date prj)`: (seconds since January 1, 1970)
  - `(gtt-project-sizing prj)`: (seconds)
  - `(gtt-project-percent-complete prj)`: (percentage)
  Subprojects of a project can be obtained with the `(gtt-project-subprojects prj)` routine. For example, here is a listing of the subprojects of the currently selected project:
  " gtt-project-title ''" -- \n" gtt-project-desc ''" --\n" gtt-project-notes ''"
\n" )) ?>

Here's the title of the parent of this project:
Here's a list of peer projects (that is, a list of all of the children of the parent project):

" gtt-project-title ''" -- \n" gtt-project-desc ''" --\n" gtt-project-notes ''"\n" )) ?>

Tasks (aka 'diary entries') can be obtained with the `(gtt-tasks prj)` routine. The various task attributes can be obtained with getters that take a task (or a task list) as an argument:

- `(gtt-task-memo tsk)`:
- `(gtt-links-off)(gtt-task-memo tsk)(gtt-links-on)`:
- `(gtt-task-notes tsk)`:

# Hints and Tips

- wrong-type-arg: this scheme error message can occur if you quoted a string literal incorrectly: be sure to use two single quotes, followed by a double-quoted string: for example: ''"some string"

# More Examples

Here's an example table for - showing some of the different task getters that can be used to build a report.

Diary Entry | Notes | Billing Status | Billable | Bill Rate | Total Time | Value | Billable Value
--- | --- | --- | --- | --- | --- | --- | ---
" ''"
\n" ''"
\n" ''"
\n" ''"
\n" ''"
\n" ''"
\n" ''"
\n" ''"
\n" ''"" ) ) ?>
" gtt-task-memo ''" | " gtt-task-notes ''" | " gtt-task-billstatus ''" | " gtt-task-billable ''" | " gtt-task-billrate ''" | " gtt-task-time-str ''" | " gtt-task-value-str ''" | " gtt-task-billable-value-str ''"

Brought to you by ...