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
80 changedate < '$start 00:00:00' + INTERVAL 1 DAY");
82 DB_DataObject::debugLevel(1);
91 $this->events = array();
92 //$this->hist= array();
94 foreach($ar as $i=>$h) {
95 $h->cls = $i % 2 ? 'odd' : '';
97 $ts = strtotime($h->changedate);
98 $day = date('D, M d Y', $ts);
99 $time = date('g:ia', $ts);
102 $add = $h->toArray();
104 if ($day !== $last_day) {
105 $add['first_of_day'] = 1;
109 $add['person_id_name'] = $p->name;
110 $add['person_id_email'] = $p->email;
111 $add['audit'] = $h->cachedAuditToString();
112 $add['audit_ar'] = $h->cachedAuditToJSONArray();
113 // add the underlying object..
114 $add = array_merge($add, $h->objectCached()->toArray('object_%s'));
122 $this->events[] = $add;
127 'metaData' => $this->meta($e, $this->events)
132 $this->jdata($this->events, count($this->events), $extra);
139 * this is a very simple version of the main one in roo.php
141 function meta($x, $data)
143 // this is not going to work on queries where the data does not match the database def..
144 // for unknown columns we send them as stirngs..
146 $cols = array_keys($data[0]);
152 $options = HTML_FlexyFramework::get()->DB_DataObject;
153 //echo '<PRE>';print_r($options); exit;
154 $reader = $options["ini_{$x->_database}"] .'.reader';
155 if (!file_exists( $reader )) {
159 $rdata = unserialize(file_get_contents($reader));
161 //echo '<PRE>';print_r($rdata);exit;
164 foreach($cols as $c ) {
165 $cc = $x->tableName().'.'.$c;
166 if ( !isset($rdata[$cc])
167 || !is_array($rdata[$cc])
181 'totalProperty' => 'total',
182 'successProperty' => 'success',