Templates

To create, edit and delete report templates, use the command report/update_report:

svc=report/update_report&params={"itemId":<long>,
				 "id":<long>,
				 "callMode":<text>,
				 "n":<text>,
				 "ct":<text>,
				 "p":<text>,
				 "tbl":[
					 {
						"n":<text>,
						"l":<text>,
						"c":<text>,
						"cl":<text>,
						"s":<text>,
						"sl":<text>,
						"p":<text>,
						"sch":{	
							"f1":<uint>,
							"f2":<uint>,
							"t1":<uint>,
							"t2":<uint>,
							"m":<uint>,
							"y":<uint>,
							"w":<uint>,
							"fl":<uint>
						},
						"f":<uint>
					}
				]}

Parameters

Name Description
itemId resource ID
id template ID
callMode action: create, update, delete

Other parameters are required only to create and edit templates. They are described in the chapter Get templates data.

Param “p”

In this param specifies the grouping of the table and other settings.

Example

"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

Advanced grouping types you can find with request (parameter gtGet list of table types

For account_tree table next parameters can be used:

"p": "{
        \"account_tree\":{
                \"group\":<bool>,
                \"types\":<text>
        }
}"
Param Description On default
group whether to group elements:
0 – no,
1 – yes
group
types element types included in table results:
avl_account
avl_resource
user
avl_unit
avl_unit_group
avl_retranslator
avl_route
all included

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\"}}"

For driver_ddd table (“Driver activity”) can be used parameter:

drv_activity (Driver activity source)

"p": "{
	\"drv_activity\":<text>
}"
Value Description
ddd use data from .ddd files (on default)
online use data from online activities

For driver_orders table (“Orders”) can be used parameter:

order_filter (“Filtration”)

"p":"{
	\"order_filter\":<uint>
}"
Value Description
0x1 visited orders
0x2 not visited orders
0x4 in time completed orders
0x8 overdue completed orders
0x10 confirmed and rejected orders
0x20 not confirmed and not rejected orders
0x40 confirmed orders
0x80 rejected orders

For unit_counter_sensors (“Counter sensors”) can be used parameters:

sensor_val:min (minimum sensor value) sensor_val:max (maximum sensor value)

"p": "{
	\"sensor_val\":{\"min\":\"10\",\"max\":\"14\"}
}"

For charts:

"p":"{
	\"sensor_mask\":<text>,		/* sensor mask */
	\"instant_speed_base\":{
		\"mask\":<text>}}	/* sensor mask to paint chart line by sensor */

For tables with shifts, to split shift – use params:

"p":{\"split_shifts\":1},
"s":{\"split_shifts\"}

Charts

Chart is a table in template. To add markers on the chart – add marker table to the template and add markers flags to the chart table.

Marker table codesample.

{"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_unit_events\"]"},

Markers flags codesample.

"p":"{
  \"chart_markers\":{
    \"f\":2556}
  }"
}

Available markers/states.

Marker Flag Description
unit_events 0x4 Events
unit_fillings 0x8 Fillings
unit_photos 0x10 Images
unit_stays 0x20 Parkings
unit_speedings 0x40 Speeding
unit_stops 0x80 Stops
unit_thefts 0x100 Thefts
unit_videos 0x800 Video
unit_engine_hours Engine hours
unit_conn_quality Connection loss

To change charts background according to units state – add marker/state to the template and add chart_regions param to the chart table.

Charts background change codesample.

"p":"{...,
\"chart_regions\":[
  {\"id\":\"chart_stops_regions\",\"color\":14413564,\"priority\":5,\"name\":\"Stops\"},
  {\"id\":\"chart_engine_hours_regions\",\"color\":16381105,\"priority\":4,\"name\":\"Engine hours\"},
  {\"id\":\"chart_conn_quality_regions\",\"color\":14474460,\"priority\":3,\"name\":\"Connection loss\"},
  {\"id\":\"chart_stays_regions\",\"color\":16773056,\"priority\":2,\"name\":\"Parkings\"},
  {\"id\":\"chart_trips_regions\",\"color\":16766408,\"priority\":1,\"name\":\"Trips\"}],
  ... }

Available state.

id 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

Advanced settings

Each setting of template is a column of the table. To activate an option – add to the template corresponding column.

Accesible settings

Table Column Description
unit_stats multi_drivers Multiple drivers/trailers
unit_stats precise_calculations Mileage/fuel/counters with accuracy to two decimal places
unit_stats exclude_thefts Exclude thefts from fuel consumption
unit_stats trips_mileage Mileage from trips only
unit_stats intersect_zone Consider track-geofence
unit_stats address_format Address Format
unit_stats time_format Time Format
unit_stats us_units Measurement
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 Theft 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

:!: Adress format, time format, shift and measurement specified in “p”.

Response

On create and edit:

[
	<long>,		/* template ID */
	{
		"id":<long>,	/* template ID */
		"n":<text>,	/* name */
		"ct":<text>,	/* template type */
		"c":<uint>	/* check sum (crc16) */
	}
]

Template types are described in the chapter Get templates data.

On delete:

[
	<long>,		/* template ID */
	null
]