final move of files
[web.mtrack] / MTrackWeb / Reports.php
1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
3
4 require_once 'MTrackWeb.php';
5  
6 class MTrackWeb_Reports extends MTrackWeb
7 {
8     var $template = 'reports.html';
9  
10     var $title = "Reports";
11  
12     function getAuth() 
13     {
14         parent::getAuth();
15         require_once 'MTrack/ACL.php';
16         MTrackACL::requireAllRights('Reports', 'read');
17         return true;
18     }
19     
20     function get($pi=0)
21     {
22         $q = MTrackDB::q("select rid, summary from reports order by rid");
23         $this->rows = $q->fetchAll(PDO::FETCH_OBJECT);
24         $this->canCreate = MTrackACL::hasAllRights('Reports', 'create');
25          
26     }
27 }
28
29
30         ?>
31 <h1>Available Reports</h1>
32
33 <p>
34   The reports below are constructed using SQL.  You may also
35   use the <a href="<?php echo $ABSWEB ?>query.php">Custom Query</a>
36   page to create a report on the fly.
37 </p>
38
39 <table>
40 <tr>
41   <th>Report</th>
42   <th>Title</th>
43 </tr>
44 <?php
45 foreach (MTrackDB::q("select rid, summary from reports order by rid"
46     )->fetchAll(PDO::FETCH_ASSOC) as $row)
47 {
48   $url = "${ABSWEB}report.php/$row[rid]";
49   $t = "<a href='$url'>{" . $row['rid'] . "}</a>";
50   $s = htmlentities($row['summary'], ENT_COMPAT, 'utf-8');
51   $s = "<a href='$url'>$s</a>";
52
53   echo <<<HTML
54 <tr><td>$t</td><td>$s</td></tr>
55 HTML;
56 }
57 ?>
58 </table>
59 <?php
60 if (MTrackACL::hasAllRights('Reports', 'create')) {
61 ?>
62 <form action="report.php" method="get">
63 <button type="submit" name="edit">Create Report</button>
64 </form>
65 <?php
66 }
67
68 mtrack_foot();
69