Create a new report

Content

Resource URL

https://apps.ticketmatic.com/api/1/{accountname}/settings/system/reports

Example

Request

 1use Ticketmatic\Endpoints\Settings\System\Reports;
 2
 3$result = Reports::create($client, array(
 4    "name" => "Financial overview",
 5    "content" => array(
 6        array(
 7            array(
 8                "columns" => array(
 9                        array(
10                                "caption" => "Id",
11                                "width" => "80px",
12                            ),
13                        array(
14                                "caption" => "Naam",
15                            ),
16                    ),
17                "query" => "select id,namenl as name from ev.event",
18                "type" => "table",
19            ),
20        ),
21    ),
22    "defaultformat" => "pdf",
23    "description" => "A financial overview per month for the last 12 months",
24    "emailbcc" => "info@mycompany.be;management@mycompany.be",
25    "emailcc" => "info@mycompany.be;management@mycompany.be",
26    "emailrecipients" => "info@mycompany.be;management@mycompany.be",
27    "emailschedule" => false,
28    "emailscheduledayofmonth" => 1,
29    "emailscheduledayofweek" => 7,
30    "emailschedulehourofday" => 8,
31    "emailschedulequery" => "select * from op.basket where createdts > CURRENT_TIMESTAMP - INTERVAL '1 DAY'",
32    "options" => array(
33        "pdfpagesize" => "A4",
34    ),
35    "reporttypeid" => 1,
36    "subtitles" => array(
37        "Subtitle 1",
38        "Subtitle 2",
39    ),
40    "translations" => array(
41        "en" => "...",
42        "nl" => "...",
43    ),
44    "usagetypeid" => 17001,
45));

Response

 1object(\Ticketmatic\Model\Report) (20) {
 2  ["id"]=>
 3  int(0)
 4  ["name"]=>
 5  string(18) "Financial overview"
 6  ["content"]=>
 7  array(1) {
 8    [0]=>
 9    array(1) {
10      [0]=>
11      array(3) {
12        ["columns"]=>
13          array(2) {
14            [0]=>
15            array(2) {
16              ["caption"]=>
17              string(2) "Id"
18              ["width"]=>
19              string(4) "80px"
20            }
21            [1]=>
22            array(1) {
23              ["caption"]=>
24              string(4) "Naam"
25            }
26          }
27        ["query"]=>
28        string(38) "select id,namenl as name from ev.event"
29        ["type"]=>
30        string(5) "table"
31      }
32    }
33  }
34  ["defaultformat"]=>
35  string(3) "pdf"
36  ["description"]=>
37  string(53) "A financial overview per month for the last 12 months"
38  ["emailbcc"]=>
39  string(41) "info@mycompany.be;management@mycompany.be"
40  ["emailcc"]=>
41  string(41) "info@mycompany.be;management@mycompany.be"
42  ["emailrecipients"]=>
43  string(41) "info@mycompany.be;management@mycompany.be"
44  ["emailschedule"]=>
45  bool(false)
46  ["emailscheduledayofmonth"]=>
47  int(0)
48  ["emailscheduledayofweek"]=>
49  int(0)
50  ["emailschedulehourofday"]=>
51  int(0)
52  ["emailschedulequery"]=>
53  string(78) "select * from op.basket where createdts > CURRENT_TIMESTAMP - INTERVAL '1 DAY'"
54  ["options"]=>
55  object(\Ticketmatic\Model\ReportOptions) (1) {
56    ["pdfpagesize"]=>
57    string(2) "A4"
58  }
59  ["reporttypeid"]=>
60  int(0)
61  ["subtitles"]=>
62  array(2) {
63    [0]=>
64    string(10) "Subtitle 1"
65    [1]=>
66    string(10) "Subtitle 2"
67  }
68  ["translations"]=>
69  array(2) {
70    ["en"]=>
71    string(3) "..."
72    ["nl"]=>
73    string(3) "..."
74  }
75  ["usagetypeid"]=>
76  int(0)
77  ["createdts"]=>
78  object(\DateTime) (3) {
79    ["date"]=>
80    string(26) "2014-09-26 15:24:36.000000"
81    ["timezone_type"]=>
82    int(3)
83    ["timezone"]=>
84    string(3) "UTC"
85  }
86  ["lastupdatets"]=>
87  object(\DateTime) (3) {
88    ["date"]=>
89    string(26) "2014-09-26 15:24:36.000000"
90    ["timezone_type"]=>
91    int(3)
92    ["timezone"]=>
93    string(3) "UTC"
94  }
95}

