Index: hci/trunk/eneraptor-web-app/.project
===================================================================
--- hci/trunk/eneraptor-web-app/.project	(revision 49)
+++ hci/trunk/eneraptor-web-app/.project	(revision 50)
@@ -50,56 +50,31 @@
 			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/navigation-1.1.1/grails-app/taglib</locationURI>
 		</link>
 		<link>
-			<name>shiro-1.1.2-grails-app-conf</name>
+			<name>pdf-0.6-grails-app-controllers</name>
 			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/conf</locationURI>
+			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/pdf-0.6/grails-app/controllers</locationURI>
 		</link>
 		<link>
-			<name>shiro-1.1.2-grails-app-controllers</name>
+			<name>pdf-0.6-grails-app-i18n</name>
 			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/controllers</locationURI>
+			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/pdf-0.6/grails-app/i18n</locationURI>
 		</link>
 		<link>
-			<name>shiro-1.1.2-grails-app-domain</name>
+			<name>pdf-0.6-grails-app-services</name>
 			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/domain</locationURI>
+			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/pdf-0.6/grails-app/services</locationURI>
 		</link>
 		<link>
-			<name>shiro-1.1.2-grails-app-i18n</name>
+			<name>pdf-0.6-grails-app-taglib</name>
 			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/i18n</locationURI>
+			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/pdf-0.6/grails-app/taglib</locationURI>
 		</link>
 		<link>
-			<name>shiro-1.1.2-grails-app-realms</name>
+			<name>pdf-0.6-grails-app-views</name>
 			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/realms</locationURI>
+			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/pdf-0.6/grails-app/views</locationURI>
 		</link>
 		<link>
-			<name>shiro-1.1.2-grails-app-services</name>
-			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/services</locationURI>
-		</link>
-		<link>
-			<name>shiro-1.1.2-grails-app-taglib</name>
-			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/taglib</locationURI>
-		</link>
-		<link>
-			<name>shiro-1.1.2-grails-app-views</name>
-			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/grails-app/views</locationURI>
-		</link>
-		<link>
-			<name>shiro-1.1.2-src-groovy</name>
-			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/src/groovy</locationURI>
-		</link>
-		<link>
-			<name>shiro-1.1.2-src-java</name>
-			<type>2</type>
-			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/shiro-1.1.2/src/java</locationURI>
-		</link>
-		<link>
 			<name>tomcat-1.3.6-src-groovy</name>
 			<type>2</type>
 			<locationURI>GRAILS_ROOT/1.3.6/projects/eneraptor-web-app/plugins/tomcat-1.3.6/src/groovy</locationURI>
Index: hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.4.war
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.4.war
===================================================================
--- hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.4.war	(revision 0)
+++ hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.4.war	(revision 50)

Property changes on: hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.4.war
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: hci/trunk/eneraptor-web-app/web-app/css/style.css
===================================================================
--- hci/trunk/eneraptor-web-app/web-app/css/style.css	(revision 49)
+++ hci/trunk/eneraptor-web-app/web-app/css/style.css	(revision 50)
@@ -413,7 +413,8 @@
 
 .statistics-main{background:transparent url(../img/icons/eye.png) no-repeat left;}
 .statistics-graphs{background:transparent url(../img/icons/chart_curve.png) no-repeat left;}
-.statistics-reports{background:transparent url(../img/icons/report.png) no-repeat left;}
+.statistics-newGraph{background:transparent url(../img/icons/chart_curve_add.png) no-repeat left;}
+.statistics-newReport{background:transparent url(../img/icons/report.png) no-repeat left;}
 
 .actions-main{background:transparent url(../img/icons/eye.png) no-repeat left;}
 .actions-view{background:transparent url(../img/icons/script.png) no-repeat left;}
Index: hci/trunk/eneraptor-web-app/.settings/org.eclipse.wst.common.component
===================================================================
--- hci/trunk/eneraptor-web-app/.settings/org.eclipse.wst.common.component	(revision 49)
+++ hci/trunk/eneraptor-web-app/.settings/org.eclipse.wst.common.component	(revision 50)
@@ -5,15 +5,10 @@
         <wb-resource deploy-path="/" source-path="/navigation-1.1.1-grails-app-services"/>
         <wb-resource deploy-path="/" source-path="/navigation-1.1.1-grails-app-taglib"/>
         <wb-resource deploy-path="/" source-path="/flot-0.2.2-grails-app-taglib"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-conf"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-controllers"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-domain"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-i18n"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-realms"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-services"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-taglib"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-views"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-src-java"/>
-        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-src-groovy"/>
+        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-controllers"/>
+        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-i18n"/>
+        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-services"/>
+        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-taglib"/>
+        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-views"/>
     </wb-module>
 </project-modules>
Index: hci/trunk/eneraptor-web-app/application.properties
===================================================================
--- hci/trunk/eneraptor-web-app/application.properties	(revision 49)
+++ hci/trunk/eneraptor-web-app/application.properties	(revision 50)
@@ -1,10 +1,11 @@
 #Grails Metadata file
-#Thu Jan 13 08:59:17 CET 2011
+#Wed Jan 26 14:49:47 CET 2011
 app.grails.version=1.3.6
 app.name=eneraptor-web-app
 app.servlet.version=2.4
-app.version=0.3
+app.version=0.4
 plugins.flot=0.2.2
 plugins.hibernate=1.3.6
 plugins.navigation=1.1.1
+plugins.pdf=0.6
 plugins.tomcat=1.3.6
Index: hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy	(revision 49)
+++ hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy	(revision 50)
@@ -43,8 +43,9 @@
 		
 		statisticsSubMenu = new ArrayList()
 		statisticsSubMenu.add(new MenuItem("Overview","statistics","main"))
-		statisticsSubMenu.add(new MenuItem("Graphs","statistics","graphs"))
-		statisticsSubMenu.add(new MenuItem("Reports","statistics","reports"))
+		statisticsSubMenu.add(new MenuItem("Saved graphs","statistics","graphs"))
+		statisticsSubMenu.add(new MenuItem("Create a new graph","statistics","newGraph"))
+		statisticsSubMenu.add(new MenuItem("Make reports","statistics","newReport"))
 		
 		actionsSubMenu = new ArrayList()
 		actionsSubMenu.add(new MenuItem("Overview","actions","main"))
Index: hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy	(revision 49)
+++ hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy	(revision 50)
@@ -19,8 +19,6 @@
 			
 	}
 	
