1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Create report template</title>
6
    <script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
7
    <script type="text/javascript" src="//hst-api.wialon.com/wsdk/script/wialon.js"></script>
8
</head>
9
<body>
10
11
<table>
12
    <tr><td colspan="2" style="text-align:center;"><b>Create unit trips report</b></td></tr>
13
    <tr><td>Select resource:</td><td><select id="res"></select></td></tr>
14
    <tr><td>Report name:</td><td><input type="text" id="r_name"/></td></tr>
15
    <tr><td>Stats:</td>
16
        <td><ul>
17
            <li><input class="rep_col" type="checkbox" id="duration"/><label for="duration">Move time</label></li>
18
            <li><input class="rep_col" type="checkbox" id="mileage"/><label for="mileage">Mileage in trips</label></li>
19
            <li><input class="rep_col" type="checkbox" id="avg_speed"/><label for="avg_speed">Average speed in trips</label></li>
20
            <li><input class="rep_col" type="checkbox" id="max_speed"/><label for="max_speed">Max speed in trips</label></li>
21
            <li><input class="rep_col" type="checkbox" id="trips_count"/><label for="trips_count">Trips count</label></li>
22
        </ul></td>
23
    </tr>
24
    <tr><td colspan="2" style="text-align:center;">
25
        <input type="button" value="Create report" id="create_btn"/>
26
    </td></tr>
27
</table>
28
<div id="log"></div>
29
30
31
</body>
32
</html>
HTML
4
 
1
td{ border: 1px solid #c6c6c6; }
2
ul{ list-style: none; margin:0px; padding:0px;}
3
label{ cursor:pointer; }
4
CSS
71
 
1
var report_result = null; // global variable
2
3
// Print message to log
4
function msg(text) { $("#log").prepend(text + "<br/>"); }
5
6
function init() { // Execute after login succeed
7
    var sess = wialon.core.Session.getInstance(); // get instance of current Session
8
    // specify what kind of data should be returned
9
    var flags = wialon.item.Item.dataFlag.base;
10
    
11
    sess.loadLibrary("resourceReports"); // load Reports Library
12
    sess.updateDataFlags( // load items to current session
13
        [{type: "type", data: "avl_resource", flags:flags , mode: 0}], // Items specification    
14
        function (code) { // updateDataFlags callback
15
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
16
            // get loaded 'avl_resource's items with edit reports access 
17
            var res = wialon.util.Helper.filterItems(sess.getItems("avl_resource"),
JS
Result
Source code of example Close ✕
1
 
1
/*source*/