var $title = 'Timeline';
var $start_time = '-2 weeks';
- var $limit = 50;
+ var $limit = 250;
// fixme = this should be alot more efficient...
$this->masterTemplate = 'timeline.html';
// perms...
$pid = $this->currentProject();
+ //DB_DataObject::debugLevel(1);
+ $isSummary = false;
+
$e = DB_DataObject::factory('mtrack_change');
$e->orderBy('changedate DESC');
- $e->limit(50);
+ $start = empty($_REQUEST['from_date']) ? date('Y-m-01') :
+ date('Y-m-01', strtotime($_REQUEST['from_date']));
+
+ $start_day = empty($_REQUEST['from_date']) ? date('Y-m-d') :
+ date('Y-m-d', strtotime($_REQUEST['from_date']));
+
$e->whereAdd("
( ontable='mtrack_ticket' AND
onid IN (SELECT id FROM mtrack_ticket where project_id = $pid)
)
+ OR
+ ( ontable='mtrack_repos' AND
+ onid IN (SELECT id FROM mtrack_repos where project_id = $pid)
+ )
");
+
+ if (!empty($_REQUEST['viewtype']) && $_REQUEST['viewtype'] == 'summary') {
+ //DB_DataObject::debugLevel(1);
+ $isSummary = true;
+ $e->whereAdd("changedate >= '$start 00:00:00' AND changedate < '$start 00:00:00' + INTERVAL 1 MONTH");
+ $e->selectAdd();
+ $e->joinAdd(DB_DataObject::factory('core_person'), 'LEFT');
+ $e->selectAdd("
+ DATE_FORMAT(changedate, '%Y-%m-%d') as changeday,
+ CONCAT(DATE_FORMAT(changedate, '%Y-%m-%d-') ,Person.id) as id,
+ Person.name as name,
+ COUNT(mtrack_change.id) as nchanges
+ ");
+ $e->groupBy("changeday,id,name");
+ $e->orderBy('changeday desc, name asc');
+ $ret = array();
+ $e->find();
+ while($e->fetch()) {
+ $ret[] = $e->toArray();
+ }
+ $this->jdata($ret);
+
+
+ }
+ $e->whereAdd("changedate >= '$start_day 00:00:00' AND
+ changedate < '$start_day 00:00:00' + INTERVAL 1 DAY");
+
+ //DB_DataObject::debugLevel(1);
+
+
+
+
+
- $this->events = $e->fetchAll();
+ $ar = $e->fetchAll();
+ $this->events = array();
+ //$this->hist= array();
+ $last_day =false;
+ foreach($ar as $i=>$h) {
+ $h->cls = $i % 2 ? 'odd' : '';
+
+ $ts = strtotime($h->changedate);
+ $day = date('D, M d Y', $ts);
+ $time = date('g:ia', $ts);
+ //print_r($ent);
+
+ $add = $h->toArray();
+
+ if ($day !== $last_day) {
+ $add['first_of_day'] = 1;
+ }
+ $last_day = $day;
+ $p = $h->person();
+ $add['person_id_name'] = $p->name;
+ $add['person_id_email'] = $p->email;
+ $add['audit'] = $h->cachedAuditToString();
+ $add['audit_ar'] = $h->cachedAuditToJSONArray();
+ // add the underlying object..
+ $add = array_merge($add, $h->objectCached()->toArray('object_%s'));
+
+
+
+
+
+
+
+ $this->events[] = $add;
+
+ }
+ $total = count($this->events);
+ $extra = !$total ? array() : array(
+ 'metaData' => $this->meta($e, $this->events)
+ );
+
+
+
+ $this->jdata($this->events, $total, $extra);
+
}
+ /**
+ * this is a very simple version of the main one in roo.php
+ */
+ function meta($x, $data)
+ {
+ // this is not going to work on queries where the data does not match the database def..
+ // for unknown columns we send them as stirngs..
+ $lost = 0;
+ $cols = array_keys($data[0]);
-
+
+
+
+
+ $options = HTML_FlexyFramework::get()->DB_DataObject;
+ //echo '<PRE>';print_r($options); exit;
+ $reader = $options["ini_{$x->_database}"] .'.reader';
+ if (!file_exists( $reader )) {
+ return;
+ }
+
+ $rdata = unserialize(file_get_contents($reader));
+
+ //echo '<PRE>';print_r($rdata);exit;
+
+ $meta = array();
+ foreach($cols as $c ) {
+ $cc = $x->tableName().'.'.$c;
+ if ( !isset($rdata[$cc])
+ || !is_array($rdata[$cc])
+ ) {
+
+ $meta[] = $c;
+ continue;
+ }
+ $add = $rdata[$cc];
+ $add['name'] = $c;
+ $meta[] = $add;
+ }
+
+
+
+ return array(
+ 'totalProperty' => 'total',
+ 'successProperty' => 'success',
+ 'root' => 'data',
+ 'id' => 'id',
+ 'fields' => $meta
+ );
+
+
+ }
}