-	def reports = { }
-	
 	def newGraph = {
 		
 		List graphTypes = ["min","max","avg","sum"]
@@ -96,7 +94,7 @@
 	
 	def showGraph = {
 		
-		def graphToShow = EneGraph.get(params['graphId'])
+		def graphToShow = EneGraph.get(params['id'])
 		String query
 		
 		List data = new ArrayList()
@@ -104,15 +102,15 @@
 		def db_sql = new Sql(dataSource)
 		
 		if(graphToShow.timeFrameType == "day") {
-			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
+			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
 				data << [it.dt.getTime(), it.vl]
 			}
 		} else if (graphToShow.timeFrameType == "month") {
-			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
+			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
 				data << [it.dt.getTime(), it.vl]
 			}
 		} else if (graphToShow.timeFrameType == "year") {
-			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
+			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
 				data << [it.dt.getTime(), it.vl]
 			}
 		} else if (graphToShow.timeFrameType == "custom") {
@@ -125,7 +123,7 @@
 				def currDateStart = new Date((long)currDateStartMillis)
 				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
 				def currDateStop = new Date((long)currDateStopMillis)
-				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "')) "
+				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
 				if (i < (graphToShow.innerSections-1) ) query += "union "
 			}
 			query += "order by dt asc"
@@ -137,5 +135,310 @@
 		[data:data]
 		
 	}
