First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
97
sites/all/modules/civicrm/CRM/Report/Page/Instance.php
Normal file
97
sites/all/modules/civicrm/CRM/Report/Page/Instance.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Page for invoking report instances
|
||||
*/
|
||||
class CRM_Report_Page_Instance extends CRM_Core_Page {
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*/
|
||||
public function run() {
|
||||
$instanceId = CRM_Report_Utils_Report::getInstanceID();
|
||||
if (!$instanceId) {
|
||||
$instanceId = CRM_Report_Utils_Report::getInstanceIDForPath();
|
||||
}
|
||||
|
||||
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
|
||||
$reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
|
||||
|
||||
if ($action & CRM_Core_Action::DELETE) {
|
||||
CRM_Report_BAO_ReportInstance::doFormDelete($instanceId, $reportUrl);
|
||||
return CRM_Utils_System::redirect($reportUrl);
|
||||
}
|
||||
|
||||
if (is_numeric($instanceId)) {
|
||||
$instanceURL = CRM_Utils_System::url("civicrm/report/instance/{$instanceId}", 'reset=1');
|
||||
CRM_Core_Session::singleton()->replaceUserContext($instanceURL);
|
||||
}
|
||||
$optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
|
||||
$templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
|
||||
if (empty($templateInfo)) {
|
||||
CRM_Core_Error::statusBounce('You have tried to access a report that does not exist.');
|
||||
}
|
||||
|
||||
$extKey = strpos($templateInfo['name'], '.');
|
||||
|
||||
$reportClass = NULL;
|
||||
|
||||
if ($extKey !== FALSE) {
|
||||
$ext = CRM_Extension_System::singleton()->getMapper();
|
||||
$reportClass = $ext->keyToClass($templateInfo['name'], 'report');
|
||||
$templateInfo['name'] = $reportClass;
|
||||
}
|
||||
|
||||
if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) {
|
||||
$instanceInfo = array();
|
||||
CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo);
|
||||
|
||||
if (!empty($instanceInfo['title'])) {
|
||||
CRM_Utils_System::setTitle($instanceInfo['title']);
|
||||
$this->assign('reportTitle', $instanceInfo['title']);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_System::setTitle($templateInfo['label']);
|
||||
$this->assign('reportTitle', $templateInfo['label']);
|
||||
}
|
||||
|
||||
$wrapper = new CRM_Utils_Wrapper();
|
||||
return $wrapper->run($templateInfo['name'], NULL, NULL);
|
||||
}
|
||||
|
||||
CRM_Core_Session::setStatus(ts('Could not find template for the instance.'), ts('Template Not Found'), 'error');
|
||||
|
||||
return CRM_Utils_System::redirect($reportUrl);
|
||||
}
|
||||
|
||||
}
|
289
sites/all/modules/civicrm/CRM/Report/Page/InstanceList.php
Normal file
289
sites/all/modules/civicrm/CRM/Report/Page/InstanceList.php
Normal file
|
@ -0,0 +1,289 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Page for invoking report instances.
|
||||
*/
|
||||
class CRM_Report_Page_InstanceList extends CRM_Core_Page {
|
||||
|
||||
static $_links = NULL;
|
||||
|
||||
static $_exceptions = array('logging/contact/detail');
|
||||
|
||||
/**
|
||||
* Name of component if report list is filtered.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_compName = NULL;
|
||||
|
||||
/**
|
||||
* ID of component if report list is filtered.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_compID = NULL;
|
||||
|
||||
/**
|
||||
* ID of grouping if report list is filtered.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_grouping = NULL;
|
||||
|
||||
/**
|
||||
* ID of parent report template if list is filtered by template.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_ovID = NULL;
|
||||
|
||||
/**
|
||||
* Title of parent report template if list is filtered by template.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title = NULL;
|
||||
|
||||
/**
|
||||
* Retrieves report instances, optionally filtered.
|
||||
*
|
||||
* Filtering available by parent report template ($ovID) or by component ($compID).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function info() {
|
||||
|
||||
$report = '';
|
||||
$queryParams = array();
|
||||
|
||||
if ($this->ovID) {
|
||||
$report .= " AND v.id = %1 ";
|
||||
$queryParams[1] = array($this->ovID, 'Integer');
|
||||
}
|
||||
|
||||
if ($this->compID) {
|
||||
if ($this->compID == 99) {
|
||||
$report .= " AND v.component_id IS NULL ";
|
||||
$this->_compName = 'Contact';
|
||||
}
|
||||
else {
|
||||
$report .= " AND v.component_id = %2 ";
|
||||
$queryParams[2] = array($this->compID, 'Integer');
|
||||
$cmpName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Component', $this->compID,
|
||||
'name', 'id'
|
||||
);
|
||||
$this->_compName = substr($cmpName, 4);
|
||||
if ($this->_compName == 'Contribute') {
|
||||
$this->_compName = 'Contribution';
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($this->grouping) {
|
||||
$report .= " AND v.grouping = %3 ";
|
||||
$queryParams[3] = array($this->grouping, 'String');
|
||||
}
|
||||
elseif ($this->myReports) {
|
||||
$report .= " AND inst.owner_id = %4 ";
|
||||
$queryParams[4] = array(CRM_Core_Session::getLoggedInContactID(), 'Integer');
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT inst.id, inst.title, inst.report_id, inst.description, inst.owner_id, v.label, v.grouping, v.name as class_name,
|
||||
CASE
|
||||
WHEN comp.name IS NOT NULL THEN SUBSTRING(comp.name, 5)
|
||||
WHEN v.grouping IS NOT NULL THEN v.grouping
|
||||
ELSE 'Contact'
|
||||
END as compName
|
||||
FROM civicrm_option_group g
|
||||
LEFT JOIN civicrm_option_value v
|
||||
ON v.option_group_id = g.id AND
|
||||
g.name = 'report_template'
|
||||
LEFT JOIN civicrm_report_instance inst
|
||||
ON v.value = inst.report_id
|
||||
LEFT JOIN civicrm_component comp
|
||||
ON v.component_id = comp.id
|
||||
|
||||
WHERE v.is_active = 1 {$report}
|
||||
AND inst.domain_id = %9
|
||||
ORDER BY v.weight ASC, inst.title ASC";
|
||||
$queryParams[9] = array(CRM_Core_Config::domainID(), 'Integer');
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($sql, $queryParams);
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$rows = array();
|
||||
$url = 'civicrm/report/instance';
|
||||
$my_reports_grouping = 'My';
|
||||
while ($dao->fetch()) {
|
||||
if (in_array($dao->report_id, self::$_exceptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$enabled = in_array("Civi{$dao->compName}", $config->enableComponents);
|
||||
if ($dao->compName == 'Contact' || $dao->compName == $dao->grouping) {
|
||||
$enabled = TRUE;
|
||||
}
|
||||
|
||||
// filter report listings for private reports
|
||||
if (!empty($dao->owner_id) && CRM_Core_Session::getLoggedInContactID() != $dao->owner_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//filter report listings by permissions
|
||||
if (!($enabled && CRM_Report_Utils_Report::isInstancePermissioned($dao->id))) {
|
||||
continue;
|
||||
}
|
||||
//filter report listing by group/role
|
||||
if (!($enabled && CRM_Report_Utils_Report::isInstanceGroupRoleAllowed($dao->id))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trim($dao->title)) {
|
||||
if ($this->ovID) {
|
||||
$this->title = ts("Report(s) created from the template: %1", array(1 => $dao->label));
|
||||
}
|
||||
|
||||
$report_grouping = $dao->compName;
|
||||
if ($dao->owner_id != NULL) {
|
||||
$report_grouping = $my_reports_grouping;
|
||||
}
|
||||
$rows[$report_grouping][$dao->id]['title'] = $dao->title;
|
||||
$rows[$report_grouping][$dao->id]['label'] = $dao->label;
|
||||
$rows[$report_grouping][$dao->id]['description'] = $dao->description;
|
||||
$rows[$report_grouping][$dao->id]['url'] = CRM_Utils_System::url("{$url}/{$dao->id}", "reset=1&output=criteria");
|
||||
$rows[$report_grouping][$dao->id]['viewUrl'] = CRM_Utils_System::url("{$url}/{$dao->id}", 'force=1&reset=1');
|
||||
$rows[$report_grouping][$dao->id]['actions'] = $this->getActionLinks($dao->id, $dao->class_name);
|
||||
}
|
||||
}
|
||||
// Move My Reports to the beginning of the reports list
|
||||
if (isset($rows[$my_reports_grouping])) {
|
||||
$my_reports = $rows[$my_reports_grouping];
|
||||
unset($rows[$my_reports_grouping]);
|
||||
$rows = array($my_reports_grouping => $my_reports) + $rows;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*/
|
||||
public function run() {
|
||||
//Filters by source report template or by component
|
||||
$this->ovID = CRM_Utils_Request::retrieve('ovid', 'Positive', $this);
|
||||
$this->myReports = CRM_Utils_Request::retrieve('myreports', 'String', $this);
|
||||
$this->compID = CRM_Utils_Request::retrieve('compid', 'Positive', $this);
|
||||
$this->grouping = CRM_Utils_Request::retrieve('grp', 'String', $this);
|
||||
|
||||
$rows = $this->info();
|
||||
|
||||
$this->assign('list', $rows);
|
||||
if ($this->ovID OR $this->compID) {
|
||||
// link to view all reports
|
||||
$reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
|
||||
$this->assign('reportUrl', $reportUrl);
|
||||
if ($this->ovID) {
|
||||
$this->assign('title', $this->title);
|
||||
}
|
||||
else {
|
||||
CRM_Utils_System::setTitle(ts('%1 Reports', array(1 => $this->_compName)));
|
||||
}
|
||||
}
|
||||
// assign link to template list for users with appropriate permissions
|
||||
if (CRM_Core_Permission::check('administer Reports')) {
|
||||
if ($this->compID) {
|
||||
$newButton = ts('New %1 Report', array(1 => $this->_compName));
|
||||
$templateUrl = CRM_Utils_System::url('civicrm/report/template/list', "reset=1&compid={$this->compID}");
|
||||
}
|
||||
else {
|
||||
$newButton = ts('New Report');
|
||||
$templateUrl = CRM_Utils_System::url('civicrm/report/template/list', "reset=1");
|
||||
}
|
||||
$this->assign('newButton', $newButton);
|
||||
$this->assign('templateUrl', $templateUrl);
|
||||
$this->assign('compName', $this->_compName);
|
||||
$this->assign('myReports', $this->myReports);
|
||||
}
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action links.
|
||||
*
|
||||
* @param int $instanceID
|
||||
* @param string $className
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getActionLinks($instanceID, $className) {
|
||||
$urlCommon = 'civicrm/report/instance/' . $instanceID;
|
||||
$actions = array(
|
||||
'copy' => array(
|
||||
'url' => CRM_Utils_System::url($urlCommon, 'reset=1&output=copy'),
|
||||
'label' => ts('Save a Copy'),
|
||||
),
|
||||
'pdf' => array(
|
||||
'url' => CRM_Utils_System::url($urlCommon, 'reset=1&force=1&output=pdf'),
|
||||
'label' => ts('View as pdf'),
|
||||
),
|
||||
'print' => array(
|
||||
'url' => CRM_Utils_System::url($urlCommon, 'reset=1&force=1&output=print'),
|
||||
'label' => ts('Print report'),
|
||||
),
|
||||
);
|
||||
// Hackery, Hackera, Hacker ahahahahahaha a super nasty hack.
|
||||
// Almost all report classes support csv & loading each class to call the method seems too
|
||||
// expensive. We also have on our later list 'do they support charts' which is instance specific
|
||||
// e.g use of group by might affect it. So, lets just skip for the few that don't for now.
|
||||
$csvBlackList = array(
|
||||
'CRM_Report_Form_Contact_Detail',
|
||||
'CRM_Report_Form_Event_Income',
|
||||
);
|
||||
if (!in_array($className, $csvBlackList)) {
|
||||
$actions['csv'] = array(
|
||||
'url' => CRM_Utils_System::url($urlCommon, 'reset=1&force=1&output=csv'),
|
||||
'label' => ts('Export to csv'),
|
||||
);
|
||||
}
|
||||
if (CRM_Core_Permission::check('administer Reports')) {
|
||||
$actions['delete'] = array(
|
||||
'url' => CRM_Utils_System::url($urlCommon, 'reset=1&action=delete'),
|
||||
'label' => ts('Delete report'),
|
||||
'confirm_message' => ts('Are you sure you want delete this report? This action cannot be undone.'),
|
||||
);
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
}
|
214
sites/all/modules/civicrm/CRM/Report/Page/Options.php
Normal file
214
sites/all/modules/civicrm/CRM/Report/Page/Options.php
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Page for displaying list of Gender
|
||||
*/
|
||||
class CRM_Report_Page_Options extends CRM_Core_Page_Basic {
|
||||
|
||||
public $useLivePageJS = TRUE;
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* The option group name.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_gName = NULL;
|
||||
|
||||
/**
|
||||
* The option group name in display format (capitalized, without underscores...etc)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_GName = NULL;
|
||||
|
||||
/**
|
||||
* The option group id.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_gId = NULL;
|
||||
|
||||
/**
|
||||
* Obtains the group name from url and sets the title.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'String', $this, FALSE);
|
||||
|
||||
self::$_gName = "report_template";
|
||||
|
||||
if (self::$_gName) {
|
||||
self::$_gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gName, 'id', 'name');
|
||||
}
|
||||
else {
|
||||
CRM_Core_Error::fatal();
|
||||
}
|
||||
|
||||
self::$_GName = ucwords(str_replace('_', ' ', self::$_gName));
|
||||
|
||||
$this->assign('GName', self::$_GName);
|
||||
$newReportURL = CRM_Utils_System::url("civicrm/admin/report/register",
|
||||
'reset=1'
|
||||
);
|
||||
$this->assign('newReport', $newReportURL);
|
||||
CRM_Utils_System::setTitle(ts('Registered Templates'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_Core_BAO_OptionValue';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links.
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/admin/report/register/' . self::$_gName,
|
||||
'qs' => 'action=update&id=%%id%%&reset=1',
|
||||
'title' => ts('Edit %1', array(1 => self::$_gName)),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Disable %1', array(1 => self::$_gName)),
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable %1', array(1 => self::$_gName)),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/admin/report/register/' . self::$_gName,
|
||||
'qs' => 'action=delete&id=%%id%%&reset=1',
|
||||
'title' => ts('Delete %1 Type', array(1 => self::$_gName)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the basic page (run essentially starts execution for that page).
|
||||
*/
|
||||
public function run() {
|
||||
$this->preProcess();
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all options.
|
||||
*/
|
||||
public function browse() {
|
||||
$groupParams = array('name' => self::$_gName);
|
||||
$optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'weight');
|
||||
$gName = self::$_gName;
|
||||
$returnURL = CRM_Utils_System::url("civicrm/admin/report/options/$gName",
|
||||
"reset=1"
|
||||
);
|
||||
$filter = "option_group_id = " . self::$_gId;
|
||||
|
||||
$session = new CRM_Core_Session();
|
||||
$session->replaceUserContext($returnURL);
|
||||
CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue',
|
||||
'id', $returnURL, $filter
|
||||
);
|
||||
$this->assign('rows', $optionValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_Report_Form_Register';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return self::$_GName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/report/options/' . self::$_gName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get userContext params.
|
||||
*
|
||||
* @param int $mode
|
||||
* Mode that we are in.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function userContextParams($mode = NULL) {
|
||||
return 'reset=1&action=browse';
|
||||
}
|
||||
|
||||
}
|
81
sites/all/modules/civicrm/CRM/Report/Page/Report.php
Normal file
81
sites/all/modules/civicrm/CRM/Report/Page/Report.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Page for invoking report templates.
|
||||
*/
|
||||
class CRM_Report_Page_Report extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*/
|
||||
public function run() {
|
||||
if (!CRM_Core_Permission::check('administer Reports')) {
|
||||
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
|
||||
}
|
||||
|
||||
$optionVal = CRM_Report_Utils_Report::getValueFromUrl();
|
||||
|
||||
$templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value',
|
||||
'String', FALSE, TRUE
|
||||
);
|
||||
|
||||
$extKey = strpos(CRM_Utils_Array::value('name', $templateInfo), '.');
|
||||
|
||||
$reportClass = NULL;
|
||||
|
||||
if ($extKey !== FALSE) {
|
||||
$ext = CRM_Extension_System::singleton()->getMapper();
|
||||
$reportClass = $ext->keyToClass($templateInfo['name'], 'report');
|
||||
$templateInfo['name'] = $reportClass;
|
||||
}
|
||||
|
||||
if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) {
|
||||
CRM_Utils_System::setTitle(ts('%1 - Template', array(1 => $templateInfo['label'])));
|
||||
$this->assign('reportTitle', $templateInfo['label']);
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->set('reportDescription', $templateInfo['description']);
|
||||
|
||||
$wrapper = new CRM_Utils_Wrapper();
|
||||
|
||||
return $wrapper->run($templateInfo['name'], NULL, NULL);
|
||||
}
|
||||
|
||||
if ($optionVal) {
|
||||
CRM_Core_Session::setStatus(ts('Could not find the report template. Make sure the report template is registered and / or url is correct.'), ts('Template Not Found'), 'error');
|
||||
}
|
||||
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
|
||||
}
|
||||
|
||||
}
|
119
sites/all/modules/civicrm/CRM/Report/Page/TemplateList.php
Normal file
119
sites/all/modules/civicrm/CRM/Report/Page/TemplateList.php
Normal file
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Page for displaying list of Report templates available.
|
||||
*/
|
||||
class CRM_Report_Page_TemplateList extends CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* @param int $compID
|
||||
* @param null $grouping
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &info($compID = NULL, $grouping = NULL) {
|
||||
$all = CRM_Utils_Request::retrieve('all', 'Boolean', CRM_Core_DAO::$_nullObject,
|
||||
FALSE, NULL, 'GET'
|
||||
);
|
||||
|
||||
$compClause = '';
|
||||
if ($compID) {
|
||||
if ($compID == 99) {
|
||||
$compClause = " AND v.component_id IS NULL ";
|
||||
}
|
||||
else {
|
||||
$compClause = " AND v.component_id = {$compID} ";
|
||||
}
|
||||
}
|
||||
elseif ($grouping) {
|
||||
$compClause = " AND v.grouping = '{$grouping}' ";
|
||||
}
|
||||
$sql = "
|
||||
SELECT v.id, v.value, v.label, v.description, v.component_id,
|
||||
CASE
|
||||
WHEN comp.name IS NOT NULL THEN SUBSTRING(comp.name, 5)
|
||||
WHEN v.grouping IS NOT NULL THEN v.grouping
|
||||
ELSE 'Contact'
|
||||
END as component_name,
|
||||
v.grouping,
|
||||
inst.id as instance_id
|
||||
FROM civicrm_option_value v
|
||||
INNER JOIN civicrm_option_group g
|
||||
ON (v.option_group_id = g.id AND g.name = 'report_template')
|
||||
LEFT JOIN civicrm_report_instance inst
|
||||
ON v.value = inst.report_id
|
||||
LEFT JOIN civicrm_component comp
|
||||
ON v.component_id = comp.id
|
||||
";
|
||||
|
||||
if (!$all) {
|
||||
$sql .= " WHERE v.is_active = 1 {$compClause}";
|
||||
}
|
||||
$sql .= " ORDER BY v.weight ";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($sql);
|
||||
$rows = array();
|
||||
$config = CRM_Core_Config::singleton();
|
||||
while ($dao->fetch()) {
|
||||
if ($dao->component_name != 'Contact' && $dao->component_name != $dao->grouping &&
|
||||
!in_array("Civi{$dao->component_name}", $config->enableComponents)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$rows[$dao->component_name][$dao->value]['title'] = ts($dao->label);
|
||||
$rows[$dao->component_name][$dao->value]['description'] = ts($dao->description);
|
||||
$rows[$dao->component_name][$dao->value]['url'] = CRM_Utils_System::url('civicrm/report/' . trim($dao->value, '/'), 'reset=1');
|
||||
if ($dao->instance_id) {
|
||||
$rows[$dao->component_name][$dao->value]['instanceUrl'] = CRM_Utils_System::url('civicrm/report/list',
|
||||
"reset=1&ovid={$dao->id}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run this page (figure out the action needed and perform it).
|
||||
*/
|
||||
public function run() {
|
||||
$compID = CRM_Utils_Request::retrieve('compid', 'Positive', $this);
|
||||
$grouping = CRM_Utils_Request::retrieve('grp', 'String', $this);
|
||||
$rows = self::info($compID, $grouping);
|
||||
$this->assign('list', $rows);
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue