/** * undocumented function * * @return void * @access public */ function admin_stats() { $this->_handleTimePeriod(); $format = '%Y-%m-%d'; if ($this->diagramType == 'hour') { $format = '%Y-%m-%d %H:00'; } $gifts = $this->Gift->find('all', array('conditions' => array('office_id' => $this->Session->read('Office.id'), "DATE_FORMAT(created, '" . $format . "') >= '" . $this->startDate . "'", "DATE_FORMAT(created, '" . $format . "') <= '" . $this->endDate . "'"), 'fields' => array('created', 'amount', 'archived', 'complete'))); $result = array(); $type = $this->diagramType; $items = DateComponent::diff($type, $this->startDate, $this->endDate, false); foreach ($items as $item) { $result[$item] = array(); foreach ($gifts as $gift) { if (DateComponent::same($gift['Gift']['created'], $item, $type)) { $result[$item][] = $gift; } } } $this->set(compact('result', 'gifts', 'months', 'type')); }