6
6
7
7
use GuzzleHttp \Psr7 \ServerRequest ;
8
8
use Icinga \Module \Reporting \Database ;
9
+ use Icinga \Module \Reporting \Model \Report ;
9
10
use Icinga \Module \Reporting \Web \Controller ;
10
11
use Icinga \Module \Reporting \Web \Forms \ReportForm ;
11
12
use Icinga \Module \Reporting \Web \ReportsTimeframesAndTemplatesTabs ;
12
13
use ipl \Html \Html ;
13
- use ipl \Sql \Select ;
14
14
use ipl \Web \Url ;
15
15
use ipl \Web \Widget \ButtonLink ;
16
16
use ipl \Web \Widget \Icon ;
@@ -35,19 +35,24 @@ public function indexAction()
35
35
36
36
$ tableRows = [];
37
37
38
- $ select = (new Select ())
39
- ->from ('report r ' )
40
- ->columns (['r.* ' , 'timeframe ' => 't.name ' ])
41
- ->join ('timeframe t ' , 'r.timeframe_id = t.id ' )
42
- ->orderBy ('r.mtime ' , SORT_DESC );
38
+ $ reports = Report::on ($ this ->getDb ())
39
+ ->withColumns (['report.timeframe.name ' ]);
43
40
44
- foreach ($ this ->getDb ()->select ($ select ) as $ report ) {
41
+ $ sortControl = $ this ->createSortControl (
42
+ $ reports ,
43
+ [
44
+ 'name ' => t ('Name ' ),
45
+ 'author ' => t ('Author ' )
46
+ ]
47
+ );
48
+
49
+ foreach ($ reports as $ report ) {
45
50
$ url = Url::fromPath ('reporting/report ' , ['id ' => $ report ->id ])->getAbsoluteUrl ('& ' );
46
51
47
52
$ tableRows [] = Html::tag ('tr ' , ['href ' => $ url ], [
48
53
Html::tag ('td ' , null , $ report ->name ),
49
54
Html::tag ('td ' , null , $ report ->author ),
50
- Html::tag ('td ' , null , $ report ->timeframe ),
55
+ Html::tag ('td ' , null , $ report ->timeframe -> name ),
51
56
Html::tag ('td ' , null , date ('Y-m-d H:i ' , $ report ->ctime / 1000 )),
52
57
Html::tag ('td ' , null , date ('Y-m-d H:i ' , $ report ->mtime / 1000 )),
53
58
Html::tag ('td ' , ['class ' => 'icon-col ' ], [
@@ -88,6 +93,7 @@ public function indexAction()
88
93
} else {
89
94
$ this ->addContent (Html::tag ('p ' , null , 'No reports created yet. ' ));
90
95
}
96
+ $ this ->addControl ($ sortControl );
91
97
}
92
98
93
99
public function newAction ()
0 commit comments