2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
26 <div class="view-content view-contact-groups">
28 <div class="messages status no-popup">
29 <div class="icon inform-icon"></div>
30 {ts}This contact does not currently belong to any groups.{/ts}
33 {include file="CRM/common/jsortable.tpl"}
36 {* Include 'add to new group' form if session has edit contact permissions *}
37 {if $permission EQ 'edit'}
38 {include file="CRM/Contact/Form/GroupContact.tpl"}
42 <div class="ht-one"></div>
43 <h3>{ts}Regular Groups{/ts}</h3>
44 <div class="description">{ts 1=$displayName}%1 has joined or been added to these group(s).{/ts}</div>
46 <table id="current_group" class="display">
49 <th>{ts}Group{/ts}</th>
50 <th>{ts}Status{/ts}</th>
51 <th>{ts}Date Added{/ts}</th>
55 {foreach from=$groupIn item=row}
56 <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
58 <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}">
62 <td>{ts 1=$row.in_method}Added (by %1){/ts}</td>
63 <td>{$row.in_date|crmDate}</td>
65 {if $permission EQ 'edit'}
66 <a class="action-item crm-hover-button" href="#Removed" title="{ts 1=$displayName 2=$row.title}Remove %1 from %2? (status in this group will be changed to 'Removed').{/ts}">
68 <a class="action-item crm-hover-button" href="#Deleted" title="{ts 1=$displayName 2=$row.title}Delete %1 from %2? (remove contact AND delete their record of having been in this group).{/ts}">
78 {if $contactSmartGroupSettings neq 3}
79 <div class="spacer" style="height: 1.5em;"></div>
80 <div class="accordion ui-accordion ui-widget ui-helper-reset">
81 <div class="crm-accordion-wrapper crm-ajax-accordion crm-smartgroup-accordion {if $contactSmartGroupSettings eq 1}collapsed{/if}">
82 <div class="crm-accordion-header" id="crm-contact_smartgroup" contact_id="{$contactId}">
85 <!-- /.crm-accordion-header -->
86 <div class="crm-accordion-body">
87 <div class="crm-contact_smartgroup" style="min-height: 3em;"></div>
89 <!-- /.crm-accordion-body -->
91 <!-- /.crm-accordion-wrapper -->
96 <div class="ht-one"></div>
97 <h3 class="status-pending">{ts}Pending{/ts}</h3>
98 <div class="description">{ts}Joining these group(s) is pending confirmation by this contact.{/ts}</div>
100 <table id="pending_group" class="display">
103 <th>{ts}Group{/ts}</th>
104 <th>{ts}Status{/ts}</th>
105 <th>{ts}Date Pending{/ts}</th>
109 {foreach from=$groupPending item=row}
110 <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
112 <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}">
116 <td>{ts 1=$row.pending_method}Pending (by %1){/ts}</td>
117 <td>{$row.pending_date|crmDate}</td>
119 {if $permission EQ 'edit'}
120 <a class="action-item crm-hover-button" href="#Removed" title="{ts 1=$displayName 2=$row.title}Remove %1 from %2? (status in this group will be changed to 'Removed').{/ts}">
122 <a class="action-item crm-hover-button" href="#Deleted" title="{ts 1=$displayName 2=$row.title}Delete %1 from %2? (this group will no longer be listed under Pending Groups){/ts}">
133 <div class="ht-one"></div>
134 <h3 class="status-removed">{ts}Past Groups{/ts}</h3>
135 <div class="description">{ts 1=$displayName}%1 is no longer part of these group(s).{/ts}</div>
137 <table id="past_group" class="display">
140 <th>{ts}Group{/ts}</th>
141 <th>{ts}Status{/ts}</th>
142 <th>{ts}Date Added{/ts}</th>
143 <th>{ts}Date Removed{/ts}</th>
147 {foreach from=$groupOut item=row}
148 <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
150 <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}">
154 <td class="status-removed">{ts 1=$row.out_method}Removed (by %1){/ts}</td>
155 <td data-order="{$row.date_added}">{$row.date_added|crmDate}</td>
156 <td data-order="{$row.out_date}">{$row.out_date|crmDate}</td>
157 <td>{if $permission EQ 'edit'}
158 <a class="action-item crm-hover-button" href="#Added" title="{ts 1=$displayName 2=$row.title}Add %1 back into %2?{/ts}">
159 {ts}Rejoin Group{/ts}</a>
160 <a class="action-item crm-hover-button" href="#Deleted" title="{ts 1=$displayName 2=$row.title}Delete %1 from %2? (this group will no longer be listed under Past Groups).{/ts}">
161 {ts}Delete{/ts}</a>{/if}
172 <script type="text/javascript">
174 // load panes function calls for snippet based on id of crm-accordion-header
175 function loadPanes() {
176 var $el = $(this).parent().find('div.crm-contact_smartgroup');
177 var contactId = $(this).attr('contact_id');
179 CRM.loadPage(CRM.url('civicrm/contact/view/smartgroup', {cid: contactId}), {target: $el});
182 // bind first click of accordion header to load crm-accordion-body with snippet
183 $('.view-contact-groups .crm-ajax-accordion.collapsed .crm-accordion-header').one('click', loadPanes);
184 $('.view-contact-groups .crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(loadPanes);
185 // Handle enable/delete links
188 CRM.refreshParent(that);
190 function enableDisableGroup() {
192 id: $(that).closest('.crm-entity').attr('id').split('-')[1],
195 var status = that.href.split('#')[1];
196 if (status === 'Deleted') {
197 params.skip_undelete = true;
199 params.status = status;
201 // This api is weird - 'delete' actually works for updating as well as deleting
202 // Normally you wouldn't put a variable within ts() but this works due to smarty hack below
203 CRM.api3('group_contact', 'delete', params, {success: ts(status)}).done(refresh);
205 $('.view-contact-groups a.action-item').click(function() {
207 CRM.confirm(enableDisableGroup, {message: this.title});
212 // Hack to ensure status msg is properly translated
213 CRM.strings.Added = "{ts escape='js'}Added{/ts}";
214 CRM.strings.Removed = "{ts escape='js'}Removed{/ts}";
215 CRM.strings.Deleted = "{ts escape='js'}Deleted{/ts}";