Exemplo n.º 1
0
 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']);
     }
 }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
 /**
  * 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']);
     }
 }
 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));
     }
 }
 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;
 }
Exemplo n.º 6
0
 /**
  * Add link fields to the row.
  *
  * Function adds the _link & _hover fields to the row.
  *
  * @param array $row
  * @param string $baseUrl
  * @param string $linkText
  * @param string $value
  * @param string $fieldName
  * @param string $tablePrefix
  * @param string $fieldLabel
  *
  * @return mixed
  */
 protected function addLinkToRow(&$row, $baseUrl, $linkText, $value, $fieldName, $tablePrefix, $fieldLabel)
 {
     $criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params);
     $url = CRM_Report_Utils_Report::getNextUrl($baseUrl, "reset=1&force=1&{$criteriaQueryParams}&" . $fieldName . "_op=in&{$fieldName}_value={$value}", $this->_absoluteUrl, $this->_id);
     $row["{$tablePrefix}_{$fieldName}_link"] = $url;
     $row["{$tablePrefix}_{$fieldName}_hover"] = ts("%1 for this %2.", array(1 => $linkText, 2 => $fieldLabel));
 }
Exemplo n.º 7
0
 function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $entryFound = FALSE;
     $dispname_flag = $phone_flag = $email_flag = 0;
     $prev_email = $prev_dispname = $prev_phone = NULL;
     foreach ($rows as $rowNum => $row) {
         // Link constituent (contributor) to contribution detail
         if (array_key_exists('civicrm_contact_display_name_constituent', $row) && array_key_exists('civicrm_contact_id_constituent', $row)) {
             $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id_constituent'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
             $rows[$rowNum]['civicrm_contact_display_name_constituent_link'] = $url;
             $rows[$rowNum]['civicrm_contact_display_name_constituent_hover'] = ts('List all direct contribution(s) from this contact.');
             $entryFound = TRUE;
         }
         // convert soft credit contact name to link
         if (array_key_exists('civicrm_contact_display_name_creditor', $row) && !empty($rows[$rowNum]['civicrm_contact_display_name_creditor']) && array_key_exists('civicrm_contact_id_creditor', $row)) {
             $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $row['civicrm_contact_id_creditor'], $this->_absoluteUrl);
             $rows[$rowNum]['civicrm_contact_display_name_creditor_link'] = $url;
             $rows[$rowNum]['civicrm_contact_display_name_creditor_hover'] = ts("view contact summary");
         }
         // make subtotals look nicer
         if (array_key_exists('civicrm_contact_id_constituent', $row) && !$row['civicrm_contact_id_constituent']) {
             $this->fixSubTotalDisplay($rows[$rowNum], $this->_statFields);
             $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;
             }
         }
         //convert soft_credit_type_id into label
         if (array_key_exists('civicrm_contribution_soft_soft_credit_type_id', $rows[$rowNum])) {
             $rows[$rowNum]['civicrm_contribution_soft_soft_credit_type_id'] = CRM_Core_OptionGroup::getLabel('soft_credit_type', $row['civicrm_contribution_soft_soft_credit_type_id']);
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
     $this->removeDuplicates($rows);
 }
