Wiki source code of timerecording/get_costcenters.php
Last modified by YellowFox_RD on 2024/12/19 10:11
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | (% class="box" %) | ||
2 | ((( | ||
3 | Table of Contents | ||
4 | ))) | ||
5 | |||
6 | {{toc/}} | ||
7 | |||
8 | (% class="box" %) | ||
9 | ((( | ||
10 | **Compatibility** | ||
11 | This function is intended to be used with timerecording V3 | ||
12 | ))) | ||
13 | |||
14 | Returns all currently available time recording cost centers. | ||
15 | |||
16 | = Description = | ||
17 | |||
18 | (% class="green mark" %)**GET**(%%)** //timerecording/get_costcenters.php?company//**//=COMPANY_RTIKEY**&import**=COMPANY_IMPORTKEY**&format**=FORMAT_TYPE// | ||
19 | |||
20 | = Parameters = | ||
21 | |||
22 | |=parameter|=description|=type|=hint|=mandatory | ||
23 | |company|RTI company key|string| |yes | ||
24 | |import|RTI import key|string| |yes | ||
25 | |format|output format|string|allowed output formats((( | ||
26 | * csv | ||
27 | * json | ||
28 | * xml | ||
29 | )))Default is csv.|no | ||
30 | |||
31 | = Return values = | ||
32 | |||
33 | This function returns a **string**. On error the return will be "**Error:Description**". | ||
34 | |||
35 | == JSON Format == | ||
36 | |||
37 | Returns a JSON formatted text with the properties of each cost center. | ||
38 | |||
39 | === Example output === | ||
40 | |||
41 | **JSON Ausgabe** | ||
42 | {{code language="js"}}[{ | ||
43 | ident: 'K1001', | ||
44 | name: 'Baustelle B', | ||
45 | valid_from: '2021-01-01', | ||
46 | valid_to: null, | ||
47 | planned_duration: 20000, | ||
48 | defined_activities: [ | ||
49 | { ident: 'A100', duration: 18000 }, | ||
50 | { ident: 'A200', duration: 2000 }, | ||
51 | { ident: 'A200', duration: null } | ||
52 | ], | ||
53 | allow_other_activities: 0, | ||
54 | defined_persons: [ | ||
55 | { id: '2093', name:'Max Mustermann' } | ||
56 | ] | ||
57 | }]{{/code}} | ||
58 | |||
59 | == XML Format == | ||
60 | |||
61 | Returns an XML formatted text with the properties of each cost center. | ||
62 | |||
63 | === Example output === | ||
64 | |||
65 | **XML Ausgabe** | ||
66 | {{code language="xml"}}<?xml version="1.0" encoding="UTF-8"?> | ||
67 | <costcenters> | ||
68 | <costcenter> | ||
69 | <defined_activities> | ||
70 | <activity> | ||
71 | <duration>18000</duration> | ||
72 | <ident>A100</ident> | ||
73 | </activity> | ||
74 | <activity> | ||
75 | <duration>2000</duration> | ||
76 | <ident>A200</ident> | ||
77 | </activity> | ||
78 | <activity> | ||
79 | <duration null="true" /> | ||
80 | <ident>A200</ident> | ||
81 | </activity> | ||
82 | </defined_activities> | ||
83 | <allow_other_activities>0</allow_other_activities> | ||
84 | <ident>K1001</ident> | ||
85 | <name>Baustelle B</name> | ||
86 | <defined_persons> | ||
87 | <person> | ||
88 | <id>2093</ident> | ||
89 | <name>Max Mustermann</name> | ||
90 | </person> | ||
91 | </defined_persons> | ||
92 | <planned_duration>20000</planned_duration> | ||
93 | <valid_from>2021-01-01</valid_from> | ||
94 | <valid_to null="true" /> | ||
95 | </costcenter> | ||
96 | <costcenters>{{/code}} | ||
97 | |||
98 | == CSV Format == | ||
99 | |||
100 | The CSV format contains one line per cost center. Fields that can contain multiple data records are output as a JSON string. | ||
101 | |||
102 | === Meta information === | ||
103 | |||
104 | |=Separator|Semicolon ( ; ) | ||
105 | |=Delimiter|Double quote ( " ) | ||
106 | |=Line break|0x0D 0x0A (CarriageReturn LineFeed) | ||
107 | |=Header|Row 1 | ||
108 | |=Encoding|Windows-1252 | ||
109 | |||
110 | === CSV columns === | ||
111 | |||
112 | |=Column|=Description|= | ||
113 | |ident|//optional// self-defined identifier of the cost center|Can be set under cost center basic data. | ||
114 | |name|self-defined name of the cost center| | ||
115 | |valid_from|Date since when this cost center has been active.|Format: YYYY-mm-dd | ||
116 | |valid_to|//optional// Date until when this cost center is active|Format: YYYY-mm-dd | ||
117 | |planned_duration|//optional// planned duration of the cost center|in minutes | ||
118 | |defined_activities|//optional// defined activities for this cost center|Format: JSON string | ||
119 | |allow_other_activities|Option that determines whether other activities can be posted to this cost center in addition to the activities defined.|Format: 0 or 1 | ||
120 | |defined_persons|//optional// defined persons for this cost center|Format: JSON string | ||
121 | |||
122 | === Example output === | ||
123 | |||
124 | {{code language="java"}}"ident";"name";"valid_from"";valid_to";"planned_duration";"defined_activities";"allow_other_activities";"defined_persons" | ||
125 | "K1001";"Baustelle B";"2021-01-01";"";"20000";"[{ ident: 'A100', duration: 18000 },{ ident: 'A200', duration: 2000 },{ ident: 'A200', duration: null }]";"0";"[{id:'2093',name:'Max Mustermann'}]"{{/code}} | ||
126 | |||
127 | = Examples = | ||
128 | |||
129 | **Get cost centers as CSV** | ||
130 | {{code language="java"}}https://map.yellowfox.de/rti/timerecording/get_costcenters.php?company=COMPANY_RTIKEY&import=COMPANY_IMPORTKEY&format=csv{{/code}} | ||
131 |