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']));
47 ( ontable='mtrack_ticket' AND
48 onid IN (SELECT id FROM mtrack_ticket where project_id = $pid)
51 ( ontable='mtrack_repos' AND
52 onid IN (SELECT id FROM mtrack_repos where project_id = $pid)
56 if (!empty($_REQUEST['viewtype']) && $_REQUEST['viewtype'] == 'summary') {
57 //DB_DataObject::debugLevel(1);
59 $e->whereAdd("changedate >= '$start 00:00:00' AND changedate < '$start 00:00:00' + INTERVAL 1 MONTH");
61 $e->joinAdd(DB_DataObject::factory('Person'), 'LEFT');
63 DATE_FORMAT(changedate, '%Y-%m-%d') as changeday,
64 CONCAT(DATE_FORMAT(changedate, '%Y-%m-%d-') ,Person.id) as id,
66 COUNT(mtrack_change.id) as nchanges
68 $e->groupBy("changeday,id,name");
69 $e->orderBy('changeday desc, name asc');
73 $ret[] = $e->toArray();
79 $e->whereAdd("changedate >= '$start 00:00:00' AND changedate < '$start 00:00:00' + INTERVAL 3 DAY");
90 $this->events = array();
91 //$this->hist= array();
93 foreach($ar as $i=>$h) {
94 $h->cls = $i % 2 ? 'odd' : '';
96 $ts = strtotime($h->changedate);
97 $day = date('D, M d Y', $ts);
98 $time = date('g:ia', $ts);
101 $add = $h->toArray();
103 if ($day !== $last_day) {
104 $add['first_of_day'] = 1;
108 $add['person_id_name'] = $p->name;
109 $add['person_id_email'] = $p->email;
110 $add['audit'] = $h->cachedAuditToString();
111 $add['audit_ar'] = $h->cachedAuditToJSONArray();
112 // add the underlying object..
113 $add = array_merge($add, $h->objectCached()->toArray('object_%s'));
121 $this->events[] = $add;
126 'metaData' => $this->meta($e, $this->events)
131 $this->jdata($this->events, count($this->events), $extra);
138 * this is a very simple version of the main one in roo.php
140 function meta($x, $data)
142 // this is not going to work on queries where the data does not match the database def..
143 // for unknown columns we send them as stirngs..
145 $cols = array_keys($data[0]);
151 $options = HTML_FlexyFramework::get()->DB_DataObject;
152 //echo '<PRE>';print_r($options); exit;
153 $reader = $options["ini_{$x->_database}"] .'.reader';
154 if (!file_exists( $reader )) {
158 $rdata = unserialize(file_get_contents($reader));
160 //echo '<PRE>';print_r($rdata);exit;
163 foreach($cols as $c ) {
164 $cc = $x->tableName().'.'.$c;
165 if ( !isset($rdata[$cc])
166 || !is_array($rdata[$cc])
180 'totalProperty' => 'total',
181 'successProperty' => 'success',