dev/core#1405 Strip any spaces from Option Group name parameter and remove the name...
[civicrm-core.git] / CRM / Contact / Page / DedupeException.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Main page for viewing contact.
20 */
21 class CRM_Contact_Page_DedupeException extends CRM_Core_Page {
22
23 /**
24 * the main function that is called when the page loads,
25 * it decides the which action has to be taken for the page.
26 *
27 * @return null
28 */
29 public function run() {
30 $this->initializePager();
31 $this->assign('exceptions', $this->getExceptions());
32 return parent::run();
33 }
34
35 /**
36 * Method to initialize pager
37 *
38 * @access protected
39 */
40 protected function initializePager() {
41 $params = [];
42
43 $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String');
44
45 if ($contactOneQ) {
46 $params['contact_id1.display_name'] = ['LIKE' => '%' . $contactOneQ . '%'];
47 $params['contact_id2.display_name'] = ['LIKE' => '%' . $contactOneQ . '%'];
48
49 $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]];
50 }
51
52 $totalitems = civicrm_api3('Exception', "getcount", $params);
53 $params = [
54 'total' => $totalitems,
55 'rowCount' => CRM_Utils_Pager::ROWCOUNT,
56 'status' => ts('Dedupe Exceptions %%StatusMessage%%'),
57 'buttonBottom' => 'PagerBottomButton',
58 'buttonTop' => 'PagerTopButton',
59 'pageID' => $this->get(CRM_Utils_Pager::PAGE_ID),
60 ];
61 $this->_pager = new CRM_Utils_Pager($params);
62 $this->assign_by_ref('pager', $this->_pager);
63 }
64
65 /**
66 * Function to get the exceptions
67 *
68 * @return array $exceptionsd
69 */
70 public function getExceptions() {
71 list($offset, $limit) = $this->_pager->getOffsetAndRowCount();
72 $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String');
73
74 if (!$contactOneQ) {
75 $contactOneQ = '';
76 }
77
78 $this->assign('searchcontact1', $contactOneQ);
79
80 $params = [
81 "options" => ['limit' => $limit, 'offset' => $offset],
82 'return' => ["contact_id1.display_name", "contact_id2.display_name", "contact_id1", "contact_id2"],
83 ];
84
85 if ($contactOneQ != '') {
86 $params['contact_id1.display_name'] = ['LIKE' => '%' . $contactOneQ . '%'];
87 $params['contact_id2.display_name'] = ['LIKE' => '%' . $contactOneQ . '%'];
88
89 $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]];
90 }
91
92 $exceptions = civicrm_api3("Exception", "get", $params);
93 $exceptions = $exceptions["values"];
94 return $exceptions;
95 }
96
97 }