From 6916489865c5028390892018529fa6b68b36c175 Mon Sep 17 00:00:00 2001 From: Nileema Date: Thu, 28 Nov 2013 18:32:22 +0530 Subject: [PATCH] -- HR-211 Change in Ajax function for organization search on sub types And Modification to webtest to add subtype while creating organization contact --- CRM/Contact/Page/AJAX.php | 3 ++- api/v3/Contact.php | 5 +++++ tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 8 ++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 478112dedd..8e7cd3f466 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -51,7 +51,8 @@ class CRM_Contact_Page_AJAX { 'fieldName' => 'field_name', 'tableName' => 'table_name', 'context' => 'context', - 'rel' => 'rel' + 'rel' => 'rel', + 'contact_sub_type' => 'contact_sub_type' ); foreach ($whitelist as $key => $param) { if (!empty($_GET[$key])) { diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 1e9d0bebb0..7c4bd8f9a8 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -649,6 +649,11 @@ function civicrm_api3_contact_getquick($params) { } } + if (CRM_Utils_Array::value('contact_sub_type', $params)) { + $contactSubType = CRM_Utils_Type::escape($params['contact_sub_type'], 'String'); + $where .= " AND cc.contact_sub_type = '{$contactSubType}'"; + } + //set default for current_employer or return contact with particular id if (CRM_Utils_Array::value('id', $params)) { $where .= " AND cc.id = " . (int) $params['id']; diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 8ba2207d81..9b9e68e85a 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -341,9 +341,13 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { return $email; } - function webtestAddOrganization($organizationName = "Organization XYZ", $email = NULL) { + function webtestAddOrganization($organizationName = "Organization XYZ", $email = NULL, $contactSubtype = NULL) { - $this->openCiviPage("contact/add", "reset=1&ct=Organization"); + $url = $this->sboxPath . 'civicrm/contact/add?reset=1&ct=Organization'; + if ($contactSubtype) { + $url = $url . "&cst={$contactSubtype}"; + } + $this->open($url); $this->click('organization_name'); $this->type('organization_name', $organizationName); -- 2.25.1