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 $start_day = empty($_REQUEST['from_date']) ? date('Y-m-d') :
46 date('Y-m-d', strtotime($_REQUEST['from_date']));
49 ( ontable='mtrack_ticket' AND
50 onid IN (SELECT id FROM mtrack_ticket where project_id = $pid)
53 ( ontable='mtrack_repos' AND
54 onid IN (SELECT id FROM mtrack_repos where project_id = $pid)
58 if (!empty($_REQUEST['viewtype']) && $_REQUEST['viewtype'] == 'summary') {
59 //DB_DataObject::debugLevel(1);
61 $e->whereAdd("changedate >= '$start 00:00:00' AND changedate < '$start 00:00:00' + INTERVAL 1 MONTH");
63 $e->joinAdd(DB_DataObject::factory('Person'), 'LEFT');
65 DATE_FORMAT(changedate, '%Y-%m-%d') as changeday,
66 CONCAT(DATE_FORMAT(changedate, '%Y-%m-%d-') ,Person.id) as id,
68 COUNT(mtrack_change.id) as nchanges
70 $e->groupBy("changeday,id,name");
71 $e->orderBy('changeday desc, name asc');
75 $ret[] = $e->toArray();
81 $e->whereAdd("changedate >= '$start_day 00:00:00' AND
82 changedate < '$start_day 00:00:00' + INTERVAL 1 DAY");
84 //DB_DataObject::debugLevel(1);
93 $this->events = array();
94 //$this->hist= array();
96 foreach($ar as $i=>$h) {
97 $h->cls = $i % 2 ? 'odd' : '';
99 $ts = strtotime($h->changedate);
100 $day = date('D, M d Y', $ts);
101 $time = date('g:ia', $ts);
104 $add = $h->toArray();
106 if ($day !== $last_day) {
107 $add['first_of_day'] = 1;
111 $add['person_id_name'] = $p->name;
112 $add['person_id_email'] = $p->email;
113 $add['audit'] = $h->cachedAuditToString();
114 $add['audit_ar'] = $h->cachedAuditToJSONArray();
115 // add the underlying object..
116 $add = array_merge($add, $h->objectCached()->toArray('object_%s'));
124 $this->events[] = $add;
127 $total = count($this->events);
128 $extra = !$total ? array() : array(
129 'metaData' => $this->meta($e, $this->events)
134 $this->jdata($this->events, $total, $extra);
141 * this is a very simple version of the main one in roo.php
143 function meta($x, $data)
145 // this is not going to work on queries where the data does not match the database def..
146 // for unknown columns we send them as stirngs..
148 $cols = array_keys($data[0]);
154 $options = HTML_FlexyFramework::get()->DB_DataObject;
155 //echo '<PRE>';print_r($options); exit;
156 $reader = $options["ini_{$x->_database}"] .'.reader';
157 if (!file_exists( $reader )) {
161 $rdata = unserialize(file_get_contents($reader));
163 //echo '<PRE>';print_r($rdata);exit;
166 foreach($cols as $c ) {
167 $cc = $x->tableName().'.'.$c;
168 if ( !isset($rdata[$cc])
169 || !is_array($rdata[$cc])
183 'totalProperty' => 'total',
184 'successProperty' => 'success',