+	
+	def editGraph = {
+		
+		EneGraph chosenGraph = EneGraph.get(params['id'])
+		
+		List graphTypes = ["min","max","avg","sum"]
+		List graphTypesFriendly = ["Minimum value","Maximum value","Average value","Cumulative"]
+		
+		List devices = new ArrayList()
+		List devicesFriendly = new ArrayList()
+		
+		DeviceInfo.list().each {
+			devices << it.deviceId
+			devicesFriendly << it.friendlyName
+		}
+		
+		[graph: chosenGraph, graphTypes:graphTypes, graphTypesFriendly:graphTypesFriendly, devices:devices, devicesFriendly:devicesFriendly]
+		
+	}
+	
+	def editGraphDo = {
+	
+		String errors = ""
+		
+		EneGraph graphToEdit = EneGraph.get(params['graphId'])
+		
+		graphToEdit.name = params['graphName']
+		graphToEdit.type = params['graphType']
+		graphToEdit.timeFrameType = params['timeFrameType']
+		graphToEdit.timeFrameStart = params['mainTimeFrameStart']
+		graphToEdit.timeFrameEnd = params['mainTimeFrameEnd']
+		graphToEdit.innerSections = params['mainTimeFrameInnerSections'] as int
+		graphToEdit.advHoursTimeFrameStart = params['advHoursStart'] as int
+		graphToEdit.advHoursTimeFrameEnd = params['advHoursEnd'] as int 
+		graphToEdit.advDayTimeFrameStart = params['advDayStart'] as int
+		graphToEdit.advDayTimeFrameEnd = params['advDayEnd'] as int
+		graphToEdit.advMonthTimeFrameStart = params['advMonthStart'] as int
+		graphToEdit.advMonthTimeFrameEnd = params['advMonthEnd'] as int
+		graphToEdit.deviceId = params['deviceId']
+		
+		if(!graphToEdit.validate()) {
+			errors += "<p>Graph could not be modified - there were some input errors. Please check if all input values are valid.</p>"
+			flash['errors'] = errors
+			redirect(action:'editGraph')
+		} else {
+			if(graphToEdit.save()){
+				flash['confirms'] = "<p>Graph modified succesfully!</p>"
+				redirect(action:'graphs')
+			} else {
+				flash['errors'] = "<p>There was an error while modifying graph.</p>"
+				redirect(action:'editGraph')
+			}
+		}
+		
+		return true
+			
+	}
+	
+	def newReport = {
+		
+		def graphsAll = EneGraph.list()
+		def graphs = new ArrayList()
+		def graphsKeys = new ArrayList()
+		graphsAll.each {
+			graphs << it.name
+			graphsKeys << it.id
+		}
+		
+		[graphs:graphs, graphsKeys:graphsKeys]
+		
+	}
+	
+	def makeReport = {
+		
+		def graphToShow = EneGraph.get(params['id'])
+		String query
+		
+		List data = new ArrayList()
+		List detailedData = new ArrayList()
+		def results
+		def innerTimeFrameHalf = 0;
+		def db_sql = new Sql(dataSource)
+		
+		if(graphToShow.timeFrameType == "day") {
+			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,10), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "month") {
+			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,7), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "year") {
+			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,4), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "custom") {
+			def innerTimeFrame = (long)((graphToShow.timeFrameEnd.getTime() - graphToShow.timeFrameStart.getTime()) / graphToShow.innerSections)
+			innerTimeFrameHalf = (long)(innerTimeFrame/2)
+			query = ""
+			for(int i = 0; i < graphToShow.innerSections;i++) {
+				def currDateMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame) + innerTimeFrame/2
+				def currDate = new Date((long)currDateMillis)
+				def currDateStartMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame)
+				def currDateStart = new Date((long)currDateStartMillis)
+				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
+				def currDateStop = new Date((long)currDateStopMillis)
+				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
+				if (i < (graphToShow.innerSections-1) ) query += "union "
+			}
+			query += "order by dt asc"
+			db_sql.eachRow(query) {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [(new Date(it.dt.getTime()-innerTimeFrameHalf)).toTimestamp().toString(),(new Date(it.dt.getTime()+innerTimeFrameHalf)).toTimestamp().toString(), it.vl]
+			}
+		}
+		
+		[data:data, detailedData:detailedData, graph:graphToShow]
+		
+	}
+	
+	def exportReport = {
+		
+		if(params['exportType'] == 'pdf') {
+			exportReportPdf(params:params)
+		} else if(params['exportType'] == 'xml') {
+			exportReportXml(params:params)
+		} else if(params['exportType'] == 'csv') {
+			exportReportCsv(params:params)
+		} else {
+			flash['errors'] = "<p>The specified export type is not valid!</p>"
+			redirect(action:'graphs')
+		}
+		
+		return true
+		
+	}
+	
+	def exportReportPdf = {
+		
+		redirect(controller: 'pdf', action: 'pdfLink', params:[pdfController: 'pdf',pdfAction:'reportToPdf',reportId:params['reportId']])
+		
+	}
+	
+	def exportReportXml = {
+		
+		def cont = ""
+		
+		def graphToShow = EneGraph.get(params['reportId'])
+		String query
+		
+		List data = new ArrayList()
+		List detailedData = new ArrayList()
+		def results
+		def innerTimeFrameHalf = 0;
+		def db_sql = new Sql(dataSource)
+		
+		if(graphToShow.timeFrameType == "day") {
+			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,10), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "month") {
+			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,7), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "year") {
+			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,4), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "custom") {
+			def innerTimeFrame = (long)((graphToShow.timeFrameEnd.getTime() - graphToShow.timeFrameStart.getTime()) / graphToShow.innerSections)
+			innerTimeFrameHalf = (long)(innerTimeFrame/2)
+			query = ""
+			for(int i = 0; i < graphToShow.innerSections;i++) {
+				def currDateMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame) + innerTimeFrame/2
+				def currDate = new Date((long)currDateMillis)
+				def currDateStartMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame)
+				def currDateStart = new Date((long)currDateStartMillis)
+				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
+				def currDateStop = new Date((long)currDateStopMillis)
+				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
+				if (i < (graphToShow.innerSections-1) ) query += "union "
+			}
+			query += "order by dt asc"
+			db_sql.eachRow(query) {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [(new Date(it.dt.getTime()-innerTimeFrameHalf)).toTimestamp().toString(),(new Date(it.dt.getTime()+innerTimeFrameHalf)).toTimestamp().toString(), it.vl]
+			}
+		}
+		
+			
+		if(graphToShow.timeFrameType == 'custom') {
+			cont += "<report>" + "\n"
+			cont += "\t<desc>" + graphToShow.name + "</desc>" + "\n"
+			cont += "\t<type>" + graphToShow.type + "</type>" + "\n"
+			cont += "\t<device>" + graphToShow.deviceId + "</device>" + "\n"
+			cont += "\t<timeframe>" + "\n"
+			cont += "\t\t<type>" + graphToShow.timeFrameType + "</type>" + "\n"
+			cont += "\t\t<start>" + graphToShow.timeFrameStart + "</start>" + "\n"
+			cont += "\t\t<end>" + graphToShow.timeFrameEnd + "</end>" + "\n"
+			cont += "\t\t<innernum>" + graphToShow.innerSections + "</innernum>" + "\n"
+			cont += "\t</timeframe>" + "\n"
+			cont += "\t<values>" + "\n"
+			detailedData.each {
+				cont += "\t\t<inner>" + "\n"
+				cont += "\t\t\t<start>" + it[0] + "</start>" + "\n"
+				cont += "\t\t\t<end>" + it[1] + "</end>" + "\n"
+				cont += "\t\t\t<value>" + it[2] + "</value>" + "\n"
+				cont += "\t\t</inner>" + "\n"
+			}
+			cont += "\t</values>" + "\n"
+			cont += "</report>" + "\n"
+		} else {
+			cont += "<report>" + "\n"
+			cont += "\t<desc>" + graphToShow.name + "</desc>" + "\n"
+			cont += "\t<type>" + graphToShow.type + "</type>" + "\n"
+			cont += "\t<device>" + graphToShow.deviceId + "</device>" + "\n"
+			cont += "\t<timeframe>" + "\n"
+			cont += "\t\t<type>" + graphToShow.timeFrameType + "</type>" + "\n"
+			cont += "\t\t<start>" + graphToShow.timeFrameStart + "</start>" + "\n"
+			cont += "\t\t<end>" + graphToShow.timeFrameEnd + "</end>" + "\n"
+			cont += "\t</timeframe>" + "\n"
+			cont += "\t<values>" + "\n"
+			detailedData.each {
+				cont += "\t\t<inner>" + "\n"
+				cont += "\t\t\t<time>" + it[0] + "</time>" + "\n"
+				cont += "\t\t\t<value>" + it[1] + "</value>" + "\n"
+				cont += "\t\t</inner>" + "\n"
+			}
+			cont += "\t</values>" + "\n"
+			cont += "</report>" + "\n"
+		}
+		
+		render(text: cont,contentType:"text/xml",encoding:"UTF-8")
+		
+	}
+	
+	def exportReportCsv = {
+		
+		def cont = ""
+		
+		def graphToShow = EneGraph.get(params['reportId'])
+		String query
+		
+		List data = new ArrayList()
+		List detailedData = new ArrayList()
+		def results
+		def innerTimeFrameHalf = 0;
+		def db_sql = new Sql(dataSource)
+		
+		if(graphToShow.timeFrameType == "day") {
+			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,10), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "month") {
+			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,7), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "year") {
+			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [it.dt.toString().substring(0,4), it.vl]
+			}
+		} else if (graphToShow.timeFrameType == "custom") {
+			def innerTimeFrame = (long)((graphToShow.timeFrameEnd.getTime() - graphToShow.timeFrameStart.getTime()) / graphToShow.innerSections)
+			innerTimeFrameHalf = (long)(innerTimeFrame/2)
+			query = ""
+			for(int i = 0; i < graphToShow.innerSections;i++) {
+				def currDateMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame) + innerTimeFrame/2
+				def currDate = new Date((long)currDateMillis)
+				def currDateStartMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame)
+				def currDateStart = new Date((long)currDateStartMillis)
+				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
+				def currDateStop = new Date((long)currDateStopMillis)
+				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
+				if (i < (graphToShow.innerSections-1) ) query += "union "
+			}
+			query += "order by dt asc"
+			db_sql.eachRow(query) {
+				data << [it.dt.getTime(), it.vl]
+				detailedData << [(new Date(it.dt.getTime()-innerTimeFrameHalf)).toTimestamp().toString(),(new Date(it.dt.getTime()+innerTimeFrameHalf)).toTimestamp().toString(), it.vl]
+			}
+		}
+		
+			
+		if(graphToShow.timeFrameType == 'custom') {
+			detailedData.each {
+				cont += it[0] + "," + it[1] + "," + it[2] + "\n"
+			}
+		} else {
+			detailedData.each {
+				cont += it[0] + "," + it[1] + "\n"
+			}
+		}
+		
+		render(text: cont,contentType:"text/csv",encoding:"UTF-8")
+		
+	}
 	
 }
