true, 'defaultOrderBy' => 'dueIdx'); protected function _init() { if (ADMIN_END) { $this->_actions[] = 'forceStatus'; $this->_actions[] = 'exportXls'; } return parent::_init(); } public function exec() { App_Doc_Acl::requireReportSummaryAccess(); $this->_doc->setBodyTemplate('Doc/Body/internal.tpl'); $this->_doc->setBodyAttrib('style', 'background:#fff;'); return parent::exec(); } public static function getPageUrl() { return Qs_SiteMap::findFirstLocal(null, array('type' => 'Report_Summary_'), null, 'url'); } protected function _bindListColumns(Qs_ViewController_List $list) { $list->addColumn( 'dateDue', 'dateDue', array('title' => 'Date Due', 'orderBy' => 'dueIdx', 'defaultText' => '–') ); $list->addColumn('text', 'section', array('orderBy' => 'section')); $list->addColumn('text', 'topic', array('orderBy' => 'topic')); return parent::_bindListColumns($list); } protected function _getListItem(Qs_ViewController_List $list = null) { if (null == $list) { $list = $this->list; } $this->_bindListColumns($list); $item = $list->toArray(); $item['exportXlsUrl'] = $this->url(array('action' => 'exportXls')); $item['schools'] = (array) $this->_getDataObj()->getSchools(); $item['statuses'] = $this->_getDataObj()->getReportStatuses(); $item['userReports'] = $this->_getDataObj()->getUserReports(); $item['forcedStatuses'] = $this->_getDataObj()->getForcedStatuses(); $item['backLink'] = $this->_getBackLink(); $item['statusesStatistics'] = $this->_getStatusesStatisticsItem(); if (array_key_exists('paginator', $item)) { if ($item['paginator']['last'] < $list->getPageNumber() && ($item['paginator']['pageCount'] != 0 || $list->getPageNumber() > 1) ) { $redirectUrl = str_replace($list->getPaginatorPagePlaceholder(), 1, $list->getPaginatorUrl()); $this->redirect($redirectUrl, 307); } } return $item; } protected function _getStatusesStatisticsItem() { return new Qs_Doc_Item(array( 'tpl' => Qs_SiteMap::getTemplate('Report/statistics.tpl'), 'statistics' => $this->_getDataObj()->getStatusesStatistics(), )); } protected function _getBackLink() { $link = array( 'url' => constant('BASE_URL'), 'title' => 'Back to Reports', ); if (ADMIN_END) { $link['url'] = Qs_SiteMap::findFirst(null, array('type' => 'Report_Admin'), null, 'url'); } else { if (App_Doc_Acl::hasReportAccess()) { $link['url'] = Qs_SiteMap::findFirst(null, array('type' => 'Report_'), null, 'url'); } else { $link['title'] = 'Back'; $link['url'] = constant('BASE_URL'); } } return $link; } protected function _addListItem(Qs_ViewController_List $list = null, $template = 'list.tpl') { $item = $this->_getListItem($list); $item['tpl'] = $this->getTemplate($template); $this->_addItem($item); $params = array( 'containerId' => 'report-summary-grid', 'requestUrl' => $this->url(), 'update' => 'cell', 'summaryTable' => '#report-summary-grid', ); $this->_doc->addScript('js/jquery.stickytableheaders.js'); $this->_doc->addScript('js/app/report/admin/list.js'); $this->_doc->addInitObject('app.report.admin.List', array($params)); return $this; } protected function _doForceStatus() { header('400 Bad Request'); exit; } protected function _doForceStatusAjax() { $reportId = Qs_Request::getPostValue('reportId'); $schoolId = Qs_Request::getPostValue('schoolId'); $statusId = Qs_Request::getPostValue('statusId'); $allowedStatuses = App_Report_AbstractObj::getForceStatusPairs(); if (empty($reportId) || empty($schoolId) || ($statusId && !array_key_exists($statusId, $allowedStatuses))) { header('400 Bad Request'); exit; } if (false == ($this->_getDataObj()->forceReportStatus($reportId, $schoolId, $statusId))) { header('500 Internal Server Error'); exit; } $this->_doc->setGroupName('ITEMS'); $this->_getDataObj()->setFilter(array('id' => $reportId)); $this->_addListItem(); $html = $this->_doc->fetch(Qs_Sitemap::getTemplate('Doc/clean.tpl')); $this->_displayJson(array('html' => $html)); } protected function _doExportXls() { $options = array( 'mode' => App_Report_Summary_Export::MODE_OUTPUT, 'dataObj' => $this->_getDataObj(), 'listOptions' => array('order' => array($this->_getList()->getOrderBy())), ); $export = new App_Report_Summary_Export($options); $export->export(); exit; } }