update_report
To create, edit, and delete report templates, use the report/update_report method.
Endpoint
svc=report/update_report¶ms={
"itemId":<long>,
"id":<long>,
"callMode":"<text>",
"n":"<text>",
"ct":"<text>",
"p":"<text>",
"tbl":[
{
"n":"<text>",
"l":"<text>",
"c":"<text>",
"cl":"<text>",
"cp":"<text>",
"s":"<text>",
"sl":"<text>",
"filter_order":"<text>",
"p":"<text>",
"sch":{"f1":<uint>,"f2":<uint>,"t1":<uint>,"t2":<uint>,"m":<uint>,"y":<uint>,"w":<uint>,"fl":<uint>},
"f":<uint>
}
]
}
Parameters
The request must contain the following parameters:
| Name | Description |
|---|---|
| itemId | Resource ID. |
| id | Template ID. |
| callMode | Action: create, update, delete. |
Other parameters are only required to create and edit templates. They are described on the get_report_data page.
The tbl[].n parameter is the system table name. It depends on the template type specified in ct. For details, see Table names and types.
Template parameters
The p parameter specifies the grouping of the table and other settings. Some settings are available only for specific tables.
Grouping
The grouping parameter defines how the rows in the table are grouped:
"p":"{
\"grouping\":\"
{\"type\":\"total\",\"nested\": /* enable grouping \"Total\" */
{\"type\":\"year\"}}\" /* enable nested grouping \"Year\" */
}"
Basic grouping types:
| Type | Description |
|---|---|
| total | Total. |
| year | Year. |
| month | Month. |
| week | Week. |
| wday | Day of the week. |
| mday | Day of the month. |
| day | Date. |
| shift | Shift. |
To see the advanced grouping types, get the table information using the get_report_tables request (the gt parameter).
account_tree table
For the account_tree table, the following parameters can be used:
"p": "{
\"account_tree\": {
\"group\": <bool>,
\"types\": \"<text>\"
}
}"
| Parameter | Description |
|---|---|
| group | Grouping the elements:
|
| types | Element types included in the table results:
|
Example (all double quotes within the value must be escaped):
"p":"{\"account_tree\":{\"group\":1,\"types\":\"avl_account,avl_resource,user,avl_unit,avl_unit_group,avl_retranslator,avl_route\"}}"
driver_ddd table
For the driver_ddd table, the drv_activity (Driver activity source) parameter can be used:
"p": "{
\"drv_activity\":"<text>"
}"
The drv_activity parameter can have the following values:
| Value | Description |
|---|---|
| ddd | Use data from the .ddd files (by default). |
| online | Use the data from online activities. |
| binds_and_trips | Use the data from assignment and trip activities. |
driver_orders table
For the driver_orders table (Orders), order_filter (Filtration) parameter can be used:
"p":"{
\"order_filter\":<uint>
}"
The order_filter parameter can have the following values:
| Value | Description |
|---|---|
| 0x1 | Visited orders. Deprecated. |
| 0x2 | Not visited orders. Deprecated. |
| 0x4 | Orders visited in time. Deprecated. |
| 0x8 | Orders visited late. Deprecated. |
| 0x10 | Confirmed and rejected orders. |
| 0x20 | Not confirmed and not rejected orders. |
| 0x40 | Confirmed orders. |
| 0x80 | Rejected orders. |
| 0x100 | Visited orders. |
| 0x200 | Not visited orders. |
| 0x400 | Orders visited in time. |
| 0x800 | Orders visited late. |
unit_counter_sensors table
For the unit_counter_sensors (Counter sensors), the following parameters can be used:
sensor_val:min(minimum sensor value);sensor_val:max(maximum sensor value).
"p": "{
\"sensor_val\":{\"min\":\"10\",\"max\":\"14\"}
}"
Shifts
To split shifts in the tables with shifts, use the following parameters:
"p":{\"split_shifts\":1},
"s":{\"split_shifts\"}
Charts
A chart is a table in a template. For charts, the following parameters can be used:
"p":"{
\"sensor_mask\":"<text>", /* sensor mask */
\"instant_speed_base\":{
\"mask\":"<text>"}} /* sensor mask to colour the chart line by sensor */
Markers
To add markers to the chart, add the marker table to the template and the marker flags to the chart table. Marker table code sample:
{"n":"unit_events",
"l":"",
"f":0,
"c":"",
"cl":"",
"p":"",
"sch":{
"y":0,
"m":0,
"w":0,
"f1":0,
"f2":0,
"t1":0,
"t2":0},
"sl":"",
"s":"[\"chart_events_markers\"]"},
Code sample for marker flags:
"p":"{
\"chart_markers\":{
\"f\":2556}
}"
Available markers/states:
| Marker | Flag | Description |
|---|---|---|
| unit_events | 0x4 | Events. |
| unit_fillings | 0x8 | Fuel fillings. |
| unit_photos | 0x10 | Images. |
| unit_stays | 0x20 | Parkings. |
| unit_speedings | 0x40 | Speedings. |
| unit_stops | 0x80 | Stops. |
| unit_thefts | 0x100 | Fuel drains. |
| unit_videos | 0x800 | Video. |
| unit_fillings | 0x4000 | Battery charges. |
The 0x4 flag also adds the violation markers to the chart.
Background
The intervals of events such as trips, stops, parkings, connection losses, and engine hours can be used as a chart background. For details on how the background looks in the interface, see Chart properties.
The background requires two objects of the tbl array: the source table, which provides the intervals, and the chart table.
In the source table, add the name of one of the columns with intervals to the s parameter. For example, to show the intervals of trips, add the following to the unit_trips object:
"s":"[\"chart_trips_regions\"]"
In the chart table, add the chart_regions object to the p parameter:
"p":"{
\"chart_regions\":{
\"0\":{
\"id\":\"<text>\",
\"name\":\"<text>\",
\"color\":<uint>,
\"priority\":<uint>}
}}"
The keys of the object are the indexes of the intervals, starting from 0. To show several types of intervals on one chart, add an object for each of them.
| Parameter | Description |
|---|---|
| id | The column name from the s parameter. |
| name | The interval name shown on the chart. |
| color | The background color of the interval. |
| priority | The display priority. If intervals overlap, the interval with the higher value is drawn on top. |
If id or name is empty, the interval isn’t added to the chart.
If you don’t need the rows of the source table in the report, leave its c and cl parameters empty. The table is still calculated and supplies the intervals for the chart.
Columns with intervals
The following columns are available:
| Column | Description |
|---|---|
| chart_stops_regions | Stops. |
| chart_engine_hours_regions | Engine hours. |
| chart_conn_quality_regions | Connection loss. |
| chart_stays_regions | Parkings. |
| chart_trips_regions | Trips. |
| chart_speedings_regions | Speedings. |
| chart_digital_sensors_regions | Digital sensors. |
Advanced settings
Every template setting is a table column. To activate an option, add the corresponding column to the template.
The following settings are available:
| Table | Column | Description |
|---|---|---|
| unit_stats | multi_drivers | Multiple drivers/trailers. |
| unit_stats | precise_calculations | Mileage/Fuel/Counters with a precision of up to two decimal places. |
| unit_stats | exclude_thefts | Exclude fuel drains from fuel consumption. |
| unit_stats | trips_mileage | Mileage from trips only. |
| unit_stats | intersect_zone | Consider track-geofence intersections. |
| unit_stats | address_format | Address format. |
| unit_stats | time_format | Time format. |
| unit_stats | us_units | Measurement system. |
| unit_stats | shifts | Shifts. |
| unit_trips | render_msgs | All messages on map. |
| unit_trips | render_trips | Trip routes. |
| geozones | render_geozones | Render geofences. |
| unit_videos | render_unit_videos | Video markers. |
| unit_fillings | render_filling_markers | Filling markers. |
| unit_photos | render_unit_photos | Image markers. |
| unit_stops | render_stops_markers | Stop markers. |
| unit_speedings | render_speedings_markers | Speeding markers. |
| unit_thefts | render_theft_markers | Fuel drain markers. |
| unit_events | render_events_markers | Event markers. |
| unit_stays | render_stays_markers | Parking markers. |
| unit_location | render_location_markers | Unit last location. |
| unit_stats_zones | all_resources | Geofences from all resources. |
| unit_stats_zones | desc_address | Add geofence description to address. |
| unit_stats_zones | address_zones | Use geofences for addresses. |
Address format, time format, shift, and measurement system are specified in the
pparameter.
Returned result
If the request is completed successfully, a response in the following format is returned.
For creation and modification requests:
[
<long>, /* template ID */
{
"id":<long>, /* template ID */
"n":"<text>", /* name */
"ct":"<text>", /* template type */
"c":<uint> /* check sum (crc16) */
}
]
For deletion requests:
[
<long>, /* template ID */
null
]
Template types are described in the Template types section on the get_report_data page.
Otherwise, an error code is returned.
Error codes
| Error code | Description |
|---|---|
| 4 | Wrong input parameters. |
| 6 | Undefined error. |
| 7 | Failed to fetch the item. The user may not have the Create, edit, and delete report templates access right to the resource. |