Index: hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo.gsp	(revision 50)
@@ -0,0 +1,342 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="layout" content="main" />
+    <title>Simple PDF demo</title>
+    <style>
+      .code_table {
+        width:80%;
+        background-color:#b2b2b2;
+      }
+      .code_table tr {padding:2px;}
+      .code_table td {
+        padding:7px;
+        background-color: #fff;
+      }
+    </style>
+  </head>
+    <body>
+    <h1>Grails PDF Plugin demo page</h1>
+    
+    <h2>Tag Documentation / Live Examples / Functional Testing</h2>
+    <h3>pdfLink tag:</h3>
+    
+    <table class="code_table">
+      <thead>
+        <tr>
+          <th>Description</th>
+          <th>Sample Source/HTML output</th>
+          <th>In Action</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr><td colspan="3"><em>URL method examples:</em></td></tr>
+        <tr>
+          <td rowspan="2" >Simple Usage:</td>
+          <td>
+            <code>&lt;g:pdfLink url="/pdf/demo2"&gt;PDF View&lt;/g:pdfLink&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfLink url="/pdf/demo2">PDF View</g:pdfLink>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2"&gt;<br />
+            PDF View <br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2" >Simple Usage w/ Get data:</td>
+          <td>
+            <code>&lt;g:pdfLink url="/pdf/demo2/5?name=bob&age=22"&gt;PDF View&lt;/g:pdfLink&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfLink url="/pdf/demo2/5?name=bob&age=22">PDF View</g:pdfLink>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2%2F5%3Fname%3Dbob%26age%3D22"&gt;<br />
+            PDF View <br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2" >Custom filename</td>
+          <td>
+            <code>&lt;g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf"&gt;sample.pdf&lt;/g:pdfLink&gt;</code>
+          </td>
+          <td rowspan="2" > 
+            <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf">sample.pdf</g:pdfLink>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf"&gt;<br />
+            sample.pdf<br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2">Bundled icon</td>
+          <td>
+            <code>&lt;g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true"/&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true"/>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf"&gt; <br />
+            &lt;img border="0" alt="PDF Version" src="/pdf/images/pdf_button.png" /&gt; <br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2">Bundled icon w/ link content</td>
+          <td>
+            <code>&lt;g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true" class="myPdfLink"&gt;Custom link&lt;/g:pdfLink&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true" class="myPdfLink">Custom link</g:pdfLink>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="myPdfLink" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf"&gt; <br />
+            &lt;img border="0" alt="PDF Version" src="/pdf/images/pdf_button.png" /&gt; <br />
+            Custom link<br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr>
+        <tr><td colspan="3"><em>String method examples:</em></td></tr>
+  %{--  <tr>
+          <td rowspan="2" >Simple Template Usage:</td>
+          <td>
+            <code>&lt;g:pdfLink template="demo2"&gt;template as PDF&lt;/g:pdfLink&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfLink template="demo2">template as PDF</g:pdfLink>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?template=demo2&filename=document.pdf"&gt;<br />
+            PDF View <br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr> --}%
+        <tr>
+          <td rowspan="2" >Simple Controller Action Usage (action and id are optional):</td>
+          <td>
+            <code>&lt;g:pdfLink pdfController="pdf" pdfAction="demo2"&gt;GSP as PDF&lt;/g:pdfLink&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfLink pdfController="pdf" pdfAction="demo2">GSP as PDF</g:pdfLink>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?&pdfController=pdf&pdfAction=demo2"&gt;<br />
+            PDF View <br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2" >Simple Controller Action + Id Usage:</td>
+          <td>
+            <code>&lt;g:pdfLink pdfController="pdf" pdfAction="demo2" pdfId="65432"&gt;GSP as PDF&lt;/g:pdfLink&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfLink pdfController="pdf" pdfAction="demo2" pdfId="65432">GSP as PDF</g:pdfLink>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?&pdfController=pdf&pdfAction=demo2&pdfId=65432"&gt;<br />
+            PDF View <br />
+            &lt;/a&gt;
+            </code>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    
+    <h3>pdfForm tag:</h3>
+    <table class="code_table">
+      <thead>
+        <tr>
+          <th>Description</th>
+          <th>Sample Source/HTML output</th>
+          <th>In Action</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr><td colspan="3"><em>GET method examples:</em></td></tr>
+        <tr>
+          <td rowspan="2" >Simple Usage:</td>
+          <td>
+            <code>&lt;g:pdfForm url="/pdf/demo2"&gt;...&lt;/g:pdfForm&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfForm url="/pdf/demo2" >
+            name:<br />
+            <g:textField name="name" size="10"/>
+            <g:submitButton name="printPdf" value="pdf" />
+            </g:pdfForm>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;form id="simplePdfForm" method="get" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
+            &lt;input type="hidden" value="/pdf/demo2" name="url"/&gt;<br />
+            &lt;input type="hidden" value="document.pdf" name="filename"/&gt;<br />
+            ...<br /> 
+            &lt;/form&gt;</code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2" >w/ Id and Filename:</td>
+          <td>
+            <code>&lt;g:pdfForm url="/pdf/demo2/1968" filename="sample.pdf"&gt;...&lt;/g:pdfForm&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfForm url="/pdf/demo2/1968" filename="sample.pdf">
+            age:<br />
+            <g:textField name="age" size="3"/>
+            <g:submitButton name="printPdf" value="pdf" />
+            </g:pdfForm>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;form id="simplePdfForm" method="get" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
+            &lt;input type="hidden" value="/pdf/demo2/1968" name="url"/&gt;<br />
+            &lt;input type="hidden" value="sample.pdf" name="filename"/&gt;<br />
+            ...<br /> 
+            &lt;/form&gt;
+            </code>
+          </td>
+        </tr>
+        <tr><td colspan="3"><em>POST method examples:</em></td></tr>
+        <tr>
+          <td rowspan="2" >Controller and Action:</td>
+          <td>
+            <code>&lt;g:pdfForm controller="pdf" action="demo3" method="post"&gt;...&lt;/g:pdfForm&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfForm controller="pdf" action="demo3" method="post" >
+            food:<br />
+            <g:textField name="food" size="10"/>
+            <g:submitButton name="printPdf" value="pdf" />
+            </g:pdfForm>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
+            &lt;input type="hidden" value="pdf" name="pdfController"/&gt;<br />
+            &lt;input type="hidden" value="demo3" name="pdfAction"/&gt;<br />
+            &lt;input type="hidden" value="document.pdf" name="filename"/&gt;<br />
+            ...<br /> 
+            &lt;/form&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2" >Controller, Action, Id and Filename:</td>
+          <td>
+            <code>&lt;g:pdfForm controller="pdf" action="demo3" method="post"&gt;...&lt;/g:pdfForm&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfForm controller="pdf" action="demo3" id="1942" method="post" filename="sample.pdf" >
+            food:<br />
+            <g:textField name="food" size="10"/>
+            <g:submitButton name="printPdf" value="pdf" />
+            </g:pdfForm>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
+            &lt;input type="hidden" value="pdf" name="pdfController"/&gt;<br />
+            &lt;input type="hidden" value="demo3" name="pdfAction"/&gt;<br />
+            &lt;input type="hidden" value="document.pdf" name="filename"/&gt;<br />
+            ...<br /> 
+            &lt;/form&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2" >Template:</td>
+          <td>
+            <code>&lt;g:pdfForm template="demo2" &gt;...&lt;/g:pdfForm&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfForm template="demo2" method="post">
+            hometown:<br />
+            <g:textField name="hometown" size="10"/>
+            <g:submitButton name="printPdf" value="pdf" />
+            </g:pdfForm>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm2" name="simplePdfForm"&gt;<br />
+            &lt;input type="hidden" value="demo2" name="template"/&gt;<br />
+            ...<br /> 
+            &lt;/form&gt;
+            </code>
+          </td>
+        </tr>
+        <tr>
+          <td rowspan="2" >Template and Filename:</td>
+          <td>
+            <code>&lt;g:pdfForm template="demo2" filename="sample.pdf"&gt;...&lt;/g:pdfForm&gt;</code>
+          </td>
+          <td rowspan="2">
+            <g:pdfForm template="demo2" filename="sample.pdf" method="post">
+            hometown:<br />
+            <g:textField name="hometown" size="10"/>
+            <g:submitButton name="printPdf" value="pdf" />
+            </g:pdfForm>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <code>
+            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm2" name="simplePdfForm"&gt;<br />
+            &lt;input type="hidden" value="demo2" name="template"/&gt;<br />
+            &lt;input type="hidden" value="sample.pdf" name="filename"/&gt;<br />
+            ...<br /> 
+            &lt;/form&gt;
+            </code>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+  </body>
+</html>
Index: hci/trunk/eneraptor-web-app/grails-app/views/pdf/_demo2.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/pdf/_demo2.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/pdf/_demo2.gsp	(revision 50)
@@ -0,0 +1,79 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <title>Simple PDF demo2</title>
+    <style>
+      .sample_table {
+        width:60%;
+        background-color:#b2b2b2;
+      }
+      .sample_table th {
+        text-align:center;
+        text-decoration:underline;
+      }
+      .sample_table td {
+        padding:7px;
+        background-color: #fff;
+      }
+      .small_text {
+        font-size:8pt;
+      }
+    </style>
+  </head>
+  <body>
+    <h1>Sample PDF Output</h1>
+    <h2>This is simple HTML</h2>
+    <h2 style='color:red'>this has inline CSS</h2>
+    
+    <h3>Here is some data passed from the contorller...</h3>
+    <p>Information gathered from the controller: ${randomString}</p>
+    
+    <h3>Here is some information sent in the URL and handled by a controller (get variables):</h3>
+    <table class="sample_table">
+      <thead>
+        <tr>
+          <th>ID</th>
+          <th>Name</th>
+          <th>Age</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>${id}</td>
+          <td>${name}</td>
+          <td>${age}</td>
+        </tr>
+        <tr>
+          <td colspan="3" class="small_text">styled with css...</td>
+        </tr>
+      </tbody>
+    </table> 
+    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
+    
+    <form>
+      <p>checkbox:
+    %{--	checkboxes used to cause an error in pdf generation, but now they simply don't show up...   --}%
+        <input type="checkbox" checked="checked" name="sample_box" title="sample_box" /> 
+      </p>
+  %{--    text field sample   --}%
+      <p>Text Input:
+       <input name="textField" />
+      </p>
+    </form>
+    
+    <h3>Here is some information gathered from a form and handled grails render method (post variables):</h3>
+    <p>Favorite food: ${pdf?.food}</p>
+    <p>Favorite food: ${pdf?.food.toString()}</p>
+    <p>Hometown: ${pdf?.hometown}</p> 
+    
+    <p>${pdf}</p>
+    
+    <p>Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin</p>
+    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
+    
+    <p>Images with absolute URI's also do just fine:</p>
+    <img src="http://system76.com/images/nb1_front_med.jpg" alt="laptop2" title="laptop2" />
+    
+    <p><strong>Hint:</strong> One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.</p>
+  </body>
+</html>
Index: hci/trunk/eneraptor-web-app/grails-app/views/pdf/sampleInclude.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/pdf/sampleInclude.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/pdf/sampleInclude.gsp	(revision 50)
@@ -0,0 +1,10 @@
+<html>
+  <head>
+  </head>
+  <body>
+    <h1>hello world!</h1>
+    <p>${bar}</p>
+    <p>${today}</p>
+    <p>${tomorrow}</p>
+  </body>
+</html>
Index: hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo2.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo2.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo2.gsp	(revision 50)
@@ -0,0 +1,73 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <title>Simple PDF demo2</title>
+    <style>
+      .sample_table {
+        width:60%;
+        background-color:#b2b2b2;
+      }
+      .sample_table th {
+        text-align:center;
+        text-decoration:underline;
+      }
+      .sample_table td {
+        padding:7px;
+        background-color: #fff;
+      }
+      .small_text {
+        font-size:8pt;
+      }
+    </style>
+  </head>
+  <body>
+    <h1>Sample PDF Output</h1>
+    <h2>This is simple HTML</h2>
+    <h2 style='color:red'>this has inline CSS</h2>
+    
+    <h3>Here is some data passed from the contorller...</h3>
+    <p>Information gathered from the controller: ${randomString}</p>
+    
+    <h3>Here is some information sent in the URL and handled by a controller (get variables):</h3>
+    <table class="sample_table">
+      <thead>
+        <tr>
+          <th>ID</th>
+          <th>Name</th>
+          <th>Age</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>${id}</td>
+          <td>${name}</td>
+          <td>${age}</td>
+        </tr>
+        <tr>
+          <td colspan="3" class="small_text">styled with css...</td>
+        </tr>
+      </tbody>
+    </table> 
+    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
+    
+    <form>
+      <p>checkbox:
+    %{--	checkboxes used to cause an error in pdf generation, but now they simply don't show up...   --}%
+        <input type="checkbox" checked="checked" name="sample_box" title="sample_box" /> 
+      </p>
+  %{--    text field sample   --}%
+      <p>Text Input:
+       <input name="textField" />
+      </p>
+    </form>
+    
+    
+    <p>Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin</p>
+    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
+    
+    <p>Images with absolute URI's also do just fine:</p>
+    <img src="http://system76.com/images/nb1_front_med.jpg" alt="laptop2" title="laptop2" />
+    
+    <p><strong>Hint:</strong> One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.</p>
+  </body>
+</html>
Index: hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo3.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo3.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo3.gsp	(revision 50)
@@ -0,0 +1,73 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="layout" content="main" />
+    <title>Simple PDF demo2</title>
+    <style>
+      .sample_table {
+        width:60%;
+        background-color:#b2b2b2;
+      }
+      .sample_table th {
+        text-align:center;
+        text-decoration:underline;
+      }
+      .sample_table td {
+        padding:7px;
+        background-color: #fff;
+      }
+      .small_text {
+        font-size:8pt;
+      }
+    </style>
+  </head>
+  <body>
+    <h1>Sample PDF Output</h1>
+    <h2>This is simple HTML</h2>
+    <h2 style='color:red'>this has inline CSS</h2>
+    
+    <h3>Here is some data passed from the contorller...</h3>
+    <p>Information gathered from the controller: ${randomString}</p>
+    
+    <h3>Here is some information sent in the URL and handled by a controller (get variables):</h3>
+    <table class="sample_table">
+      <thead>
+        <tr>
+          <th>ID</th>
+          <th>Name</th>
+          <th>Age</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>${id}</td>
+          <td>${name}</td>
+          <td>${age}</td>
+        </tr>
+        <tr>
+          <td colspan="3" class="small_text">styled with css...</td>
+        </tr>
+      </tbody>
+    </table> 
+    
+    <h3>Here is some information gathered from a form and handled by a controller (post variables):</h3>
+    <p>Favorite food: ${pdf?.food}</p>
+    <p>Favorite food: ${pdf?.food.toString()}</p>
+    <p>Hometown: ${pdf?.hometown}</p> 
+    
+    <p>${pdf}</p>
+    
+    <p>Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin</p>
+    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
+    
+    <p>Images with absolute URI's also do just fine:</p>
+    <img src="http://system76.com/images/nb1_front_med.jpg" alt="laptop2" title="laptop2" />
+    
+    <p><strong>Hint:</strong> One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.</p>
+    
+    <p>Varialbles passed into gsp that the plugin will render as PDF need to start with pdf. so for example the form field name was hometown and to reference that varialbe here we needed {pdf.hometown}</p>
+    <code>
+      ${content}
+    </code>
+  </body>
+</html>
Index: hci/trunk/eneraptor-web-app/grails-app/views/pdf/reportToPdf.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/pdf/reportToPdf.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/pdf/reportToPdf.gsp	(revision 50)
@@ -0,0 +1,72 @@
+<html>
+
+<head>
+	<title>Report</title>
+	<style>
+	body {
+		font-family: monospace;
+		font-size: small;
+	}
+	table {
+		width:100%;
+	}
+	</style>
+</head>
+
+<body>
+
+	<h1>${graph.name}</h1>
+	<h2>Report info</h2>
+	
+	<p>Type: <b>${graph.type}</b> / <b>${graph.timeFrameType}</b><br />
+	From <b>${graph.timeFrameStart}</b> till <b>${graph.timeFrameEnd}</b><br />
+	Device ID: <b>${graph.deviceId}</b></p>
+	
+	<h2>Report data</h2>
+	
+	<g:if test="${graph.timeFrameType == 'custom'}">
+		<table>
+			<thead>
+				<tr>
+					<th>From</th>
+					<th>Till</th>
+					<th>Value (${graph.type})</th>
+					<th>Rounded</th>
+				</tr>
+			</thead>
+			<tbody>
+				<g:each in="${detailedData}" var="dent">
+					<tr>
+						<td>${dent[0]}</td>
+						<td>${dent[1]}</td>
+						<td>${dent[2]}</td>
+						<td>${((double)dent[2]).round(1)}</td>
+					</tr>
+				</g:each>
+			</tbody>
+		</table>
+	</g:if>
+	<g:else>
+		<table>
+			<thead>
+				<tr>
+					<th>Time</th>
+					<th>Value (${graph.type})</th>
+					<th>Rounded</th>
+				</tr>
+			</thead>
+			<tbody>
+				<g:each in="${detailedData}" var="dent">
+					<tr>
+						<td>${dent[0]}</td>
+						<td>${dent[1]}</td>
+						<td>${((double)dent[1]).round(1)}</td>
+					</tr>
+				</g:each>
+			</tbody>
+		</table>
+	</g:else>
+
+</body>
+
+</html>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/sysLog/graph.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/sysLog/graph.gsp	(revision 49)
+++ hci/trunk/eneraptor-web-app/grails-app/views/sysLog/graph.gsp	(revision 50)
@@ -30,7 +30,11 @@
 	<erptr:box title="Graphical representation of logged data">
 		<g:javascript>
 			var data = [${data}];
-			var options = { lines: { show: true }, points: { show: true } };
+			var options = {
+				lines: { show: true },
+				points: { show: true },
+				xaxis: { mode: "time", timeformat: "%y/%m/%d %H:%M" }
+			};
 		</g:javascript>
 		<div class="chart">
 			<flot:plot id="placeholder" style="width: 900px; height: 300px; padding:5px;" data="data" options="options" />
Index: hci/trunk/eneraptor-web-app/grails-app/views/statistics/graphs.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/statistics/graphs.gsp	(revision 49)
+++ hci/trunk/eneraptor-web-app/grails-app/views/statistics/graphs.gsp	(revision 50)
@@ -15,16 +15,21 @@
 					<th><p>Graph name (short description)</p></th>
 					<th><p>For device</p></th>
 					<th><p>Type</p></th>
-					<th><p>Options</p></th>
+					<th style="width:78px;"><p>Options</p></th>
 				</tr>
 			</thead>
 			<tbody>
 				<g:each in="${savedGraphs}" var="savedGraph">
 					<tr>
-						<td><p><erptr:icon w="chart_curve" /><g:link action="showGraph" params="[graphId: savedGraph.id]">${savedGraph.name}</g:link></p></td>
+						<td><p><erptr:icon w="chart_curve" /><g:link action="showGraph" id="${savedGraph.id}" >${savedGraph.name}</g:link></p></td>
 						<td><p>${savedGraph.deviceId}</p></td>
 						<td><p>${savedGraph.type}</p></td>
-						<td><p>TODO</p></td>
+						<td><p>
+							<g:link action="showGraph" id="${savedGraph.id}" title="View graph only" ><erptr:icon w="chart_line" /></g:link>
+							<g:link action="makeReport" id="${savedGraph.id}" title="Make report" ><erptr:icon w="report" /></g:link>
+							<g:link action="editGraph" id="${savedGraph.id}" title="Edit" ><erptr:icon w="pencil" /></g:link>
+							<g:link action="deleteGraph" id="${savedGraph.id}" title="Delete" ><erptr:icon w="delete" /></g:link>
+						</p></td>
 					</tr>
 				</g:each>
 			</tbody>
Index: hci/trunk/eneraptor-web-app/grails-app/views/statistics/main.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/statistics/main.gsp	(revision 49)
+++ hci/trunk/eneraptor-web-app/grails-app/views/statistics/main.gsp	(revision 50)
@@ -8,7 +8,9 @@
 <body>
 	
 	<erptr:box title="Statistics">
-		<p>TODO</p>
+		<p>Here you can view different information gathered by Eneraptor.</p>
+		<p>You can create many types of graphs (charts) and reports, which you can export.</p>
+		<p>Once you <g:link action="newGraph">create a new graph</g:link>, you can find it in the <g:link action="graphs">Graphs and reports</g:link> section. There you can either view it, modify it, delete it or create a report from it.</p>
 	</erptr:box>
 
 </body>
Index: hci/trunk/eneraptor-web-app/grails-app/views/statistics/newReport.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/statistics/newReport.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/statistics/newReport.gsp	(revision 50)
@@ -0,0 +1,27 @@
+<html>
+
+<head>
+	<title>Statistics &raquo; Reports</title>
+	<meta name="layout" content="main" />
+</head>
+
+<body>
+	
+	<erptr:box title="Statistics">
+		<p>Reports are created automatically from graphs.</p>
+		<br />
+		<p>Please choose a graph to make report from:</p>
+		
+		<g:form method="GET" name="newReportForm" action="makeReport">
+			<g:select name="id" from="${graphs}" keys="${graphsKeys}" style="width:600px;" />
+			<br /><br />
+			
+			<g:submitButton name="newReportSubmit" value="View report" />
+			
+		</g:form>
+		
+	</erptr:box>
+
+</body>
+
+</html>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/statistics/editGraph.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/statistics/editGraph.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/statistics/editGraph.gsp	(revision 50)
@@ -0,0 +1,109 @@
+<html>
+
+<head>
+	<title>Statistics &raquo; Edit graph</title>
+	<meta name="layout" content="main" />
+	<flot:resources />
+</head>
+
+<body>
+
+	<erptr:box title="Edit graph">
+		
+		<g:form name="editGraphForm" action="editGraphDo">
+		
+			<fieldset>
+				<legend>General information</legend>
+				
+				<label for="graphName">Graph name (short description)</label>
+				<g:textField name="graphName" style="width:500px;" value="${graph.name}" />
+				<br /><br />
+				<label for="deviceId">Device</label>
+				<g:select name="deviceId" from="${devicesFriendly}" keys="${devices}" value="${graph.deviceId}" />
+				<br /><br />
+				
+			</fieldset>
+			
+			<fieldset>
+				<legend>Graph type</legend>
+				
+				<label for="graphType">Calculation type</label>
+				<g:select from="${graphTypesFriendly}" value="${graph.type}" name="graphType" keys="${graphTypes}" />
+				<br /><br />
+			
+				<label for="timeFrameType">Time frame type</label>
+				<g:select name="timeFrameType" from="['Daily','Monthly','Yearly','Custom']" keys="['day','month','year','custom']" value="${graph.timeFrameType}" />
+				<br /><br />
+				
+			</fieldset>
+			
+			<fieldset>
+				<legend>Main time frame</legend>
+				
+				<label for="mainTimeFrameStart">From</label>
+				<g:datePicker name="mainTimeFrameStart" value="${graph.timeFrameStart}" />
+				<br /><br />
+				<label for="mainTimeFrameEnd">From</label>
+				<g:datePicker name="mainTimeFrameEnd" value="${graph.timeFrameEnd}" />
+				<br /><br />
+				<label for="mainTimeFrameInnerSections">Number of inner intervals</label>
+				<input onkeyup="checkInnerSections();" type="text" id="mainTimeFrameInnerSections" name="mainTimeFrameInnerSections" value="${graph.innerSections}" />
+				<br /><br />
+				
+			</fieldset>
+			
+			<fieldset>
+				<legend>Advanced options</legend>
+				
+				<label for="advHoursStart">Include only hours from</label>
+				<g:select name="advHoursStart" from="${0..23}" value="${graph.advHoursTimeFrameStart}" />
+				<span> to </span>
+				<g:select name="advHoursEnd" from="${0..23}" value="${graph.advHoursTimeFrameEnd}" />
+				<br /><br />
+				<label for="advDayStart">Include only days from</label>
+				<g:select name="advDayStart" from="${1..31}" value="${graph.advDayTimeFrameStart}" />
+				<span> to </span>
+				<g:select name="advDayEnd" from="${1..31}" value="${graph.advDayTimeFrameEnd}" />
+				<br /><br />
+				<label for="advMonthStart">Include only months from</label>
+				<g:select name="advMonthStart" from="${1..12}" value="${graph.advMonthTimeFrameStart}" />
+				<span> to </span>
+				<g:select name="advMonthEnd" from="${1..12}" value="${graph.advMonthTimeFrameEnd}" />
+				<br /><br />
+				
+			</fieldset>
+			
+			<g:hiddenField name="graphId" type="hidden" value="${graph.id}" />
+			
+			<g:submitButton name="editGraphSubmit" value="Save changes" />
+			<g:actionSubmit name="editGraphCancel" value="Cancel" action="graphs" />
+		
+		</g:form>
+		
+	</erptr:box>
+	
+	<g:javascript>
+		function checkInnerSections() {
+			var sText = $('mainTimeFrameInnerSections').value;
+			var validChars = "0123456789";
+			var isNumber = true;
+			var currChar;
+					 
+			for (i = 0; i < sText.length; i++) { 
+				currChar = sText.charAt(i); 
+				if (validChars.indexOf(currChar) == -1) {
+					isNumber = false;
+					break;
+				}
+			}
+			
+			if(isNumber == false) {
+				$('mainTimeFrameInnerSections').value = sText.substring(0,(sText.length)-1)
+			}
+			
+		}
+	</g:javascript>
+
+</body>
+
+</html>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/statistics/makeReport.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/statistics/makeReport.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/statistics/makeReport.gsp	(revision 50)
@@ -0,0 +1,101 @@
+<html>
+
+<head>
+	<title>Statistics &raquo; Report</title>
+	<meta name="layout" content="main" />
+	<flot:resources />
+</head>
+
+<body>
+
+	<erptr:box title="Report info">
+	
+		<p>Description: <b>${graph.name}</b></p>
+		<p>Type: <b>${graph.type}</b> / <b>${graph.timeFrameType}</b></p>
+		<p>From <b>${graph.timeFrameStart}</b> till <b>${graph.timeFrameEnd}</b></p>
+		<p>Device ID: <b>${graph.deviceId}</b></p>
+	
+	</erptr:box>
+	
+	<erptr:box title="Graph">
+
+		<g:javascript>
+			var data = [${data}];
+			var options = {
+				lines: { show: true },
+				points: { show: true },
+				xaxis: { mode: "time", timeformat: "%y/%m/%d %H:%M" }
+			};
+		</g:javascript>
+		<div class="chart">
+			<flot:plot id="placeholder" style="width: 900px; height: 300px; padding:5px;" data="data" options="options" />
+		</div>		
+
+	</erptr:box>
+
+	<erptr:box title="Report data">
+	
+		<g:if test="${graph.timeFrameType == 'custom'}">
+			<table>
+				<thead>
+					<tr>
+						<th><p>From</p></th>
+						<th><p>Till</p></th>
+						<th><p>Value (${graph.type})</p></th>
+						<th><p>Rounded</p></th>
+					</tr>
+				</thead>
+				<tbody>
+					<g:each in="${detailedData}" var="dent">
+						<tr>
+							<td><p>${dent[0]}</p></td>
+							<td><p>${dent[1]}</p></td>
+							<td><p>${dent[2]}</p></td>
+							<td><p>${((double)dent[2]).round(1)}</p></td>
+						</tr>
+					</g:each>
+				</tbody>
+			</table>
+		</g:if>
+		<g:else>
+			<table>
+				<thead>
+					<tr>
+						<th><p>Time</p></th>
+						<th><p>Value (${graph.type})</p></th>
+						<th><p>Rounded</p></th>
+					</tr>
+				</thead>
+				<tbody>
+					<g:each in="${detailedData}" var="dent">
+						<tr>
+							<td><p>${dent[0]}</p></td>
+							<td><p>${dent[1]}</p></td>
+							<td><p>${((double)dent[1]).round(1)}</p></td>
+						</tr>
+					</g:each>
+				</tbody>
+			</table>
+		</g:else>
+	
+	</erptr:box>
+	
+	<erptr:box title="Export (save) report">
+	
+		<g:form method="GET" name="exportReportForm" action="exportReport" target="_blank">
+		
+			<label for="exportType">Export type</label>
+			<g:select name="exportType" from="['Portable document format (.pdf)','Extensible markub language (.xml)','Comma-separated values (.csv)']" keys="['pdf','xml','csv']"></g:select>
+			<br /><br />
+			
+			<g:hiddenField name="reportId" value="${graph.id}" />
+			
+			<g:submitButton name="exportReportSubmit" value="Export" />
+		
+		</g:form>
+	
+	</erptr:box>
+
+</body>
+
+</html>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/statistics/newGraph.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/statistics/newGraph.gsp	(revision 49)
+++ hci/trunk/eneraptor-web-app/grails-app/views/statistics/newGraph.gsp	(revision 50)
@@ -29,10 +29,10 @@
 			
 				<label for="timeFrameType">Time frame type</label>
 				<select name="timeFrameType" id="timeFrameType" >				
-					<option onclick="changeTimeFrameType('day')" value="day" selected="${timeFrameType == 'day'}">Daily</option>
-					<option onclick="changeTimeFrameType('month')" value="month" selected="${timeFrameType == 'month'}">Monthly</option>
-					<option onclick="changeTimeFrameType('year')" value="year" selected="${timeFrameType == 'year'}">Yearly</option>
-					<option onclick="changeTimeFrameType('custom')" value="custom" selected="${timeFrameType == 'custom'}">Custom</option>
+					<option onclick="changeTimeFrameType('day')" value="day" >Daily</option>
+					<option onclick="changeTimeFrameType('month')" value="month" >Monthly</option>
+					<option onclick="changeTimeFrameType('year')" value="year" >Yearly</option>
+					<option onclick="changeTimeFrameType('custom')" value="custom" >Custom</option>
 				</select>
 				<br />
 				
Index: hci/trunk/eneraptor-web-app/.classpath
===================================================================
--- hci/trunk/eneraptor-web-app/.classpath	(revision 49)
+++ hci/trunk/eneraptor-web-app/.classpath	(revision 50)
@@ -31,56 +31,31 @@
 			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry excluding="BuildConfig.groovy|*DataSource.groovy|UrlMappings.groovy|Config.groovy|BootStrap.groovy|spring/resources.groovy" kind="src" path="shiro-1.1.2-grails-app-conf">
+	<classpathentry kind="src" path="pdf-0.6-grails-app-controllers">
 		<attributes>
 			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-grails-app-controllers">
+	<classpathentry kind="src" path="pdf-0.6-grails-app-i18n">
 		<attributes>
 			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-grails-app-domain">
+	<classpathentry kind="src" path="pdf-0.6-grails-app-services">
 		<attributes>
 			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-grails-app-i18n">
+	<classpathentry kind="src" path="pdf-0.6-grails-app-taglib">
 		<attributes>
 			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-grails-app-realms">
+	<classpathentry kind="src" path="pdf-0.6-grails-app-views">
 		<attributes>
 			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-grails-app-services">
-		<attributes>
-			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-grails-app-taglib">
-		<attributes>
-			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-grails-app-views">
-		<attributes>
-			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-src-java">
-		<attributes>
-			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="src" path="shiro-1.1.2-src-groovy">
-		<attributes>
-			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
-		</attributes>
-	</classpathentry>
 	<classpathentry kind="src" path="tomcat-1.3.6-src-groovy">
 		<attributes>
 			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
