@@ -52,7 +52,7 @@ var dtf = require("./dateformat.js");
5252 'The Month Before Last' : [ moment ( ) . subtract ( 2 , 'month' ) . startOf ( 'month' ) , moment ( ) . subtract ( 2 , 'month' ) . endOf ( 'month' ) ] ,
5353 'This Year' : [ moment ( ) . startOf ( 'year' ) , moment ( ) . endOf ( 'year' ) ] ,
5454 'Last Year' : [ moment ( ) . subtract ( 1 , 'year' ) . startOf ( 'year' ) , moment ( ) . subtract ( 1 , 'year' ) . endOf ( 'year' ) ] ,
55-
55+
5656 } ,
5757 locale : {
5858 format : dtf . dformat ( ) ,
@@ -68,15 +68,15 @@ var dtf = require("./dateformat.js");
6868 $ ( "#group1" ) . select2 ( ) ;
6969 $ ( "#group2" ) . select2 ( ) ;
7070 $ ( "#group3" ) . select2 ( ) ;
71- $ ( '#group1' ) . on ( "select2:select select2:unselect" , function ( e ) {
71+ $ ( '#group1' ) . on ( "select2:select select2:unselect" , function ( e ) {
7272 group1 = e . params . data . id ;
7373 getReport ( ) ;
7474 } ) ;
75- $ ( '#group2' ) . on ( "select2:select select2:unselect" , function ( e ) {
75+ $ ( '#group2' ) . on ( "select2:select select2:unselect" , function ( e ) {
7676 group2 = e . params . data . id ;
7777 getReport ( ) ;
7878 } ) ;
79- $ ( '#group3' ) . on ( "select2:select select2:unselect" , function ( e ) {
79+ $ ( '#group3' ) . on ( "select2:select select2:unselect" , function ( e ) {
8080 group3 = e . params . data . id ;
8181 getReport ( ) ;
8282 } ) ;
@@ -96,15 +96,15 @@ var dtf = require("./dateformat.js");
9696 ) ;
9797 return $state ;
9898 } ,
99- ajax : {
99+ ajax : {
100100 tags : true ,
101101 url : OC . generateUrl ( '/apps/timetracker/ajax/projects' ) ,
102-
102+
103103 dataType : 'json' ,
104104 delay : 250 ,
105-
105+
106106 processResults : function ( data , page ) { //json parse
107- return {
107+ return {
108108 results : $ . map ( data . Projects , function ( val , i ) {
109109 return { id : val . id , text :val . name , color : val . color } ;
110110 } ) ,
@@ -114,13 +114,13 @@ var dtf = require("./dateformat.js");
114114 } ;
115115 } ,
116116 cache : false ,
117-
117+
118118 } ,
119119 } ) ;
120120
121- $ ( '#filter-project' ) . on ( "select2:select select2:unselect" , function ( e ) {
122-
123-
121+ $ ( '#filter-project' ) . on ( "select2:select select2:unselect" , function ( e ) {
122+
123+
124124 filterProjectId = ( $ ( e . target ) . val ( ) != null ) ? $ ( e . target ) . val ( ) : "" ;
125125 getReport ( ) ;
126126 } ) ;
@@ -133,14 +133,14 @@ var dtf = require("./dateformat.js");
133133 escapeMarkup : function ( markup ) { return markup ; } ,
134134 placeholder : "Select client" ,
135135 allowClear : true ,
136- ajax : {
136+ ajax : {
137137 tags : true ,
138138 url : OC . generateUrl ( '/apps/timetracker/ajax/clients' ) ,
139-
139+
140140 dataType : 'json' ,
141141 delay : 250 ,
142142 processResults : function ( data , page ) { //json parse
143- return {
143+ return {
144144 results : $ . map ( data . Clients , function ( val , i ) {
145145 return { id : val . id , text :val . name } ;
146146 } ) ,
@@ -150,23 +150,23 @@ var dtf = require("./dateformat.js");
150150 } ;
151151 } ,
152152 cache : false ,
153-
153+
154154 } ,
155155 } ) ;
156156
157-
158- $ ( '#filter-client' ) . on ( "select2:select select2:unselect" , function ( e ) {
159-
160-
157+
158+ $ ( '#filter-client' ) . on ( "select2:select select2:unselect" , function ( e ) {
159+
160+
161161 filterClientId = ( $ ( e . target ) . val ( ) != null ) ? $ ( e . target ) . val ( ) : "" ;
162162 getReport ( ) ;
163163 } ) ;
164164
165165
166166 $ ( 'input.select2-input' ) . attr ( 'autocomplete' , "xxxxxxxxxxx" ) ;
167167
168-
169-
168+
169+
170170 function getReport ( ) {
171171 var baseUrl = OC . generateUrl ( '/apps/timetracker/ajax/report?name=&from=' + start . unix ( ) + '&to=' + end . unix ( ) + '&group1=' + group1 + '&group2=' + group2 + '&timegroup=' + group3 + '&filterProjectId=' + filterProjectId + '&filterClientId=' + filterClientId ) ;
172172 function pad ( n , width , z ) {
@@ -203,6 +203,10 @@ var dtf = require("./dateformat.js");
203203 var nullCheckAccessor = function ( value , data , type , params , column ) {
204204 return value ? value : '' ;
205205 }
206+
207+ var money = function ( value , data , type , params , component ) {
208+ return value / 100 ;
209+ }
206210 var table = new Tabulator ( "#report" , {
207211 ajaxURL :baseUrl ,
208212 layout :"fitColumns" ,
@@ -229,6 +233,7 @@ var dtf = require("./dateformat.js");
229233 return moment . unix ( t ) . format ( dtf . dtformat ( ) ) ;
230234 }
231235 } } ,
236+ { title :"Cost" , field :"cost" , mutator :money , accessorDownload : nullCheckAccessor , widthGrow :1 , bottomCalc : "sum" , formatter : "money" , bottomCalcFormatter : "money" } , //column will be allocated 1/5 of the remaining space
232237 { title :"Total Duration" , field :"totalDuration" , accessorDownload :totalDurationAccessor , formatter :function ( cell , formatterParams , onRendered ) {
233238 //cell - the cell component
234239 //formatterParams - parameters set for the column
@@ -238,7 +243,7 @@ var dtf = require("./dateformat.js");
238243 var m = Math . floor ( ( duration / 60 ) % 60 ) ;
239244 var h = Math . floor ( ( duration / ( 60 * 60 ) ) ) ;
240245 return pad ( h , 2 ) + ':' + pad ( m , 2 ) + ':' + pad ( s , 2 ) ;
241-
246+
242247 } , bottomCalc :"sum" , bottomCalcParams :{
243248 precision :1 ,
244249 } , bottomCalcFormatter :function ( cell , formatterParams , onRendered ) {
@@ -263,11 +268,11 @@ var dtf = require("./dateformat.js");
263268 var time = cell . getRow ( ) . getData ( ) . time ;
264269 var duration = cell . getRow ( ) . getData ( ) . totalDuration ;
265270 return moment . unix ( parseInt ( time ) + parseInt ( duration ) ) . format ( dtf . dtformat ( ) ) ;
266-
271+
267272 } } ,
268273 ] ,
269274 ajaxResponse :function ( url , params , response ) {
270-
275+
271276 return response . items ; //return the tableData property of a response json object
272277 } ,
273278 } ) ;
0 commit comments