# Customers report example

John DOE

    foo@example.com

2007 The GNOME Foundation

This report extratcs some supposedly interresting data from the customers as recorded in the SalesTest data source. It aims at illustrating all the features of the GDA Report's engine which operates on XML data, in which some specific <gda_report_...> tags are interpreted when the engine is run to generate the final report.

The generated XML can then be converted into another format depending on the XML "dialect" of the specifications (DocBook, ...).

## List of customers ()

Here is the list of customers, as per the database. The query executed to create the list of customers was created in the source code and declared to the GdaReportEngine object, so only its name is used in the report.

The first two columns are data extracted as-is from the SELECT query, and the 3rd column's contents is some data computed using a "IF THEN ELSE" kind of statement.

List of customers

Id | Name | Country
--- | --- | ---
|  | Country: -Unknown-

## Detailed customers' information

This section gives detailed information for each customer, it shows how to create nested report components: For each row of the data model containing the list of customers, some other SELECT queries are executed while referencing the ID of the customer. The SQL queries used here are directly defined into the spec. file.

### Details for

Here are the details for customer "" such as the salesperson assigned to it, and the orders the customer has passed.

- SELECT s.* FROM salesrep s INNER JOIN customers c ON (s.id=c.default_served_by) WHERE c.id=##customers|@id::gint

  No salesRep!

  Sales person:

- SELECT o.*, (SELECT count (*) FROM order_contents oc WHERE oc.order_id = o.id) AS nb FROM ORDERS o WHERE customer = ##customers|@id::gint

  No order yet!

  Orders so far ()

  Order date | Number of items in order | Delivery date
  --- | --- | ---