Skip to content
Snippets Groups Projects
Commit 93c071bc authored by Deepak Srivastava's avatar Deepak Srivastava
Browse files

Merge pull request #2336 from deepak-srivastava/CRM-14057

CRM-14057 - contact logging detail report may have missing/wrong altered...
parents 2de6ecf3 02e02ac5
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,10 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form {
protected $tables = array();
protected $interval = '10 SECOND';
protected $altered_name;
protected $altered_by;
protected $altered_by_id;
// detail/summary report ids
protected $detail;
protected $summary;
......@@ -57,6 +61,10 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form {
$this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$this->raw = CRM_Utils_Request::retrieve('raw', 'Boolean', CRM_Core_DAO::$_nullObject);
$this->altered_name = CRM_Utils_Request::retrieve('alteredName', 'String', CRM_Core_DAO::$_nullObject);
$this->altered_by = CRM_Utils_Request::retrieve('alteredBy', 'String', CRM_Core_DAO::$_nullObject);
$this->altered_by_id = CRM_Utils_Request::retrieve('alteredById', 'Integer', CRM_Core_DAO::$_nullObject);
parent::__construct();
CRM_Utils_System::resetBreadCrumb();
......@@ -199,22 +207,16 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form {
2 => array($this->log_date, 'String'),
);
// let the template know who updated whom when
$dao = CRM_Core_DAO::executeQuery($this->whoWhomWhenSql(), $params);
if ($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('whom_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->cid}"));
$this->assign('who_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->altered_by_id}"));
$this->assign('whom_name', $this->altered_name);
$this->assign('who_name', $this->altered_by);
$this->assign('log_date', CRM_Utils_Date::mysqlToIso($this->log_date));
$q = "reset=1&log_conn_id={$this->log_conn_id}&log_date={$this->log_date}";
$this->assign('revertURL', CRM_Report_Utils_Report::getNextUrl($this->detail, "$q&revert=1", FALSE, TRUE));
$this->assign('revertConfirm', ts('Are you sure you want to revert all these changes?'));
}
// redefine this accordingly in ancestors for buildQuickForm()’s sake
protected function whoWhomWhenSql() {}
}
......@@ -74,15 +74,5 @@ class CRM_Report_Form_Contact_LoggingDetail extends CRM_Logging_ReportDetail {
$this->assign('backURL', CRM_Report_Utils_Report::getNextUrl('logging/contact/summary', 'reset=1', FALSE, TRUE));
}
}
protected function whoWhomWhenSql() {
return "
SELECT who.id who_id, who.display_name who_name, whom.id whom_id, whom.display_name whom_name, l.is_deleted
FROM `{$this->db}`.log_civicrm_contact l
JOIN civicrm_contact who ON (l.log_user_id = who.id)
JOIN civicrm_contact whom ON (l.id = whom.id)
WHERE log_action = 'Update' AND log_conn_id = %1 AND log_date = %2 ORDER BY log_date DESC LIMIT 1
";
}
}
......@@ -201,6 +201,12 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
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);
......
......@@ -51,15 +51,5 @@ class CRM_Report_Form_Contribute_LoggingDetail extends CRM_Logging_ReportDetail
// link back to summary report
$this->assign('backURL', CRM_Report_Utils_Report::getNextUrl('logging/contribute/summary', 'reset=1', FALSE, TRUE));
}
protected function whoWhomWhenSql() {
return "
SELECT who.id who_id, who.display_name who_name, whom.id whom_id, whom.display_name whom_name
FROM `{$this->db}`.log_civicrm_contribution l
LEFT JOIN civicrm_contact who ON (l.log_user_id = who.id)
LEFT JOIN civicrm_contact whom ON (l.contact_id = whom.id)
WHERE log_action = 'Update' AND log_conn_id = %1 AND log_date = %2 ORDER BY log_date DESC LIMIT 1
";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment