| 1 | {* |
| 2 | +--------------------------------------------------------------------+ |
| 3 | | CiviCRM version 4.4 | |
| 4 | +--------------------------------------------------------------------+ |
| 5 | | Copyright CiviCRM LLC (c) 2004-2013 | |
| 6 | +--------------------------------------------------------------------+ |
| 7 | | This file is a part of CiviCRM. | |
| 8 | | | |
| 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. | |
| 12 | | | |
| 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. | |
| 17 | | | |
| 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 | +--------------------------------------------------------------------+ |
| 25 | *} |
| 26 | <div class="view-content view-contact-groups"> |
| 27 | {if $groupCount eq 0} |
| 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} |
| 31 | </div> |
| 32 | {else} |
| 33 | {include file="CRM/common/jsortable.tpl"} |
| 34 | {/if} |
| 35 | |
| 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"} |
| 39 | {/if} |
| 40 | |
| 41 | {if $groupIn } |
| 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> |
| 45 | {strip} |
| 46 | <table id="current_group" class="display"> |
| 47 | <thead> |
| 48 | <tr> |
| 49 | <th>{ts}Group{/ts}</th> |
| 50 | <th>{ts}Status{/ts}</th> |
| 51 | <th>{ts}Date Added{/ts}</th> |
| 52 | <th></th> |
| 53 | </tr> |
| 54 | </thead> |
| 55 | {foreach from=$groupIn item=row} |
| 56 | <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}"> |
| 57 | <td class="bold"> |
| 58 | <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}"> |
| 59 | {$row.title} |
| 60 | </a> |
| 61 | </td> |
| 62 | <td>{ts 1=$row.in_method}Added (by %1){/ts}</td> |
| 63 | <td>{$row.in_date|crmDate}</td> |
| 64 | <td> |
| 65 | {if $permission EQ 'edit'} |
| 66 | <a class="action-item action-item-first" href="#Removed" title="{ts 1=$displayName 2=$row.title}Remove %1 from %2? (status in this group will be changed to 'Removed').{/ts}"> |
| 67 | {ts}Remove{/ts}</a> |
| 68 | <a class="action-item" 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}"> |
| 69 | {ts}Delete{/ts}</a> |
| 70 | {/if} |
| 71 | </td> |
| 72 | </tr> |
| 73 | {/foreach} |
| 74 | </table> |
| 75 | {/strip} |
| 76 | {/if} |
| 77 | |
| 78 | {if $contactSmartGroupSettings neq 3} |
| 79 | <div class="accordion ui-accordion ui-widget ui-helper-reset"> |
| 80 | <div class="crm-accordion-wrapper crm-ajax-accordion crm-smartgroup-accordion {if $contactSmartGroupSettings eq 1}collapsed{/if}"> |
| 81 | <div class="crm-accordion-header" id="crm-contact_smartgroup" contact_id="{$contactId}"> |
| 82 | {ts}Smart Groups{/ts} |
| 83 | </div> |
| 84 | <!-- /.crm-accordion-header --> |
| 85 | <div class="crm-accordion-body"> |
| 86 | <div class="crm-contact_smartgroup"></div> |
| 87 | </div> |
| 88 | <!-- /.crm-accordion-body --> |
| 89 | </div> |
| 90 | <!-- /.crm-accordion-wrapper --> |
| 91 | </div> |
| 92 | {/if} |
| 93 | |
| 94 | {if $groupPending} |
| 95 | <div class="ht-one"></div> |
| 96 | <h3 class="status-pending">{ts}Pending{/ts}</h3> |
| 97 | <div class="description">{ts}Joining these group(s) is pending confirmation by this contact.{/ts}</div> |
| 98 | {strip} |
| 99 | <table id="pending_group" class="display"> |
| 100 | <thead> |
| 101 | <tr> |
| 102 | <th>{ts}Group{/ts}</th> |
| 103 | <th>{ts}Status{/ts}</th> |
| 104 | <th>{ts}Date Pending{/ts}</th> |
| 105 | <th></th> |
| 106 | </tr> |
| 107 | </thead> |
| 108 | {foreach from=$groupPending item=row} |
| 109 | <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}"> |
| 110 | <td class="bold"> |
| 111 | <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}"> |
| 112 | {$row.title} |
| 113 | </a> |
| 114 | </td> |
| 115 | <td>{ts 1=$row.pending_method}Pending (by %1){/ts}</td> |
| 116 | <td>{$row.pending_date|crmDate}</td> |
| 117 | <td> |
| 118 | {if $permission EQ 'edit'} |
| 119 | <a class="action-item action-item-first" href="#Removed" title="{ts 1=$displayName 2=$row.title}Remove %1 from %2? (status in this group will be changed to 'Removed').{/ts}"> |
| 120 | {ts}Remove{/ts}</a> |
| 121 | <a class="action-item" href="#Deleted" title="{ts 1=$displayName 2=$row.title}Delete %1 from %2? (this group will no longer be listed under Pending Groups){/ts}"> |
| 122 | {ts}Delete{/ts}</a> |
| 123 | {/if} |
| 124 | </td> |
| 125 | </tr> |
| 126 | {/foreach} |
| 127 | </table> |
| 128 | {/strip} |
| 129 | {/if} |
| 130 | |
| 131 | {if $groupOut} |
| 132 | <div class="ht-one"></div> |
| 133 | <h3 class="status-removed">{ts}Past Groups{/ts}</h3> |
| 134 | <div class="description">{ts 1=$displayName}%1 is no longer part of these group(s).{/ts}</div> |
| 135 | {strip} |
| 136 | <table id="past_group" class="display"> |
| 137 | <thead> |
| 138 | <tr> |
| 139 | <th>{ts}Group{/ts}</th> |
| 140 | <th>{ts}Status{/ts}</th> |
| 141 | <th>{ts}Date Added{/ts}</th> |
| 142 | <th>{ts}Date Removed{/ts}</th> |
| 143 | <th></th> |
| 144 | </tr> |
| 145 | </thead> |
| 146 | {foreach from=$groupOut item=row} |
| 147 | <tr id="group_contact-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}"> |
| 148 | <td class="bold"> |
| 149 | <a href="{crmURL p='civicrm/group/search' q="reset=1&force=1&context=smog&gid=`$row.group_id`"}"> |
| 150 | {$row.title} |
| 151 | </a> |
| 152 | </td> |
| 153 | <td class="status-removed">{ts 1=$row.out_method}Removed (by %1){/ts}</td> |
| 154 | <td>{$row.date_added|crmDate}</td> |
| 155 | <td>{$row.out_date|crmDate}</td> |
| 156 | <td>{if $permission EQ 'edit'} |
| 157 | <a class="action-item action-item-first" href="#Added" title="{ts 1=$displayName 2=$row.title}Add %1 back into %2?{/ts}"> |
| 158 | {ts}Rejoin Group{/ts}</a> |
| 159 | <a class="action-item" href="#Deleted" title="{ts 1=$displayName 2=$row.title}Delete %1 from %2? (this group will no longer be listed under Past Groups).{/ts}"> |
| 160 | {ts}Delete{/ts}</a>{/if} |
| 161 | </td> |
| 162 | </tr> |
| 163 | {/foreach} |
| 164 | </table> |
| 165 | {/strip} |
| 166 | {/if} |
| 167 | </div> |
| 168 | |
| 169 | |
| 170 | {literal} |
| 171 | <script type="text/javascript"> |
| 172 | cj(function($) { |
| 173 | // load panes function calls for snippet based on id of crm-accordion-header |
| 174 | function loadPanes() { |
| 175 | var id = $(this).attr('id'); |
| 176 | var contactId = $(this).attr('contact_id'); |
| 177 | if (!$('div.' + id).html()) { |
| 178 | var loading = '<img src="{/literal}{$config->resourceBase}i/loading.gif{literal}" alt="{/literal}{ts escape='js'}loading{/ts}{literal}" /> {/literal}{ts escape='js'}Loading{/ts}{literal}...'; |
| 179 | $('div.' + id).html(loading).load(CRM.url('civicrm/contact/view/smartgroup', {snippet: 4, cid: contactId})); |
| 180 | } |
| 181 | } |
| 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 |
| 186 | var that; |
| 187 | function refresh() { |
| 188 | $(that).closest('.crm-ajax-container, #crm-main-content-wrapper').crmSnippet().crmSnippet('refresh'); |
| 189 | } |
| 190 | function enableDisableGroup() { |
| 191 | var params = { |
| 192 | id: $(that).closest('.crm-entity').attr('id').split('-')[1], |
| 193 | method: 'Admin' |
| 194 | }; |
| 195 | var status = that.href.split('#')[1]; |
| 196 | if (status === 'Deleted') { |
| 197 | params.skip_undelete = true; |
| 198 | } else { |
| 199 | params.status = status; |
| 200 | } |
| 201 | // This api is weird - 'delete' actually works for updating as well as deleting |
| 202 | CRM.api('group_contact', 'delete', params, {success: function() { |
| 203 | refresh(); |
| 204 | // Normally you wouldn't put a variable within ts() but this works due to smarty hack below |
| 205 | CRM.alert('', ts(status), 'success'); |
| 206 | }}); |
| 207 | } |
| 208 | $('.view-contact-groups a.action-item').click(function() { |
| 209 | that = this; |
| 210 | CRM.confirm(enableDisableGroup, {message: this.title}); |
| 211 | return false; |
| 212 | }); |
| 213 | }); |
| 214 | {/literal} |
| 215 | // Hack to ensure status msg is properly translated |
| 216 | CRM.strings.Added = "{ts escape='js'}Added{/ts}"; |
| 217 | CRM.strings.Removed = "{ts escape='js'}Removed{/ts}"; |
| 218 | CRM.strings.Deleted = "{ts escape='js'}Deleted{/ts}"; |
| 219 | </script> |