Request

 1import (
 2    "github.com/ticketmatic/tm-go/ticketmatic"
 3    "github.com/ticketmatic/tm-go/ticketmatic/settings/system/reports"
 4)
 5
 6result, err := reports.Create(client, &ticketmatic.Report{
 7    Name: "Financial overview",
 8    Content: [][]map[string]interface{}{
 9        []map[string]interface{}{
10            map[string]interface{}{
11                "columns": []interface {}{map[string]interface {}{"caption":"Id", "width":"80px"}, map[string]interface {}{"caption":"Naam"}},
12                "query": "select id,namenl as name from ev.event",
13                "type": "table",
14            },
15        },
16    },
17    Defaultformat: "pdf",
18    Description: "A financial overview per month for the last 12 months",
19    Emailbcc: "info@mycompany.be;management@mycompany.be",
20    Emailcc: "info@mycompany.be;management@mycompany.be",
21    Emailrecipients: "info@mycompany.be;management@mycompany.be",
22    Emailschedule: false,
23    Emailscheduledayofmonth: 1,
24    Emailscheduledayofweek: 7,
25    Emailschedulehourofday: 8,
26    Emailschedulequery: "select * from op.basket where createdts > CURRENT_TIMESTAMP - INTERVAL '1 DAY'",
27    Options: &ticketmatic.ReportOptions{
28        Pdfpagesize: "A4",
29    },
30    Reporttypeid: 1,
31    Subtitles: []string{
32        "Subtitle 1",
33        "Subtitle 2",
34    },
35    Translations: map[string]string{
36        "en": "...",
37        "nl": "...",
38    },
39    Usagetypeid: 17001,
40})

Response

 1result := &ticketmatic.Report{
 2    Id: 123,
 3    Name: "Financial overview",
 4    Content: [][]map[string]interface{}{
 5        []map[string]interface{}{
 6            map[string]interface{}{
 7                "columns": []interface {}{map[string]interface {}{"caption":"Id", "width":"80px"}, map[string]interface {}{"caption":"Naam"}},
 8                "query": "select id,namenl as name from ev.event",
 9                "type": "table",
10            },
11        },
12    },
13    Defaultformat: "pdf",
14    Description: "A financial overview per month for the last 12 months",
15    Emailbcc: "info@mycompany.be;management@mycompany.be",
16    Emailcc: "info@mycompany.be;management@mycompany.be",
17    Emailrecipients: "info@mycompany.be;management@mycompany.be",
18    Emailschedule: false,
19    Emailscheduledayofmonth: 1,
20    Emailscheduledayofweek: 7,
21    Emailschedulehourofday: 8,
22    Emailschedulequery: "select * from op.basket where createdts > CURRENT_TIMESTAMP - INTERVAL '1 DAY'",
23    Options: &ticketmatic.ReportOptions{
24        Pdfpagesize: "A4",
25    },
26    Reporttypeid: 1,
27    Subtitles: []string{
28        "Subtitle 1",
29        "Subtitle 2",
30    },
31    Translations: map[string]string{
32        "en": "...",
33        "nl": "...",
34    },
35    Usagetypeid: 17001,
36    Createdts: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
37    Lastupdatets: ticketmatic.NewTime(ticketmatic.MustParseTime("2014-09-26 15:24:36")),
38}

