MTrackWeb/Timeline.php
[web.mtrack] / MTrackWeb / Timeline.php
1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
3
4
5
6
7 require_once 'MTrack/Attachment.php';
8 require_once 'MTrackWeb.php';
9
10 class MTrackWeb_Timeline extends MTrackWeb
11 {
12         
13     
14     var $title = 'Timeline';
15     
16      var $start_time = '-2 weeks';
17     var $limit = 50;
18     // fixme = this should be alot more efficient...
19     
20      
21     
22     
23     function get($only_users)
24     {
25         
26         
27         if (!isset($_REQUEST['ajax_body'])) {
28             return;
29         }
30         
31         
32         $this->masterTemplate = 'timeline.html';
33         // perms... 
34         $pid = $this->currentProject();
35         //DB_DataObject::debugLevel(1);
36         
37         $e = DB_DataObject::factory('mtrack_change');
38         $e->orderBy('changedate DESC');
39         $e->limit(50);
40         
41         $e->whereAdd("
42             ( ontable='mtrack_ticket' AND
43                 onid IN (SELECT id FROM mtrack_ticket where project_id = $pid)
44             )
45         ");
46         $ar = $e->fetchAll();
47         $this->events = array();
48         //$this->hist= array();
49         $last_day  =false;
50         foreach($ar as $i=>$h) {
51             $h->cls = $i % 2 ? 'odd' : '';
52         
53             $ts = strtotime($h->changedate);
54             $day = date('D, M d Y', $ts);
55             $time = date('g:ia', $ts);
56             //print_r($ent);
57             if ($day !== $last_day) {
58                 $this->events[] = (object) array(
59                     'isday' => 1,
60                     'day' => $day
61                 );
62             }
63             $h->time = $time;
64                 
65             $last_day = $day;
66             $M = array();
67            
68              
69        
70     
71             $this->events[] = $h;
72         }
73         
74          
75          
76     
77     }
78      
79
80 }
81