Exemplo n.º 8
0
 /**
  * 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;
     $checkList = array();
     foreach ($rows as $rowNum => $row) {
         if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') {
             // not repeat contact display names if it matches with the one
             // in previous row
             $repeatFound = FALSE;
             foreach ($row as $colName => $colVal) {
                 if (!empty($checkList[$colName]) && is_array($checkList[$colName]) && in_array($colVal, $checkList[$colName])) {
                     $rows[$rowNum][$colName] = "";
                     $repeatFound = TRUE;
                 }
                 if (in_array($colName, $this->_noRepeats)) {
                     $checkList[$colName][] = $colVal;
                 }
             }
         }
         //handle the Membership Type Ids
         if (array_key_exists('civicrm_membership_membership_type_id', $row)) {
             if ($value = $row['civicrm_membership_membership_type_id']) {
                 $rows[$rowNum]['civicrm_membership_membership_type_id'] = CRM_Member_PseudoConstant::membershipType($value, FALSE);
             }
             $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);
             }
             $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);
             }
             $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('member/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 Membership Detail for this Contact.");
         }
         // If using campaigns, convert campaign_id to campaign title
         if (array_key_exists('civicrm_membership_campaign_id', $row)) {
             if ($value = $row['civicrm_membership_campaign_id']) {
                 $rows[$rowNum]['civicrm_membership_campaign_id'] = $this->activeCampaigns[$value];
             }
             $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;
     $eventType = CRM_Core_OptionGroup::values('event_type');
     foreach ($rows as $rowNum => $row) {
         // convert sort name to links
         if (array_key_exists('civicrm_contact_sort_name', $row) && array_key_exists('civicrm_contact_id', $row)) {
             if ($value = $row['civicrm_contact_sort_name']) {
                 $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $row['civicrm_contact_id'], $this->_absoluteUrl);
                 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
                 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
             }
             $entryFound = TRUE;
         }
         // convert participant ID to links
         if (array_key_exists('civicrm_participant_participant_id', $row) && array_key_exists('civicrm_contact_id', $row)) {
             if ($value = $row['civicrm_participant_participant_id']) {
                 $url = CRM_Utils_System::url("civicrm/contact/view/participant", 'reset=1&id=' . $row['civicrm_participant_participant_id'] . '&cid=' . $row['civicrm_contact_id'] . '&action=view&context=participant', $this->_absoluteUrl);
                 $rows[$rowNum]['civicrm_participant_participant_id_link'] = $url;
                 $rows[$rowNum]['civicrm_participant_participant_id_hover'] = ts("View Participant Record for this Contact.");
             }
             $entryFound = TRUE;
         }
         // convert event 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&event_id_op=eq&event_id_value=' . $value, $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
         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']) {
                 $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
                 $value = array();
                 foreach ($roles as $role) {
                     $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
                 }
                 $rows[$rowNum]['civicrm_participant_role_id'] = implode(', ', $value);
             }
             $entryFound = TRUE;
         }
         //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;
         }
     }
 }
Exemplo n.º 10
0
 /**
  * @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;
         }
     }
 }
Exemplo n.º 11
0
 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;
     }
 }
Exemplo n.º 12
0
 function alterDisplay(&$rows)
 {
     // custom code to alter 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;
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }
Exemplo n.º 13
0
 /**
  * @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&section=2&layout=overlay", FALSE, TRUE);
             $url2 = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', "{$q}&section=2", FALSE, TRUE);
             $row['log_civicrm_entity_log_action'] = "<a href='{$url1}' class='crm-summary-link'><div class='icon details-icon'></div></a>&nbsp;<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;
 }
 /**
  * Create links to detailed report for various numbers
  * (non-PHPdoc)
  * @see CRM_Extendedreport_Form_Report_Contribute_ContributionAggregates::alterDisplay()
  */
 function alterDisplay(&$rows)
 {
     foreach ($rows as &$row) {
         $availableKpi = array_flip($this->_kpiDescriptors);
         //kpiName looks like 'total_amount__individual'
         $kpiName = $availableKpi[$row['description']];
         $kpiDetails = explode('__', $kpiName);
         if ($this->_kpiSpecs[$kpiDetails[0]]['type'] == CRM_Utils_Type::T_MONEY) {
             $row['this_year'] = CRM_Utils_Money::format($row['this_year']);
             $row['last_year'] = CRM_Utils_Money::format($row['last_year']);
         }
         if ($row['percent_change'] == 0 && $row['this_year'] != $row['last_year']) {
             $row['percent_change'] = 'n/a';
         } else {
             $row['percent_change'] = $row['percent_change'] . '%';
         }
         if (!$this->_kpiSpecs[$kpiDetails[0]]['link_status']) {
             // spec specifies no link
             continue;
         }
         // we are dealing with rows not columns so this differs from parent approach
         $queryURL = "reset=1&force=1";
         foreach ($this->_potentialCriteria as $criterion) {
             if (empty($this->_params[$criterion])) {
                 continue;
             }
             $criterionValue = is_array($this->_params[$criterion]) ? implode(',', $this->_params[$criterion]) : $this->_params[$criterion];
             $queryURL .= "&{$criterion}=" . $criterionValue;
         }
         if (!empty($kpiDetails[1])) {
             // we are going to do some extra handling in case of unexpected case for contact type
             $contactTypes = $this->getContactTypeOptions();
             $contactTypes = array_keys($contactTypes);
             $lcKey = array_search(strtolower($kpiDetails[1]), array_map('strtolower', $contactTypes));
             $contactType = $contactTypes[$lcKey];
             $queryURL .= "&contact_type_value=" . $contactType . "&contact_type_op=in";
         }
         $years = array(0 => 'this_year', 1 => 'last_year');
         foreach ($years as $interval => $year) {
             $queryURLYear = "&comparison_date_from=" . date('YmdHis', strtotime($this->_ranges['interval_' . $interval]['comparison_from_date'])) . "&comparison_date_to=" . date('YmdHis', strtotime($this->_ranges['interval_' . $interval]['comparison_to_date'])) . "&receive_date_from=" . date('YmdHis', strtotime($this->_ranges['interval_' . $interval]['from_date'])) . "&receive_date_to=" . date('YmdHis', strtotime($this->_ranges['interval_' . $interval]['to_date']));
             $url = CRM_Report_Utils_Report::getNextUrl('contribute/aggregatedetails', $queryURL . "&behaviour_type_value=" . $this->_kpiSpecs[$kpiDetails[0]]['link_status'] . $queryURLYear, $this->_absoluteUrl, NULL, $this->_drilldownReport);
             $row[$year . '_link'] = $url;
         }
     }
     parent::alterDisplay($rows);
 }
