diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index f875fcee64551f70f5fbf5c9d4d9b4d0df31018a..341b293af397bff2a8f94bb651a9f1378a78c899 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2444,8 +2444,8 @@ class CRM_Contact_BAO_Query { continue; case 'civicrm_log': - $from .= " $side JOIN civicrm_log ON (civicrm_log.entity_id = contact_a.id AND civicrm_log.entity_table = 'civicrm_contact')"; - $from .= " $side JOIN civicrm_contact contact_b_log ON (civicrm_log.modified_id = contact_b_log.id)"; + $from .= " INNER JOIN civicrm_log ON (civicrm_log.entity_id = contact_a.id AND civicrm_log.entity_table = 'civicrm_contact')"; + $from .= " INNER JOIN civicrm_contact contact_b_log ON (civicrm_log.modified_id = contact_b_log.id)"; continue; case 'civicrm_tag': @@ -3653,7 +3653,7 @@ WHERE id IN ( $groupIDs ) $name = $targetName[4] ? "%$name%" : $name; $this->_where[$grouping][] = "contact_b_log.sort_name LIKE '%$name%'"; $this->_tables['civicrm_log'] = $this->_whereTables['civicrm_log'] = 1; - $this->_qill[$grouping][] = ts('Changed by') . ": $name"; + $this->_qill[$grouping][] = ts('Modified by') . ": $name"; } function modifiedDates($values) { @@ -3661,18 +3661,20 @@ WHERE id IN ( $groupIDs ) // CRM-11281, default to added date if not set $fieldTitle = ts('Added Date'); - + $fieldName = 'created_date'; foreach (array_keys($this->_params) as $id) { if ($this->_params[$id][0] == 'log_date') { if ($this->_params[$id][2] == 2) { $fieldTitle = ts('Modified Date'); + $fieldName = 'modified_date'; } } } - $this->dateQueryBuilder($values, - 'civicrm_log', 'log_date', 'modified_date', $fieldTitle - ); + + $this->dateQueryBuilder($values, 'contact_a', 'log_date', $fieldName, $fieldTitle); + + self::$_openedPanes[ts('Change Log')] = TRUE; } function demographics(&$values) { @@ -4751,16 +4753,6 @@ SELECT COUNT( civicrm_contribution.total_amount ) as cancel_count, $this->_tables[$tableName] = $this->_whereTables[$tableName] = 1; $this->_qill[$grouping][] = "$fieldTitle - $phrase \"$format\""; } - - if ( - $tableName == 'civicrm_log' && - $fieldTitle == ts('Added Date') - ) { - //CRM-6903 --hack to check modified date of first record. - //as added date means first modified date of object. - $addedDateQuery = 'select id from civicrm_log group by entity_id order by id'; - $this->_where[$grouping][] = "civicrm_log.id IN ( {$addedDateQuery} )"; - } } function numberRangeBuilder(&$values, diff --git a/templates/CRM/Contact/Form/Search/Criteria/ChangeLog.tpl b/templates/CRM/Contact/Form/Search/Criteria/ChangeLog.tpl index 698f8073cf6b62a7a96f5ce5d6c11d714101fbab..d441ccd98e5b49293d2d0775c1ffc2830cb76e99 100644 --- a/templates/CRM/Contact/Form/Search/Criteria/ChangeLog.tpl +++ b/templates/CRM/Contact/Form/Search/Criteria/ChangeLog.tpl @@ -24,23 +24,57 @@ +--------------------------------------------------------------------+ *} <div id="changelog" class="form-item"> - <table class="form-layout"> - <tr> - <td> - {$form.changed_by.label}<br /> - {$form.changed_by.html} - </td> - <td width="100%"> - {$form.log_date.html}<span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('log_date', '{$form.formName}'); return false;" >{ts}clear{/ts}</a>)</span><br /> - </td> - </tr> - <tr> - <td> - <label>{ts}Modified Between{/ts}</label> - </td> - </tr> - <tr> - {include file="CRM/Core/DateRange.tpl" fieldName="log_date" from='_low' to='_high'} - </tr> - </table> - </div> + <table class="form-layout"> + <tr> + <td> + <span class="modifiedBy"><label>{ts}Modified By{/ts}</label></span> + <span class="hiddenElement addedBy"><label>{ts}Added By{/ts}</label></span> + <br/> + {$form.changed_by.html} + </td> + <td width="100%"> + {$form.log_date.html} + <span class="crm-clear-link">(<a href="#" title="unselect" + onclick="unselectRadio('log_date', '{$form.formName}'); + return false;">{ts}clear{/ts}</a>) + </span> + <br/> + </td> + </tr> + <tr> + <td> + <span class="modifiedBy"><label>{ts}Modified Between{/ts}</label></span> + <span class="hiddenElement addedBy"><label>{ts}Added Between{/ts}</label></span> + </td> + </tr> + <tr> + {include file="CRM/Core/DateRange.tpl" fieldName="log_date" from='_low' to='_high'} + </tr> + </table> +</div> + +{literal} + <script type="text/javascript"> + cj(function () { + updateChangeLogLabels(); + }); + + cj('[name=log_date]:input').change(function () { + updateChangeLogLabels(); + }); + + function updateChangeLogLabels() { + var changeType = cj('input[name=log_date]:checked').val(); + if (changeType == 2) { + cj('.addedBy').hide(); + cj('.modifiedBy').show(); + } + else { + if (changeType == 1) { + cj('.addedBy').show(); + cj('.modifiedBy').hide(); + } + } + } + </script> +{/literal}