$customClass =
CRM_Contact_BAO_SearchCustom::customClass($ssParams['customSearchID'], $savedSearchID);
$searchSQL = $customClass->contactIDs();
+ $searchSQL = str_replace('ORDER BY contact_a.id ASC', '', $searchSQL);
$idName = 'contact_id';
}
else {
}
}
else {
- $sql .= ' ORDER BY contact_a.sort_name';
+ //CRM-14107, since there could be multiple activities against same contact,
+ //we need to provide GROUP BY on contact id to prevent duplicacy on prev/next entries
+ $sql .= 'GROUP BY contact_a.id
+ORDER BY contact_a.sort_name';
}
if ($rowcount > 0 && $offset >= 0) {
return NULL;
}
+ function contactIDs($offset = 0, $rowcount = 0, $sort = NULL, $returnSQL = FALSE) {
+ return $this->all($offset, $rowcount, $sort, FALSE, TRUE);
+ }
+
/**
* @param int $offset
* @param int $rowcount
}
if ($justIDs) {
- $select = "contact_a.id as contact_id";
+ $selectClause = "contact_a.id as contact_id";
+ $groupBy = " GROUP BY contact_a.id";
+ $sort = "contact_a.id";
}
else {
$selectClause = "contact_a.id as contact_id,
contact_a.contact_type as contact_type,
contact_a.sort_name as sort_name,
d.date_added as date_added";
+ $groupBy = " GROUP BY contact_id ";
}
- $groupBy = " GROUP BY contact_id ";
return $this->sql($selectClause,
$offset, $rowcount, $sort,
$includeContactIDs, $groupBy
return NULL;
}
+ function contactIDs($offset = 0, $rowcount = 0, $sort = NULL, $returnSQL = FALSE) {
+ return $this->all($offset, $rowcount, $sort, FALSE, TRUE);
+ }
+
/**
* @param int $offset
* @param int $rowcount
if ($justIDs) {
$selectClause = "contact_a.id as contact_id";
+ $sort = "contact_a.id";
+
+ return $this->sql($selectClause, $offset, $rowcount, $sort, $includeContactIDs, NULL);
}
else {
$selectClause = "
{foreach from=$columnHeaders item=header}
{assign var=fName value=$header.sort}
{if $fName eq 'sort_name'}
- <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
+ <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`"}">{$row.sort_name}</a></td>
{else}
<td>{$row.$fName}</td>
{/if}
{if ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status') or ($header.sort eq 'activity_type') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) }
{assign var=fName value=$header.sort}
{if $fName eq 'sort_name'}
- <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
+ <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`"}">{$row.sort_name}</a></td>
{elseif $fName eq 'activity_subject'}
<td>
{if $row.case_id }
{foreach from=$columnHeaders item=header}
{assign var=fName value=$header.sort}
{if $fName eq 'sort_name'}
- <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
+ <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`"}">{$row.sort_name}</a></td>
{else}
<td>{$row.$fName}</td>
{/if}
{foreach from=$columnHeaders item=header}
{assign var=fName value=$header.sort}
{if $fName eq 'sort_name'}
- <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
+ <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`"}">{$row.sort_name}</a></td>
{else}
<td>{$row.$fName}</td>
{/if}
{foreach from=$columnHeaders item=header}
{assign var=fName value=$header.sort}
{if $fName eq 'sort_name'}
- <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
+ <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`"}">{$row.sort_name}</a></td>
{else}
<td>{$row.$fName}</td>
{/if}
{foreach from=$columnHeaders item=header}
{assign var=fName value=$header.sort}
{if $fName eq 'sort_name'}
- <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
+ <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`"}">{$row.sort_name}</a></td>
{else}
<td>{$row.$fName}</td>
{/if}