Request

 1POST /api/1/{accountname}/settings/system/reports HTTP/1.1
 2Content-Type: application/json
 3
 4{
 5    "name": "Financial overview",
 6    "content": [
 7        [
 8            {
 9                "columns": [
10                    {
11                        "caption": "Id",
12                        "width": "80px"
13                    },
14                    {
15                        "caption": "Naam"
16                    }
17                ],
18                "query": "select id,namenl as name from ev.event",
19                "type": "table"
20            }
21        ]
22    ],
23    "defaultformat": "pdf",
24    "description": "A financial overview per month for the last 12 months",
25    "emailbcc": "info@mycompany.be;management@mycompany.be",
26    "emailcc": "info@mycompany.be;management@mycompany.be",
27    "emailrecipients": "info@mycompany.be;management@mycompany.be",
28    "emailschedule": false,
29    "emailscheduledayofmonth": 1,
30    "emailscheduledayofweek": 7,
31    "emailschedulehourofday": 8,
32    "emailschedulequery": "select * from op.basket where createdts > CURRENT_TIMESTAMP - INTERVAL '1 DAY'",
33    "options": {
34        "pdfpagesize": "A4"
35    },
36    "reporttypeid": 1,
37    "subtitles": [
38        "Subtitle 1",
39        "Subtitle 2"
40    ],
41    "translations": {
42        "en": "...",
43        "nl": "..."
44    },
45    "usagetypeid": 17001
46}

Response

 1HTTP/1.1 200 OK
 2Content-Type: application/json
 3
 4{
 5    "id": 123,
 6    "name": "Financial overview",
 7    "content": [
 8        [
 9            {
10                "columns": [
11                    {
12                        "caption": "Id",
13                        "width": "80px"
14                    },
15                    {
16                        "caption": "Naam"
17                    }
18                ],
19                "query": "select id,namenl as name from ev.event",
20                "type": "table"
21            }
22        ]
23    ],
24    "defaultformat": "pdf",
25    "description": "A financial overview per month for the last 12 months",
26    "emailbcc": "info@mycompany.be;management@mycompany.be",
27    "emailcc": "info@mycompany.be;management@mycompany.be",
28    "emailrecipients": "info@mycompany.be;management@mycompany.be",
29    "emailschedule": false,
30    "emailscheduledayofmonth": 1,
31    "emailscheduledayofweek": 7,
32    "emailschedulehourofday": 8,
33    "emailschedulequery": "select * from op.basket where createdts > CURRENT_TIMESTAMP - INTERVAL '1 DAY'",
34    "options": {
35        "pdfpagesize": "A4"
36    },
37    "reporttypeid": 1,
38    "subtitles": [
39        "Subtitle 1",
40        "Subtitle 2"
41    ],
42    "translations": {
43        "en": "...",
44        "nl": "..."
45    },
46    "usagetypeid": 17001,
47    "createdts": "2014-09-26 15:24:36",
48    "lastupdatets": "2014-09-26 15:24:36"
49}

Request body fields

FieldDescription
name
mlstring 
(required)

Name of the report

Example value:"Financial overview"
content
map<string, mixed>[][] 
(required)

The actual report definition, see reports for more information.

Example value:[ [ { "columns": [ { "caption": "Id", "width": "80px" }, { "caption": "Naam" } ], "query": "select id,namenl as name from ev.event", "type": "table" } ] ]
defaultformat
string 
(required)

Reports can be generated as pdf or excel file. This field defines the default format. Possible values are ‘pdf’ or ‘excel’

Example value:"pdf"
description
mlstring 
(required)

Description of the report

Example value:"A financial overview per month for the last 12 months"
emailbcc
string 
(required)

List of email recipients that should receive the report in bcc, separated by ;

Example value:"info@mycompany.be;management@mycompany.be"
emailcc
string 
(required)

List of email recipients that should receive the report in cc, separated by ;

Example value:"info@mycompany.be;management@mycompany.be"
emailrecipients
string 
(required)

List of email recipients that should receive the report, separated by ;

Example value:"info@mycompany.be;management@mycompany.be"
emailschedule
bool 
(required)

