Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * Main page for viewing contact. | |
6a488035 TO |
20 | */ |
21 | class CRM_Contact_Page_DedupeException extends CRM_Core_Page { | |
69078420 | 22 | |
6a488035 | 23 | /** |
a60e3208 AP |
24 | * the main function that is called when the page loads, |
25 | * it decides the which action has to be taken for the page. | |
6a488035 | 26 | * |
a60e3208 | 27 | * @return null |
6a488035 | 28 | */ |
a60e3208 AP |
29 | public function run() { |
30 | $this->initializePager(); | |
31 | $this->assign('exceptions', $this->getExceptions()); | |
32 | return parent::run(); | |
33 | } | |
6a488035 | 34 | |
a60e3208 AP |
35 | /** |
36 | * Method to initialize pager | |
37 | * | |
38 | * @access protected | |
39 | */ | |
40 | protected function initializePager() { | |
be2fb01f | 41 | $params = []; |
916a3577 AP |
42 | |
43 | $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String'); | |
916a3577 AP |
44 | |
45 | if ($contactOneQ) { | |
be2fb01f CW |
46 | $params['contact_id1.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; |
47 | $params['contact_id2.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; | |
916a3577 | 48 | |
cf3d3207 | 49 | $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]]; |
916a3577 AP |
50 | } |
51 | ||
52 | $totalitems = civicrm_api3('Exception', "getcount", $params); | |
be2fb01f | 53 | $params = [ |
a60e3208 AP |
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), | |
be2fb01f | 60 | ]; |
a60e3208 AP |
61 | $this->_pager = new CRM_Utils_Pager($params); |
62 | $this->assign_by_ref('pager', $this->_pager); | |
6a488035 TO |
63 | } |
64 | ||
65 | /** | |
a60e3208 | 66 | * Function to get the exceptions |
6a488035 | 67 | * |
7d0c4217 | 68 | * @return array $exceptionsd |
6a488035 | 69 | */ |
7d0c4217 | 70 | public function getExceptions() { |
a60e3208 AP |
71 | list($offset, $limit) = $this->_pager->getOffsetAndRowCount(); |
72 | $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String'); | |
a60e3208 AP |
73 | |
74 | if (!$contactOneQ) { | |
75 | $contactOneQ = ''; | |
76 | } | |
a60e3208 AP |
77 | |
78 | $this->assign('searchcontact1', $contactOneQ); | |
a60e3208 | 79 | |
be2fb01f CW |
80 | $params = [ |
81 | "options" => ['limit' => $limit, 'offset' => $offset], | |
a60e3208 | 82 | 'return' => ["contact_id1.display_name", "contact_id2.display_name", "contact_id1", "contact_id2"], |
be2fb01f | 83 | ]; |
a60e3208 AP |
84 | |
85 | if ($contactOneQ != '') { | |
be2fb01f CW |
86 | $params['contact_id1.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; |
87 | $params['contact_id2.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; | |
a60e3208 | 88 | |
cf3d3207 | 89 | $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]]; |
a60e3208 AP |
90 | } |
91 | ||
92 | $exceptions = civicrm_api3("Exception", "get", $params); | |
93 | $exceptions = $exceptions["values"]; | |
94 | return $exceptions; | |
6a488035 | 95 | } |
96025800 | 96 | |
6a488035 | 97 | } |