Merge pull request #15820 from seamuslee001/dev_core_183_custom_contribsybnt
[civicrm-core.git] / templates / CRM / Contact / Page / View / GroupContact.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}
10 <div class="view-content view-contact-groups">
11 {if $groupCount eq 0}
12 <div class="messages status no-popup">
13 <div class="icon inform-icon"></div>
14 &nbsp;{ts}This contact does not currently belong to any groups.{/ts}
15 </div>
16 {else}
17 {include file="CRM/common/jsortable.tpl"}
18 {/if}
19
20 {* Include 'add to new group' form if session has edit contact permissions *}
21 {if $permission EQ 'edit'}
22 {include file="CRM/Contact/Form/GroupContact.tpl"}
23 {/if}
24
25 {if $groupIn }
26 <div class="ht-one"></div>
27 <h3>{ts}Regular Groups{/ts}</h3>
28 <div class="description">{ts 1=$displayName}%1 has joined or been added to these group(s).{/ts}</div>
29 {strip}
30 <table id="current_group" class="display">
31 <thead>
32 <tr>
33 <th>{ts}Group{/ts}</th>
34 <th>{ts}Status{/ts}</th>
35 <th>{ts}Date Added{/ts}</th>
36 <th></th>
37 </tr>
38 </thead>
39 {foreach from=$groupIn item=row}
40 <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
41 <td class="bold">
42 <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}">
43 {$row.title}
44 </a>
45 </td>
46 <td>{ts 1=$row.in_method}Added (by %1){/ts}</td>
47 <td>{$row.in_date|crmDate}</td>
48 <td>
49 {if $permission EQ 'edit'}
50 <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}">
51 {ts}Remove{/ts}</a>
52 <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}">
53 {ts}Delete{/ts}</a>
54 {/if}
55 </td>
56 </tr>
57 {/foreach}
58 </table>
59 {/strip}
60 {/if}
61
62 {if $contactSmartGroupSettings neq 3}
63 <div class="spacer" style="height: 1.5em;"></div>
64 <div class="accordion ui-accordion ui-widget ui-helper-reset">
65 <div class="crm-accordion-wrapper crm-ajax-accordion crm-smartgroup-accordion {if $contactSmartGroupSettings eq 1}collapsed{/if}">
66 <div class="crm-accordion-header" id="crm-contact_smartgroup" contact_id="{$contactId}">
67 {ts}Smart Groups{/ts}
68 </div>
69 <!-- /.crm-accordion-header -->
70 <div class="crm-accordion-body">
71 <div class="crm-contact_smartgroup" style="min-height: 3em;"></div>
72 </div>
73 <!-- /.crm-accordion-body -->
74 </div>
75 <!-- /.crm-accordion-wrapper -->
76 </div>
77 {/if}
78
79 {if $groupPending}
80 <div class="ht-one"></div>
81 <h3 class="status-pending">{ts}Pending{/ts}</h3>
82 <div class="description">{ts}Joining these group(s) is pending confirmation by this contact.{/ts}</div>
83 {strip}
84 <table id="pending_group" class="display">
85 <thead>
86 <tr>
87 <th>{ts}Group{/ts}</th>
88 <th>{ts}Status{/ts}</th>
89 <th>{ts}Date Pending{/ts}</th>
90 <th></th>
91 </tr>
92 </thead>
93 {foreach from=$groupPending item=row}
94 <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
95 <td class="bold">
96 <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}">
97 {$row.title}
98 </a>
99 </td>
100 <td>{ts 1=$row.pending_method}Pending (by %1){/ts}</td>
101 <td>{$row.pending_date|crmDate}</td>
102 <td>
103 {if $permission EQ 'edit'}
104 <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}">
105 {ts}Remove{/ts}</a>
106 <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}">
107 {ts}Delete{/ts}</a>
108 {/if}
109 </td>
110 </tr>
111 {/foreach}
112 </table>
113 {/strip}
114 {/if}
115
116 {if $groupOut}
117 <div class="ht-one"></div>
118 <h3 class="status-removed">{ts}Past Groups{/ts}</h3>
119 <div class="description">{ts 1=$displayName}%1 is no longer part of these group(s).{/ts}</div>
120 {strip}
121 <table id="past_group" class="display">
122 <thead>
123 <tr>
124 <th>{ts}Group{/ts}</th>
125 <th>{ts}Status{/ts}</th>
126 <th>{ts}Date Added{/ts}</th>
127 <th>{ts}Date Removed{/ts}</th>
128 <th></th>
129 </tr>
130 </thead>
131 {foreach from=$groupOut item=row}
132 <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
133 <td class="bold">
134 <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}">
135 {$row.title}
136 </a>
137 </td>
138 <td class="status-removed">{ts 1=$row.out_method}Removed (by %1){/ts}</td>
139 <td data-order="{$row.date_added}">{$row.date_added|crmDate}</td>
140 <td data-order="{$row.out_date}">{$row.out_date|crmDate}</td>
141 <td>{if $permission EQ 'edit'}
142 <a class="action-item crm-hover-button" href="#Added" title="{ts 1=$displayName 2=$row.title}Add %1 back into %2?{/ts}">
143 {ts}Rejoin Group{/ts}</a>
144 <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}">
145 {ts}Delete{/ts}</a>{/if}
146 </td>
147 </tr>
148 {/foreach}
149 </table>
150 {/strip}
151 {/if}
152 </div>
153
154
155 {literal}
156 <script type="text/javascript">
157 CRM.$(function($) {
158 // load panes function calls for snippet based on id of crm-accordion-header
159 function loadPanes() {
160 var $el = $(this).parent().find('div.crm-contact_smartgroup');
161 var contactId = $(this).attr('contact_id');
162 if (!$el.html()) {
163 CRM.loadPage(CRM.url('civicrm/contact/view/smartgroup', {cid: contactId}), {target: $el});
164 }
165 }
166 // bind first click of accordion header to load crm-accordion-body with snippet
167 $('.view-contact-groups .crm-ajax-accordion.collapsed .crm-accordion-header').one('click', loadPanes);
168 $('.view-contact-groups .crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(loadPanes);
169 // Handle enable/delete links
170 var that;
171 function refresh() {
172 CRM.refreshParent(that);
173 }
174 function enableDisableGroup() {
175 var params = {
176 id: $(that).closest('.crm-entity').attr('id').split('-')[1],
177 method: 'Admin'
178 };
179 var status = that.href.split('#')[1];
180 if (status === 'Deleted') {
181 params.skip_undelete = true;
182 } else {
183 params.status = status;
184 }
185 // This api is weird - 'delete' actually works for updating as well as deleting
186 // Normally you wouldn't put a variable within ts() but this works due to smarty hack below
187 CRM.api3('group_contact', 'delete', params, {success: ts(status)}).done(refresh);
188 }
189 $('.view-contact-groups a.action-item').click(function() {
190 that = this;
191 CRM.confirm(enableDisableGroup, {message: this.title});
192 return false;
193 });
194 });
195 {/literal}
196 // Hack to ensure status msg is properly translated
197 CRM.strings.Added = "{ts escape='js'}Added{/ts}";
198 CRM.strings.Removed = "{ts escape='js'}Removed{/ts}";
199 CRM.strings.Deleted = "{ts escape='js'}Deleted{/ts}";
200 </script>