1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
7 require_once 'MTrack/Attachment.php';
8 require_once 'MTrackWeb.php';
10 class MTrackWeb_Timeline extends MTrackWeb
14 var $title = 'Timeline';
16 var $start_time = '-2 weeks';
18 // fixme = this should be alot more efficient...
23 function get($only_users)
27 if (!isset($_REQUEST['ajax_body'])) {
32 $this->masterTemplate = 'timeline.html';
34 $pid = $this->currentProject();
35 //DB_DataObject::debugLevel(1);
39 $e = DB_DataObject::factory('mtrack_change');
40 $e->orderBy('changedate DESC');
42 $start = empty($_REQUEST['from_date']) ? date('Y-m-01') :
43 date('Y-m-01', strtotime($_REQUEST['from_date']));
45 if (!empty($_REQUEST['viewtype']) && $_REQUEST['viewtype'] = 'summary') {
46 DB_DataObject::debugLevel(1);
48 $e->whereAdd("changedate >= '$start 00:00:00' AND changedate < '$start 00:00:00' + INTERVAL 1 MONTH");
50 $e->joinAdd(DB_DataObject::factory('Person'), 'LEFT');
52 DATE_FORMAT(changedate, '%Y-%m-%d') as changeday,
56 $e->groupBy("changeday,id,name");
57 $e->orderBy('changeday desc, name asc');
61 $ret[] = $e->toArray();
67 $e->whereAdd("changedate >= '$start 00:00:00' AND changedate < '$start 00:00:00' + INTERVAL 3 DAY");
72 ( ontable='mtrack_ticket' AND
73 onid IN (SELECT id FROM mtrack_ticket where project_id = $pid)
76 ( ontable='mtrack_repos' AND
77 onid IN (SELECT id FROM mtrack_repos where project_id = $pid)
86 $this->events = array();
87 //$this->hist= array();
89 foreach($ar as $i=>$h) {
90 $h->cls = $i % 2 ? 'odd' : '';
92 $ts = strtotime($h->changedate);
93 $day = date('D, M d Y', $ts);
94 $time = date('g:ia', $ts);
99 if ($day !== $last_day) {
100 $add['first_of_day'] = 1;
104 $add['person_id_name'] = $p->name;
105 $add['person_id_email'] = $p->email;
106 $add['audit'] = $h->cachedAuditToString();
107 $add['audit_ar'] = $h->cachedAuditToJSONArray();
108 // add the underlying object..
109 $add = array_merge($add, $h->objectCached()->toArray('object_%s'));
117 $this->events[] = $add;
121 $this->jdata($this->events);