public static function &info($ovID = null, &$title = null) { $report = ''; if ($ovID) { $report = " AND v.id = {$ovID} "; } $sql = "\n SELECT inst.id, inst.title, inst.report_id, inst.description, v.label, \n ifnull( SUBSTRING(comp.name, 5), 'Contact' ) as compName\n FROM civicrm_option_group g\n LEFT JOIN civicrm_option_value v\n ON v.option_group_id = g.id AND\n g.name = 'report_template'\n LEFT JOIN civicrm_report_instance inst\n ON v.value = inst.report_id\n LEFT JOIN civicrm_component comp \n ON v.component_id = comp.id\n \n WHERE v.is_active = 1 {$report}\n\n ORDER BY v.weight\n "; $dao = CRM_Core_DAO::executeQuery($sql); $config = CRM_Core_Config::singleton(); $rows = array(); $url = 'civicrm/report/instance'; while ($dao->fetch()) { $enabled = in_array("Civi{$dao->compName}", $config->enableComponents); if ($dao->compName == 'Contact') { $enabled = true; } //filter report listings by permissions if (!($enabled && CRM_Report_Utils_Report::isInstancePermissioned($dao->id))) { continue; } if (trim($dao->title)) { if ($ovID) { $title = ts("Report(s) created from the template: %1", array(1 => $dao->label)); } $rows[$dao->compName][$dao->id]['title'] = $dao->title; $rows[$dao->compName][$dao->id]['label'] = $dao->label; $rows[$dao->compName][$dao->id]['description'] = $dao->description; $rows[$dao->compName][$dao->id]['url'] = CRM_Utils_System::url("{$url}/{$dao->id}", "reset=1"); if (CRM_Core_Permission::check('administer Reports')) { $rows[$dao->compName][$dao->id]['deleteUrl'] = CRM_Utils_System::url("{$url}/{$dao->id}", 'action=delete&reset=1'); } } } return $rows; }
/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { $instanceId = CRM_Report_Utils_Report::getInstanceID(); $action = CRM_Utils_Request::retrieve('action', 'String', $this); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('administer Reports')) { $statusMessage = ts('Your do not have permission to Delete Report.'); CRM_Core_Error::statusBounce($statusMessage, $reportUrl); } CRM_Report_BAO_Instance::delete($instanceId); CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.')); } else { require_once 'CRM/Core/OptionGroup.php'; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); if (strstr($templateInfo['name'], '_Form')) { $instanceInfo = array(); CRM_Report_BAO_Instance::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.')); } return CRM_Utils_System::redirect($reportUrl); }
function buildRows($sql, &$rows) { // safeguard for when there aren’t any log entries yet if (!$this->log_conn_id or !$this->log_date) { return; } $params = array(1 => array($this->log_conn_id, 'Integer'), 2 => array($this->log_date, 'String')); // let the template know who updated whom when $sql = "\n SELECT who.id who_id, who.display_name who_name, whom.id whom_id, whom.display_name whom_name, l.is_deleted\n FROM `{$this->loggingDB}`.log_civicrm_contact l\n JOIN civicrm_contact who ON (l.log_user_id = who.id)\n JOIN civicrm_contact whom ON (l.id = whom.id)\n WHERE log_action = 'Update' AND log_conn_id = %1 AND log_date = %2 ORDER BY log_date DESC LIMIT 1\n "; $dao =& CRM_Core_DAO::executeQuery($sql, $params); $dao->fetch(); $this->assign('who_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->who_id}")); $this->assign('whom_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->whom_id}")); $this->assign('who_name', $dao->who_name); $this->assign('whom_name', $dao->whom_name); $this->assign('log_date', $this->log_date); // link back to summary report require_once 'CRM/Report/Utils/Report.php'; $this->assign('summaryReportURL', CRM_Report_Utils_Report::getNextUrl('logging/contact/summary', 'reset=1', false, true)); $rows = $this->diffsInTable('log_civicrm_contact'); // add custom data changes $dao = CRM_Core_DAO::executeQuery("SHOW TABLES FROM `{$this->loggingDB}` LIKE 'log_civicrm_value_%'"); while ($dao->fetch()) { $table = $dao->toValue("Tables_in_{$this->loggingDB}_(log_civicrm_value_%)"); $rows = array_merge($rows, $this->diffsInTable($table)); } }
/** * run this page (figure out the action needed and perform it). * * @return void */ 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); $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($templateInfo['label'] . ' - Template'); $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')); }
function alterDisplay(&$rows) { // cache for id → is_deleted mapping $isDeleted = array(); foreach ($rows as &$row) { if (!isset($isDeleted[$row['log_civicrm_contact_id']])) { $isDeleted[$row['log_civicrm_contact_id']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['log_civicrm_contact_id'], 'is_deleted') !== '0'; } if (!$isDeleted[$row['log_civicrm_contact_id']]) { $row['log_civicrm_contact_altered_contact_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contact_id']); $row['log_civicrm_contact_altered_contact_hover'] = ts("Go to contact summary"); } $row['civicrm_contact_altered_by_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contact_log_user_id']); $row['civicrm_contact_altered_by_hover'] = ts("Go to contact summary"); if ($row['log_civicrm_contact_is_deleted'] and $row['log_civicrm_contact_log_action'] == 'Update') { $row['log_civicrm_contact_log_action'] = ts('Delete (to trash)'); } if ($row['log_civicrm_contact_log_action'] == 'Update') { $q = "reset=1&log_conn_id={$row['log_civicrm_contact_log_conn_id']}&log_date={$row['log_civicrm_contact_log_date']}"; $url = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', $q, false, true); $row['log_civicrm_contact_log_action_link'] = $url; $row['log_civicrm_contact_log_action_hover'] = ts("View details for this update"); $row['log_civicrm_contact_log_action'] = '<div class="icon details-icon"></div> ' . ts('Update'); } unset($row['log_civicrm_contact_log_user_id']); unset($row['log_civicrm_contact_log_conn_id']); } }
/** * Alter display of rows. * * Iterate through the rows retrieved via SQL and make changes for display purposes, * such as rendering contacts as links. * * @param array $rows * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { // cache for id → is_deleted mapping $isDeleted = array(); foreach ($rows as &$row) { if (!isset($isDeleted[$row['civicrm_contact_is_deleted']])) { $isDeleted[$row['civicrm_contact_is_deleted']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['civicrm_contact_altered_contact_id'], 'is_deleted') !== '0'; } if (!$isDeleted[$row['civicrm_contact_is_deleted']]) { $row['civicrm_contact_altered_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contribution_contact_id']); $row['civicrm_contact_altered_contact_display_name_hover'] = ts('Go to contact summary'); } $row['civicrm_contact_altered_by_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_contribution_log_user_id']); $row['civicrm_contact_altered_by_display_name_hover'] = ts('Go to contact summary'); if ($row['civicrm_contact_altered_contact_is_deleted'] and $row['log_civicrm_contribution_log_action'] == 'Update') { $row['log_civicrm_contribution_log_action'] = ts('Delete'); } if ($row['log_civicrm_contribution_log_action'] == 'Update') { $q = "reset=1&log_conn_id={$row['log_civicrm_contribution_log_conn_id']}&log_date={$row['log_civicrm_contribution_log_date']}"; if ($this->cid) { $q .= '&cid=' . $this->cid; } $url = CRM_Report_Utils_Report::getNextUrl('logging/contribute/detail', $q, FALSE, TRUE); $row['log_civicrm_contribution_log_action_link'] = $url; $row['log_civicrm_contribution_log_action_hover'] = ts('View details for this update'); $row['log_civicrm_contribution_log_action'] = '<div class="icon ui-icon-zoomin"></div> ' . ts('Update'); } unset($row['log_civicrm_contribute_log_user_id']); unset($row['log_civicrm_contribute_log_conn_id']); } }
/** * 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(); } if (is_numeric($instanceId)) { $instanceURL = CRM_Utils_System::url("civicrm/report/instance/{$instanceId}", 'reset=1'); CRM_Core_Session::singleton()->replaceUserContext($instanceURL); } $action = CRM_Utils_Request::retrieve('action', 'String', $this); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('administer Reports')) { $statusMessage = ts('You do not have permission to Delete Report.'); CRM_Core_Error::statusBounce($statusMessage, $reportUrl); } $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceId, 'navigation_id', 'id'); CRM_Report_BAO_ReportInstance::del($instanceId); //delete navigation if exists if ($navId) { CRM_Core_BAO_Navigation::processDelete($navId); CRM_Core_BAO_Navigation::resetNavigation(); } CRM_Core_Session::setStatus(ts('Selected report has been deleted.'), ts('Deleted'), 'success'); } else { $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); }
function buildQuickForm() { parent::buildQuickForm(); if ($this->cid) { // link back to contact summary $this->assign('backURL', CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE)); $this->assign('revertURL', self::$_template->get_template_vars('revertURL') . "&cid={$this->cid}"); } else { // link back to summary report $this->assign('backURL', CRM_Report_Utils_Report::getNextUrl('logging/contact/summary', 'reset=1', FALSE, TRUE)); } }
static function registerScripts() { static $loaded = FALSE; if ($loaded) { return; } $loaded = TRUE; CRM_Core_Resources::singleton()->addSettingsFactory(function () { $config = CRM_Core_Config::singleton(); return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'job_hours_time' => CRM_Hrjobcontract_Page_JobContractTab::getJobHoursTime(), 'working_days' => CRM_Hrjobcontract_Page_JobContractTab::getDaysPerTime()), 'FieldOptions' => CRM_Hrjobcontract_Page_JobContractTab::getFieldOptions(), 'jobContractTabApp' => array('contactId' => CRM_Utils_Request::retrieve('cid', 'Integer'), 'domainId' => CRM_Core_Config::domainID(), 'isLogEnabled' => (bool) $config->logging, 'loggingReportId' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'currencies' => CRM_Hrjobcontract_Page_JobContractTab::getCurrencyFormats(), 'defaultCurrency' => $config->defaultCurrency, 'path' => CRM_Core_Resources::singleton()->getUrl('org.civicrm.hrjobcontract'), 'fields' => CRM_Hrjobcontract_Page_JobContractTab::getFields(), 'contractList' => CRM_Hrjobcontract_Page_JobContractTab::getContractList(), 'maxFileSize' => file_upload_max_size()), 'debug' => $config->debug); }); }
/** * Implementation of hook_civicrm_buildProfile */ function hrvisa_civicrm_buildProfile($name) { if ($name == 'hrvisa_tab') { // To fix validation alert issue $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('urlIsPublic', FALSE); $contactID = CRM_Utils_Request::retrieve('id', 'Positive', $this); $config = CRM_Core_Config::singleton(); if ($config->logging && 'multiProfileDialog' !== CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject)) { CRM_Core_Region::instance('profile-form-hrvisa_tab')->add(array('template' => 'CRM/common/logButton.tpl', 'instance_id' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'css_class' => 'hrvisa-revision-link', 'table_name' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'Immigration', 'table_name', 'name'), 'contact_id' => $contactID, 'weight' => -2)); } } }
/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { $instanceId = CRM_Report_Utils_Report::getInstanceID(); if (!$instanceId) { $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath(); } $action = CRM_Utils_Request::retrieve('action', 'String', $this); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('administer Reports')) { $statusMessage = ts('Your do not have permission to Delete Report.'); CRM_Core_Error::statusBounce($statusMessage, $reportUrl); } $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_Instance', $instanceId, 'navigation_id', 'id'); CRM_Report_BAO_Instance::delete($instanceId); //delete navigation if exists if ($navId) { require_once 'CRM/Core/BAO/Navigation.php'; CRM_Core_BAO_Navigation::processDelete($navId); CRM_Core_BAO_Navigation::resetNavigation(); } CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.')); } else { require_once 'CRM/Core/OptionGroup.php'; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); $extKey = strpos($templateInfo['name'], '.'); $reportClass = null; if ($extKey !== FALSE) { require_once 'CRM/Core/Extensions.php'; $ext = new CRM_Core_Extensions(); $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); $templateInfo['name'] = $reportClass; } if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) { $instanceInfo = array(); CRM_Report_BAO_Instance::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.')); } return CRM_Utils_System::redirect($reportUrl); }
/** * YoteUp ProcessCounselor API * * @return array API result descriptor * @see civicrm_api3_create_success * @see civicrm_api3_create_error * @throws API_Exception */ function civicrm_api3_nrm_processcounselor($params) { // Get list of counselors $counsellorCount = civicrm_api3('Contact', 'getCount', array('contact_sub_type' => 'Counselors')); $counselorParams = array('contact_sub_type' => 'Counselors', 'return.email' => 1, 'return.custom_' . TERRITORY_COUNSELOR => 1, 'rowCount' => $counsellorCount); $counselors = civicrm_api3('Contact', 'get', $counselorParams); $ind = array(); $is_error = 0; $messages = array("Report Mail Triggered..."); if ($counselors['count'] >= 1) { $counselors = $counselors['values']; foreach ($counselors as $key => $value) { if (!empty($value['custom_' . TERRITORY_COUNSELOR])) { $ind[$key]['contact_id'] = $value['contact_id']; $ind[$key]['email'] = $value['email']; } } // Now email $instanceId = CRM_Utils_Array::value('instanceId', $params); $_REQUEST['instanceId'] = $instanceId; $_REQUEST['sendmail'] = CRM_Utils_Array::value('sendmail', $params, 1); // if cron is run from terminal --output is reserved, and therefore we would provide another name 'format' $_REQUEST['output'] = CRM_Utils_Array::value('format', $params, CRM_Utils_Array::value('output', $params, 'pdf')); $_REQUEST['reset'] = CRM_Utils_Array::value('reset', $params, 1); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value'); if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) { $obj = new CRM_Report_Page_Instance(); $instanceInfo = array(); CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { $obj->assign('reportTitle', $instanceInfo['title']); } else { $obj->assign('reportTitle', $templateInfo['label']); } foreach ($ind as $key => $value) { $_REQUEST['email_to_send'] = $value['email']; $_GET['counsellor_id_value'] = $value['contact_id']; $wrapper = new CRM_Utils_Wrapper(); $arguments = array('urlToSession' => array(array('urlVar' => 'instanceId', 'type' => 'Positive', 'sessionVar' => 'instanceId', 'default' => 'null')), 'ignoreKey' => TRUE); $messages[] = $wrapper->run($templateInfo['name'], NULL, $arguments); } } } if ($is_error == 0) { return civicrm_api3_create_success(); } else { return civicrm_api3_create_error($messages); } }
function alterDisplay(&$rows) { // cache for id → is_deleted mapping $isDeleted = array(); $newRows = array(); foreach ($rows as $key => &$row) { if (!isset($isDeleted[$row['log_civicrm_entity_altered_contact_id']])) { $isDeleted[$row['log_civicrm_entity_altered_contact_id']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['log_civicrm_entity_altered_contact_id'], 'is_deleted') !== '0'; } if (!$isDeleted[$row['log_civicrm_entity_altered_contact_id']]) { $row['log_civicrm_entity_altered_contact_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_altered_contact_id']); $row['log_civicrm_entity_altered_contact_hover'] = ts("Go to contact summary"); $entity = $this->getEntityValue($row['log_civicrm_entity_id'], $row['log_civicrm_entity_log_type']); if ($entity) { $row['log_civicrm_entity_altered_contact'] = $row['log_civicrm_entity_altered_contact'] . " [{$entity}]"; } } $row['altered_by_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_log_user_id']); $row['altered_by_contact_display_name_hover'] = ts("Go to contact summary"); if ($row['log_civicrm_entity_is_deleted'] and $row['log_civicrm_entity_log_action'] == 'Update') { $row['log_civicrm_entity_log_action'] = ts('Delete (to trash)'); } if ('Contact' == CRM_Utils_Array::value('log_type', $this->_logTables[$row['log_civicrm_entity_log_type']]) && $row['log_civicrm_entity_log_action'] == 'Insert') { $row['log_civicrm_entity_log_action'] = ts('Update'); } if ($newAction = $this->getEntityAction($row['log_civicrm_entity_id'], $row['log_civicrm_entity_log_conn_id'], $row['log_civicrm_entity_log_type'])) { $row['log_civicrm_entity_log_action'] = $newAction; } $row['log_civicrm_entity_log_type'] = $this->getLogType($row['log_civicrm_entity_log_type']); if ($row['log_civicrm_entity_log_action'] == 'Update') { $q = "reset=1&log_conn_id={$row['log_civicrm_entity_log_conn_id']}&log_date={$row['log_civicrm_entity_log_date']}"; if ($this->cid) { $q .= '&cid=' . $this->cid; } $url = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', $q, FALSE, TRUE); $row['log_civicrm_entity_log_action_link'] = $url; $row['log_civicrm_entity_log_action_hover'] = ts("View details for this update"); $row['log_civicrm_entity_log_action'] = '<div class="icon details-icon"></div> ' . ts('Update'); } $date = CRM_Utils_Date::isoToMysql($row['log_civicrm_entity_log_date']); $key = $date . '_' . $row['log_civicrm_entity_log_type'] . '_' . $row['log_civicrm_entity_log_conn_id'] . '_' . $row['log_civicrm_entity_log_user_id']; $newRows[$key] = $row; unset($row['log_civicrm_entity_log_user_id']); unset($row['log_civicrm_entity_log_conn_id']); } krsort($newRows); $rows = $newRows; }
public function run() { $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.report.CiviReportMail'); if ($lock->isAcquired()) { // try to unset any time limits if (!ini_get('safe_mode')) { set_time_limit(0); } // if there are named sets of settings, use them - otherwise use the default (null) require_once 'CRM/Report/Utils/Report.php'; $result = CRM_Report_Utils_Report::processReport(); echo $result['messages']; } else { throw new Exception('Could not acquire lock, another CiviReportMail process is running'); } $lock->release(); }
function run() { require_once 'CRM/Core/Lock.php'; $lock = new CRM_Core_Lock('CiviReportMail'); if ($lock->isAcquired()) { // try to unset any time limits if (!ini_get('safe_mode')) { set_time_limit(0); } // if there are named sets of settings, use them - otherwise use the default (null) require_once 'CRM/Report/Utils/Report.php'; $result = CRM_Report_Utils_Report::processReport(); echo $result['messages']; } else { throw new Exception('Could not acquire lock, another CiviReportMail process is running'); } $lock->release(); }
/** * Implementation of hook_civicrm_buildProfile */ function hrqual_civicrm_buildProfile($name) { if ($name == 'hrqual_tab') { // To fix validation alert issue $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('urlIsPublic', FALSE); $action = CRM_Utils_Request::retrieve('multiRecord', 'String', $this); // display the select box only in add and update mode if (in_array($action, array("add", "update"))) { $regionParams = array('markup' => "<select id='category_name' name='category_name' style='display:none' class='form-select required'></select>"); CRM_Core_Region::instance('profile-form-hrqual_tab')->add($regionParams); } $config = CRM_Core_Config::singleton(); if ($config->logging && 'multiProfileDialog' !== CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject)) { $contactID = CRM_Utils_Request::retrieve('id', 'Positive', $this); CRM_Core_Region::instance('profile-form-hrqual_tab')->add(array('template' => 'CRM/common/logButton.tpl', 'instance_id' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'css_class' => 'hrqual-revision-link', 'table_name' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'Qualifications', 'table_name', 'name'), 'contact_id' => $contactID, 'weight' => -2)); } } }
function getReportOutputAsCsv($reportClass, $inputParams) { $config = CRM_Core_Config::singleton(); $config->keyDisable = TRUE; $controller = new CRM_Core_Controller_Simple($reportClass, ts('some title')); $tmpReportVal = explode('_', $reportClass); $reportName = array_pop($tmpReportVal); $reportObj =& $controller->_pages[$reportName]; $tmpGlobals = array(); $tmpGlobals['_REQUEST']['force'] = 1; $tmpGlobals['_GET'][$config->userFrameworkURLVar] = 'civicrm/placeholder'; $tmpGlobals['_SERVER']['QUERY_STRING'] = ''; if (!empty($inputParams['fields'])) { $fields = implode(',', $inputParams['fields']); $tmpGlobals['_GET']['fld'] = $fields; $tmpGlobals['_GET']['ufld'] = 1; } if (!empty($inputParams['filters'])) { foreach ($inputParams['filters'] as $key => $val) { $tmpGlobals['_GET'][$key] = $val; } } if (!empty($inputParams['group_bys'])) { $groupByFields = implode(' ', $inputParams['group_bys']); $tmpGlobals['_GET']['gby'] = $groupByFields; } CRM_Utils_GlobalStack::singleton()->push($tmpGlobals); try { $reportObj->storeResultSet(); $reportObj->buildForm(); $rows = $reportObj->getResultSet(); $tmpFile = $this->createTempDir() . CRM_Utils_File::makeFileName('CiviReport.csv'); $csvContent = CRM_Report_Utils_Report::makeCsv($reportObj, $rows); file_put_contents($tmpFile, $csvContent); } catch (Exception $e) { // print_r($e->getCause()->getUserInfo()); CRM_Utils_GlobalStack::singleton()->pop(); throw $e; } CRM_Utils_GlobalStack::singleton()->pop(); return $tmpFile; }
/** * run this page (figure out the action needed and perform it). * * @return void */ 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(); require_once 'CRM/Core/OptionGroup.php'; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value', 'String', false); if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) { CRM_Utils_System::setTitle($templateInfo['label'] . ' - Template'); $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.')); } return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', "reset=1")); }
static function registerScripts() { static $loaded = FALSE; if ($loaded) { return; } $loaded = TRUE; CRM_Core_Resources::singleton()->addSettingsFactory(function () { $config = CRM_Core_Config::singleton(); return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'job_hours_time' => CRM_HRJob_Page_JobsTab::getJobHoursTime(), 'working_days' => CRM_HRJob_Page_JobsTab::getDaysPerTime()), 'FieldOptions' => CRM_HRJob_Page_JobsTab::getFieldOptions(), 'jobTabApp' => array('contact_id' => CRM_Utils_Request::retrieve('cid', 'Integer'), 'domain_id' => CRM_Core_Config::domainID(), 'isLogEnabled' => (bool) $config->logging, 'loggingReportId' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'currencies' => CRM_HRJob_Page_JobsTab::getCurrencyFormats(), 'defaultCurrency' => $config->defaultCurrency)); })->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.js', 120, 'html-header')->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.modelbinder.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'js/jquery/jquery.crmRevisionLink.js', 125, 'html-header', FALSE)->addScriptFile('org.civicrm.hrjob', 'js/jquery/jquery.hrContactLink.js', 125, 'html-header', FALSE)->addScriptFile('org.civicrm.hrjob', 'js/jquery/jquery.hrFileLink.js', 125, 'html-header', FALSE)->addScriptFile('org.civicrm.hrjob', 'js/jquery/jquery.lockButton.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'js/crm.backbone.js', 130, 'html-header', FALSE)->addStyleFile('org.civicrm.hrjob', 'css/hrjob.css', 140, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/hrapp.js', 150, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/renderutil.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/entities/hrjob.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/common/navigation.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/common/mbind.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/common/views.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/intro/show_controller.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/intro/show_views.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/tree/tree_controller.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/tree/tree_views.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/summary/summary_controller.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/summary/summary_views.js', 160, 'html-header'); foreach (array('general', 'funding', 'health', 'hour', 'leave', 'pay', 'pension', 'role') as $module) { CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrjob', "js/jobtabapp/{$module}/edit_controller.js", 160, 'html-header')->addScriptFile('org.civicrm.hrjob', "js/jobtabapp/{$module}/edit_views.js", 160, 'html-header')->addScriptFile('org.civicrm.hrjob', "js/jobtabapp/{$module}/summary_views.js", 160, 'html-header'); } $templateDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.hrjob') . '/templates/'; $region = CRM_Core_Region::instance('page-header'); foreach (glob($templateDir . 'CRM/HRJob/Underscore/*.tpl') as $file) { $fileName = substr($file, strlen($templateDir)); $region->add(array('template' => $fileName)); } $region->add(array('template' => 'CRM/Form/validate.tpl')); }
function processReport() { $sendmail = CRM_Utils_Request::retrieve('sendmail', 'Boolean', CRM_Core_DAO::$_nullObject, true, null, 'REQUEST'); $instanceId = CRM_Utils_Request::retrieve('instanceId', 'Positive', CRM_Core_DAO::$_nullObject, true, null, 'REQUEST'); $resetVal = CRM_Utils_Request::retrieve('reset', 'Positive', CRM_Core_DAO::$_nullObject, true, null, 'REQUEST'); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); echo "Report Mail Triggered...<br />"; require_once 'CRM/Core/OptionGroup.php'; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value'); $obj = new CRM_Report_Page_Instance(); if (strstr($templateInfo['name'], '_Form')) { $instanceInfo = array(); CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { $obj->assign('reportTitle', $instanceInfo['title']); } else { $obj->assign('reportTitle', $templateInfo['label']); } $wrapper =& new CRM_Utils_Wrapper(); $arguments['urlToSession'] = array(array('urlVar' => 'instanceId', 'type' => 'Positive', 'sessionVar' => 'instanceId', 'default' => 'null')); return $wrapper->run($templateInfo['name'], null, $arguments); } }
/** * Alter display of rows. * * Iterate through the rows retrieved via SQL and make changes for display purposes, * such as rendering contacts as links. * * @param array $rows * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { $entryFound = FALSE; $eventType = CRM_Core_OptionGroup::values('event_type'); $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); foreach ($rows as $rowNum => $row) { // make count columns point to detail report // convert display name to links if (array_key_exists('civicrm_participant_event_id', $row)) { $eventId = $row['civicrm_participant_event_id']; if ($eventId) { $rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($eventId, FALSE); $url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $eventId, $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['civicrm_participant_event_id_link'] = $url; $rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event"); } $entryFound = TRUE; } // handle event type id $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_event_event_type_id', $rowNum, $eventType); // handle participant status id if (array_key_exists('civicrm_participant_status_id', $row)) { $statusId = $row['civicrm_participant_status_id']; if ($statusId) { $rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($statusId, FALSE, 'label'); } $entryFound = TRUE; } // handle participant role id if (array_key_exists('civicrm_participant_role_id', $row)) { $roleId = $row['civicrm_participant_role_id']; if ($roleId) { $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $roleId); $roleId = array(); foreach ($roles as $role) { $roleId[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE); } $rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $roleId); } $entryFound = TRUE; } // Handel value seperator in Fee Level if (array_key_exists('civicrm_participant_participant_fee_level', $row)) { $feeLevel = $row['civicrm_participant_participant_fee_level']; if ($feeLevel) { CRM_Event_BAO_Participant::fixEventLevel($feeLevel); $rows[$rowNum]['civicrm_participant_participant_fee_level'] = $feeLevel; } $entryFound = TRUE; } // Convert display name to link $displayName = CRM_Utils_Array::value('civicrm_contact_sort_name_linked', $row); $cid = CRM_Utils_Array::value('civicrm_contact_id', $row); $id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row); if ($displayName && $cid && $id) { $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', "reset=1&force=1&id_op=eq&id_value={$cid}", $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant", "reset=1&id={$id}&cid={$cid}&action=view&context=participant"); $contactTitle = ts('View Contact Details'); $participantTitle = ts('View Participant Record'); $rows[$rowNum]['civicrm_contact_sort_name_linked'] = "<a title='{$contactTitle}' href={$url}>{$displayName}</a>"; if ($this->_outputMode !== 'csv') { $rows[$rowNum]['civicrm_contact_sort_name_linked'] .= "<span style='float: right;'><a title='{$participantTitle}' href={$viewUrl}>" . ts('View') . "</a></span>"; } $entryFound = TRUE; } // Handle country id if (array_key_exists('civicrm_address_country_id', $row)) { $countryId = $row['civicrm_address_country_id']; if ($countryId) { $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($countryId, TRUE); } $entryFound = TRUE; } // Handle state/province id if (array_key_exists('civicrm_address_state_province_id', $row)) { $provinceId = $row['civicrm_address_state_province_id']; if ($provinceId) { $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($provinceId, TRUE); } $entryFound = TRUE; } // Handle employer id if (array_key_exists('civicrm_contact_employer_id', $row)) { $employerId = $row['civicrm_contact_employer_id']; if ($employerId) { $rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($employerId); $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $employerId, $this->_absoluteUrl); $rows[$rowNum]['civicrm_contact_employer_id_link'] = $url; $rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.'); } } // Convert campaign_id to campaign title $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_participant_campaign_id', $rowNum, $this->activeCampaigns); // handle contribution status $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_contribution_status_id', $rowNum, $contributionStatus); // handle payment instrument $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_payment_instrument_id', $rowNum, $paymentInstruments); // handle financial type $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contribution_financial_type_id', $rowNum, $financialTypes); $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'event/participantListing', 'View Event Income Details') ? TRUE : $entryFound; // display birthday in the configured custom format if (array_key_exists('civicrm_contact_birth_date', $row)) { $birthDate = $row['civicrm_contact_birth_date']; if ($birthDate) { $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d'); } $entryFound = TRUE; } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } } }
/** * Alter display of rows. * * Iterate through the rows retrieved via SQL and make changes for display purposes, * such as rendering contacts as links. * * @param array $rows * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { list($from1, $to1) = $this->getFromTo(CRM_Utils_Array::value("receive_date1_relative", $this->_params), CRM_Utils_Array::value("receive_date1_from", $this->_params), CRM_Utils_Array::value("receive_date1_to", $this->_params)); list($from2, $to2) = $this->getFromTo(CRM_Utils_Array::value("receive_date2_relative", $this->_params), CRM_Utils_Array::value("receive_date2_from", $this->_params), CRM_Utils_Array::value("receive_date2_to", $this->_params)); $dateUrl = ""; if ($from1) { $dateUrl .= "receive_date1_from={$from1}&"; } if ($to1) { $dateUrl .= "receive_date1_to={$to1}&"; } if ($from2) { $dateUrl .= "receive_date2_from={$from2}&"; } if ($to2) { $dateUrl .= "receive_date2_to={$to2}&"; } foreach ($rows as $rowNum => $row) { // handle country if (array_key_exists('address_civireport_country_id', $row)) { if ($value = $row['address_civireport_country_id']) { $rows[$rowNum]['address_civireport_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE); $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . "country_id_op=in&country_id_value={$value}&" . "{$dateUrl}", $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['address_civireport_country_id_link'] = $url; $rows[$rowNum]['address_civireport_country_id_hover'] = ts("View contributions for this Country."); } } // handle state province if (array_key_exists('address_civireport_state_province_id', $row)) { if ($value = $row['address_civireport_state_province_id']) { $rows[$rowNum]['address_civireport_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE); $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . "state_province_id_op=in&state_province_id_value={$value}&" . "{$dateUrl}", $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['address_civireport_state_province_id_link'] = $url; $rows[$rowNum]['address_civireport_state_province_id_hover'] = ts("View repeatDetails for this state."); } } // convert display name to links if (array_key_exists('contact_civireport_sort_name', $row) && array_key_exists('contact_civireport_id', $row)) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['contact_civireport_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['contact_civireport_sort_name_link'] = $url; $rows[$rowNum]['contact_civireport_sort_name_hover'] = ts("View Contribution details for this contact"); } } // foreach ends }
/** * Alter display of rows. * * Iterate through the rows retrieved via SQL and make changes for display purposes, * such as rendering contacts as links. * * @param array $rows * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { $entryFound = FALSE; foreach ($rows as $rowNum => $row) { //Convert Display name into link if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contribution_contact_id', $row)) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contribution_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contribution Details for this Contact."); $entryFound = TRUE; } // convert campaign_id to campaign title if (array_key_exists('civicrm_contribution_campaign_id', $row)) { if ($value = $row['civicrm_contribution_campaign_id']) { $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns[$value]; $entryFound = TRUE; } } $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s)') ? TRUE : $entryFound; //handle gender if (array_key_exists('civicrm_contact_gender_id', $row)) { if ($value = $row['civicrm_contact_gender_id']) { $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value]; } $entryFound = TRUE; } // display birthday in the configured custom format if (array_key_exists('civicrm_contact_birth_date', $row)) { $birthDate = $row['civicrm_contact_birth_date']; if ($birthDate) { $rows[$rowNum]['civicrm_contact_birth_date'] = CRM_Utils_Date::customFormat($birthDate, '%Y%m%d'); } $entryFound = TRUE; } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } } }
function alterDisplay(&$rows) { // custom code to alter rows $checkList = array(); $entryFound = false; $display_flag = $prev_cid = $cid = 0; $contributionTypes = CRM_Contribute_PseudoConstant::contributionType(); foreach ($rows as $rowNum => $row) { if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') { // don't repeat contact details if its same as the previous row if (array_key_exists('civicrm_contact_id', $row)) { if ($cid = $row['civicrm_contact_id']) { if ($rowNum == 0) { $prev_cid = $cid; } else { if ($prev_cid == $cid) { $display_flag = 1; $prev_cid = $cid; } else { $display_flag = 0; $prev_cid = $cid; } } if ($display_flag) { foreach ($row as $colName => $colVal) { if (in_array($colName, $this->_noRepeats)) { unset($rows[$rowNum][$colName]); } } } $entryFound = true; } } } // handle state province if (array_key_exists('civicrm_address_state_province_id', $row)) { if ($value = $row['civicrm_address_state_province_id']) { $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, false); $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . "state_province_id_op=in&state_province_id_value={$value}", $this->_absoluteUrl, $this->_id); $rows[$rowNum]['civicrm_address_state_province_id_link'] = $url; $rows[$rowNum]['civicrm_address_state_province_id_hover'] = ts("List all contribution(s) for this State."); } $entryFound = true; } // handle country if (array_key_exists('civicrm_address_country_id', $row)) { if ($value = $row['civicrm_address_country_id']) { $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, false); $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . "country_id_op=in&country_id_value={$value}", $this->_absoluteUrl, $this->_id); $rows[$rowNum]['civicrm_address_country_id_link'] = $url; $rows[$rowNum]['civicrm_address_country_id_hover'] = ts("List all contribution(s) for this Country."); } $entryFound = true; } // convert display name to links if (array_key_exists('civicrm_contact_display_name', $row) && CRM_Utils_Array::value('civicrm_contact_display_name', $rows[$rowNum]) && array_key_exists('civicrm_contact_id', $row)) { $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $row['civicrm_contact_id'], $this->_absoluteUrl); $rows[$rowNum]['civicrm_contact_display_name_link'] = $url; $rows[$rowNum]['civicrm_contact_display_name_hover'] = ts("View Contact Summary for this Contact."); } if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_type_id', $row)) { $rows[$rowNum]['civicrm_contribution_contribution_type_id'] = $contributionTypes[$value]; $entryFound = true; } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } $lastKey = $rowNum; } }
function alterDisplay(&$rows) { if (is_array($rows)) { $eventType = CRM_Core_OptionGroup::values('event_type'); foreach ($rows as $rowNum => $row) { if (array_key_exists('civicrm_event_title', $row)) { if ($value = $row['civicrm_event_id']) { CRM_Event_PseudoConstant::event($value, FALSE); $url = CRM_Report_Utils_Report::getNextUrl('event/participantlist', 'reset=1&force=1&event_id_op=eq&event_id_value=' . $value, $this->_absoluteUrl, $this->_id); $rows[$rowNum]['civicrm_event_title_link'] = $url; $rows[$rowNum]['civicrm_event_title_hover'] = ts("View Event Participants For this Event"); } } //handle event type if (array_key_exists('civicrm_event_event_type_id', $row)) { if ($value = $row['civicrm_event_event_type_id']) { $rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value]; } } } } }
/** * @param $rows */ function alterDisplay(&$rows) { // custom code to alter rows $entryFound = FALSE; foreach ($rows as $rowNum => $row) { // make count columns point to detail report // convert sort name to links if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contact_id', $row)) { $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Constituent Detail Report for this contact."); $entryFound = TRUE; } if (array_key_exists('civicrm_address_state_province_id', $row)) { if ($value = $row['civicrm_address_state_province_id']) { $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE); } $entryFound = TRUE; } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } } }
/** * Alter display of rows. * * Iterate through the rows retrieved via SQL and make changes for display purposes, * such as rendering contacts as links. * * @param array $rows * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { $entryFound = FALSE; $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); foreach ($rows as $rowNum => $row) { // make count columns point to detail report if (!empty($this->_params['group_bys']['receive_date']) && !empty($row['civicrm_contribution_receive_date_start']) && CRM_Utils_Array::value('civicrm_contribution_receive_date_start', $row) && !empty($row['civicrm_contribution_receive_date_subtotal'])) { $dateStart = CRM_Utils_Date::customFormat($row['civicrm_contribution_receive_date_start'], '%Y%m%d'); $endDate = new DateTime($dateStart); $dateEnd = array(); list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d')); switch (strtolower($this->_params['group_bys_freq']['receive_date'])) { case 'month': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 1, $dateEnd['d'] - 1, $dateEnd['Y'])); break; case 'year': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], $dateEnd['d'] - 1, $dateEnd['Y'] + 1)); break; case 'fiscalyear': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], $dateEnd['d'] - 1, $dateEnd['Y'] + 1)); break; case 'yearweek': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], $dateEnd['d'] + 6, $dateEnd['Y'])); break; case 'quarter': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 3, $dateEnd['d'] - 1, $dateEnd['Y'])); break; } $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&receive_date_from={$dateStart}&receive_date_to={$dateEnd}", $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['civicrm_contribution_receive_date_start_link'] = $url; $rows[$rowNum]['civicrm_contribution_receive_date_start_hover'] = ts('List all contribution(s) for this date unit.'); $entryFound = TRUE; } // make subtotals look nicer if (array_key_exists('civicrm_contribution_receive_date_subtotal', $row) && !$row['civicrm_contribution_receive_date_subtotal']) { $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields); $entryFound = TRUE; } // convert display name to links if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contact_id', $row)) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport); $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("Lists detailed contribution(s) for this record."); $entryFound = TRUE; } // convert contribution status id to status name if ($value = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) { $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = $contributionStatus[$value]; $entryFound = TRUE; } // If using campaigns, convert campaign_id to campaign title if (array_key_exists('civicrm_contribution_campaign_id', $row)) { if ($value = $row['civicrm_contribution_campaign_id']) { $rows[$rowNum]['civicrm_contribution_campaign_id'] = $this->activeCampaigns[$value]; } $entryFound = TRUE; } $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound; $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound; // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } } }
/** * @param $rows */ function alterDisplay(&$rows) { // cache for id → is_deleted mapping $isDeleted = array(); $newRows = array(); foreach ($rows as $key => &$row) { if (!isset($isDeleted[$row['log_civicrm_entity_altered_contact_id']])) { $isDeleted[$row['log_civicrm_entity_altered_contact_id']] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['log_civicrm_entity_altered_contact_id'], 'is_deleted') !== '0'; } if (!empty($row['log_civicrm_entity_altered_contact']) && !$isDeleted[$row['log_civicrm_entity_altered_contact_id']]) { $row['log_civicrm_entity_altered_contact_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_altered_contact_id']); $row['log_civicrm_entity_altered_contact_hover'] = ts("Go to contact summary"); $entity = $this->getEntityValue($row['log_civicrm_entity_id'], $row['log_civicrm_entity_log_type'], $row['log_civicrm_entity_log_date']); if ($entity) { $row['log_civicrm_entity_altered_contact'] = $row['log_civicrm_entity_altered_contact'] . " [{$entity}]"; } } $row['altered_by_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_log_user_id']); $row['altered_by_contact_display_name_hover'] = ts("Go to contact summary"); if ($row['log_civicrm_entity_is_deleted'] and 'Update' == CRM_Utils_Array::value('log_civicrm_entity_log_action', $row)) { $row['log_civicrm_entity_log_action'] = ts('Delete (to trash)'); } if ('Contact' == CRM_Utils_Array::value('log_type', $this->_logTables[$row['log_civicrm_entity_log_type']]) && CRM_Utils_Array::value('log_civicrm_entity_log_action', $row) == 'Insert') { $row['log_civicrm_entity_log_action'] = ts('Update'); } if ($newAction = $this->getEntityAction($row['log_civicrm_entity_id'], $row['log_civicrm_entity_log_conn_id'], $row['log_civicrm_entity_log_type'], CRM_Utils_Array::value('log_civicrm_entity_log_action', $row))) { $row['log_civicrm_entity_log_action'] = $newAction; } $row['log_civicrm_entity_log_type'] = $this->getLogType($row['log_civicrm_entity_log_type']); $date = CRM_Utils_Date::isoToMysql($row['log_civicrm_entity_log_date']); if ('Update' == CRM_Utils_Array::value('log_civicrm_entity_log_action', $row)) { $q = "reset=1&log_conn_id={$row['log_civicrm_entity_log_conn_id']}&log_date=" . $date; if ($this->cid) { $q .= '&cid=' . $this->cid; } $q .= !empty($row['log_civicrm_entity_altered_contact']) ? '&alteredName=' . $row['log_civicrm_entity_altered_contact'] : ''; $q .= !empty($row['altered_by_contact_display_name']) ? '&alteredBy=' . $row['altered_by_contact_display_name'] : ''; $q .= !empty($row['log_civicrm_entity_log_user_id']) ? '&alteredById=' . $row['log_civicrm_entity_log_user_id'] : ''; $url1 = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', "{$q}&snippet=4§ion=2&layout=overlay", FALSE, TRUE); $url2 = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', "{$q}§ion=2", FALSE, TRUE); $row['log_civicrm_entity_log_action'] = "<a href='{$url1}' class='crm-summary-link'><div class='icon details-icon'></div></a> <a title='View details for this update' href='{$url2}'>" . ts('Update') . '</a>'; } $key = $date . '_' . $row['log_civicrm_entity_log_type'] . '_' . $row['log_civicrm_entity_log_conn_id'] . '_' . $row['log_civicrm_entity_log_user_id'] . '_' . $row['log_civicrm_entity_altered_contact_id']; $newRows[$key] = $row; unset($row['log_civicrm_entity_log_user_id']); unset($row['log_civicrm_entity_log_conn_id']); } krsort($newRows); $rows = $newRows; }
function alterDisplay(&$rows) { // custom code to alter rows $entryFound = false; $eventType = CRM_Core_OptionGroup::values('event_type'); foreach ($rows as $rowNum => $row) { // make count columns point to detail report // convert display name to links if (array_key_exists('civicrm_participant_event_id', $row)) { if ($value = $row['civicrm_participant_event_id']) { $rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($value, false); $url = CRM_Report_Utils_Report::getNextUrl('event/income', 'reset=1&force=1&id_op=in&id_value=' . $value, $this->_absoluteUrl, $this->_id); $rows[$rowNum]['civicrm_participant_event_id_link'] = $url; $rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event"); } $entryFound = true; } // handle event type id if (array_key_exists('civicrm_event_event_type_id', $row)) { if ($value = $row['civicrm_event_event_type_id']) { $rows[$rowNum]['civicrm_event_event_type_id'] = $eventType[$value]; } $entryFound = true; } // handle participant status id if (array_key_exists('civicrm_participant_status_id', $row)) { if ($value = $row['civicrm_participant_status_id']) { $rows[$rowNum]['civicrm_participant_status_id'] = CRM_Event_PseudoConstant::participantStatus($value, false); } $entryFound = true; } // handle participant role id if (array_key_exists('civicrm_participant_role_id', $row)) { if ($value = $row['civicrm_participant_role_id']) { $rows[$rowNum]['civicrm_participant_role_id'] = CRM_Event_PseudoConstant::participantRole($value, false); } $entryFound = true; } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { break; } } }
function alterDisplay(&$rows) { foreach ($rows as $rowNum => $row) { //Convert Display name into link if (array_key_exists('civicrm_contact_display_name', $row) && array_key_exists('civicrm_contribution_contact_id', $row)) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contribution_contact_id'], $this->_absoluteUrl, $this->_id); $rows[$rowNum]['civicrm_contact_display_name_link'] = $url; $rows[$rowNum]['civicrm_contact_display_name_hover'] = ts("View Contribution Details for this Contact."); } } }