Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
1188c7a8 | 3 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 4 | | | |
1188c7a8 TO |
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 | | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | *} | |
6cc459df | 10 | <div class="view-content view-contact-groups"> |
559865a0 | 11 | {if $groupCount eq 0} |
13d0ffc3 KJ |
12 | <div class="messages status no-popup"> |
13 | <div class="icon inform-icon"></div> | |
14 | {ts}This contact does not currently belong to any groups.{/ts} | |
15 | </div> | |
6cc459df CW |
16 | {else} |
17 | {include file="CRM/common/jsortable.tpl"} | |
13d0ffc3 | 18 | {/if} |
6a488035 | 19 | |
13d0ffc3 KJ |
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} | |
6a488035 | 24 | |
13d0ffc3 KJ |
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> | |
6a488035 | 32 | <tr> |
13d0ffc3 KJ |
33 | <th>{ts}Group{/ts}</th> |
34 | <th>{ts}Status{/ts}</th> | |
35 | <th>{ts}Date Added{/ts}</th> | |
36 | <th></th> | |
6a488035 | 37 | </tr> |
13d0ffc3 KJ |
38 | </thead> |
39 | {foreach from=$groupIn item=row} | |
3d700d00 | 40 | <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}"> |
13d0ffc3 KJ |
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'} | |
455b3ea4 | 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}"> |
3d700d00 | 51 | {ts}Remove{/ts}</a> |
455b3ea4 | 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}"> |
3d700d00 | 53 | {ts}Delete{/ts}</a> |
13d0ffc3 KJ |
54 | {/if} |
55 | </td> | |
56 | </tr> | |
57 | {/foreach} | |
58 | </table> | |
59 | {/strip} | |
60 | {/if} | |
6a488035 | 61 | |
559865a0 | 62 | {if $contactSmartGroupSettings neq 3} |
b99924ad | 63 | <div class="spacer" style="height: 1.5em;"></div> |
3d700d00 CW |
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"> | |
b99924ad | 71 | <div class="crm-contact_smartgroup" style="min-height: 3em;"></div> |
3d700d00 CW |
72 | </div> |
73 | <!-- /.crm-accordion-body --> | |
559865a0 | 74 | </div> |
3d700d00 | 75 | <!-- /.crm-accordion-wrapper --> |
559865a0 | 76 | </div> |
559865a0 | 77 | {/if} |
6a488035 | 78 | |
926dcf00 | 79 | {if $groupPending} |
13d0ffc3 KJ |
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} | |
3d700d00 | 94 | <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}"> |
13d0ffc3 KJ |
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> | |
6a488035 TO |
100 | <td>{ts 1=$row.pending_method}Pending (by %1){/ts}</td> |
101 | <td>{$row.pending_date|crmDate}</td> | |
13d0ffc3 KJ |
102 | <td> |
103 | {if $permission EQ 'edit'} | |
455b3ea4 | 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}"> |
3d700d00 | 105 | {ts}Remove{/ts}</a> |
455b3ea4 | 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}"> |
3d700d00 | 107 | {ts}Delete{/ts}</a> |
13d0ffc3 | 108 | {/if} |
6a488035 | 109 | </td> |
13d0ffc3 KJ |
110 | </tr> |
111 | {/foreach} | |
112 | </table> | |
113 | {/strip} | |
114 | {/if} | |
6a488035 | 115 | |
13d0ffc3 KJ |
116 | {if $groupOut} |
117 | <div class="ht-one"></div> | |
118 | <h3 class="status-removed">{ts}Past Groups{/ts}</h3> | |
6a488035 TO |
119 | <div class="description">{ts 1=$displayName}%1 is no longer part of these group(s).{/ts}</div> |
120 | {strip} | |
13d0ffc3 KJ |
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} | |
3d700d00 | 132 | <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}"> |
13d0ffc3 KJ |
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> | |
21f96d9b KL |
139 | <td data-order="{$row.date_added}">{$row.date_added|crmDate}</td> |
140 | <td data-order="{$row.out_date}">{$row.out_date|crmDate}</td> | |
13d0ffc3 | 141 | <td>{if $permission EQ 'edit'} |
455b3ea4 | 142 | <a class="action-item crm-hover-button" href="#Added" title="{ts 1=$displayName 2=$row.title}Add %1 back into %2?{/ts}"> |
3d700d00 | 143 | {ts}Rejoin Group{/ts}</a> |
455b3ea4 | 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}"> |
3d700d00 | 145 | {ts}Delete{/ts}</a>{/if} |
13d0ffc3 KJ |
146 | </td> |
147 | </tr> | |
148 | {/foreach} | |
149 | </table> | |
150 | {/strip} | |
6a488035 | 151 | {/if} |
559865a0 KJ |
152 | </div> |
153 | ||
154 | ||
155 | {literal} | |
156 | <script type="text/javascript"> | |
3cc60a06 | 157 | CRM.$(function($) { |
6cc459df CW |
158 | // load panes function calls for snippet based on id of crm-accordion-header |
159 | function loadPanes() { | |
b99924ad | 160 | var $el = $(this).parent().find('div.crm-contact_smartgroup'); |
6cc459df | 161 | var contactId = $(this).attr('contact_id'); |
b99924ad CW |
162 | if (!$el.html()) { |
163 | CRM.loadPage(CRM.url('civicrm/contact/view/smartgroup', {cid: contactId}), {target: $el}); | |
6cc459df CW |
164 | } |
165 | } | |
3d700d00 | 166 | // bind first click of accordion header to load crm-accordion-body with snippet |
6cc459df CW |
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); | |
3d700d00 CW |
169 | // Handle enable/delete links |
170 | var that; | |
171 | function refresh() { | |
554b1768 | 172 | CRM.refreshParent(that); |
3d700d00 CW |
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 | |
e11b84ce CW |
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); | |
3d700d00 CW |
188 | } |
189 | $('.view-contact-groups a.action-item').click(function() { | |
190 | that = this; | |
191 | CRM.confirm(enableDisableGroup, {message: this.title}); | |
192 | return false; | |
193 | }); | |
559865a0 | 194 | }); |
3d700d00 | 195 | {/literal} |
3d700d00 CW |
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}"; | |
559865a0 | 200 | </script> |