Exemplo n.º 15
0
 /**
  * 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)
 {
     if (is_array($rows)) {
         $eventType = CRM_Core_OptionGroup::values('event_type');
         foreach ($rows as $rowNum => $row) {
             if (array_key_exists('totalAmount', $row) && array_key_exists('currency', $row)) {
                 $rows[$rowNum]['totalAmount'] = CRM_Utils_Money::format($rows[$rowNum]['totalAmount'], $rows[$rowNum]['currency']);
             }
             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/income', 'reset=1&force=1&id_op=in&id_value=' . $value, $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
                     $rows[$rowNum]['civicrm_event_title_link'] = $url;
                     $rows[$rowNum]['civicrm_event_title_hover'] = ts('View Event Income 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];
                 }
             }
         }
     }
 }
Exemplo n.º 16
0
 function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $entryFound = false;
     foreach ($rows as $rowNum => $row) {
         // 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);
             }
             $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;
         }
         if (array_key_exists('civicrm_contact_display_name_a', $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);
             $rows[$rowNum]['civicrm_contact_display_name_a_link'] = $url;
             $rows[$rowNum]['civicrm_contact_display_name_a_hover'] = ts("View Contact details for this contact.");
             $entryFound = true;
         }
         if (array_key_exists('civicrm_contact_b_display_name_b', $row) && array_key_exists('civicrm_contact_b_id', $row)) {
             $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_b_id'], $this->_absoluteUrl, $this->_id);
             $rows[$rowNum]['civicrm_contact_b_display_name_b_link'] = $url;
             $rows[$rowNum]['civicrm_contact_b_display_name_b_hover'] = ts("View Contact details for this contact.");
             $entryFound = true;
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }
Exemplo n.º 17
0
 /**
  * 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)
 {
     if (empty($rows)) {
         return;
     }
     $last_primary = NULL;
     foreach ($rows as $rowNum => $row) {
         //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');
                 $row['civicrm_contact_gender_id'] = $rows[$rowNum]['civicrm_contact_gender_id'] = $gender[$value];
             }
             $entryFound = TRUE;
         }
         // Highlight primary contact and amount row
         if (is_numeric($rowNum) || $last_primary && $rowNum == "{$last_primary}_total") {
             if (is_numeric($rowNum)) {
                 $last_primary = $rowNum;
             }
             foreach ($row as $key => $value) {
                 if ($key == 'civicrm_contact_id') {
                     continue;
                 }
                 if (empty($value)) {
                     $row[$key] = '';
                     continue;
                 }
                 if ($last_primary && $rowNum == "{$last_primary}_total") {
                     $value = CRM_Utils_Money::format($value, ' ');
                 }
                 $row[$key] = '<strong>' . $value . '</strong>';
             }
             $rows[$rowNum] = $row;
         }
         // Convert Display name into link
         if (!empty($row['civicrm_contact_sort_name']) && !empty($row['civicrm_contact_id'])) {
             $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);
             $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
             $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contribution Details for this Contact.");
         }
         // 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;
         }
     }
 }
Exemplo n.º 18
0
 /**
  * @param $rows
  */
 public function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $entryFound = FALSE;
     foreach ($rows as $rowNum => $row) {
         // 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);
             }
             $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;
         }
         if (array_key_exists('civicrm_contact_sort_name_a', $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_a'] = $rows[$rowNum]['civicrm_contact_sort_name_a'] . ' (' . $rows[$rowNum]['civicrm_contact_id'] . ')';
             $rows[$rowNum]['civicrm_contact_sort_name_a_link'] = $url;
             $rows[$rowNum]['civicrm_contact_sort_name_a_hover'] = ts("View Contact details for this contact.");
             $entryFound = TRUE;
         }
         if (array_key_exists('civicrm_contact_b_sort_name_b', $row) && array_key_exists('civicrm_contact_b_id', $row)) {
             $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_b_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
             $rows[$rowNum]['civicrm_contact_b_sort_name_b'] = $rows[$rowNum]['civicrm_contact_b_sort_name_b'] . ' (' . $rows[$rowNum]['civicrm_contact_b_id'] . ')';
             $rows[$rowNum]['civicrm_contact_b_sort_name_b_link'] = $url;
             $rows[$rowNum]['civicrm_contact_b_sort_name_b_hover'] = ts("View Contact details for this contact.");
             $entryFound = TRUE;
         }
         if (array_key_exists('civicrm_relationship_relationship_id', $row) && array_key_exists('civicrm_contact_id', $row)) {
             $url = "/civicrm/contact/view/rel?reset=1&action=update&rtype=a_b&cid=" . $row['civicrm_contact_id'] . "&id=" . $row['civicrm_relationship_relationship_id'];
             $rows[$rowNum]['civicrm_relationship_relationship_id_link'] = $url;
             $rows[$rowNum]['civicrm_relationship_relationship_id_hover'] = ts("Edit this relationship.");
             $entryFound = TRUE;
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }
Exemplo n.º 19
0
 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.");
         }
     }
 }
