if (!empty($groups)) {
foreach ($groups as $id => $value) {
$groupList[$id]['group_id'] = $value['id'];
+ $groupList[$id]['members'] = $value['members'];
$groupList[$id]['group_name'] = $value['title'];
- $groupList[$id]['class'] = implode(' ', $value['class']);
// append parent names if in search mode
if (empty($params['parent_id']) && !empty($value['parents'])) {
$title[] = $allGroups[$gId];
}
$groupList[$id]['group_name'] .= '<div class="crm-row-parent-name"><em>'.ts('Child of').'</em>: ' . implode(', ', $title) . '</div>';
- $groupList[$id]['class'] = in_array('disabled', $value['class']) ? 'disabled' : '';
+ $value['class'] = array_diff($value['class'], array('crm-row-parent'));
}
+ $value['class'][] = 'crm-entity';
+ $groupList[$id]['class'] = $value['id'] . ',' . implode(' ', $value['class']);
$groupList[$id]['group_description'] = CRM_Utils_Array::value('description', $value);
if (!empty($value['group_type'])) {
}
$query = "
- SELECT groups.*, createdBy.sort_name as created_by {$select}
+ SELECT groups.*, createdBy.sort_name as created_by, IF(groups.saved_search_id, COUNT(smart_members.id), COUNT(members.id)) as members {$select}
FROM civicrm_group groups
- LEFT JOIN civicrm_contact createdBy
- ON createdBy.id = groups.created_id
- {$from}
+ LEFT JOIN civicrm_group_contact members
+ ON members.group_id = groups.id AND members.status = 'Added'
+ LEFT JOIN civicrm_group_contact_cache smart_members
+ ON smart_members.group_id = groups.id
+ LEFT JOIN civicrm_contact createdBy
+ ON createdBy.id = groups.created_id
+ {$from}
WHERE $whereClause {$where}
+ GROUP BY groups.id
{$orderBy}
{$limit}";
$values[$object->id]['visibility'] = $visibility[$values[$object->id]['visibility']];
+ $values[$object->id]['members'] = $object->members;
+
if (isset($values[$object->id]['group_type'])) {
$groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR,
substr($values[$object->id]['group_type'], 1, -1)
<thead>
<tr>
<th class='crm-group-name'>{ts}Name{/ts}</th>
- <th class='crm-group-group_id'>{ts}ID{/ts}</th>
+ <th class='crm-group-members'>{ts}Members{/ts}</th>
<th class='crm-group-created_by'>{ts}Created By{/ts}</th>
<th class='crm-group-description'>{ts}Description{/ts}</th>
<th class='crm-group-group_type'>{ts}Group Type{/ts}</th>
"aaSorting" : [],
"aoColumns" : [
{sClass:'crm-group-name'},
- {sClass:'crm-group-group_id'},
+ {sClass:'crm-group-members'},
{sClass:'crm-group-created_by'},
{sClass:'crm-group-description', bSortable:false},
{sClass:'crm-group-group_type'},
}
},
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
- var id = $('td:eq(1)', nRow).text();
- $(nRow).addClass('crm-entity').attr('data-entity', 'group').attr('data-id', id);
+ var id = $('td:last', nRow).text().split(',')[0];
+ var cl = $('td:last', nRow).text().split(',')[1];
+ $(nRow).addClass(cl).attr({id: 'row_' + id, 'data-id': id, 'data-entity': 'group'});
$('td:eq(0)', nRow).wrapInner('<span class="crm-editable crmf-name" />');
$('td:eq(3)', nRow).wrapInner('<span class="crm-editable crmf-description" data-type="textarea" />');
+ if (parentsOnly) {
+ if ($(nRow).hasClass('crm-group-parent')) {
+ $(nRow).find('td:first').prepend('{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}');
+ }
+ }
return nRow;
},
"fnDrawCallback": function() {
- setSelectorClass( parentsOnly, showOrgInfo );
$('.crm-editable').crmEditable();
},
"fnServerData": function ( sSource, aoData, fnCallback ) {
});
}
- function setSelectorClass( parentsOnly, showOrgInfo ) {
- var $context = $('#crm-main-content-wrapper');
- $('table.crm-group-selector tr', $context).each( function( ) {
- var className = $(this).find('td:last-child').text();
- $(this).addClass( className );
- var rowID = $(this).find('td:nth-child(2)').text();
- $(this).prop( 'id', 'row_' + rowID );
- if (parentsOnly) {
- if ( $(this).hasClass('crm-group-parent') ) {
- $(this).find('td:first').prepend('{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}');
- }
- }
- });
- }
// show hide children
var $context = $('#crm-main-content-wrapper');
$('table.crm-group-selector', $context).on( 'click', 'span.show-children', function(){
"success": function(response){
var appendHTML = '';
$.each( response, function( i, val ) {
- appendHTML += '<tr id="row_'+ val.group_id +'_'+parent_id+'" data-entity="group" data-id="'+ val.group_id +'" class="crm-entity parent_is_' + parent_id + ' crm-row-child ' + val.class + '">';
+ appendHTML += '<tr id="row_'+ val.group_id +'_'+parent_id+'" data-entity="group" data-id="'+ val.group_id +'" class="parent_is_' + parent_id + ' crm-row-child ' + val.class.split(',')[1] + '">';
if ( val.is_parent ) {
appendHTML += '<td class="crm-group-name ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}<span class="crm-editable crmf-name">' + val.group_name + '</span></td>';
}
else {
appendHTML += '<td class="crm-group-name ' + levelClass + '"><span class="crm-no-children"></span><span class="crm-editable crmf-name">' + val.group_name + '</span></td>';
}
- appendHTML += "<td>" + val.group_id + "</td>";
+ appendHTML += "<td>" + val.members + "</td>";
appendHTML += "<td>" + val.created_by + "</td>";
appendHTML += '<td><span class="crm-editable crmf-description" data-type="textarea">' + (val.group_description || '') + "</span></td>";
appendHTML += "<td>" + val.group_type + "</td>";