/** * 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')); }
/** * 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); }
static function getValueIDFromUrl($instanceID = null) { $optionVal = self::getValueFromUrl($instanceID); if ($optionVal) { require_once 'CRM/Core/OptionGroup.php'; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); return array($templateInfo['id'], $optionVal); } return false; }
/** * 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); }
/** * 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); } }
/** * 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")); }
/** * Returns array of needs matching a set of one or more group properties * * @param array $params Array of one or more valid * property_name=>value pairs. If $params is set * as null, all needs will be returned * * @return array (referance) Array of matching needs * {@getfields need_get} * @access public */ function civicrm_api3_volunteer_need_get($params) { $result = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); if (!empty($result['values'])) { foreach ($result['values'] as &$need) { if (!empty($need['start_time'])) { $need['display_time'] = CRM_Volunteer_BAO_Need::getTimes($need['start_time'], CRM_Utils_Array::value('duration', $need), CRM_Utils_Array::value('end_time', $need)); } else { $need['display_time'] = CRM_Volunteer_BAO_Need::getFlexibleDisplayTime(); } if (isset($need['role_id'])) { $role = CRM_Core_OptionGroup::getRowValues(CRM_Volunteer_BAO_Assignment::ROLE_OPTION_GROUP, $need['role_id'], 'value'); $need['role_label'] = $role['label']; $need['role_description'] = $role['description']; } elseif (CRM_Utils_Array::value('is_flexible', $need)) { $need['role_label'] = CRM_Volunteer_BAO_Need::getFlexibleRoleLabel(); $need['role_description'] = NULL; } } } return $result; }
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); } }
static function processReport($params) { $instanceId = CRM_Utils_Array::value('instanceId', $params); // hack for now, CRM-8358 $_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 = self::getValueFromUrl($instanceId); $messages = array("Report Mail Triggered..."); $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value'); $obj = new CRM_Report_Page_Instance(); $is_error = 0; if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) { $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']); } $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); } else { $is_error = 1; if (!$instanceId) { $messages[] = 'Required parameter missing: instanceId'; } else { $messages[] = 'Did not find valid instance to execute'; } } $result = array('is_error' => $is_error, 'messages' => implode("\n", $messages)); return $result; }