Exemplo n.º 20
0
 /**
  * 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) {
         // CRM-16506
         if (array_key_exists('civicrm_mailing_name', $row) && array_key_exists('civicrm_mailing_id', $row)) {
             $rows[$rowNum]['civicrm_mailing_name_link'] = CRM_Report_Utils_Report::getNextUrl('mailing/detail', 'reset=1&force=1&mailing_id_op=eq&mailing_id_value=' . $row['civicrm_mailing_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport);
             $rows[$rowNum]['civicrm_mailing_name_hover'] = ts('View Mailing details for this mailing');
             $entryFound = TRUE;
         }
         // skip looking further in rows, if first row itself doesn't
         // have the column we need
         if (!$entryFound) {
             break;
         }
     }
 }
Exemplo n.º 21
0
 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;
         }
     }
 }
Exemplo n.º 22
0
 /**
  * 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
 }
Exemplo n.º 23
0
 /**
  * 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;
         }
     }
 }
 function buildQuickForm()
 {
     parent::buildQuickForm();
     // link back to summary report
     $this->assign('backURL', CRM_Report_Utils_Report::getNextUrl('logging/contribute/summary', 'reset=1', FALSE, TRUE));
 }
 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];
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
 /**
  * Generate a report.  Fetch event count information, mailing data, and job
  * status.
  *
  * @param int $id
  *   The mailing id to report.
  * @param bool $skipDetails
  *   Whether return all detailed report.
  *
  * @param bool $isSMS
  *
  * @return array
  *   Associative array of reporting data
  */
 public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE)
 {
     $mailing_id = CRM_Utils_Type::escape($id, 'Integer');
     $mailing = new CRM_Mailing_BAO_Mailing();
     $t = array('mailing' => self::getTableName(), 'mailing_group' => CRM_Mailing_DAO_MailingGroup::getTableName(), 'group' => CRM_Contact_BAO_Group::getTableName(), 'job' => CRM_Mailing_BAO_MailingJob::getTableName(), 'queue' => CRM_Mailing_Event_BAO_Queue::getTableName(), 'delivered' => CRM_Mailing_Event_BAO_Delivered::getTableName(), 'opened' => CRM_Mailing_Event_BAO_Opened::getTableName(), 'reply' => CRM_Mailing_Event_BAO_Reply::getTableName(), 'unsubscribe' => CRM_Mailing_Event_BAO_Unsubscribe::getTableName(), 'bounce' => CRM_Mailing_Event_BAO_Bounce::getTableName(), 'forward' => CRM_Mailing_Event_BAO_Forward::getTableName(), 'url' => CRM_Mailing_BAO_TrackableURL::getTableName(), 'urlopen' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName(), 'component' => CRM_Mailing_BAO_Component::getTableName(), 'spool' => CRM_Mailing_BAO_Spool::getTableName());
     $report = array();
     $additionalWhereClause = " AND ";
     if (!$isSMS) {
         $additionalWhereClause .= " {$t['mailing']}.sms_provider_id IS NULL ";
     } else {
         $additionalWhereClause .= " {$t['mailing']}.sms_provider_id IS NOT NULL ";
     }
     /* Get the mailing info */
     $mailing->query("\n            SELECT          {$t['mailing']}.*\n            FROM            {$t['mailing']}\n            WHERE           {$t['mailing']}.id = {$mailing_id} {$additionalWhereClause}");
     $mailing->fetch();
     $report['mailing'] = array();
     foreach (array_keys(self::fields()) as $field) {
         $report['mailing'][$field] = $mailing->{$field};
     }
     //get the campaign
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $report['mailing'])) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $report['mailing']['campaign'] = $campaigns[$campaignId];
     }
     //mailing report is called by activity
     //we dont need all detail report
     if ($skipDetails) {
         return $report;
     }
     /* Get the component info */
     $query = array();
     $components = array('header' => ts('Header'), 'footer' => ts('Footer'), 'reply' => ts('Reply'), 'unsubscribe' => ts('Unsubscribe'), 'optout' => ts('Opt-Out'));
     foreach (array_keys($components) as $type) {
         $query[] = "SELECT          {$t['component']}.name as name,\n                                        '{$type}' as type,\n                                        {$t['component']}.id as id\n                        FROM            {$t['component']}\n                        INNER JOIN      {$t['mailing']}\n                                ON      {$t['mailing']}.{$type}_id =\n                                                {$t['component']}.id\n                        WHERE           {$t['mailing']}.id = {$mailing_id}";
     }
     $q = '(' . implode(') UNION (', $query) . ')';
     $mailing->query($q);
     $report['component'] = array();
     while ($mailing->fetch()) {
         $report['component'][] = array('type' => $components[$mailing->type], 'name' => $mailing->name, 'link' => CRM_Utils_System::url('civicrm/mailing/component', "reset=1&action=update&id={$mailing->id}"));
     }
     /* Get the recipient group info */
     $mailing->query("\n            SELECT          {$t['mailing_group']}.group_type as group_type,\n                            {$t['group']}.id as group_id,\n                            {$t['group']}.title as group_title,\n                            {$t['group']}.is_hidden as group_hidden,\n                            {$t['mailing']}.id as mailing_id,\n                            {$t['mailing']}.name as mailing_name\n            FROM            {$t['mailing_group']}\n            LEFT JOIN       {$t['group']}\n                    ON      {$t['mailing_group']}.entity_id = {$t['group']}.id\n                    AND     {$t['mailing_group']}.entity_table =\n                                                                '{$t['group']}'\n            LEFT JOIN       {$t['mailing']}\n                    ON      {$t['mailing_group']}.entity_id =\n                                                            {$t['mailing']}.id\n                    AND     {$t['mailing_group']}.entity_table =\n                                                            '{$t['mailing']}'\n\n            WHERE           {$t['mailing_group']}.mailing_id = {$mailing_id}\n            ");
     $report['group'] = array('include' => array(), 'exclude' => array(), 'base' => array());
     while ($mailing->fetch()) {
         $row = array();
         if (isset($mailing->group_id)) {
             $row['id'] = $mailing->group_id;
             $row['name'] = $mailing->group_title;
             $row['link'] = CRM_Utils_System::url('civicrm/group/search', "reset=1&force=1&context=smog&gid={$row['id']}");
         } else {
             $row['id'] = $mailing->mailing_id;
             $row['name'] = $mailing->mailing_name;
             $row['mailing'] = TRUE;
             $row['link'] = CRM_Utils_System::url('civicrm/mailing/report', "mid={$row['id']}");
         }
         /* Rename hidden groups */
         if ($mailing->group_hidden == 1) {
             $row['name'] = "Search Results";
         }
         if ($mailing->group_type == 'Include') {
             $report['group']['include'][] = $row;
         } elseif ($mailing->group_type == 'Base') {
             $report['group']['base'][] = $row;
         } else {
             $report['group']['exclude'][] = $row;
         }
     }
     /* Get the event totals, grouped by job (retries) */
     $mailing->query("\n            SELECT          {$t['job']}.*,\n                            COUNT(DISTINCT {$t['queue']}.id) as queue,\n                            COUNT(DISTINCT {$t['delivered']}.id) as delivered,\n                            COUNT(DISTINCT {$t['reply']}.id) as reply,\n                            COUNT(DISTINCT {$t['forward']}.id) as forward,\n                            COUNT(DISTINCT {$t['bounce']}.id) as bounce,\n                            COUNT(DISTINCT {$t['urlopen']}.id) as url,\n                            COUNT(DISTINCT {$t['spool']}.id) as spool\n            FROM            {$t['job']}\n            LEFT JOIN       {$t['queue']}\n                    ON      {$t['queue']}.job_id = {$t['job']}.id\n            LEFT JOIN       {$t['reply']}\n                    ON      {$t['reply']}.event_queue_id = {$t['queue']}.id\n            LEFT JOIN       {$t['forward']}\n                    ON      {$t['forward']}.event_queue_id = {$t['queue']}.id\n            LEFT JOIN       {$t['bounce']}\n                    ON      {$t['bounce']}.event_queue_id = {$t['queue']}.id\n            LEFT JOIN       {$t['delivered']}\n                    ON      {$t['delivered']}.event_queue_id = {$t['queue']}.id\n                    AND     {$t['bounce']}.id IS null\n            LEFT JOIN       {$t['urlopen']}\n                    ON      {$t['urlopen']}.event_queue_id = {$t['queue']}.id\n            LEFT JOIN       {$t['spool']}\n                    ON      {$t['spool']}.job_id = {$t['job']}.id\n            WHERE           {$t['job']}.mailing_id = {$mailing_id}\n                    AND     {$t['job']}.is_test = 0\n            GROUP BY        {$t['job']}.id");
     $report['jobs'] = array();
     $report['event_totals'] = array();
     $elements = array('queue', 'delivered', 'url', 'forward', 'reply', 'unsubscribe', 'optout', 'opened', 'bounce', 'spool');
     // initialize various counters
     foreach ($elements as $field) {
         $report['event_totals'][$field] = 0;
     }
     while ($mailing->fetch()) {
         $row = array();
         foreach ($elements as $field) {
             if (isset($mailing->{$field})) {
                 $row[$field] = $mailing->{$field};
                 $report['event_totals'][$field] += $mailing->{$field};
             }
         }
         // compute open total separately to discount duplicates
         // CRM-1258
         $row['opened'] = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailing_id, $mailing->id, TRUE);
         $report['event_totals']['opened'] += $row['opened'];
         // compute unsub total separately to discount duplicates
         // CRM-1783
         $row['unsubscribe'] = CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($mailing_id, $mailing->id, TRUE, TRUE);
         $report['event_totals']['unsubscribe'] += $row['unsubscribe'];
         $row['optout'] = CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($mailing_id, $mailing->id, TRUE, FALSE);
         $report['event_totals']['optout'] += $row['optout'];
         foreach (array_keys(CRM_Mailing_BAO_MailingJob::fields()) as $field) {
             $row[$field] = $mailing->{$field};
         }
         if ($mailing->queue) {
             $row['delivered_rate'] = 100.0 * $mailing->delivered / $mailing->queue;
             $row['bounce_rate'] = 100.0 * $mailing->bounce / $mailing->queue;
             $row['unsubscribe_rate'] = 100.0 * $row['unsubscribe'] / $mailing->queue;
             $row['optout_rate'] = 100.0 * $row['optout'] / $mailing->queue;
         } else {
             $row['delivered_rate'] = 0;
             $row['bounce_rate'] = 0;
             $row['unsubscribe_rate'] = 0;
             $row['optout_rate'] = 0;
         }
         $row['links'] = array('clicks' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=click&mid={$mailing_id}&jid={$mailing->id}"), 'queue' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=queue&mid={$mailing_id}&jid={$mailing->id}"), 'delivered' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=delivered&mid={$mailing_id}&jid={$mailing->id}"), 'bounce' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=bounce&mid={$mailing_id}&jid={$mailing->id}"), 'unsubscribe' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=unsubscribe&mid={$mailing_id}&jid={$mailing->id}"), 'forward' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=forward&mid={$mailing_id}&jid={$mailing->id}"), 'reply' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=reply&mid={$mailing_id}&jid={$mailing->id}"), 'opened' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=opened&mid={$mailing_id}&jid={$mailing->id}"));
         foreach (array('scheduled_date', 'start_date', 'end_date') as $key) {
             $row[$key] = CRM_Utils_Date::customFormat($row[$key]);
         }
         $report['jobs'][] = $row;
     }
     $newTableSize = CRM_Mailing_BAO_Recipients::mailingSize($mailing_id);
     // we need to do this for backward compatibility, since old mailings did not
     // use the mailing_recipients table
     if ($newTableSize > 0) {
         $report['event_totals']['queue'] = $newTableSize;
     } else {
         $report['event_totals']['queue'] = self::getRecipientsCount($mailing_id, $mailing_id);
     }
     if (!empty($report['event_totals']['queue'])) {
         $report['event_totals']['delivered_rate'] = 100.0 * $report['event_totals']['delivered'] / $report['event_totals']['queue'];
         $report['event_totals']['bounce_rate'] = 100.0 * $report['event_totals']['bounce'] / $report['event_totals']['queue'];
         $report['event_totals']['unsubscribe_rate'] = 100.0 * $report['event_totals']['unsubscribe'] / $report['event_totals']['queue'];
         $report['event_totals']['optout_rate'] = 100.0 * $report['event_totals']['optout'] / $report['event_totals']['queue'];
     } else {
         $report['event_totals']['delivered_rate'] = 0;
         $report['event_totals']['bounce_rate'] = 0;
         $report['event_totals']['unsubscribe_rate'] = 0;
         $report['event_totals']['optout_rate'] = 0;
     }
     /* Get the click-through totals, grouped by URL */
     $mailing->query("\n            SELECT      {$t['url']}.url,\n                        {$t['url']}.id,\n                        COUNT({$t['urlopen']}.id) as clicks,\n                        COUNT(DISTINCT {$t['queue']}.id) as unique_clicks\n            FROM        {$t['url']}\n            LEFT JOIN   {$t['urlopen']}\n                    ON  {$t['urlopen']}.trackable_url_id = {$t['url']}.id\n            LEFT JOIN  {$t['queue']}\n                    ON  {$t['urlopen']}.event_queue_id = {$t['queue']}.id\n            LEFT JOIN  {$t['job']}\n                    ON  {$t['queue']}.job_id = {$t['job']}.id\n            WHERE       {$t['url']}.mailing_id = {$mailing_id}\n                    AND {$t['job']}.is_test = 0\n            GROUP BY    {$t['url']}.id");
     $report['click_through'] = array();
     while ($mailing->fetch()) {
         $report['click_through'][] = array('url' => $mailing->url, 'link' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=click&mid={$mailing_id}&uid={$mailing->id}"), 'link_unique' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=click&mid={$mailing_id}&uid={$mailing->id}&distinct=1"), 'clicks' => $mailing->clicks, 'unique' => $mailing->unique_clicks, 'rate' => CRM_Utils_Array::value('delivered', $report['event_totals']) ? 100.0 * $mailing->unique_clicks / $report['event_totals']['delivered'] : 0);
     }
     $report['event_totals']['links'] = array('clicks' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=click&mid={$mailing_id}"), 'clicks_unique' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=click&mid={$mailing_id}&distinct=1"), 'queue' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=queue&mid={$mailing_id}"), 'delivered' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=delivered&mid={$mailing_id}"), 'bounce' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=bounce&mid={$mailing_id}"), 'unsubscribe' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=unsubscribe&mid={$mailing_id}"), 'optout' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=optout&mid={$mailing_id}"), 'forward' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=forward&mid={$mailing_id}"), 'reply' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=reply&mid={$mailing_id}"), 'opened' => CRM_Utils_System::url('civicrm/mailing/report/event', "reset=1&event=opened&mid={$mailing_id}"));
     $actionLinks = array(CRM_Core_Action::VIEW => array('name' => ts('Report')));
     if (CRM_Core_Permission::check('view all contacts')) {
         $actionLinks[CRM_Core_Action::ADVANCED] = array('name' => ts('Advanced Search'), 'url' => 'civicrm/contact/search/advanced');
     }
     $action = array_sum(array_keys($actionLinks));
     $report['event_totals']['actionlinks'] = array();
     foreach (array('clicks', 'clicks_unique', 'queue', 'delivered', 'bounce', 'unsubscribe', 'forward', 'reply', 'opened', 'optout') as $key) {
         $url = 'mailing/detail';
         $reportFilter = "reset=1&mailing_id_value={$mailing_id}";
         $searchFilter = "force=1&mailing_id=%%mid%%";
         switch ($key) {
             case 'delivered':
                 $reportFilter .= "&delivery_status_value=successful";
                 $searchFilter .= "&mailing_delivery_status=Y";
                 break;
             case 'bounce':
                 $url = "mailing/bounce";
                 $searchFilter .= "&mailing_delivery_status=N";
                 break;
             case 'forward':
                 $reportFilter .= "&is_forwarded_value=1";
                 $searchFilter .= "&mailing_forward=1";
                 break;
             case 'reply':
                 $reportFilter .= "&is_replied_value=1";
                 $searchFilter .= "&mailing_reply_status=Y";
                 break;
             case 'unsubscribe':
                 $reportFilter .= "&is_unsubscribed_value=1";
                 $searchFilter .= "&mailing_unsubscribe=1";
                 break;
             case 'optout':
                 $reportFilter .= "&is_optout_value=1";
                 $searchFilter .= "&mailing_optout=1";
                 break;
             case 'opened':
                 $url = "mailing/opened";
                 $searchFilter .= "&mailing_open_status=Y";
                 break;
             case 'clicks':
             case 'clicks_unique':
                 $url = "mailing/clicks";
                 $searchFilter .= "&mailing_click_status=Y";
                 break;
         }
         $actionLinks[CRM_Core_Action::VIEW]['url'] = CRM_Report_Utils_Report::getNextUrl($url, $reportFilter, FALSE, TRUE);
         if (array_key_exists(CRM_Core_Action::ADVANCED, $actionLinks)) {
             $actionLinks[CRM_Core_Action::ADVANCED]['qs'] = $searchFilter;
         }
         $report['event_totals']['actionlinks'][$key] = CRM_Core_Action::formLink($actionLinks, $action, array('mid' => $mailing_id), ts('more'), FALSE, 'mailing.report.action', 'Mailing', $mailing_id);
     }
     return $report;
 }