Indicates if this report is scheduled to be sent by mail at a certain interval

        </td>
    </tr><tr>
        <td class="field">
            <div class="name">emailscheduledayofmonth</div>
            <div class="type">int&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>Day of the month the report will be sent.</p> 
            <strong>Example value:</strong><code>1</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">emailscheduledayofweek</div>
            <div class="type">int&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>Day of the week the report will be sent. 1 = monday -&gt; 7 = sunday</p> 
            <strong>Example value:</strong><code>7</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">emailschedulehourofday</div>
            <div class="type">int&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>Hour of the day the report will be sent</p> 
            <strong>Example value:</strong><code>8</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">emailschedulequery</div>
            <div class="type">string&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>Report will only be sent if the given query returns at least one result.</p> 
            <strong>Example value:</strong><code>&#34;select * from op.basket where createdts &gt; CURRENT_TIMESTAMP - INTERVAL &#39;1 DAY&#39;&#34;</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">options</div>
            <div class="type"><a href="api/types/ReportOptions">ReportOptions</a>&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>Key-value array of options. Can contain: pdfpagesize, excelpagewidth, excelscaling, usesystemfont</p> 
            <strong>Example value:</strong><code>{ &#34;pdfpagesize&#34;: &#34;A4&#34; }</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">reporttypeid</div>
            <div class="type">int&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>The report type defines the UI and parameters that are used when generating the report</p> 
            <strong>Example value:</strong><code>1</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">subtitles</div>
            <div class="type">string<span class="code">[]</span>&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>A list of subtitles for the report</p> 
            <strong>Example value:</strong><code>[ &#34;Subtitle 1&#34;, &#34;Subtitle 2&#34; ]</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">translations</div>
            <div class="type">map&lt;string, string&gt;&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>A map of language codes to <a href="http://en.wikipedia.org/wiki/Gettext">gettext .po files</a>.</p> 
            <strong>Example value:</strong><code>{ &#34;en&#34;: &#34;...&#34;, &#34;nl&#34;: &#34;...&#34; }</code>
        </td>
    </tr><tr>
        <td class="field">
            <div class="name">usagetypeid</div>
            <div class="type">int&nbsp;<div class="required">(required)</div></div>
        </td>
        <td class="description">
            <p>Indicates where the report is being used. Possible values: 17001 (Sales), 17002 (External sales), 17003 (Hidden)</p> 
            <strong>Example value:</strong><code>17001</code>
        </td>
    </tr>
</tbody>

Type reference: Report

Result fields

FieldDescription
id
int

Unique ID

Example value:123
name

Name of the report

Example value:"Financial overview"
content
map<string, mixed>[][]

The actual report definition, see reports for more information.

Example value:[ [ { "columns": [ { "caption": "Id", "width": "80px" }, { "caption": "Naam" } ], "query": "select id,namenl as name from ev.event", "type": "table" } ] ]
defaultformat
string

Reports can be generated as pdf or excel file. This field defines the default format. Possible values are ‘pdf’ or ‘excel’

Example value:"pdf"
description

Description of the report

Example value:"A financial overview per month for the last 12 months"
emailbcc
string

List of email recipients that should receive the report in bcc, separated by ;

Example value:"info@mycompany.be;management@mycompany.be"
emailcc
string

List of email recipients that should receive the report in cc, separated by ;

Example value:"info@mycompany.be;management@mycompany.be"
emailrecipients
string

List of email recipients that should receive the report, separated by ;

Example value:"info@mycompany.be;management@mycompany.be"
emailschedule
bool

Indicates if this report is scheduled to be sent by mail at a certain interval

emailscheduledayofmonth
int

Day of the month the report will be sent.

Example value:1
emailscheduledayofweek
int

Day of the week the report will be sent. 1 = monday -> 7 = sunday

Example value:7
emailschedulehourofday
int

Hour of the day the report will be sent

Example value:8
emailschedulequery
string

Report will only be sent if the given query returns at least one result.

Example value:"select * from op.basket where createdts > CURRENT_TIMESTAMP - INTERVAL '1 DAY'"
options

Key-value array of options. Can contain: pdfpagesize, excelpagewidth, excelscaling, usesystemfont

Example value:{ "pdfpagesize": "A4" }
reporttypeid
int

The report type defines the UI and parameters that are used when generating the report

Example value:1
subtitles
string[]

A list of subtitles for the report

Example value:[ "Subtitle 1", "Subtitle 2" ]
translations
map<string, string>

A map of language codes to gettext .po files.

Example value:{ "en": "...", "nl": "..." }
usagetypeid
int

Indicates where the report is being used. Possible values: 17001 (Sales), 17002 (External sales), 17003 (Hidden)

Example value:17001
createdts
timestamp

Created timestamp

Example value:"2014-09-26 15:24:36"
lastupdatets
timestamp

Last updated timestamp

Example value:"2014-09-26 15:24:36"

Type reference: Report