diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 82b605a4989f..555f42a4e9fe 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -959,25 +959,39 @@ static function selectUnselectContacts() { static function toggleDedupeSelect() { $rgid = CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer'); $gid = CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer'); - $pnid = CRM_Utils_Type::escape($_REQUEST['pnid'], 'Integer'); + $pnid = $_REQUEST['pnid']; $isSelected = CRM_Utils_Type::escape($_REQUEST['is_selected'], 'Boolean'); $contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type'); $cacheKeyString = "merge $contactType"; $cacheKeyString .= $rgid ? "_{$rgid}" : '_0'; $cacheKeyString .= $gid ? "_{$gid}" : '_0'; - - $sql = "UPDATE civicrm_prevnext_cache SET is_selected = %1 WHERE id = %2 AND cacheKey LIKE %3"; + + $params = array( 1 => array($isSelected, 'Boolean'), - 2 => array($pnid, 'Integer'), 3 => array("$cacheKeyString%", 'String') // using % to address rows with conflicts as well ); + + //check pnid is_array or integer + $whereClause = NULL; + if (is_array($pnid) && !CRM_Utils_Array::crmIsEmptyArray($pnid)) { + $pnid = implode(', ', $pnid); + $pnid = CRM_Utils_Type::escape($pnid, 'String'); + $whereClause = " id IN ( {$pnid} ) "; + } + else { + $pnid = CRM_Utils_Type::escape($pnid, 'Integer'); + $whereClause = " id = %2"; + $params[2] = array($pnid, 'Integer'); + } + + $sql = "UPDATE civicrm_prevnext_cache SET is_selected = %1 WHERE {$whereClause} AND cacheKey LIKE %3"; CRM_Core_DAO::executeQuery($sql, $params); CRM_Utils_System::civiExit(); } - + /** * @param $name * diff --git a/CRM/Core/xml/Menu/Contact.xml b/CRM/Core/xml/Menu/Contact.xml index 2196378239a3..cde8148ce1de 100644 --- a/CRM/Core/xml/Menu/Contact.xml +++ b/CRM/Core/xml/Menu/Contact.xml @@ -393,7 +393,7 @@ civicrm/ajax/toggleDedupeSelect CRM_Contact_Page_AJAX::toggleDedupeSelect - access CiviCRM + merge duplicate contacts civicrm/activity/sms/add diff --git a/templates/CRM/Contact/Page/DedupeFind.tpl b/templates/CRM/Contact/Page/DedupeFind.tpl index c5602a4abca4..fd1a84e607f3 100644 --- a/templates/CRM/Contact/Page/DedupeFind.tpl +++ b/templates/CRM/Contact/Page/DedupeFind.tpl @@ -84,7 +84,7 @@ - + @@ -231,9 +231,21 @@ CRM.$(function($) { $(this).toggleClass('crm-row-selected'); $('input.crm-dedupe-select', this).prop('checked', $(this).hasClass('crm-row-selected')); var sth = $('input.crm-dedupe-select', this); - toggleDedupeSelect(sth); + toggleDedupeSelect(sth, 0); }); - + + $('#dupePairs thead tr .crm-dedupe-merge').on('click', function() { + var checked = $('.crm-dedupe-select-all').prop('checked'); + if (checked) { + $("#dupePairs tbody tr input[type='checkbox']").prop('checked', true); + } + else{ + $("#dupePairs tbody tr input[type='checkbox']").prop('checked', false); + } + var sth = $('#dupePairs tbody tr'); + toggleDedupeSelect(sth, 1); + }); + // inline search boxes placed in tfoot $('#dupePairsColFilters thead th').each( function () { var title = $('#dupePairs thead th').eq($(this).index()).text(); @@ -271,9 +283,20 @@ CRM.$(function($) { } }); -function toggleDedupeSelect(element) { - var is_selected = CRM.$(element).prop('checked') ? 1: 0; - var id = CRM.$(element).prop('name').substr(5); +function toggleDedupeSelect(element, isMultiple) { + if (!isMultiple) { + var is_selected = CRM.$(element).prop('checked') ? 1: 0; + var id = CRM.$(element).prop('name').substr(5); + } + else { + var id = []; + CRM.$(element).each(function() { + CRM.$(this).toggleClass('crm-row-selected'); + var sth = CRM.$('input.crm-dedupe-select', this); + id.push(CRM.$(sth).prop('name').substr(5)); + }); + var is_selected = CRM.$('.crm-dedupe-select-all').prop('checked') ? 1 : 0; + } var dataUrl = {/literal}"{crmURL p='civicrm/ajax/toggleDedupeSelect' h=0 q='snippet=4'}"{literal}; var rgid = {/literal}"{$rgid}"{literal};
    {ts}Contact{/ts} 1 {ts}Email{/ts} 1