Exemplo n.º 27
0
 /**
  * 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;
         }
     }
 }
Exemplo n.º 28
0
 function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $entryFound = FALSE;
     $entities = array('HRJobContract', 'HRJobDetails', 'HRJobHour', 'HRJobHealth', 'HRJobLeave', 'HRJobPay', 'HRJobPension', 'HRJobRole');
     $ei = CRM_Hrjobcontract_ExportImportValuesConverter::singleton();
     $changeReasonOptions = array();
     CRM_Core_OptionGroup::getAssoc('hrjc_revision_change_reason', $changeReasonOptions);
     foreach ($rows as $rowNum => $row) {
         // make count columns point to detail report
         // convert sort name to links
         if (!empty($row['civicrm_contact_sort_name']) && !empty($row['civicrm_hrjobcontract_contact_id'])) {
             $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_hrjobcontract_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;
         }
         // Convert revisionable HRJobContract Entities values for export
         foreach ($entities as $entity) {
             $tableName = _civicrm_get_table_name($entity);
             $fields = $this->_columns['civicrm_hrjobcontract_' . $tableName]['fields'];
             foreach ($fields as $key => $value) {
                 $fieldName = substr($key, strlen($tableName) + 1);
                 $rowKey = 'civicrm_hrjobcontract_' . $tableName . '_' . $tableName . '_' . $fieldName;
                 if (isset($row[$rowKey])) {
                     $rows[$rowNum][$rowKey] = $ei->export($tableName, $fieldName, $row[$rowKey]);
                 }
             }
         }
         // Convert non-revisionable HRJobContract Entities values for export
         if (!empty($row['civicrm_hrjobcontract_revision_change_reason'])) {
             $rows[$rowNum]['civicrm_hrjobcontract_revision_change_reason'] = $changeReasonOptions['label'][$rows[$rowNum]['civicrm_hrjobcontract_revision_change_reason']];
             $entryFound = TRUE;
         }
     }
 }
 /**
  * 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;
         }
     }
 }
 function alterDisplay(&$rows)
 {
     // custom code to alter rows
     $type = substr($this->_params['relationship_type_id_value'], -3);
     $entryFound = FALSE;
     $flagHousehold = $flagContact = 0;
     foreach ($rows as $rowNum => $row) {
         //replace retionship id by relationship name
         if (array_key_exists('civicrm_relationship_relationship_type_id', $row)) {
             if ($value = $row['civicrm_relationship_relationship_type_id']) {
                 $rows[$rowNum]['civicrm_relationship_relationship_type_id'] = $this->relationTypes[$value . '_' . $type];
                 $entryFound = TRUE;
             }
         }
         //remove duplicate Organization names
         if (array_key_exists('civicrm_contact_household_household_name', $row) && $this->_outputMode != 'csv') {
             if ($value = $row['civicrm_contact_household_household_name']) {
                 if ($rowNum == 0) {
                     $priviousHousehold = $value;
                 } else {
                     if ($priviousHousehold == $value) {
                         $flagHousehold = 1;
                         $priviousHousehold = $value;
                     } else {
                         $flagHousehold = 0;
                         $priviousHousehold = $value;
                     }
                 }
                 if ($flagHousehold == 1) {
                     $rows[$rowNum]['civicrm_contact_household_household_name'] = "";
                 } else {
                     $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $rows[$rowNum]['civicrm_contact_household_id'], $this->_absoluteUrl);
                     $rows[$rowNum]['civicrm_contact_household_household_name'] = "<a href='{$url}' title='" . ts('View contact summary for this househould') . "'>" . $value . '</a>';
                 }
                 $entryFound = TRUE;
             }
         }
         //remove duplicate Contact names and relationship type
         if (array_key_exists('civicrm_contact_id', $row) && $this->_outputMode != 'csv') {
             if ($value = $row['civicrm_contact_id']) {
                 if ($rowNum == 0) {
                     $priviousContact = $value;
                 } else {
                     if ($priviousContact == $value) {
                         $flagContact = 1;
                         $priviousContact = $value;
                     } else {
                         $flagContact = 0;
                         $priviousContact = $value;
                     }
                 }
                 if ($flagContact == 1 && $flagHousehold == 1) {
                     $rows[$rowNum]['civicrm_contact_sort_name'] = "";
                     $rows[$rowNum]['civicrm_relationship_relationship_type_id'] = "";
                 }
                 $entryFound = TRUE;
             }
         }
         if (array_key_exists('civicrm_contribution_contribution_status_id', $row)) {
             if ($value = $row['civicrm_contribution_contribution_status_id']) {
                 $rows[$rowNum]['civicrm_contribution_contribution_status_id'] = CRM_Contribute_PseudoConstant::contributionStatus($value);
             }
         }
         // 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::stateProvinceAbbreviation($value, FALSE);
             }
             $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);
             }
             $entryFound = TRUE;
         }
         // convert display name to links
         if (array_key_exists('civicrm_contact_sort_name', $row) && $rows[$rowNum]['civicrm_contact_sort_name'] && 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);
             $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
             $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts('View contribution details for this individual');
             $entryFound = TRUE;
         }
         // Contribution amount links to view contribution
         if (($value = CRM_Utils_Array::value('civicrm_contribution_total_amount', $row)) && CRM_Core_Permission::check('access CiviContribute')) {
             $url = CRM_Utils_System::url("civicrm/contact/view/contribution", "reset=1&id=" . $row['civicrm_contribution_id'] . "&cid=" . $row['civicrm_contact_id'] . "&action=view&context=contribution&selectedChild=contribute", $this->_absoluteUrl);
             $rows[$rowNum]['civicrm_contribution_total_amount_link'] = $url;
             $rows[$rowNum]['civicrm_contribution_total_amount_hover'] = ts("View this contribution.");
             $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;
             }
         }
         // skip looking further in rows, if first row itself doesn't
         if (!$entryFound) {
             break;
         }
         $lastKey = $rowNum;
     }
 }