$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);
+ 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(new DB_DataObject('Person'), 'LEFT');
+ $e->joinAdd(DB_DataObject::factory('core_person'), 'LEFT');
$e->selectAdd("
DATE_FORMAT(changedate, '%Y-%m-%d') as changeday,
- Person.name as id,
- Person.name as name
+ 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);
- } else {
- $e->whereAdd("changedate >= '$start 00:00:00' AND changedate < '$start 00:00:00' + INTERVAL 3 DAY");
- }
-
+ }
+ $e->whereAdd("changedate >= '$start_day 00:00:00' AND
+ changedate < '$start_day 00:00:00' + INTERVAL 1 DAY");
+
+ //DB_DataObject::debugLevel(1);
- $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)
- )
- ");
+
$this->events[] = $add;
}
-
- $this->jdata($this->events);
+ $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
+ );
+
+
+ }
}