Merge pull request #16545 from eileenmcnaughton/part_pend
[civicrm-core.git] / tests / extensions / test.extension.manager.reporttest / main.php
1 <?php
2
3 /**
4 * Class test_extension_manager_reporttest
5 */
6 class test_extension_manager_reporttest extends CRM_Core_Report {
7
8 /**
9 * Class constructor.
10 */
11 public function __construct() {
12 $logging = new CRM_Logging_Schema();
13 $this->tables[] = 'civicrm_contact';
14 $this->tables = array_merge($this->tables, array_keys($logging->customDataLogTables()));
15 $this->tables[] = 'civicrm_email';
16 $this->tables[] = 'civicrm_phone';
17 $this->tables[] = 'civicrm_im';
18 $this->tables[] = 'civicrm_openid';
19 $this->tables[] = 'civicrm_website';
20 $this->tables[] = 'civicrm_address';
21 $this->tables[] = 'civicrm_note';
22 $this->tables[] = 'civicrm_relationship';
23
24 $this->detail = 'logging/contact/detail';
25 $this->summary = 'logging/contact/summary';
26
27 parent::__construct();
28 }
29
30 public function buildQuickForm() {
31 $layout = CRM_Utils_Request::retrieve('layout', 'String', $this);
32 $this->assign('layout', $layout);
33
34 parent::buildQuickForm();
35
36 if ($this->cid) {
37 // link back to contact summary
38 $this->assign('backURL', CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE));
39 $this->assign('revertURL', self::$_template->get_template_vars('revertURL') . "&cid={$this->cid}");
40 }
41 else {
42 // link back to summary report
43 $this->assign('backURL', CRM_Report_Utils_Report::getNextUrl('logging/contact/summary', 'reset=1', FALSE, TRUE));
44 }
45 }
46
47 /**
48 * @return string
49 */
50 protected function whoWhomWhenSql() {
51 return "
52 SELECT who.id who_id, who.display_name who_name, whom.id whom_id, whom.display_name whom_name, l.is_deleted
53 FROM `{$this->db}`.log_civicrm_contact l
54 JOIN civicrm_contact who ON (l.log_user_id = who.id)
55 JOIN civicrm_contact whom ON (l.id = whom.id)
56 WHERE log_action = 'Update' AND log_conn_id = %1 AND log_date = %2 ORDER BY log_date DESC LIMIT 1
57 ";
58 }
59
60 }